From: Paul Durrant <paul@xen.org>
To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Paul Durrant <pdurrant@amazon.com>,
Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
David Woodhouse <dwmw2@infradead.org>,
x86@kernel.org
Subject: [PATCH 8/8] KVM: xen: automatically use the vcpu_info embedded in shared_info
Date: Thu, 14 Sep 2023 08:49:46 +0000 [thread overview]
Message-ID: <20230914084946.200043-9-paul@xen.org> (raw)
In-Reply-To: <20230914084946.200043-1-paul@xen.org>
From: Paul Durrant <pdurrant@amazon.com>
Add a KVM_XEN_HVM_CONFIG_DEFAULT_VCPU_INFO flag so that the VMM knows it
need only set the KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO attribute in response to
a VCPUOP_register_vcpu_info hypercall, and modify get_vcpu_info_cache()
to pass back a pointer to the shared info pfn cache (and appropriate
offset) for any of the first 32 vCPUs if the attribute has not been set.
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
Cc: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: x86@kernel.org
---
arch/x86/kvm/x86.c | 3 ++-
arch/x86/kvm/xen.c | 15 +++++++++++++++
include/uapi/linux/kvm.h | 1 +
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4cd577d01bc4..cdce8c463a1b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4528,7 +4528,8 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
KVM_XEN_HVM_CONFIG_SHARED_INFO |
KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL |
KVM_XEN_HVM_CONFIG_EVTCHN_SEND |
- KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA;
+ KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA |
+ KVM_XEN_HVM_CONFIG_DEFAULT_VCPU_INFO;
if (sched_info_on())
r |= KVM_XEN_HVM_CONFIG_RUNSTATE |
KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG;
diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index 892563fea40f..66050a96ba25 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -491,6 +491,21 @@ static void kvm_xen_inject_vcpu_vector(struct kvm_vcpu *v)
struct gfn_to_pfn_cache *get_vcpu_info_cache(struct kvm_vcpu *v, unsigned long *offset)
{
+ if (!v->arch.xen.vcpu_info_cache.active && v->arch.xen.vcpu_id < MAX_VIRT_CPUS) {
+ struct kvm *kvm = v->kvm;
+
+ if (offset) {
+ if (IS_ENABLED(CONFIG_64BIT) && kvm->arch.xen.long_mode)
+ *offset = offsetof(struct shared_info,
+ vcpu_info[v->arch.xen.vcpu_id]);
+ else
+ *offset = offsetof(struct compat_shared_info,
+ vcpu_info[v->arch.xen.vcpu_id]);
+ }
+
+ return &kvm->arch.xen.shinfo_cache;
+ }
+
if (offset)
*offset = 0;
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index d3f371bafad8..480612f73fc2 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -1283,6 +1283,7 @@ struct kvm_x86_mce {
#define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5)
#define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6)
#define KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA (1 << 7)
+#define KVM_XEN_HVM_CONFIG_DEFAULT_VCPU_INFO (1 << 8)
struct kvm_xen_hvm_config {
__u32 flags;
--
2.39.2
next prev parent reply other threads:[~2023-09-14 9:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-14 8:49 [PATCH 0/8] KVM: xen: update shared_info and vcpu_info handling Paul Durrant
2023-09-14 8:49 ` [PATCH 1/8] KVM: pfncache: add a map helper function Paul Durrant
2023-09-14 9:17 ` David Woodhouse
2023-09-14 8:49 ` [PATCH 2/8] KVM: pfncache: add a mark-dirty helper Paul Durrant
2023-09-14 9:21 ` David Woodhouse
2023-09-14 9:34 ` Paul Durrant
2023-09-14 12:39 ` David Woodhouse
2023-09-14 13:07 ` Paul Durrant
2023-09-14 8:49 ` [PATCH 3/8] KVM: pfncache: add a helper to get the gpa Paul Durrant
2023-09-14 13:03 ` David Woodhouse
2023-09-14 8:49 ` [PATCH 4/8] KVM: pfncache: base offset check on khva rather than gpa Paul Durrant
2023-09-14 12:42 ` David Woodhouse
2023-09-14 8:49 ` [PATCH 5/8] KVM: pfncache: allow a cache to be activated with a fixed (userspace) HVA Paul Durrant
2023-09-14 9:29 ` David Woodhouse
2023-09-14 9:38 ` Paul Durrant
2023-09-14 13:51 ` David Woodhouse
2023-09-14 13:58 ` Paul Durrant
2023-09-14 8:49 ` [PATCH 6/8] KVM: xen: allow shared_info to be mapped by fixed HVA Paul Durrant
2023-09-14 13:43 ` David Woodhouse
2023-09-14 8:49 ` [PATCH 7/8] KVM: xen: prepare for using 'default' vcpu_info Paul Durrant
2023-09-14 13:17 ` David Woodhouse
2023-09-14 20:10 ` kernel test robot
2023-09-18 9:25 ` kernel test robot
2023-09-14 8:49 ` Paul Durrant [this message]
2023-09-14 9:09 ` [PATCH 8/8] KVM: xen: automatically use the vcpu_info embedded in shared_info David Woodhouse
2023-09-14 9:17 ` Paul Durrant
2023-09-14 9:24 ` David Woodhouse
2023-09-14 9:15 ` [PATCH 0/8] KVM: xen: update shared_info and vcpu_info handling David Woodhouse
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=20230914084946.200043-9-paul@xen.org \
--to=paul@xen.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pdurrant@amazon.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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®