[GIT PULL] KVM: x86: Emulated MMIO changes for 7.1

From: Sean Christopherson

Date: Fri Apr 10 2026 - 19:59:30 EST


Emulated MMIO changes to fix a use-after-free (kernel stack) bug, and do a
spring cleaning of the code (though it could certainly use even more cleaning).

The following changes since commit 11439c4635edd669ae435eec308f4ab8a0804808:

Linux 7.0-rc2 (2026-03-01 15:39:31 -0800)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-mmio-7.1

for you to fetch changes up to e2138c4a5be1e50d75281136bdc3e709cb07ec5e:

KVM: x86: Add helpers to prepare kvm_run for userspace MMIO exit (2026-03-02 16:06:49 -0800)

----------------------------------------------------------------
KVM x86 emulated MMIO changes for 7.1

Copy single-chunk MMIO write values into a persistent (per-fragment) field to
fix use-after-free stack bugs due to KVM dereferencing a stack pointer after an
exit to userspace.

Clean up and comment the emulated MMIO code to try to make it easier to
maintain (not necessarily "easy", but "easier").

----------------------------------------------------------------
Sean Christopherson (14):
KVM: x86: Use scratch field in MMIO fragment to hold small write values
KVM: x86: Open code handling of completed MMIO reads in emulator_read_write()
KVM: x86: Trace unsatisfied MMIO reads on a per-page basis
KVM: x86: Use local MMIO fragment variable to clean up emulator_read_write()
KVM: x86: Open code read vs. write userspace MMIO exits in emulator_read_write()
KVM: x86: Move MMIO write tracing into vcpu_mmio_write()
KVM: x86: Harden SEV-ES MMIO against on-stack use-after-free
KVM: x86: Dedup kvm_sev_es_mmio_{read,write}()
KVM: x86: Consolidate SEV-ES MMIO emulation into a single public API
KVM: x86: Bury emulator read/write ops in emulator_{read,write}_emulated()
KVM: x86: Fold emulator_write_phys() into write_emulate()
KVM: x86: Rename .read_write_emulate() to .read_write_guest()
KVM: x86: Don't panic the kernel if completing userspace I/O / MMIO goes sideways
KVM: x86: Add helpers to prepare kvm_run for userspace MMIO exit

arch/x86/include/asm/kvm_host.h | 3 -
arch/x86/kvm/emulate.c | 13 ++
arch/x86/kvm/svm/sev.c | 20 +--
arch/x86/kvm/vmx/tdx.c | 14 +-
arch/x86/kvm/x86.c | 287 ++++++++++++++++++----------------------
arch/x86/kvm/x86.h | 32 ++++-
include/linux/kvm_host.h | 3 +-
7 files changed, 180 insertions(+), 192 deletions(-)