From: Paul Durrant <paul@xen.org>
To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Paul Durrant <pdurrant@amazon.com>,
David Woodhouse <dwmw@amazon.co.uk>,
Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH v4 10/13] KVM: selftests / xen: set KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID
Date: Tue, 19 Sep 2023 13:41:46 +0000 [thread overview]
Message-ID: <20230919134149.6091-11-paul@xen.org> (raw)
In-Reply-To: <20230919134149.6091-1-paul@xen.org>
From: Paul Durrant <pdurrant@amazon.com>
If the capability (KVM_XEN_HVM_CONFIG_EVTCHN_SEND) is present then set
the guest's vCPU id to match the chosen vcpu_info offset.
Also make some cosmetic fixes to the code for clarity.
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
---
Cc: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: David Woodhouse <dwmw2@infradead.org>
v3:
- Remame VCPU_ID to XEN_VCPU_ID.
- Set vcpu_id before the shared_info page is set.
v2:
- New in this version.
---
.../selftests/kvm/x86_64/xen_shinfo_test.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
index 05898ad9f4d9..b0c3a00ea6a6 100644
--- a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
+++ b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
@@ -38,6 +38,8 @@
#define VCPU_INFO_VADDR (SHINFO_REGION_GVA + 0x40)
#define RUNSTATE_VADDR (SHINFO_REGION_GVA + PAGE_SIZE + PAGE_SIZE - 15)
+#define XEN_VCPU_ID 1 /* Must correspond to offset of VCPU_INFO_[V]ADDR */
+
#define EVTCHN_VECTOR 0x10
#define EVTCHN_TEST1 15
@@ -410,7 +412,7 @@ static void *juggle_shinfo_state(void *arg)
struct kvm_xen_hvm_attr cache_activate = {
.type = KVM_XEN_ATTR_TYPE_SHARED_INFO,
- .u.shared_info.gfn = SHINFO_REGION_GPA / PAGE_SIZE
+ .u.shared_info.gfn = SHINFO_ADDR / PAGE_SIZE
};
struct kvm_xen_hvm_attr cache_deactivate = {
@@ -446,6 +448,7 @@ int main(int argc, char *argv[])
bool do_runstate_flag = !!(xen_caps & KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG);
bool do_eventfd_tests = !!(xen_caps & KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL);
bool do_evtchn_tests = do_eventfd_tests && !!(xen_caps & KVM_XEN_HVM_CONFIG_EVTCHN_SEND);
+ bool has_vcpu_id = !!(xen_caps & KVM_XEN_HVM_CONFIG_EVTCHN_SEND);
clock_gettime(CLOCK_REALTIME, &min_ts);
@@ -492,9 +495,17 @@ int main(int argc, char *argv[])
"Failed to read back RUNSTATE_UPDATE_FLAG attr");
}
+ if (has_vcpu_id) {
+ struct kvm_xen_vcpu_attr vid = {
+ .type = KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID,
+ .u.vcpu_id = XEN_VCPU_ID,
+ };
+ vcpu_ioctl(vcpu, KVM_XEN_VCPU_SET_ATTR, &vid);
+ }
+
struct kvm_xen_hvm_attr ha = {
.type = KVM_XEN_ATTR_TYPE_SHARED_INFO,
- .u.shared_info.gfn = SHINFO_REGION_GPA / PAGE_SIZE,
+ .u.shared_info.gfn = SHINFO_ADDR / PAGE_SIZE,
};
vm_ioctl(vm, KVM_XEN_HVM_SET_ATTR, &ha);
@@ -983,8 +994,8 @@ int main(int argc, char *argv[])
struct pvclock_wall_clock *wc;
struct pvclock_vcpu_time_info *ti, *ti2;
- wc = addr_gpa2hva(vm, SHINFO_REGION_GPA + 0xc00);
- ti = addr_gpa2hva(vm, SHINFO_REGION_GPA + 0x40 + 0x20);
+ wc = addr_gpa2hva(vm, SHINFO_ADDR + 0xc00);
+ ti = addr_gpa2hva(vm, VCPU_INFO_ADDR + 0x20);
ti2 = addr_gpa2hva(vm, PVTIME_ADDR);
if (verbose) {
--
2.39.2
next prev parent reply other threads:[~2023-09-19 14:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 13:41 [PATCH v4 00/13] KVM: xen: update shared_info and vcpu_info handling Paul Durrant
2023-09-19 13:41 ` [PATCH v4 01/13] KVM: pfncache: add a map helper function Paul Durrant
2023-09-19 13:41 ` [PATCH v4 02/13] KVM: pfncache: add a mark-dirty helper Paul Durrant
2023-09-19 13:41 ` [PATCH v4 03/13] KVM: pfncache: add a helper to get the gpa Paul Durrant
2023-09-19 13:41 ` [PATCH v4 04/13] KVM: pfncache: base offset check on khva rather than gpa Paul Durrant
2023-09-19 13:41 ` [PATCH v4 05/13] KVM: pfncache: allow a cache to be activated with a fixed (userspace) HVA Paul Durrant
2023-09-19 14:20 ` David Woodhouse
2023-09-19 14:22 ` Paul Durrant
2023-09-19 13:41 ` [PATCH v4 06/13] KVM: xen: allow shared_info to be mapped by fixed HVA Paul Durrant
2023-09-19 13:41 ` [PATCH v4 07/13] KVM: xen: prepare for using 'default' vcpu_info Paul Durrant
2023-09-19 13:41 ` [PATCH v4 08/13] KVM: xen: prevent vcpu_id from changing whilst shared_info is valid Paul Durrant
2023-09-19 13:41 ` [PATCH v4 09/13] KVM: xen: automatically use the vcpu_info embedded in shared_info Paul Durrant
2023-09-19 14:18 ` David Woodhouse
2023-09-19 14:34 ` Paul Durrant
2023-09-19 15:38 ` David Woodhouse
2023-09-19 15:47 ` Paul Durrant
2023-09-19 16:14 ` David Woodhouse
2023-09-19 13:41 ` Paul Durrant [this message]
2023-09-19 13:41 ` [PATCH v4 11/13] KVM: selftests / xen: map shared_info using HVA rather than GFN Paul Durrant
2023-09-19 13:41 ` [PATCH v4 12/13] KVM: selftests / xen: don't explicitly set the vcpu_info address Paul Durrant
2023-09-19 13:41 ` [PATCH v4 13/13] KVM: xen: advertize the KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA capability Paul Durrant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230919134149.6091-11-paul@xen.org \
--to=paul@xen.org \
--cc=dwmw2@infradead.org \
--cc=dwmw@amazon.co.uk \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=pdurrant@amazon.com \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®