Skip to content

Commit b4dfbfd

Browse files
Paul Durrantsean-jc
authored andcommitted
KVM: selftests: re-map Xen's vcpu_info using HVA rather than GPA
If the relevant capability (KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA) is present then re-map vcpu_info using the HVA part way through the tests to make sure then there is no functional change. Signed-off-by: Paul Durrant <pdurrant@amazon.com> Reviewed-by: David Woodhouse <dwmw@amazon.co.uk> Link: https://lore.kernel.org/r/20240215152916.1158-16-paul@xen.org Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 9397b53 commit b4dfbfd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum {
6262
TEST_POLL_TIMEOUT,
6363
TEST_POLL_MASKED,
6464
TEST_POLL_WAKE,
65+
SET_VCPU_INFO,
6566
TEST_TIMER_PAST,
6667
TEST_LOCKING_SEND_RACE,
6768
TEST_LOCKING_POLL_RACE,
@@ -321,6 +322,10 @@ static void guest_code(void)
321322

322323
GUEST_SYNC(TEST_POLL_WAKE);
323324

325+
/* Set the vcpu_info to point at exactly the place it already is to
326+
* make sure the attribute is functional. */
327+
GUEST_SYNC(SET_VCPU_INFO);
328+
324329
/* A timer wake an *unmasked* port which should wake us with an
325330
* actual interrupt, while we're polling on a different port. */
326331
ports[0]++;
@@ -888,6 +893,16 @@ int main(int argc, char *argv[])
888893
alarm(1);
889894
break;
890895

896+
case SET_VCPU_INFO:
897+
if (has_shinfo_hva) {
898+
struct kvm_xen_vcpu_attr vih = {
899+
.type = KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO_HVA,
900+
.u.hva = (unsigned long)vinfo
901+
};
902+
vcpu_ioctl(vcpu, KVM_XEN_VCPU_SET_ATTR, &vih);
903+
}
904+
break;
905+
891906
case TEST_TIMER_PAST:
892907
TEST_ASSERT(!evtchn_irq_expected,
893908
"Expected event channel IRQ but it didn't happen");

0 commit comments

Comments
 (0)