All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: nSVM: Expose DecodeAssists to L1
@ 2026-06-29 12:52 Tina Zhang
  2026-06-29 12:52 ` [PATCH 1/2] KVM: nSVM: Virtualize DecodeAssists for nested guests Tina Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Tina Zhang @ 2026-06-29 12:52 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, kvm
  Cc: Shuah Khan, zhouyanjing, linux-kselftest, linux-kernel

The SVM DecodeAssists feature is reported in CPUID
Fn8000_000A_EDX[7].  When available, hardware provides the length and bytes
of the intercepted instruction in the VMCB, allowing a hypervisor to consume
the decode information directly instead of re-decoding the instruction in
software on relevant VM-Exit paths.

KVM currently does not expose DecodeAssists to nested SVM guests, even when
the host supports it, and does not propagate the hardware-provided
instruction length and bytes from VMCB02 to VMCB12 on nested VM-Exit.  This
leaves L1 with an incomplete virtual SVM CPUID model and prevents L1 from
using the same hardware-assisted decode information that KVM receives for
L2 exits.

The missing virtualization was observed in practice with Hyper-V as L1,
where the absence of DecodeAssists prevented nested SVM from being made
available to L2 guests.  The fix is not Hyper-V specific.  Complete nested
SVM virtualization of DecodeAssists by advertising the feature to L1 when
supported by hardware, and by copying the decode-assist fields into VMCB12
on nested VM-Exit.

Add a selftest that triggers a nested page fault from L2 and verifies that
L1 sees a non-zero instruction length and instruction bytes matching the
faulting instruction.

Tested with:

  make -C tools/testing/selftests TARGETS=kvm run_tests

Tina Zhang (2):
  KVM: nSVM: Virtualize DecodeAssists for nested guests
  KVM: selftests: Add nested SVM DecodeAssists test

 arch/x86/kvm/svm/nested.c                     | 47 ++++++++-
 arch/x86/kvm/svm/svm.c                        |  3 +
 arch/x86/kvm/svm/svm.h                        |  6 ++
 tools/testing/selftests/kvm/Makefile.kvm      |  1 +
 .../selftests/kvm/include/x86/processor.h     |  1 +
 .../kvm/x86/svm_nested_decode_assists_test.c  | 99 +++++++++++++++++++
 6 files changed, 156 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/kvm/x86/svm_nested_decode_assists_test.c

-- 
2.43.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-06-30 15:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 12:52 [PATCH 0/2] KVM: nSVM: Expose DecodeAssists to L1 Tina Zhang
2026-06-29 12:52 ` [PATCH 1/2] KVM: nSVM: Virtualize DecodeAssists for nested guests Tina Zhang
2026-06-29 13:12   ` sashiko-bot
2026-06-30 15:11   ` Jim Mattson
2026-06-29 12:52 ` [PATCH 2/2] KVM: selftests: Add nested SVM DecodeAssists test Tina Zhang
2026-06-30 15:52 ` [PATCH 0/2] KVM: nSVM: Expose DecodeAssists to L1 Jim Mattson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.