From patchwork Tue Feb 2 23:17:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Ostrovsky X-Patchwork-Id: 8196411 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1716DBEEE5 for ; Tue, 2 Feb 2016 23:21:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4672E202E9 for ; Tue, 2 Feb 2016 23:21:27 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6481E202D1 for ; Tue, 2 Feb 2016 23:21:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQkDK-0005i5-T3; Tue, 02 Feb 2016 23:18:26 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQkDJ-0005i0-Gk for xen-devel@lists.xen.org; Tue, 02 Feb 2016 23:18:25 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 5E/DB-06010-04931B65; Tue, 02 Feb 2016 23:18:24 +0000 X-Env-Sender: boris.ostrovsky@oracle.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1454455102!19830648!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35330 invoked from network); 2 Feb 2016 23:18:23 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-12.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 2 Feb 2016 23:18:23 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u12NIFCc011817 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 2 Feb 2016 23:18:16 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u12NIFw2029018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 2 Feb 2016 23:18:15 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u12NIEtr009948; Tue, 2 Feb 2016 23:18:14 GMT Received: from ovs104.us.oracle.com (/10.149.76.204) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 02 Feb 2016 15:18:14 -0800 From: Boris Ostrovsky To: jbeulich@suse.com, andrew.cooper3@citrix.com, keir@xen.org Date: Tue, 2 Feb 2016 18:17:21 -0500 Message-Id: <1454455041-4647-1-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.7.1 X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Boris Ostrovsky , roger.pau@citrix.com, david.vrabel@citrix.com, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH] x86/hvm: Provide list of emulated features in HVM CPUID leaf X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Kevin Tian --- 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