public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/ucode: replace redundant string literals
@ 2015-12-22 15:40 Jan Beulich
  2015-12-22 17:07 ` Borislav Petkov
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2015-12-22 15:40 UTC (permalink / raw)
  To: mingo, tglx, hpa; +Cc: Borislav Petkov, linux-kernel

This doesn't just eliminate needless redundancy (plus avoid a possible
disconnect if one string instance gets changed without the other(s)),
but also eliminates a warning some gcc versions emit ("array access
beyond array bounds", observed with 4.3.4) in the 32-bit case.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
 arch/x86/kernel/cpu/microcode/core.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--- 4.4-rc6/arch/x86/kernel/cpu/microcode/core.c
+++ 4.4-rc6-x86-ucode-early-string/arch/x86/kernel/cpu/microcode/core.c
@@ -83,13 +83,11 @@ static bool __init check_loader_disabled
 {
 #ifdef CONFIG_X86_32
 	const char *cmdline = (const char *)__pa_nodebug(boot_command_line);
-	const char *opt	    = "dis_ucode_ldr";
-	const char *option  = (const char *)__pa_nodebug(opt);
+	const char *option  = (const char *)__pa_nodebug(__setup_str_disable_loader);
 	bool *res = (bool *)__pa_nodebug(&dis_ucode_ldr);
-
 #else /* CONFIG_X86_64 */
 	const char *cmdline = boot_command_line;
-	const char *option  = "dis_ucode_ldr";
+	const char *option  = __setup_str_disable_loader;
 	bool *res = &dis_ucode_ldr;
 #endif
 




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

* Re: [PATCH] x86/ucode: replace redundant string literals
  2015-12-22 15:40 [PATCH] x86/ucode: replace redundant string literals Jan Beulich
@ 2015-12-22 17:07 ` Borislav Petkov
  2015-12-22 17:20   ` Jan Beulich
  0 siblings, 1 reply; 8+ messages in thread
From: Borislav Petkov @ 2015-12-22 17:07 UTC (permalink / raw)
  To: Jan Beulich; +Cc: mingo, tglx, hpa, linux-kernel

On Tue, Dec 22, 2015 at 08:40:43AM -0700, Jan Beulich wrote:
> This doesn't just eliminate needless redundancy
> (plus avoid a possible disconnect if one string instance gets changed
> without the other(s)),

This argument is bogus. We will never ever change a user-visible command
line option. Ever.

> but also eliminates a warning some gcc versions emit ("array access
> beyond array bounds", observed with 4.3.4) in the 32-bit case.

Now that I'm interested in - how exactly do you trigger this? gcc
version, etc?

> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
>  arch/x86/kernel/cpu/microcode/core.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> --- 4.4-rc6/arch/x86/kernel/cpu/microcode/core.c
> +++ 4.4-rc6-x86-ucode-early-string/arch/x86/kernel/cpu/microcode/core.c
> @@ -83,13 +83,11 @@ static bool __init check_loader_disabled
>  {
>  #ifdef CONFIG_X86_32
>  	const char *cmdline = (const char *)__pa_nodebug(boot_command_line);
> -	const char *opt	    = "dis_ucode_ldr";
> -	const char *option  = (const char *)__pa_nodebug(opt);
> +	const char *option  = (const char *)__pa_nodebug(__setup_str_disable_loader);
>  	bool *res = (bool *)__pa_nodebug(&dis_ucode_ldr);
> -
>  #else /* CONFIG_X86_64 */
>  	const char *cmdline = boot_command_line;
> -	const char *option  = "dis_ucode_ldr";
> +	const char *option  = __setup_str_disable_loader;
>  	bool *res = &dis_ucode_ldr;
>  #endif

I don't like it: it is not clear at a glance that this __setup_str*
magic gets generated from the __setup macro. In addition, this code is
as unreadable as it is now - your patch makes it even more cryptic.

I much prefer the redundancy.

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

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

* Re: [PATCH] x86/ucode: replace redundant string literals
  2015-12-22 17:07 ` Borislav Petkov
@ 2015-12-22 17:20   ` Jan Beulich
  2015-12-22 18:14     ` Borislav Petkov
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2015-12-22 17:20 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: mingo, tglx, linux-kernel, hpa

