]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: selftests: Add nested page fault injection test
authorKevin Cheng <chengkev@google.com>
Fri, 22 May 2026 23:27:01 +0000 (16:27 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 26 May 2026 21:54:21 +0000 (14:54 -0700)
commit0de1020f7bbb3e1c9cd5b6f3eb4bdd661b1ff735
tree7afc5d61c155dcbbfe12ea4c4c9fe98af00029bf
parent96b067b59ad9ccede585fcadab27543188353bff
KVM: selftests: Add nested page fault injection test

Add a test that exercises nested page fault injection during L2
execution. L2 executes I/O string instructions (OUTSB/INSB) that access
memory restricted in L1's nested page tables (NPT/EPT), triggering a
nested page fault that L0 must inject to L1.

The test supports both AMD SVM (NPF) and Intel VMX (EPT violation) and
verifies that:
  - The exit reason is an NPF/EPT violation
  - The access type and permission bits are correct
  - The faulting GPA is correct

Three test cases are implemented:
  - Unmap the final data page (final translation fault, OUTSB read)
  - Unmap a PT page (page walk fault, OUTSB read)
  - Write-protect the final data page (protection violation, INSB write)
  - Write-protect a PT page (protection violation on A/D update, OUTSB
    read)

Signed-off-by: Kevin Cheng <chengkev@google.com>
[sean: name it nested_tdp_fault_test, consolidate asserts]
Link: https://patch.msgid.link/20260522232701.3671446-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/Makefile.kvm
tools/testing/selftests/kvm/include/x86/processor.h
tools/testing/selftests/kvm/x86/nested_tdp_fault_test.c [new file with mode: 0644]