x86/urgent for v5.13-rc5
Hi Linus,
a bunch of x86/urgent stuff accumulated for the last two weeks so lemme unload it to you. It should be all totally risk-free, ofcourse. :-)
Please pull,
thx.
---
The following changes since commit c4681547bcce777daf576925a966ffa824edd09d:
Linux 5.13-rc3 (2021-05-23 11:42:48 -1000)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git tags/x86_urgent_for_v5.13-rc5
for you to fetch changes up to 009767dbf42ac0dbe3cf48c1ee224f6b778aa85a:
x86/sev: Check SME/SEV support in CPUID first (2021-06-04 18:39:09 +0200)
----------------------------------------------------------------
- Fix out-of-spec hardware (1st gen Hygon) which does not implement MSR_AMD64_SEV even though the spec clearly states so, and check CPUID bits first.
- Send only one signal to a task when it is a SEGV_PKUERR si_code type.
- Do away with all the wankery of reserving X amount of memory in the first megabyte to prevent BIOS corrupting it and simply and unconditionally reserve the whole first megabyte.
- Make alternatives NOP optimization work at an arbitrary position within the patched sequence because the compiler can put single-byte NOPs for alignment anywhere in the sequence (32-bit retpoline), vs our previous assumption that the NOPs are only appended.
- Force-disable ENQCMD[S] instructions support and remove update_pasid() because of insufficient protection against FPU state modification in an interrupt context, among other xstate horrors which are being addressed at the moment. This one limits the fallout until proper enablement.
- Use cpu_feature_enabled() in the idxd driver so that it can be build-time disabled through the defines in .../asm/disabled-features.h.
- Fix LVT thermal setup for SMI delivery mode by making sure the APIC LVT value is read before APIC initialization so that softlockups during boot do not happen at least on one machine.
- Mark all legacy interrupts as legacy vectors when the IO-APIC is disabled and when all legacy interrupts are routed through the PIC.
----------------------------------------------------------------
Borislav Petkov (3):
x86/thermal: Fix LVT thermal setup for SMI delivery mode
dmaengine: idxd: Use cpu_feature_enabled() x86/alternative: Optimize single-byte NOPs at an arbitrary position
Jiashuo Liang (1):
x86/fault: Don't send SIGSEGV twice on SEGV_PKUERR
Mike Rapoport (1):
x86/setup: Always reserve the first 1M of RAM
Pu Wen (1):
x86/sev: Check SME/SEV support in CPUID first
Thomas Gleixner (2):
x86/apic: Mark _all_ legacy interrupts when IO/APIC is missing x86/cpufeatures: Force disable X86_FEATURE_ENQCMD and remove update_pasid()
arch/x86/include/asm/apic.h | 1 + arch/x86/include/asm/disabled-features.h | 7 +--- arch/x86/include/asm/fpu/api.h | 6 +-- arch/x86/include/asm/fpu/internal.h | 7 ---- arch/x86/include/asm/thermal.h | 4 +- arch/x86/kernel/alternative.c | 64 +++++++++++++++++++++++--------- arch/x86/kernel/apic/apic.c | 1 + arch/x86/kernel/apic/vector.c | 20 ++++++++++ arch/x86/kernel/fpu/xstate.c | 57 ---------------------------- arch/x86/kernel/setup.c | 44 +++++++++++++++------- arch/x86/mm/fault.c | 4 +- arch/x86/mm/mem_encrypt_identity.c | 11 +++--- arch/x86/platform/efi/quirks.c | 12 ++++++ arch/x86/realmode/init.c | 14 ++++--- drivers/dma/idxd/init.c | 4 +- drivers/thermal/intel/therm_throt.c | 15 ++++++-- 16 files changed, 145 insertions(+), 126 deletions(-)
Signature · 4 lines
Regards/Gruss,
Boris.
SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG NürnbergQuoted 4 lines · Borislav Petkov
- Do away with all the wankery of reserving X amount of memory in the first megabyte to prevent BIOS corrupting it and simply and unconditionally reserve the whole first megabyte.
This seems a bit draconic.
How does this work at all under Windows? There must be some windows knowledge about what the BIOS updates that we're not aware of.
I've pulled it, but it does seem like something odd is going on.
And that
makes me go "Umm.." too. What did a799c2bd29d1 actually break? It looks like it was meant to be a no-op consolidation - if somebody bisected to it, I think that is a sign that there's something odd there.
Linus
Quoted 10 lines · Linus Torvalds
Quoted 4 lines · Borislav Petkov
- Do away with all the wankery of reserving X amount of memory in the first megabyte to prevent BIOS corrupting it and simply and unconditionally reserve the whole first megabyte.
This seems a bit draconic.
How does this work at all under Windows? There must be some windows knowledge about what the BIOS updates that we're not aware of.
A while ago hpa said:
As far as I know, Windows 7 actually reserves all memory below 1 MiB to avoid BIOS bugs.
(https://bugzilla.kernel.org/show_bug.cgi?id=16661#c2)
Quoted 10 lines
I've pulled it, but it does seem like something odd is going on.
And that
Fixes a799c2bd29d1 ("x86/setup: Consolidate early memory reservations")makes me go "Umm.." too. What did
a799c2bd29d1actually break? It looks like it was meant to be a no-op consolidation - if somebody bisected to it, I think that is a sign that there's something odd there.
I also hoped that a799c2bd29d1 would be a no-op consolidation, but I overlooked that if a user sets CONFIG_X86_RESERVE_LOW or reservelow to 640K instead of the default 64K, we end up reserving all the memory below 1M before we allocate the real mode trampoline. This gets even more hairy because of other things that may also need to reserve the entire first megabyte, like crash kernel or workaround for Sandy Bridge integrated graphics bugs.
I believe that reserving everything below 1M after the real mode trampoline is allocated reduces amount of hidden dependencies and makes things simpler overall.
Signature · 2 lines
Sincerely yours, Mike.
Quoted 7 lines · Mike Rapoport
A while ago hpa said:
As far as I know, Windows 7 actually reserves all memory below 1 MiB to avoid BIOS bugs.
It would be good to have that checked somehow.
I don't think this matters on any machine with gigs of RAM, but I do wonder about the people who want to do small configurations. Maybe they've given up on x86?
It also eats into that somewhat precious legacy DMA resource and eats up a fair chunk of that. Again, not an issue on modern hardware, but ..
Quoted 3 lines
I believe that reserving everything below 1M after the real mode trampoline is allocated reduces amount of hidden dependencies and makes things simpler overall.
Simpler, perhaps, and _I_ personally don't care about about 512kB of memory any more on any machines I have, but ..
Linus
Borislav Petkov
maintainerQuoted 19 lines · Linus Torvalds
Quoted 7 lines · Mike Rapoport
A while ago hpa said:
As far as I know, Windows 7 actually reserves all memory below 1 MiB to avoid BIOS bugs.
It would be good to have that checked somehow.
I don't think this matters on any machine with gigs of RAM, but I do wonder about the people who want to do small configurations. Maybe they've given up on x86?
It also eats into that somewhat precious legacy DMA resource and eats up a fair chunk of that. Again, not an issue on modern hardware, but ..
Quoted 6 lines
Quoted 3 lines
I believe that reserving everything below 1M after the real mode trampoline is allocated reduces amount of hidden dependencies and makes things simpler overall.
Simpler, perhaps, and _I_ personally don't care about about 512kB of memory any more on any machines I have, but ..
Let's see if Sasha can dig out something... CCed.
@Sasha, can you figure out who we can talk to whether Windoze reserves the first megabyte of memory unconditionally?
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 24 lines · Borislav Petkov
Quoted 23 lines · Linus Torvalds
Quoted 7 lines · Mike Rapoport
A while ago hpa said:
As far as I know, Windows 7 actually reserves all memory below 1 MiB to avoid BIOS bugs.
It would be good to have that checked somehow.
I don't think this matters on any machine with gigs of RAM, but I do wonder about the people who want to do small configurations. Maybe they've given up on x86?
It also eats into that somewhat precious legacy DMA resource and eats up a fair chunk of that. Again, not an issue on modern hardware, but ..
Quoted 3 lines
I believe that reserving everything below 1M after the real mode trampoline is allocated reduces amount of hidden dependencies and makes things simpler overall.
Quoted 7 lines
Quoted 2 lines
Simpler, perhaps, and _I_ personally don't care about about 512kB of memory any more on any machines I have, but ..
Let's see if Sasha can dig out something... CCed.
@Sasha, can you figure out who we can talk to whether Windoze reserves the first megabyte of memory unconditionally?
That's a great question, but I can't help there anymore :)
Adding James Morris...
Signature · 2 lines
Thanks, Sasha
Quoted 9 lines · Sasha Levin
Quoted 5 lines
Let's see if Sasha can dig out something... CCed.
@Sasha, can you figure out who we can talk to whether Windoze reserves the first megabyte of memory unconditionally?
That's a great question, but I can't help there anymore :)
Adding James Morris...
Adding Michael Kelley.
Signature · 2 lines
James Morris <[email protected]>
From: James Morris <[email protected]> Sent: Monday, June 7, 2021 11:47 AM
Quoted 6 lines · Sasha Levin
Quoted 4 lines
Quoted 4 lines
Let's see if Sasha can dig out something... CCed.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
@Sasha, can you figure out who we can talk to whether Windoze reserves the first megabyte of memory unconditionally?
That's a great question, but I can't help there anymore :)
Adding James Morris...
Adding Michael Kelley.
I checked with the Windows team. Peter Anvin's statement from 11 years ago is true. On Intel and AMD processors, Windows unconditionally reserves the 1st megabyte of memory, minus one page used for real
mode startup. This is done to work around BIOS bugs.
Michael
Borislav Petkov
maintainerQuoted 4 lines · Michael Kelley
I checked with the Windows team. Peter Anvin's statement from 11 years ago is true. On Intel and AMD processors, Windows unconditionally reserves the 1st megabyte of memory, minus one page used for real
mode startup. This is done to work around BIOS bugs.
Thanks for checking!
I guess us doing the same is probably fine.
Linus, maybe we should at least give it a try and see whether someone complains and revert, potentially...?
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 3 lines · Borislav Petkov
Linus, maybe we should at least give it a try and see whether someone complains and revert, potentially...?
I already merged the change that did that.
It might be worth adding a comment about the verified Windows behavior here, but I think otherwise we're all done.
Unless somebody complains, as you say.
Linus
Borislav Petkov
maintainerQuoted 6 lines · Linus Torvalds
Quoted 3 lines · Borislav Petkov
Linus, maybe we should at least give it a try and see whether someone complains and revert, potentially...?
I already merged the change that did that.
Oh yeah, I meant: let's leave it in and try it and only revert if there's trouble.
Quoted 2 lines
It might be worth adding a comment about the verified Windows behavior here, but I think otherwise we're all done.
How's that (comment re-flowed):
arch/x86/kernel/setup.c +11 -10
@@ -1084,17 +1084,18 @@ void __init setup_arch(char **cmdline_p)#endif /* -* Find free memory for the real mode trampoline and place it -* there. -* If there is not enough free memory under 1M, on EFI-enabled -* systems there will be additional attempt to reclaim the memory -* for the real mode trampoline at efi_free_boot_services(). +* Find free memory for the real mode trampoline and place it there. If +* there is not enough free memory under 1M, on EFI-enabled systems +* there will be additional attempt to reclaim the memory for the real +* mode trampoline at efi_free_boot_services(). * -* Unconditionally reserve the entire first 1M of RAM because -* BIOSes are know to corrupt low memory and several -* hundred kilobytes are not worth complex detection what memory gets -* clobbered. Moreover, on machines with SandyBridge graphics or in -* setups that use crashkernel the entire 1M is reserved anyway. +* Unconditionally reserve the entire first 1M of RAM because BIOSes +* are known to corrupt low memory and several hundred kilobytes are not +* worth complex detection what memory gets clobbered. Windows does the +* same thing for very similar reasons. +* +* Moreover, on machines with SandyBridge graphics or in setups that use +* crashkernel the entire 1M is reserved anyway. */ reserve_real_mode ();
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 2 lines · Borislav Petkov
How's that (comment re-flowed):
Ack, looks good. Additionally, please refer to this thread on lore.kernel.org in the commit message so that we can find that confirmation about Windows behavior, and I think we're all set.
Linus
Borislav Petkov
maintainerPATCH 1/1 x86/setup: Document that Windows reserves the first MiB
It does so unconditionally too, on Intel and AMD machines, to work around BIOS bugs, as confirmed by Microsoft folks (see Link for full details).
Reflow the paragraph, while at it.
--- arch/x86/kernel/setup.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
arch/x86/kernel/setup.c +11 -10
@@ -1060,17 +1060,18 @@ void __init setup_arch(char **cmdline_p)#endif /* -* Find free memory for the real mode trampoline and place it -* there. -* If there is not enough free memory under 1M, on EFI-enabled -* systems there will be additional attempt to reclaim the memory -* for the real mode trampoline at efi_free_boot_services(). +* Find free memory for the real mode trampoline and place it there. If +* there is not enough free memory under 1M, on EFI-enabled systems +* there will be additional attempt to reclaim the memory for the real +* mode trampoline at efi_free_boot_services(). * -* Unconditionally reserve the entire first 1M of RAM because -* BIOSes are know to corrupt low memory and several -* hundred kilobytes are not worth complex detection what memory gets -* clobbered. Moreover, on machines with SandyBridge graphics or in -* setups that use crashkernel the entire 1M is reserved anyway. +* Unconditionally reserve the entire first 1M of RAM because BIOSes +* are known to corrupt low memory and several hundred kilobytes are not +* worth complex detection what memory gets clobbered. Windows does the +* same thing for very similar reasons. +* +* Moreover, on machines with SandyBridge graphics or in setups that use +* crashkernel the entire 1M is reserved anyway. */ reserve_real_mode ();
Signature · 7 lines
2.29.2
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH] x86/setup: Document that Windows reserves the first MiB
Quoted 7 lines · Borislav Petkov
It does so unconditionally too, on Intel and AMD machines, to work around BIOS bugs, as confirmed by Microsoft folks (see Link for full details).
Reflow the paragraph, while at it.
Signed-off-by Borislav Petkov <[email protected]>
Thanks for taking care of this!
Quoted 46 lines
--- arch/x86/kernel/setup.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)arch/x86/kernel/setup.c +11
-10@@ -1060,17 +1060,18 @@ void __init setup_arch(char **cmdline_p)#endif /* -* Find free memory for the real mode trampoline and place it -* there. -* If there is not enough free memory under 1M, on EFI-enabled -* systems there will be additional attempt to reclaim the memory -* for the real mode trampoline at efi_free_boot_services(). +* Find free memory for the real mode trampoline and place it there. If +* there is not enough free memory under 1M, on EFI-enabled systems +* there will be additional attempt to reclaim the memory for the real +* mode trampoline at efi_free_boot_services(). * -* Unconditionally reserve the entire first 1M of RAM because -* BIOSes are know to corrupt low memory and several -* hundred kilobytes are not worth complex detection what memory gets -* clobbered. Moreover, on machines with SandyBridge graphics or in -* setups that use crashkernel the entire 1M is reserved anyway. +* Unconditionally reserve the entire first 1M of RAM because BIOSes +* are known to corrupt low memory and several hundred kilobytes are not +* worth complex detection what memory gets clobbered. Windows does the +* same thing for very similar reasons. +* +* Moreover, on machines with SandyBridge graphics or in setups that use +* crashkernel the entire 1M is reserved anyway. */ reserve_real_mode ();Signature · 7 lines
2.29.2 -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette
Signature · 2 lines
Sincerely yours, Mike.
Quoted 14 lines · Michael Kelley
From: James Morris <[email protected]> Sent: Monday, June 7, 2021 11:47 AM
Quoted 13 lines · Sasha Levin
Quoted 10 lines
Quoted 6 lines
Let's see if Sasha can dig out something... CCed.
@Sasha, can you figure out who we can talk to whether Windoze reserves the first megabyte of memory unconditionally?
That's a great question, but I can't help there anymore :)
Adding James Morris...
Quoted 7 lines
Quoted 2 lines
Adding Michael Kelley.
I checked with the Windows team. Peter Anvin's statement from 11 years ago is true. On Intel and AMD processors, Windows unconditionally reserves the 1st megabyte of memory, minus one page used for real
mode startup. This is done to work around BIOS bugs.
Sorry to dredge up old skeletons. Do you know *where* Windows allocates that one page used for real mode startup? The current code in Linux has some bugs allocating that page, and it would be nice to sort it out.
From: Andy Lutomirski <[email protected]> Sent: Thursday, March 2, 2023 8:14 AM
Quoted 19 lines · Michael Kelley
Quoted 17 lines
From: James Morris <[email protected]> Sent: Monday, June 7, 2021 11:47 AM
Quoted 15 lines · Sasha Levin
Quoted 10 lines
Quoted 6 lines
Let's see if Sasha can dig out something... CCed.
@Sasha, can you figure out who we can talk to whether Windoze reserves the first megabyte of memory unconditionally?
That's a great question, but I can't help there anymore :)
Adding James Morris...
Adding Michael Kelley.
Quoted 8 lines
Quoted 4 lines
I checked with the Windows team. Peter Anvin's statement from 11 years ago is true. On Intel and AMD processors, Windows unconditionally reserves the 1st megabyte of memory, minus one page used for real
mode startup. This is done to work around BIOS bugs.Sorry to dredge up old skeletons. Do you know *where* Windows allocates that one page used for real mode startup? The current code in Linux has some bugs allocating that page, and it would be nice to sort it out.
The Windows folks tell me that the single page is typically allocated at physical address0x1000. They don't allocate physical page 0, so they scan upward starting at physical
page 1 and use the first page that is not reserved by firmware. That's usually page 1.
Michael
The pull request you sent on Sun, 6 Jun 2021 09:55:52 +0200:
The pull request you sent on Sun, 6 Jun 2021 09:55:52 +0200:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gittags/x86_urgent_for_v5.13-rc5
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/773ac53bbfcebb58ce03577d94ce471cadf3ea18
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html