diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-10-19 19:24:25 -1000 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-10-20 08:07:29 -1000 |
| commit | 5d64749b7df20ec3f0820fc94eefecfbf10f197e (patch) | |
| tree | da0926d228f678ce039e08e48f77a6efabe63f33 /scripts/Makefile.thinlto | |
| parent | 7170bd79ca52afbe1e0258f3080401385a6b3c49 (diff) | |
| download | linux-5d64749b7df20ec3f0820fc94eefecfbf10f197e.tar.gz linux-5d64749b7df20ec3f0820fc94eefecfbf10f197e.zip | |
x86/sev: Use explicit user-or-kernel accessors for #VC memory operands
vc_read_mem() and vc_write_mem() access the memory operand of an
emulated MOVS or INS/OUTS. That address may be a kernel address or a
user one, and the access must be a single MOV rather than a string
instruction, since the operand can itself be MMIO and take a nested #VC.
The code used __get_user() and __put_user() for this, on the grounds
that they do no pointer checks. That is a side effect of how x86
happens to implement them, not something they are for, and they are
going away.
Replace them with two local helpers that say what this is: a "user or
kernel" access with fault handling. They enable user access by hand
rather than through user_access_begin(), whose range check would reject
a kernel address, and use unsafe_get_user() and unsafe_put_user() for
the single MOV and its exception table entry. The read side uses
__uaccess_begin_nospec(), keeping the lfence that __get_user() used to
provide.
The old comment also claimed this always runs in atomic context, so the
page fault handler would not try to handle a fault. That holds when the
exception comes from kernel mode, where the handler runs as an NMI. It
does not hold when it comes from user mode, where the handler only has
interrupts disabled and so is not in_atomic(). A user-mode "rep insb"
into a not-yet-faulted buffer therefore went into do_user_addr_fault()
with interrupts off, and was only stopped by its legacy WARN_ON_ONCE()
on a clear IF flag. The helpers now disable page faults explicitly, so
the fault is refused up front and forwarded to the instruction as a #PF,
which is what was intended.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
