x86/ucode: replace redundant string literals
Subsystems (2)
PATCH 1/1 x86/ucode: replace redundant string literals
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.
--- arch/x86/kernel/cpu/microcode/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/microcode/core.c +2 -4
@@ -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
Quoted 3 lines · Jan Beulich
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.
Quoted 2 lines
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?
Quoted 12 lines
Signed-off-by Jan Beulich <[email protected]>--- arch/x86/kernel/cpu/microcode/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/x86/kernel/cpu/microcode/core.c +0
-1@@ -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" ;
arch/x86/kernel/cpu/microcode/core.c static bool __init check_loader_disabled · line 92
Quoted 10 lines
arch/x86/kernel/cpu/microcode/core.c +2
-3-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.
Signature · 5 lines
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 22.12.15 at 18:07, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
This doesn't just eliminate needless redundancy
(plus avoid a possible disconnect if one string instance gets changed without the other(s)),
Quoted 8 lines
This argument is bogus. We will never ever change a user-visible command line option. Ever.
Quoted 2 lines
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).
Quoted 22 lines
Quoted 7 lines
arch/x86/kernel/cpu/microcode/core.c +0
-1@@ -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" ;arch/x86/kernel/cpu/microcode/core.c static bool __init check_loader_disabled · line 92
Quoted 10 lines
arch/x86/kernel/cpu/microcode/core.c +2
-3-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
__setupmacro. In addition, this code is as unreadable as it is now - your patch makes it even more cryptic.
Quoted 1 line
I much prefer the redundancy.
And the compiler warning? At the very least these should then be const char __initconst [].
Jan
Quoted 2 lines · Jan Beulich
As said - 4.3.4 (I only now realize that this could also have been a kernel version).
Just fetched stable fromgit://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...
Quoted 2 lines
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.
Signature · 5 lines
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- Quoted 21 lines
Quoted 1 line
Quoted 1 line
Borislav Petkov <[email protected]> 12/22/15 7:14 PM >>>
Quoted 2 lines · Jan Beulich
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
Quoted 1 line
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
Quoted 4 lines · Jan Beulich
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.
Signature · 5 lines
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- Quoted 9 lines
Quoted 1 line
Quoted 1 line
Borislav Petkov <[email protected]> 12/23/15 11:10 AM >>>
Quoted 4 lines · Jan Beulich
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
PATCH 1/1 x86/microcode: Remove redundant __setup() param parsing
From: Borislav Petkov <[email protected]>
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 <[email protected]>:
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
--- arch/x86/kernel/cpu/microcode/core.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
arch/x86/kernel/cpu/microcode/core.c +4 -11
@@ -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
Signature · 4 lines
2.3.5 SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --