linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/boot: Move detecting acpi=off in cmdline to get_rsdp_addr()
@ 2019-02-15  9:10 Chao Fan
  2019-02-15  9:28 ` Borislav Petkov
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Fan @ 2019-02-15  9:10 UTC (permalink / raw)
  To: linux-kernel, tglx, mingo, hpa, x86, bp

If "acpi=off" specified in cmdline, the whole functions of acpi.c
should not work, there is no need to ealy parse RSDP, so detect
"acpi=off" in the very first place.

Also replace magic number with macro.

Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
---
 arch/x86/boot/compressed/acpi.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
index 0ef4ad55b29b..5510a2105b7b 100644
--- a/arch/x86/boot/compressed/acpi.c
+++ b/arch/x86/boot/compressed/acpi.c
@@ -213,8 +213,13 @@ static acpi_physical_address bios_get_rsdp_addr(void)
 /* Return RSDP address on success, otherwise 0. */
 acpi_physical_address get_rsdp_addr(void)
 {
+	char arg[MAX_ACPI_ARG_LENGTH];
 	acpi_physical_address pa;
 
+	if (cmdline_find_option("acpi", arg, sizeof(arg)) == 3 &&
+	    !strncmp(arg, "off", 3))
+		return 0;
+
 	pa = get_acpi_rsdp();
 
 	if (!pa)
@@ -235,9 +240,9 @@ static unsigned long get_acpi_srat_table(void)
 {
 	unsigned long root_table, acpi_table;
 	struct acpi_table_header *header;
+	char arg[MAX_ACPI_ARG_LENGTH];
 	struct acpi_table_rsdp *rsdp;
 	u32 num_entries, size, len;
-	char arg[10];
 	u8 *entry;
 
 	rsdp = (struct acpi_table_rsdp *)(long)boot_params->acpi_rsdp_addr;
@@ -299,13 +304,8 @@ int count_immovable_mem_regions(void)
 	unsigned long table_addr, table_end, table;
 	struct acpi_subtable_header *sub_table;
 	struct acpi_table_header *table_header;
-	char arg[MAX_ACPI_ARG_LENGTH];
 	int num = 0;
 
-	if (cmdline_find_option("acpi", arg, sizeof(arg)) == 3 &&
-	    !strncmp(arg, "off", 3))
-		return 0;
-
 	table_addr = get_acpi_srat_table();
 	if (!table_addr)
 		return 0;
-- 
2.20.1




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/boot: Move detecting acpi=off in cmdline to get_rsdp_addr()
  2019-02-15  9:10 [PATCH] x86/boot: Move detecting acpi=off in cmdline to get_rsdp_addr() Chao Fan
@ 2019-02-15  9:28 ` Borislav Petkov
  2019-02-15  9:46   ` Chao Fan
  0 siblings, 1 reply; 3+ messages in thread
From: Borislav Petkov @ 2019-02-15  9:28 UTC (permalink / raw)
  To: Chao Fan; +Cc: linux-kernel, tglx, mingo, hpa, x86

On Fri, Feb 15, 2019 at 05:10:47PM +0800, Chao Fan wrote:
> If "acpi=off" specified in cmdline, the whole functions of acpi.c
> should not work, there is no need to ealy parse RSDP, so detect
> "acpi=off" in the very first place.
> 
> Also replace magic number with macro.
> 
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> ---
>  arch/x86/boot/compressed/acpi.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
> index 0ef4ad55b29b..5510a2105b7b 100644
> --- a/arch/x86/boot/compressed/acpi.c
> +++ b/arch/x86/boot/compressed/acpi.c
> @@ -213,8 +213,13 @@ static acpi_physical_address bios_get_rsdp_addr(void)
>  /* Return RSDP address on success, otherwise 0. */
>  acpi_physical_address get_rsdp_addr(void)
>  {
> +	char arg[MAX_ACPI_ARG_LENGTH];
>  	acpi_physical_address pa;
>  
> +	if (cmdline_find_option("acpi", arg, sizeof(arg)) == 3 &&
> +	    !strncmp(arg, "off", 3))
> +		return 0;

This place looks wrong because we have a get_acpi_rsdp() call before
that which overrides acpi=off practically.

Also, if you move it to get_rsdp_addr(), add a static variable recording
the previous result of the cmdline parsing because I don't want it
parsing cmdline each time it is called.

Thx.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/boot: Move detecting acpi=off in cmdline to get_rsdp_addr()
  2019-02-15  9:28 ` Borislav Petkov
@ 2019-02-15  9:46   ` Chao Fan
  0 siblings, 0 replies; 3+ messages in thread
From: Chao Fan @ 2019-02-15  9:46 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, tglx, mingo, hpa, x86

On Fri, Feb 15, 2019 at 10:28:41AM +0100, Borislav Petkov wrote:
>On Fri, Feb 15, 2019 at 05:10:47PM +0800, Chao Fan wrote:
>> If "acpi=off" specified in cmdline, the whole functions of acpi.c
>> should not work, there is no need to ealy parse RSDP, so detect
>> "acpi=off" in the very first place.
>> 
>> Also replace magic number with macro.
>> 
>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> ---
>>  arch/x86/boot/compressed/acpi.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>> 
>> diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
>> index 0ef4ad55b29b..5510a2105b7b 100644
>> --- a/arch/x86/boot/compressed/acpi.c
>> +++ b/arch/x86/boot/compressed/acpi.c
>> @@ -213,8 +213,13 @@ static acpi_physical_address bios_get_rsdp_addr(void)
>>  /* Return RSDP address on success, otherwise 0. */
>>  acpi_physical_address get_rsdp_addr(void)
>>  {
>> +	char arg[MAX_ACPI_ARG_LENGTH];
>>  	acpi_physical_address pa;
>>  
>> +	if (cmdline_find_option("acpi", arg, sizeof(arg)) == 3 &&
>> +	    !strncmp(arg, "off", 3))
>> +		return 0;
>
>This place looks wrong because we have a get_acpi_rsdp() call before
>that which overrides acpi=off practically.

Oh thanks.
In my old version PATCH, it was in count_immovable_mem_regions() which
is the entry function of acpi.c. Then in last version, I splite acpi.c
so that the first entry is get_rsdp_addr(), that's why I want to move
the detecting here.

>
>Also, if you move it to get_rsdp_addr(), add a static variable recording
>the previous result of the cmdline parsing because I don't want it
>parsing cmdline each time it is called.

Thanks,
Chao Fan

>
>Thx.
>
>-- 
>Regards/Gruss,
>    Boris.
>
>Good mailing practices for 400: avoid top-posting and trim the reply.
>
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-15  9:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15  9:10 [PATCH] x86/boot: Move detecting acpi=off in cmdline to get_rsdp_addr() Chao Fan
2019-02-15  9:28 ` Borislav Petkov
2019-02-15  9:46   ` Chao Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).