From patchwork Mon Jan 9 11:03:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9504353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EA42660710 for ; Mon, 9 Jan 2017 11:18:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 042F8282ED for ; Mon, 9 Jan 2017 11:18:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED43E2848D; Mon, 9 Jan 2017 11:18:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A3AC8282ED for ; Mon, 9 Jan 2017 11:18:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQXwF-0003gB-4b; Mon, 09 Jan 2017 11:16:31 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQXwD-0003fA-O1 for xen-devel@lists.xen.org; Mon, 09 Jan 2017 11:16:29 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id C1/4A-19998-C0173785; Mon, 09 Jan 2017 11:16:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeJIrShJLcpLzFFi42JxWrohUpensDj CYNsfeYslHxezODB6HN39mymAMYo1My8pvyKBNaPr0j2WgiPCFb136hsY3/B2MXJySAj4S/zY uoUNxGYT0JfY/eITE4gtIqAucbrjImsXIwcHs4CuxKqfGiBhYQFPiX3PfzCC2CwCKhJXL8xmB rF5BbwkOub8YYcYKSdx/vhPsDgnUHzanxNg9UJAvQsfvmCGsNUkrvVfYofoFZQ4OfMJC4jNLC AhcfDFC+YJjLyzkKRmIUktYGRaxahRnFpUllqka2Sgl1SUmZ5RkpuYmaNraGCsl5taXJyYnpq TmFSsl5yfu4kRGDj1DAyMOxibT/gdYpTkYFIS5XWMKogQ4kvKT6nMSCzOiC8qzUktPsQow8Gh JMH7Kr84QkiwKDU9tSItMwcYwjBpCQ4eJRHe2SBp3uKCxNzizHSI1ClGRSlx3hsgCQGQREZpH lwbLG4uMcpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLmXQQyhSczrwRu+iugxUxAiyPtwBaXJC KkpBoYReaXuUud9zwqv6HzMYP7C+tff0KYT36U6HiwQaavbN2RRD7/a/YhCS8ydbN2vnsUxcO VcMFo3hcZO7WNO92zxHJb593pfa7DXF64513Xk18SzjpblmXkal1uOvGl8v7ViWHvrTZ3To7a 9izx2/9Fz+6fqyiMuC6nv/VF6m5eE3XXO/7BDQ+qlViKMxINtZiLihMByWdCtpYCAAA= X-Env-Sender: prvs=175ce6123=Andrew.Cooper3@citrix.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1483960586!62824564!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 59479 invoked from network); 9 Jan 2017 11:16:28 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-12.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 9 Jan 2017 11:16:28 -0000 X-IronPort-AV: E=Sophos;i="5.33,339,1477958400"; d="scan'208";a="398663311" From: Andrew Cooper To: Xen-devel Date: Mon, 9 Jan 2017 11:03:29 +0000 Message-ID: <1483959822-30484-13-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1483959822-30484-1-git-send-email-andrew.cooper3@citrix.com> References: <1483959822-30484-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper Subject: [Xen-devel] [PATCH v2 12/25] x86/pv: Improve pv_cpuid() using named features X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This avoids refering back to domain_cpuid() or native CPUID to obtain information which is directly available. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- xen/arch/x86/traps.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 5ce8936..47c7ce7 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1024,6 +1024,7 @@ void pv_cpuid(struct cpu_user_regs *regs) uint32_t leaf, subleaf, a, b, c, d; struct vcpu *curr = current; struct domain *currd = curr->domain; + const struct cpuid_policy *p = currd->arch.cpuid; leaf = a = regs->_eax; b = regs->_ebx; @@ -1060,7 +1061,7 @@ void pv_cpuid(struct cpu_user_regs *regs) switch ( leaf ) { - uint32_t tmp, _ecx, _ebx; + uint32_t tmp; case 0x00000001: c &= pv_featureset[FEATURESET_1c]; @@ -1246,14 +1247,7 @@ void pv_cpuid(struct cpu_user_regs *regs) break; case XSTATE_CPUID: - - if ( !is_control_domain(currd) && !is_hardware_domain(currd) ) - domain_cpuid(currd, 1, 0, &tmp, &tmp, &_ecx, &tmp); - else - _ecx = cpuid_ecx(1); - _ecx &= pv_featureset[FEATURESET_1c]; - - if ( !(_ecx & cpufeat_mask(X86_FEATURE_XSAVE)) || subleaf >= 63 ) + if ( !p->basic.xsave || subleaf >= 63 ) goto unsupported; switch ( subleaf ) { @@ -1262,20 +1256,14 @@ void pv_cpuid(struct cpu_user_regs *regs) uint64_t xfeature_mask = XSTATE_FP_SSE; uint32_t xstate_size = XSTATE_AREA_MIN_SIZE; - if ( _ecx & cpufeat_mask(X86_FEATURE_AVX) ) + if ( p->basic.avx ) { xfeature_mask |= XSTATE_YMM; xstate_size = (xstate_offsets[_XSTATE_YMM] + xstate_sizes[_XSTATE_YMM]); } - if ( !is_control_domain(currd) && !is_hardware_domain(currd) ) - domain_cpuid(currd, 7, 0, &tmp, &_ebx, &tmp, &tmp); - else - cpuid_count(7, 0, &tmp, &_ebx, &tmp, &tmp); - _ebx &= pv_featureset[FEATURESET_7b0]; - - if ( _ebx & cpufeat_mask(X86_FEATURE_AVX512F) ) + if ( p->feat.avx512f ) { xfeature_mask |= XSTATE_OPMASK | XSTATE_ZMM | XSTATE_HI_ZMM; xstate_size = max(xstate_size,