Skip to content

Commit d396360

Browse files
committed
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: "Misc fixes and updates: - a handful of MDS documentation/comment updates - a cleanup related to hweight interfaces - a SEV guest fix for large pages - a kprobes LTO fix - and a final cleanup commit for vDSO HPET support removal" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/speculation/mds: Improve CPU buffer clear documentation x86/speculation/mds: Revert CPU buffer clear on double fault exit x86/kconfig: Disable CONFIG_GENERIC_HWEIGHT and remove __HAVE_ARCH_SW_HWEIGHT x86/mm: Do not use set_{pud, pmd}_safe() when splitting a large page x86/kprobes: Make trampoline_handler() global and visible x86/vdso: Remove hpet_page from vDSO
2 parents b2c3dda + 9d8d029 commit d396360

11 files changed

Lines changed: 121 additions & 103 deletions

File tree

‎Documentation/x86/mds.rst‎

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -142,45 +142,13 @@ Mitigation points
142142
mds_user_clear.
143143

144144
The mitigation is invoked in prepare_exit_to_usermode() which covers
145-
most of the kernel to user space transitions. There are a few exceptions
146-
which are not invoking prepare_exit_to_usermode() on return to user
147-
space. These exceptions use the paranoid exit code.
145+
all but one of the kernel to user space transitions. The exception
146+
is when we return from a Non Maskable Interrupt (NMI), which is
147+
handled directly in do_nmi().
148148

149-
- Non Maskable Interrupt (NMI):
150-
151-
Access to sensible data like keys, credentials in the NMI context is
152-
mostly theoretical: The CPU can do prefetching or execute a
153-
misspeculated code path and thereby fetching data which might end up
154-
leaking through a buffer.
155-
156-
But for mounting other attacks the kernel stack address of the task is
157-
already valuable information. So in full mitigation mode, the NMI is
158-
mitigated on the return from do_nmi() to provide almost complete
159-
coverage.
160-
161-
- Double fault (#DF):
162-
163-
A double fault is usually fatal, but the ESPFIX workaround, which can
164-
be triggered from user space through modify_ldt(2) is a recoverable
165-
double fault. #DF uses the paranoid exit path, so explicit mitigation
166-
in the double fault handler is required.
167-
168-
- Machine Check Exception (#MC):
169-
170-
Another corner case is a #MC which hits between the CPU buffer clear
171-
invocation and the actual return to user. As this still is in kernel
172-
space it takes the paranoid exit path which does not clear the CPU
173-
buffers. So the #MC handler repopulates the buffers to some
174-
extent. Machine checks are not reliably controllable and the window is
175-
extremly small so mitigation would just tick a checkbox that this
176-
theoretical corner case is covered. To keep the amount of special
177-
cases small, ignore #MC.
178-
179-
- Debug Exception (#DB):
180-
181-
This takes the paranoid exit path only when the INT1 breakpoint is in
182-
kernel space. #DB on a user space address takes the regular exit path,
183-
so no extra mitigation required.
149+
(The reason that NMI is special is that prepare_exit_to_usermode() can
150+
enable IRQs. In NMI context, NMIs are blocked, and we don't want to
151+
enable IRQs with NMIs blocked.)
184152

185153

186154
2. C-State transition

‎arch/x86/Kconfig‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,6 @@ config GENERIC_BUG
270270
config GENERIC_BUG_RELATIVE_POINTERS
271271
bool
272272

273-
config GENERIC_HWEIGHT
274-
def_bool y
275-
276273
config ARCH_MAY_HAVE_PC_FDC
277274
def_bool y
278275
depends on ISA_DMA_API

‎arch/x86/entry/vdso/vdso2c.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,12 @@ const char *outfilename;
7373
enum {
7474
sym_vvar_start,
7575
sym_vvar_page,
76-
sym_hpet_page,
7776
sym_pvclock_page,
7877
sym_hvclock_page,
7978
};
8079

8180
const int special_pages[] = {
8281
sym_vvar_page,
83-
sym_hpet_page,
8482
sym_pvclock_page,
8583
sym_hvclock_page,
8684
};
@@ -93,7 +91,6 @@ struct vdso_sym {
9391
struct vdso_sym required_syms[] = {
9492
[sym_vvar_start] = {"vvar_start", true},
9593
[sym_vvar_page] = {"vvar_page", true},
96-
[sym_hpet_page] = {"hpet_page", true},
9794
[sym_pvclock_page] = {"pvclock_page", true},
9895
[sym_hvclock_page] = {"hvclock_page", true},
9996
{"VDSO32_NOTE_MASK", true},

‎arch/x86/include/asm/arch_hweight.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#define REG_OUT "a"
1313
#endif
1414

15-
#define __HAVE_ARCH_SW_HWEIGHT
16-
1715
static __always_inline unsigned int __arch_hweight32(unsigned int w)
1816
{
1917
unsigned int res;

‎arch/x86/include/asm/vdso.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct vdso_image {
1919
long sym_vvar_start; /* Negative offset to the vvar area */
2020

2121
long sym_vvar_page;
22-
long sym_hpet_page;
2322
long sym_pvclock_page;
2423
long sym_hvclock_page;
2524
long sym_VDSO32_NOTE_MASK;

‎arch/x86/kernel/kprobes/core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ static struct kprobe kretprobe_kprobe = {
768768
/*
769769
* Called from kretprobe_trampoline
770770
*/
771-
static __used void *trampoline_handler(struct pt_regs *regs)
771+
__used __visible void *trampoline_handler(struct pt_regs *regs)
772772
{
773773
struct kprobe_ctlblk *kcb;
774774
struct kretprobe_instance *ri = NULL;

‎arch/x86/kernel/traps.c‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
#include <asm/alternative.h>
5959
#include <asm/fpu/xstate.h>
6060
#include <asm/trace/mpx.h>
61-
#include <asm/nospec-branch.h>
6261
#include <asm/mpx.h>
6362
#include <asm/vm86.h>
6463
#include <asm/umip.h>
@@ -368,13 +367,6 @@ dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
368367
regs->ip = (unsigned long)general_protection;
369368
regs->sp = (unsigned long)&gpregs->orig_ax;
370369

371-
/*
372-
* This situation can be triggered by userspace via
373-
* modify_ldt(2) and the return does not take the regular
374-
* user space exit, so a CPU buffer clear is required when
375-
* MDS mitigation is enabled.
376-
*/
377-
mds_user_clear_cpu_buffers();
378370
return;
379371
}
380372
#endif

0 commit comments

Comments
 (0)