Re: [PATCH 00/14] KVM: x86: Emulator MMIO fix and cleanups
From: Sean Christopherson
Date: Thu Mar 05 2026 - 12:18:37 EST
On Tue, 24 Feb 2026 17:20:35 -0800, Sean Christopherson wrote:
> Fix a UAF stack bug where KVM references a stack pointer around an exit to
> userspace, and then clean up the related code to try to make it easier to
> maintain (not necessarily "easy", but "easier").
>
> The SEV-ES and TDX changes are compile-tested only.
>
> 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
>
> [...]
Applied to kvm-x86 mmio, with the hardened version of the helper in patch 14.
Thanks for the testing!
[01/14] KVM: x86: Use scratch field in MMIO fragment to hold small write values
https://github.com/kvm-x86/linux/commit/0b16e69d17d8
[02/14] KVM: x86: Open code handling of completed MMIO reads in emulator_read_write()
https://github.com/kvm-x86/linux/commit/4046823e78b0
[03/14] KVM: x86: Trace unsatisfied MMIO reads on a per-page basis
https://github.com/kvm-x86/linux/commit/4f11fded5381
[04/14] KVM: x86: Use local MMIO fragment variable to clean up emulator_read_write()
https://github.com/kvm-x86/linux/commit/523b6269f700
[05/14] KVM: x86: Open code read vs. write userspace MMIO exits in emulator_read_write()
https://github.com/kvm-x86/linux/commit/cbbf8228c071
[06/14] KVM: x86: Move MMIO write tracing into vcpu_mmio_write()
https://github.com/kvm-x86/linux/commit/72f36f99072c
[07/14] KVM: x86: Harden SEV-ES MMIO against on-stack use-after-free
https://github.com/kvm-x86/linux/commit/144089f5c394
[08/14] KVM: x86: Dedup kvm_sev_es_mmio_{read,write}()
https://github.com/kvm-x86/linux/commit/33e09e2f9735
[09/14] KVM: x86: Consolidate SEV-ES MMIO emulation into a single public API
https://github.com/kvm-x86/linux/commit/326e810eaaa5
[10/14] KVM: x86: Bury emulator read/write ops in emulator_{read,write}_emulated()
https://github.com/kvm-x86/linux/commit/3517193ef9c2
[11/14] KVM: x86: Fold emulator_write_phys() into write_emulate()
https://github.com/kvm-x86/linux/commit/929613b3cd1a
[12/14] KVM: x86: Rename .read_write_emulate() to .read_write_guest()
https://github.com/kvm-x86/linux/commit/216729846603
[13/14] KVM: x86: Don't panic the kernel if completing userspace I/O / MMIO goes sideways
https://github.com/kvm-x86/linux/commit/4f09e62afcd6
[14/14] KVM: x86: Add helpers to prepare kvm_run for userspace MMIO exit
https://github.com/kvm-x86/linux/commit/e2138c4a5be1
--
https://github.com/kvm-x86/linux/tree/next