Re: [PATCH v2 10/11] KVM: selftests: nSVM: Add svm_nested_soft_inject_test

From: Maciej S. Szmigiero
Date: Mon Apr 25 2022 - 19:00:52 EST


On 23.04.2022 04:14, Sean Christopherson wrote:
From: Maciej S. Szmigiero <maciej.szmigiero@xxxxxxxxxx>

Add a KVM self-test that checks whether a nSVM L1 is able to successfully
inject a software interrupt and a soft exception into its L2 guest.

In practice, this tests both the next_rip field consistency and
L1-injected event with intervening L0 VMEXIT during its delivery:
the first nested VMRUN (that's also trying to inject a software interrupt)
will immediately trigger a L0 NPF.
This L0 NPF will have zero in its CPU-returned next_rip field, which if
incorrectly reused by KVM will trigger a #PF when trying to return to
such address 0 from the interrupt handler.

Reviewed-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@xxxxxxxxxx>
[sean: check exact L2 RIP on first soft interrupt]
Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>

Looks like this version doesn't integrate the changes that Maxim has suggested [1].
Will provide an updated version after I test the patch set.

Thanks,
Maciej

[1]: https://lore.kernel.org/kvm/2401bf729beab6d9348fda18f55e90ed9c1f7583.camel@xxxxxxxxxx/