>>> On 22.12.15 at 18:07, <bp@suse.de> wrote:
> On Tue, Dec 22, 2015 at 08:40:43AM -0700, Jan Beulich wrote:
>> This doesn't just eliminate needless redundancy
>> (plus avoid a possible disconnect if one string instance gets changed
>> without the other(s)),
> 
> This argument is bogus. We will never ever change a user-visible command
> line option. Ever.
> 
>> but also eliminates a warning some gcc versions emit ("array access
>> beyond array bounds", observed with 4.3.4) in the 32-bit case.
> 
> Now that I'm interested in - how exactly do you trigger this? gcc
> version, etc?

As said - 4.3.4 (I only now realize that this could also have been a
kernel version).

>> --- 4.4-rc6/arch/x86/kernel/cpu/microcode/core.c
>> +++ 4.4-rc6-x86-ucode-early-string/arch/x86/kernel/cpu/microcode/core.c
>> @@ -83,13 +83,11 @@ static bool __init check_loader_disabled
>>  {
>>  #ifdef CONFIG_X86_32
>>  	const char *cmdline = (const char *)__pa_nodebug(boot_command_line);
>> -	const char *opt	    = "dis_ucode_ldr";
>> -	const char *option  = (const char *)__pa_nodebug(opt);
>> +	const char *option  = (const char *)__pa_nodebug(__setup_str_disable_loader);
>>  	bool *res = (bool *)__pa_nodebug(&dis_ucode_ldr);
>> -
>>  #else /* CONFIG_X86_64 */
>>  	const char *cmdline = boot_command_line;
>> -	const char *option  = "dis_ucode_ldr";
>> +	const char *option  = __setup_str_disable_loader;
>>  	bool *res = &dis_ucode_ldr;
>>  #endif
> 
> I don't like it: it is not clear at a glance that this __setup_str*
> magic gets generated from the __setup macro. In addition, this code is
> as unreadable as it is now - your patch makes it even more cryptic.
> 
> I much prefer the redundancy.

And the compiler warning? At the very least these should then be
const char __initconst [].

Jan


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

* Re: [PATCH] x86/ucode: replace redundant string literals
  2015-12-22 17:20   ` Jan Beulich
@ 2015-12-22 18:14     ` Borislav Petkov
  2015-12-23 10:06       ` Jan Beulich
  0 siblings, 1 reply; 8+ messages in thread
From: Borislav Petkov @ 2015-12-22 18:14 UTC (permalink / raw)
  To: Jan Beulich; +Cc: mingo, tglx, linux-kernel, hpa

On Tue, Dec 22, 2015 at 10:20:36AM -0700, Jan Beulich wrote:
> As said - 4.3.4 (I only now realize that this could also have been a
> kernel version).

Just fetched stable from
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable

$ git tag --list | grep v4.3
v4.3
v4.3-rc1
v4.3-rc2
v4.3-rc3
v4.3-rc4
v4.3-rc5
v4.3-rc6
v4.3-rc7
v4.3.1
v4.3.2
v4.3.3

I don't see a v4.3.4 tag yet...

> And the compiler warning? At the very least these should then be
> const char __initconst [].

Let's sort out the issue first - this is the first time I hear of this
warning.

Thanks.

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

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

* Re: [PATCH] x86/ucode: replace redundant string literals
  2015-12-22 18:14     ` Borislav Petkov
@ 2015-12-23 10:06       ` Jan Beulich
  2015-12-23 10:10         ` Borislav Petkov
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2015-12-23 10:06 UTC (permalink / raw)
  To: bp; +Cc: mingo, tglx, linux-kernel, hpa

>>> Borislav Petkov <bp@suse.de> 12/22/15 7:14 PM >>>
>On Tue, Dec 22, 2015 at 10:20:36AM -0700, Jan Beulich wrote:
>> As said - 4.3.4 (I only now realize that this could also have been a
>> kernel version).
>
>Just fetched stable from
>git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable
>
>$ git tag --list | grep v4.3
>v4.3
>v4.3-rc1
>v4.3-rc2
>v4.3-rc3
>v4.3-rc4
>v4.3-rc5
>v4.3-rc6
>v4.3-rc7
>v4.3.1
>v4.3.2
>v4.3.3
>
>I don't see a v4.3.4 tag yet...

Sigh - this was in reply to your gcc version question. Right after having sent
the most recent reply I realized that there's no Linux 4.3.4 yet, so there really
was no ambiguity from the beginning. Therefore I have a hard time
understanding what you're asking for.

Jan


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

* Re: [PATCH] x86/ucode: replace redundant string literals
  2015-12-23 10:06       ` Jan Beulich
@ 2015-12-23 10:10         ` Borislav Petkov
  2015-12-23 10:11           ` Jan Beulich
  0 siblings, 1 reply; 8+ messages in thread
From: Borislav Petkov @ 2015-12-23 10:10 UTC (permalink / raw)
  To: Jan Beulich; +Cc: mingo, tglx, linux-kernel, hpa

On Wed, Dec 23, 2015 at 03:06:08AM -0700, Jan Beulich wrote:
> Sigh - this was in reply to your gcc version question. Right after having sent
> the most recent reply I realized that there's no Linux 4.3.4 yet, so there really
> was no ambiguity from the beginning. Therefore I have a hard time
> understanding what you're asking for.

I'm asking how exactly you're triggering this so that I can reproduce it too
here.

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

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

* Re: [PATCH] x86/ucode: replace redundant string literals
  2015-12-23 10:10         ` Borislav Petkov
@ 2015-12-23 10:11           ` Jan Beulich
  2016-01-05 20:44             ` [PATCH] x86/microcode: Remove redundant __setup() param parsing Borislav Petkov
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2015-12-23 10:11 UTC (permalink / raw)
  To: bp; +Cc: mingo, tglx, linux-kernel, hpa

>>> Borislav Petkov <bp@suse.de> 12/23/15 11:10 AM >>>
>On Wed, Dec 23, 2015 at 03:06:08AM -0700, Jan Beulich wrote:
>> Sigh - this was in reply to your gcc version question. Right after having sent
>> the most recent reply I realized that there's no Linux 4.3.4 yet, so there really
>> was no ambiguity from the beginning. Therefore I have a hard time
>> understanding what you're asking for.
>
>I'm asking how exactly you're triggering this so that I can reproduce it too
>here.

Simple 32-bit build on SLE11 SP4.

Jan


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

* [PATCH] x86/microcode: Remove redundant __setup() param parsing
  2015-12-23 10:11           ` Jan Beulich
@ 2016-01-05 20:44             ` Borislav Petkov
  0 siblings, 0 replies; 8+ messages in thread
From: Borislav Petkov @ 2016-01-05 20:44 UTC (permalink / raw)
  To: Jan Beulich; +Cc: mingo, tglx, linux-kernel, hpa

From: Borislav Petkov <bp@suse.de>

We do parse for the disable microcode loader chicken bit very early.
After the driver merge, the __setup() param parsing method is not needed
anymore so get rid of it.

In addition, fix a compiler warning from an old SLES11 gcc (4.3.4)
reported by Jan Beulich <jbeulich@suse.com>:

  arch/x86/kernel/cpu/microcode/core.c: In function ‘load_ucode_bsp’:
  arch/x86/kernel/cpu/microcode/core.c:96: warning: array subscript is above array bounds

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/kernel/cpu/microcode/core.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index b3e94ef461fd..f49e4d011e6f 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -43,16 +43,8 @@
 #define MICROCODE_VERSION	"2.01"
 
 static struct microcode_ops	*microcode_ops;
-
 static bool dis_ucode_ldr;
 
-static int __init disable_loader(char *str)
-{
-	dis_ucode_ldr = true;
-	return 1;
-}
-__setup("dis_ucode_ldr", disable_loader);
-
 /*
  * Synchronization.
  *
@@ -81,15 +73,16 @@ struct cpu_info_ctx {
 
 static bool __init check_loader_disabled_bsp(void)
 {
+	static const char *__dis_opt_str = "dis_ucode_ldr";
+
 #ifdef CONFIG_X86_32
 	const char *cmdline = (const char *)__pa_nodebug(boot_command_line);
-	const char *opt	    = "dis_ucode_ldr";
-	const char *option  = (const char *)__pa_nodebug(opt);
+	const char *option  = (const char *)__pa_nodebug(__dis_opt_str);
 	bool *res = (bool *)__pa_nodebug(&dis_ucode_ldr);
 
 #else /* CONFIG_X86_64 */
 	const char *cmdline = boot_command_line;
-	const char *option  = "dis_ucode_ldr";
+	const char *option  = __dis_opt_str;
 	bool *res = &dis_ucode_ldr;
 #endif
 
-- 
2.3.5

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

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

end of thread, other threads:[~2016-01-05 20:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-22 15:40 [PATCH] x86/ucode: replace redundant string literals Jan Beulich
2015-12-22 17:07 ` Borislav Petkov
2015-12-22 17:20   ` Jan Beulich
2015-12-22 18:14     ` Borislav Petkov
2015-12-23 10:06       ` Jan Beulich
2015-12-23 10:10         ` Borislav Petkov
2015-12-23 10:11           ` Jan Beulich
2016-01-05 20:44             ` [PATCH] x86/microcode: Remove redundant __setup() param parsing Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox