From patchwork Mon Feb 20 11:00:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9582555 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 B013F604A0 for ; Mon, 20 Feb 2017 11:03:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0693287F0 for ; Mon, 20 Feb 2017 11:03:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 950A828856; Mon, 20 Feb 2017 11:03:08 +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 1AB54287F0 for ; Mon, 20 Feb 2017 11:03:08 +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 1cfliA-0007d3-Vk; Mon, 20 Feb 2017 11:00:54 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cfli9-0007aj-Ej for xen-devel@lists.xen.org; Mon, 20 Feb 2017 11:00:53 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id D2/5D-04270-46CCAA85; Mon, 20 Feb 2017 11:00:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpikeJIrShJLcpLzFFi42JxWrohUjflzKo Ig66DjBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8btI/tYCjaZVfT8X87awPhKvYuRg0NCwF9i zxavLkZODjYBfYndLz4xgdgiAuoSpzsusoKUMAv4SRx64AsSFhZwkth+sYcdJMwioCoxcZo4S JhXwFPiSdcPRhBbQkBO4vzxn8wgNidQfMrhD2wgtpCAh8S2hsdQtprEtf5L7BC9ghInZz5hAb GZBSQkDr54wTyBkXcWktQsJKkFjEyrGDWKU4vKUot0DQ30kooy0zNKchMzc4A8Y73c1OLixPT UnMSkYr3k/NxNjMCwqWdgYNzBuK3L+RCjJAeTkijvnSWrIoT4kvJTKjMSizPii0pzUosPMcpw cChJ8E4/DZQTLEpNT61Iy8wBBjBMWoKDR0mEdxVImre4IDG3ODMdInWKUVFKnLcBJCEAksgoz YNrg0XNJUZZKWFeRgYGBiGegtSi3MwSVPlXjOIcjErCvJ4gU3gy80rgpr8CWswEtPimx0qQxS WJCCmpBkbxh1pyDCWp0mX/mztFP+vM+Fne6JQUzl7+/NaPsIwU9ZsLvQs9PipkpR/T/Fwcu9K LK+bdk6lK4tsTIpcFC62fcV27Stsw3+Di6okN4SqvOxulZk77deyeRYfa11ahjZ2fIsIPnjp1 t9egsUZPpUnqgkFehZ98sfHk50frT5ZmXb+8pyrhpxJLcUaioRZzUXEiAGagWryVAgAA X-Env-Sender: prvs=21759e352=Andrew.Cooper3@citrix.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1487588447!30982674!4 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.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22468 invoked from network); 20 Feb 2017 11:00:51 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-9.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 20 Feb 2017 11:00:51 -0000 X-IronPort-AV: E=Sophos;i="5.35,186,1484006400"; d="scan'208";a="408330951" From: Andrew Cooper To: Xen-devel Date: Mon, 20 Feb 2017 11:00:33 +0000 Message-ID: <1487588434-4359-10-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1487588434-4359-1-git-send-email-andrew.cooper3@citrix.com> References: <1487588434-4359-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH 09/10] x86/cpuid: Drop legacy CPUID infrastructure 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 Now that all leaves have been altered to use the guest_cpuid() path, remove all the remaining legacy infrastructure. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich --- xen/arch/x86/cpuid.c | 76 --------------------------------------------- xen/arch/x86/domctl.c | 45 +-------------------------- xen/include/asm-x86/cpuid.h | 27 ---------------- 3 files changed, 1 insertion(+), 147 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index f1bcd7d..eaeec97 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -582,8 +582,6 @@ void recalculate_cpuid_policy(struct domain *d) int init_domain_cpuid_policy(struct domain *d) { - unsigned int i; - d->arch.cpuid = xmalloc(struct cpuid_policy); if ( !d->arch.cpuid ) @@ -596,70 +594,9 @@ int init_domain_cpuid_policy(struct domain *d) recalculate_cpuid_policy(d); - for ( i = 0; i < MAX_CPUID_INPUT; i++ ) - { - d->arch.cpuid->legacy[i].input[0] = XEN_CPUID_INPUT_UNUSED; - d->arch.cpuid->legacy[i].input[1] = XEN_CPUID_INPUT_UNUSED; - } - return 0; } -static void domain_cpuid(const struct domain *d, uint32_t leaf, - uint32_t subleaf, struct cpuid_leaf *res) -{ - unsigned int i; - - for ( i = 0; i < MAX_CPUID_INPUT; i++ ) - { - xen_domctl_cpuid_t *cpuid = &d->arch.cpuid->legacy[i]; - - if ( (cpuid->input[0] == leaf) && - ((cpuid->input[1] == XEN_CPUID_INPUT_UNUSED) || - (cpuid->input[1] == subleaf)) ) - { - *res = (struct cpuid_leaf){ cpuid->eax, cpuid->ebx, - cpuid->ecx, cpuid->edx }; - return; - } - } -} - -static void pv_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res) -{ - struct vcpu *curr = current; - struct domain *currd = curr->domain; - - if ( !is_control_domain(currd) && !is_hardware_domain(currd) ) - domain_cpuid(currd, leaf, subleaf, res); - else - cpuid_count_leaf(leaf, subleaf, res); - - switch ( leaf ) - { - case 0x0 ... XSTATE_CPUID: - case 0x80000000 ... 0xffffffff: - ASSERT_UNREACHABLE(); - /* Now handled in guest_cpuid(). */ - } -} - -static void hvm_cpuid(uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res) -{ - struct vcpu *v = current; - struct domain *d = v->domain; - - domain_cpuid(d, leaf, subleaf, res); - - switch ( leaf ) - { - case 0x0 ... XSTATE_CPUID: - case 0x80000000 ... 0xffffffff: - ASSERT_UNREACHABLE(); - /* Now handled in guest_cpuid(). */ - } -} - void guest_cpuid(const struct vcpu *v, uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *res) { @@ -709,11 +646,6 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, break; default: - goto legacy; - - case 0x0 ... 0x3: - case 0x5 ... 0x6: - case 0x8 ... 0xc: *res = p->basic.raw[leaf]; break; } @@ -1037,14 +969,6 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, res->a = (res->d & v->arch.hvm_svm.guest_lwp_cfg) | 1; break; } - - /* Done. */ - return; - - legacy: - /* {hvm,pv}_cpuid() have this expectation. */ - ASSERT(v == current); - (is_hvm_domain(d) ? hvm_cpuid : pv_cpuid)(leaf, subleaf, res); } static void __init __maybe_unused build_assertions(void) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index aa0d914..e345767 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -47,51 +47,12 @@ static int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio *iop) return iop->remain ? -EFAULT : 0; } -static int update_legacy_cpuid_array(struct domain *d, - const xen_domctl_cpuid_t *ctl) -{ - xen_domctl_cpuid_t *cpuid, *unused = NULL; - unsigned int i; - - /* Try to insert ctl into d->arch.cpuids[] */ - for ( i = 0; i < MAX_CPUID_INPUT; i++ ) - { - cpuid = &d->arch.cpuid->legacy[i]; - - if ( cpuid->input[0] == XEN_CPUID_INPUT_UNUSED ) - { - if ( !unused ) - unused = cpuid; - continue; - } - - if ( (cpuid->input[0] == ctl->input[0]) && - ((cpuid->input[1] == XEN_CPUID_INPUT_UNUSED) || - (cpuid->input[1] == ctl->input[1])) ) - break; - } - - if ( !(ctl->eax | ctl->ebx | ctl->ecx | ctl->edx) ) - { - if ( i < MAX_CPUID_INPUT ) - cpuid->input[0] = XEN_CPUID_INPUT_UNUSED; - } - else if ( i < MAX_CPUID_INPUT ) - *cpuid = *ctl; - else if ( unused ) - *unused = *ctl; - else - return -ENOENT; - - return 0; -} - static int update_domain_cpuid_info(struct domain *d, const xen_domctl_cpuid_t *ctl) { struct cpuid_policy *p = d->arch.cpuid; const struct cpuid_leaf leaf = { ctl->eax, ctl->ebx, ctl->ecx, ctl->edx }; - int rc, old_vendor = p->x86_vendor; + int old_vendor = p->x86_vendor; /* * Skip update for leaves we don't care about. This avoids the overhead @@ -125,10 +86,6 @@ static int update_domain_cpuid_info(struct domain *d, return 0; } - rc = update_legacy_cpuid_array(d, ctl); - if ( rc ) - return rc; - /* Insert ctl data into cpuid_policy. */ switch ( ctl->input[0] ) { diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h index 14fc95c..8d6a653 100644 --- a/xen/include/asm-x86/cpuid.h +++ b/xen/include/asm-x86/cpuid.h @@ -72,29 +72,6 @@ DECLARE_PER_CPU(bool, cpuid_faulting_enabled); struct cpuid_policy { - /* - * WARNING: During the CPUID transition period, not all information here - * is accurate. The following items are accurate, and can be relied upon. - * - * Global *_policy objects: - * - * - Guest accurate: - * - All of the feat, xstate and extd unions - * - max_{,sub}leaf - * - All FEATURESET_* words - * - Short vendor infomation - * - * Per-domain objects: - * - * - Guest accurate: - * - All of the feat, xstate and extd unions - * - max_{,sub}leaf - * - All FEATURESET_* words - * - Short vendor infomation - * - * Everything else should be considered inaccurate, and not necesserily 0. - */ - #define DECL_BITFIELD(word) _DECL_BITFIELD(FEATURESET_ ## word) #define _DECL_BITFIELD(x) __DECL_BITFIELD(x) #define __DECL_BITFIELD(x) CPUID_BITFIELD_ ## x @@ -230,10 +207,6 @@ struct cpuid_policy /* Value calculated from raw data above. */ uint8_t x86_vendor; - - /* Temporary: Legacy data array. */ -#define MAX_CPUID_INPUT 40 - xen_domctl_cpuid_t legacy[MAX_CPUID_INPUT]; }; /* Fill in a featureset bitmap from a CPUID policy. */