From 048279bdcb596cebd83c7b6d7f33218cba8926eb Mon Sep 17 00:00:00 2001 From: Roger Pau Monne Date: Fri, 12 Jan 2018 16:41:11 +0000 Subject: [PATCH] xen/x86: report domain id on cpuid MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use the ECX register of the hypervisor leaf 5. The EAX register on this leaf is a flags field that can be used to notice the presence of the domain id in ECX. Note that this is only available to HVM guests. Signed-off-by: Roger Pau Monné --- Changes since v1: - Use leaf 5 instead. --- xen/arch/x86/hvm/hvm.c | 5 +++++ xen/include/public/arch-x86/cpuid.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 68b684bed0..1a06345dbc 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3479,6 +3479,11 @@ 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 presence of domain id and set it on ecx */ + *eax |= XEN_HVM_CPUID_DOMID_PRESENT; + *ecx = current->domain->domain_id; + } } diff --git a/xen/include/public/arch-x86/cpuid.h b/xen/include/public/arch-x86/cpuid.h index d709340f18..634d6aa571 100644 --- a/xen/include/public/arch-x86/cpuid.h +++ b/xen/include/public/arch-x86/cpuid.h @@ -78,12 +78,14 @@ * HVM-specific features * EAX: Features * EBX: vcpu id (iff EAX has XEN_HVM_CPUID_VCPU_ID_PRESENT flag) + * ECX: domain id (iff EAX has XEN_HVM_CPUID_DOMID_PRESENT 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 */ +#define XEN_HVM_CPUID_DOMID_PRESENT (1u << 4) /* domid is present in ECX */ #define XEN_CPUID_MAX_NUM_LEAVES 4 -- 2.39.5