xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/hvm: Provide list of emulated features in HVM CPUID leaf
@ 2016-02-02 23:17 Boris Ostrovsky
  2016-02-02 23:22 ` Andrew Cooper
  2016-02-03  3:51 ` Tian, Kevin
  0 siblings, 2 replies; 11+ messages in thread
From: Boris Ostrovsky @ 2016-02-02 23:17 UTC (permalink / raw)
  To: jbeulich, andrew.cooper3, keir
  Cc: Boris Ostrovsky, roger.pau, david.vrabel, xen-devel

Hypervisor may choose which features to emulate for HVMlite guests.
Guest will query the HVM CPUID leaf to find out what is available.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---

Another option to expose this is via features interface. The advantage of using cpuid
is that we don't need to setup hypercall page to make the query (although at least for
Linux and at least for now this does not buy us anything)

I also don't particularly like the fact that we reference another file (even if it is
a public header) for bits definition. Should we move those definitions here?

 xen/arch/x86/hvm/hvm.c              |    4 ++++
 xen/include/public/arch-x86/cpuid.h |    6 ++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index dfeecca..8d63724 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4585,6 +4585,10 @@ void hvm_hypervisor_cpuid_leaf(uint32_t sub_idx,
         /* Indicate presence of vcpu id and set it in ebx */
         *eax |= XEN_HVM_CPUID_VCPU_ID_PRESENT;
         *ebx = current->vcpu_id;
+
+        /* Indicate which features are emulated */
+        *eax |= XEN_HVM_CPUID_EMU_FEATURES;
+        *ecx = current->domain->arch.emulation_flags;
     }
 }
 
diff --git a/xen/include/public/arch-x86/cpuid.h b/xen/include/public/arch-x86/cpuid.h
index d709340..a4f60c1 100644
--- a/xen/include/public/arch-x86/cpuid.h
+++ b/xen/include/public/arch-x86/cpuid.h
@@ -78,12 +78,18 @@
  * HVM-specific features
  * EAX: Features
  * EBX: vcpu id (iff EAX has XEN_HVM_CPUID_VCPU_ID_PRESENT flag)
+ * ECX: Emulated features (iff EAX has XEN_HVM_CPUID_EMU_FEATURES flag)
  */
 #define XEN_HVM_CPUID_APIC_ACCESS_VIRT (1u << 0) /* Virtualized APIC registers */
 #define XEN_HVM_CPUID_X2APIC_VIRT      (1u << 1) /* Virtualized x2APIC accesses */
 /* Memory mapped from other domains has valid IOMMU entries */
 #define XEN_HVM_CPUID_IOMMU_MAPPINGS   (1u << 2)
 #define XEN_HVM_CPUID_VCPU_ID_PRESENT  (1u << 3) /* vcpu id is present in EBX */
+/*
+ * Emulated features (enumerated in include/public/arch-x86/xen.h as
+ * XEN_X86_EMU_*) are present in ECX.
+ */
+#define XEN_HVM_CPUID_EMU_FEATURES     (1u << 4)
 
 #define XEN_CPUID_MAX_NUM_LEAVES 4
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-02-03 15:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-02 23:17 [PATCH] x86/hvm: Provide list of emulated features in HVM CPUID leaf Boris Ostrovsky
2016-02-02 23:22 ` Andrew Cooper
2016-02-02 23:30   ` Boris Ostrovsky
2016-02-03  0:17     ` Andrew Cooper
2016-02-03  8:43       ` Roger Pau Monné
2016-02-03 14:30         ` Boris Ostrovsky
2016-02-03 14:37           ` Andrew Cooper
2016-02-03 14:46             ` Boris Ostrovsky
2016-02-03 15:05           ` Roger Pau Monné
2016-02-03 15:27             ` Boris Ostrovsky
2016-02-03  3:51 ` Tian, Kevin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).