From patchwork Thu Jul 27 15:35:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9867137 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 4A9376038C for ; Thu, 27 Jul 2017 15:38:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AFC427D16 for ; Thu, 27 Jul 2017 15:38:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E6E128560; Thu, 27 Jul 2017 15:38:41 +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 7DD6F27D16 for ; Thu, 27 Jul 2017 15:38:40 +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 1dakq1-0007kc-0I; Thu, 27 Jul 2017 15:36:33 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dakq0-0007kT-C0 for xen-devel@lists.xen.org; Thu, 27 Jul 2017 15:36:32 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 6B/4B-03368-F780A795; Thu, 27 Jul 2017 15:36:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsXitHSDvW49R1W kwcw3ohZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bdo0eZCu7bV/yb8Zi5gfG0URcjJ4eEgL/E 8l9LWUFsNgF9id0vPjGB2CIC6hKnOy6CxZkF8iTOtPSygNjCArYSn7/MAathEVCVeLW5hRHE5 hXwlGh4v4sNYqacxPnjP5lBbCEBNYlr/ZfYIWoEJU7OfMICMVNC4uCLF8wTGLlnIUnNQpJawM i0ilG9OLWoLLVI11gvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMwFBiAYAdjxz+ nQ4ySHExKoryTTCsihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnw7mKrihQSLEpNT61Iy8wBBiVM WoKDR0mE9w5Imre4IDG3ODMdInWKUZfj1YT/35iEWPLy81KlxHn52YGKBECKMkrz4EbAIuQSo 6yUMC8j0FFCPAWpRbmZJajyrxjFORiVhHlTQKbwZOaVwG16BXQEE9ARE5sqQY4oSURISTUwzt 5R2P1WXeX/5rBlOi3ybz7w6iQ3+r9Z4h0yXyQxao/xzYg9K1oiT10qOr2v7Lpb+P9Dp15O2Ps 7/az9zL1F5RqW9dVcz+s5dbyev2g77tO1alr9VFV5nWWWHE0ynjdnbJnDtFtpCmuM23RWh8Nv +CPm7bHc/S7xsZ1ZafqmGpbHUW0PHxwVUGIpzkg01GIuKk4EADs/e2GLAgAA X-Env-Sender: prvs=374e0231e=Andrew.Cooper3@citrix.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1501169789!77339198!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45789 invoked from network); 27 Jul 2017 15:36:31 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-11.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 27 Jul 2017 15:36:31 -0000 X-IronPort-AV: E=Sophos;i="5.40,419,1496102400"; d="scan'208";a="441599944" From: Andrew Cooper To: Xen-devel Date: Thu, 27 Jul 2017 16:35:48 +0100 Message-ID: <1501169748-26111-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Cc: Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH] x86/cpuid: Rename *_policy to *_cpuid_policy 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 In the future, there will be other policy objects, e.g. MSR. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Wei Liu --- CC: Jan Beulich --- xen/arch/x86/cpuid.c | 50 +++++++++++++++++++++++---------------------- xen/arch/x86/hvm/hvm.c | 4 ++-- xen/arch/x86/sysctl.c | 8 ++++---- xen/include/asm-x86/cpuid.h | 4 ++-- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index d359e09..c02635d 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -25,10 +25,10 @@ static void zero_leaves(struct cpuid_leaf *l, memset(&l[first], 0, sizeof(*l) * (last - first + 1)); } -struct cpuid_policy __read_mostly raw_policy, - __read_mostly host_policy, - __read_mostly pv_max_policy, - __read_mostly hvm_max_policy; +struct cpuid_policy __read_mostly raw_cpuid_policy, + __read_mostly host_cpuid_policy, + __read_mostly pv_max_cpuid_policy, + __read_mostly hvm_max_cpuid_policy; static void cpuid_leaf(uint32_t leaf, struct cpuid_leaf *data) { @@ -230,7 +230,7 @@ static void recalculate_misc(struct cpuid_policy *p) static void __init calculate_raw_policy(void) { - struct cpuid_policy *p = &raw_policy; + struct cpuid_policy *p = &raw_cpuid_policy; unsigned int i; cpuid_leaf(0, &p->basic.raw[0]); @@ -310,9 +310,9 @@ static void __init calculate_raw_policy(void) static void __init calculate_host_policy(void) { - struct cpuid_policy *p = &host_policy; + struct cpuid_policy *p = &host_cpuid_policy; - *p = raw_policy; + *p = raw_cpuid_policy; p->basic.max_leaf = min_t(uint32_t, p->basic.max_leaf, ARRAY_SIZE(p->basic.raw) - 1); @@ -341,11 +341,11 @@ static void __init calculate_host_policy(void) static void __init calculate_pv_max_policy(void) { - struct cpuid_policy *p = &pv_max_policy; + struct cpuid_policy *p = &pv_max_cpuid_policy; uint32_t pv_featureset[FSCAPINTS]; unsigned int i; - *p = host_policy; + *p = host_cpuid_policy; cpuid_policy_to_featureset(p, pv_featureset); for ( i = 0; i < ARRAY_SIZE(pv_featureset); ++i ) @@ -363,7 +363,7 @@ static void __init calculate_pv_max_policy(void) static void __init calculate_hvm_max_policy(void) { - struct cpuid_policy *p = &hvm_max_policy; + struct cpuid_policy *p = &hvm_max_cpuid_policy; uint32_t hvm_featureset[FSCAPINTS]; unsigned int i; const uint32_t *hvm_featuremask; @@ -371,7 +371,7 @@ static void __init calculate_hvm_max_policy(void) if ( !hvm_enabled ) return; - *p = host_policy; + *p = host_cpuid_policy; cpuid_policy_to_featureset(p, hvm_featureset); hvm_featuremask = hvm_funcs.hap_supported ? @@ -394,7 +394,8 @@ static void __init calculate_hvm_max_policy(void) * long mode (and init_amd() has cleared it out of host capabilities), but * HVM guests are able if running in protected mode. */ - if ( (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && raw_policy.basic.sep ) + if ( (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && + raw_cpuid_policy.basic.sep ) __set_bit(X86_FEATURE_SEP, hvm_featureset); /* @@ -457,7 +458,7 @@ void recalculate_cpuid_policy(struct domain *d) { struct cpuid_policy *p = d->arch.cpuid; const struct cpuid_policy *max = - is_pv_domain(d) ? &pv_max_policy : &hvm_max_policy; + is_pv_domain(d) ? &pv_max_cpuid_policy : &hvm_max_cpuid_policy; uint32_t fs[FSCAPINTS], max_fs[FSCAPINTS]; unsigned int i; @@ -532,7 +533,7 @@ void recalculate_cpuid_policy(struct domain *d) /* Fold host's FDP_EXCP_ONLY and NO_FPU_SEL into guest's view. */ fs[FEATURESET_7b0] &= ~special_features[FEATURESET_7b0]; - fs[FEATURESET_7b0] |= (host_policy.feat._7b0 & + fs[FEATURESET_7b0] |= (host_cpuid_policy.feat._7b0 & special_features[FEATURESET_7b0]); cpuid_featureset_to_policy(fs, p); @@ -587,7 +588,8 @@ int init_domain_cpuid_policy(struct domain *d) if ( !d->arch.cpuid ) return -ENOMEM; - *d->arch.cpuid = is_pv_domain(d) ? pv_max_policy : hvm_max_policy; + *d->arch.cpuid = is_pv_domain(d) + ? pv_max_cpuid_policy : hvm_max_cpuid_policy; if ( d->disable_migrate ) d->arch.cpuid->extd.itsc = cpu_has_itsc; @@ -837,7 +839,7 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, if ( is_pv_domain(d) && is_hardware_domain(d) && guest_kernel_mode(v, regs) && cpu_has_monitor && regs->entry_vector == TRAP_gp_fault ) - *res = raw_policy.basic.raw[leaf]; + *res = raw_cpuid_policy.basic.raw[leaf]; break; case 0x7: @@ -976,14 +978,14 @@ static void __init __maybe_unused build_assertions(void) /* Find some more clever allocation scheme if this trips. */ BUILD_BUG_ON(sizeof(struct cpuid_policy) > PAGE_SIZE); - BUILD_BUG_ON(sizeof(raw_policy.basic) != - sizeof(raw_policy.basic.raw)); - BUILD_BUG_ON(sizeof(raw_policy.feat) != - sizeof(raw_policy.feat.raw)); - BUILD_BUG_ON(sizeof(raw_policy.xstate) != - sizeof(raw_policy.xstate.raw)); - BUILD_BUG_ON(sizeof(raw_policy.extd) != - sizeof(raw_policy.extd.raw)); + BUILD_BUG_ON(sizeof(raw_cpuid_policy.basic) != + sizeof(raw_cpuid_policy.basic.raw)); + BUILD_BUG_ON(sizeof(raw_cpuid_policy.feat) != + sizeof(raw_cpuid_policy.feat.raw)); + BUILD_BUG_ON(sizeof(raw_cpuid_policy.xstate) != + sizeof(raw_cpuid_policy.xstate.raw)); + BUILD_BUG_ON(sizeof(raw_cpuid_policy.extd) != + sizeof(raw_cpuid_policy.extd.raw)); } /* diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 1ec37bd..555133f 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -893,7 +893,7 @@ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value, if ( cr0_pg < 0 && !is_hardware_domain(d) ) p = d->arch.cpuid; else - p = &host_policy; + p = &host_cpuid_policy; if ( (value & EFER_SCE) && !p->extd.syscall ) return "SCE without feature"; @@ -937,7 +937,7 @@ unsigned long hvm_cr4_guest_valid_bits(const struct vcpu *v, bool restore) if ( !restore && !is_hardware_domain(d) ) p = d->arch.cpuid; else - p = &host_policy; + p = &host_cpuid_policy; /* Logic broken out simply to aid readability below. */ mce = p->basic.mce || p->basic.mca; diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 2f7056e..7c294be 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -199,10 +199,10 @@ long arch_do_sysctl( case XEN_SYSCTL_get_cpu_featureset: { static const struct cpuid_policy *const policy_table[] = { - [XEN_SYSCTL_cpu_featureset_raw] = &raw_policy, - [XEN_SYSCTL_cpu_featureset_host] = &host_policy, - [XEN_SYSCTL_cpu_featureset_pv] = &pv_max_policy, - [XEN_SYSCTL_cpu_featureset_hvm] = &hvm_max_policy, + [XEN_SYSCTL_cpu_featureset_raw] = &raw_cpuid_policy, + [XEN_SYSCTL_cpu_featureset_host] = &host_cpuid_policy, + [XEN_SYSCTL_cpu_featureset_pv] = &pv_max_cpuid_policy, + [XEN_SYSCTL_cpu_featureset_hvm] = &hvm_max_cpuid_policy, }; const struct cpuid_policy *p = NULL; uint32_t featureset[FSCAPINTS]; diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h index ac25908..d2dd841 100644 --- a/xen/include/asm-x86/cpuid.h +++ b/xen/include/asm-x86/cpuid.h @@ -253,8 +253,8 @@ static inline void cpuid_featureset_to_policy( p->feat._7d0 = fs[FEATURESET_7d0]; } -extern struct cpuid_policy raw_policy, host_policy, pv_max_policy, - hvm_max_policy; +extern struct cpuid_policy raw_cpuid_policy, host_cpuid_policy, + pv_max_cpuid_policy, hvm_max_cpuid_policy; /* Allocate and initialise a CPUID policy suitable for the domain. */ int init_domain_cpuid_policy(struct domain *d);