Skip to content

Commit e8ffcd3

Browse files
committed
Merge tag 'x86_urgent_for_v5.16_rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Borislav Petkov: - Prevent potential undefined behavior due to shifting pkey constants into the sign bit - Move the EFI memory reservation code *after* the efi= cmdline parsing has happened - Revert two commits which turned out to be the wrong direction to chase when accommodating early memblock reservations consolidation and command line parameters parsing * tag 'x86_urgent_for_v5.16_rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/pkey: Fix undefined behaviour with PKRU_WD_BIT x86/boot: Move EFI range reservation after cmdline parsing Revert "x86/boot: Pull up cmdline preparation and early param parsing" Revert "x86/boot: Mark prepare_command_line() __init"
2 parents 2afa90b + 5769055 commit e8ffcd3

File tree

2 files changed

+32
-44
lines changed

2 files changed

+32
-44
lines changed

arch/x86/include/asm/pkru.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#include <asm/cpufeature.h>
66

7-
#define PKRU_AD_BIT 0x1
8-
#define PKRU_WD_BIT 0x2
7+
#define PKRU_AD_BIT 0x1u
8+
#define PKRU_WD_BIT 0x2u
99
#define PKRU_BITS_PER_PKEY 2
1010

1111
#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS

arch/x86/kernel/setup.c

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,6 @@ static void __init early_reserve_memory(void)
713713

714714
early_reserve_initrd();
715715

716-
if (efi_enabled(EFI_BOOT))
717-
efi_memblock_x86_reserve_range();
718-
719716
memblock_x86_reserve_range_setup_data();
720717

721718
reserve_ibft_region();
@@ -742,28 +739,6 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
742739
return 0;
743740
}
744741

745-
static char * __init prepare_command_line(void)
746-
{
747-
#ifdef CONFIG_CMDLINE_BOOL
748-
#ifdef CONFIG_CMDLINE_OVERRIDE
749-
strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
750-
#else
751-
if (builtin_cmdline[0]) {
752-
/* append boot loader cmdline to builtin */
753-
strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
754-
strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
755-
strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
756-
}
757-
#endif
758-
#endif
759-
760-
strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
761-
762-
parse_early_param();
763-
764-
return command_line;
765-
}
766-
767742
/*
768743
* Determine if we were loaded by an EFI loader. If so, then we have also been
769744
* passed the efi memmap, systab, etc., so we should use these data structures
@@ -852,23 +827,6 @@ void __init setup_arch(char **cmdline_p)
852827

853828
x86_init.oem.arch_setup();
854829

855-
/*
856-
* x86_configure_nx() is called before parse_early_param() (called by
857-
* prepare_command_line()) to detect whether hardware doesn't support
858-
* NX (so that the early EHCI debug console setup can safely call
859-
* set_fixmap()). It may then be called again from within noexec_setup()
860-
* during parsing early parameters to honor the respective command line
861-
* option.
862-
*/
863-
x86_configure_nx();
864-
865-
/*
866-
* This parses early params and it needs to run before
867-
* early_reserve_memory() because latter relies on such settings
868-
* supplied as early params.
869-
*/
870-
*cmdline_p = prepare_command_line();
871-
872830
/*
873831
* Do some memory reservations *before* memory is added to memblock, so
874832
* memblock allocations won't overwrite it.
@@ -902,6 +860,36 @@ void __init setup_arch(char **cmdline_p)
902860
bss_resource.start = __pa_symbol(__bss_start);
903861
bss_resource.end = __pa_symbol(__bss_stop)-1;
904862

863+
#ifdef CONFIG_CMDLINE_BOOL
864+
#ifdef CONFIG_CMDLINE_OVERRIDE
865+
strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
866+
#else
867+
if (builtin_cmdline[0]) {
868+
/* append boot loader cmdline to builtin */
869+
strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
870+
strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
871+
strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
872+
}
873+
#endif
874+
#endif
875+
876+
strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
877+
*cmdline_p = command_line;
878+
879+
/*
880+
* x86_configure_nx() is called before parse_early_param() to detect
881+
* whether hardware doesn't support NX (so that the early EHCI debug
882+
* console setup can safely call set_fixmap()). It may then be called
883+
* again from within noexec_setup() during parsing early parameters
884+
* to honor the respective command line option.
885+
*/
886+
x86_configure_nx();
887+
888+
parse_early_param();
889+
890+
if (efi_enabled(EFI_BOOT))
891+
efi_memblock_x86_reserve_range();
892+
905893
#ifdef CONFIG_MEMORY_HOTPLUG
906894
/*
907895
* Memory used by the kernel cannot be hot-removed because Linux

0 commit comments

Comments
 (0)