Re: [PATCH V2 4/4] KVM: selftests: Add nested page fault injection test

From: Sean Christopherson

Date: Tue Feb 24 2026 - 12:38:29 EST


On Tue, Feb 24, 2026, Kevin Cheng wrote:
> 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)

Either in this test or in KUT, we need coverage for validating faults that are
reported by hardware, i.e. for faults that _don't_ go through the emulator.

E.g. there's this "todo" of sorts in KUT:

case VMX_EPT_VIOLATION:
/*
* Exit-qualifications are masked not to account for advanced
* VM-exit information. Once KVM supports this feature, this
* masking should be removed.
*/
exit_qual &= ~EPT_VLT_GUEST_MASK;


Or maybe both? I generally prefer selftests for maintenance purposes, and you've
already written this test...