From patchwork Tue Jan 10 07:42:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9506625 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 1E4C6606E1 for ; Tue, 10 Jan 2017 07:45:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10E3D28156 for ; Tue, 10 Jan 2017 07:45:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0552728485; Tue, 10 Jan 2017 07:45:33 +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 DBE6328156 for ; Tue, 10 Jan 2017 07:45:31 +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 1cQr5Z-0003pi-TN; Tue, 10 Jan 2017 07:43:25 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQr5Z-0003pG-2q for xen-devel@lists.xenproject.org; Tue, 10 Jan 2017 07:43:25 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 96/88-01684-C9094785; Tue, 10 Jan 2017 07:43:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrALMWRWlGSWpSXmKPExsVywNykWHf2hJI Ig1c3JCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ow/p2cxFjQ3MVZsa1/B1sB4P6SLkZNDSKBS 4tTka2wgtoQAr8SRZTNYIWx/ieNnpzF3MXIB1TQwSnxfs5AdJMEmoC7x+GsPE4gtIqAkcW/VZ CaQImaB/YwS848fZwZJCAsESjx/8RJsKouAqsSrV3PB4rwC7hLHd01hgtggJ3Hy2GSwbZwCHh ItV9cxQlzkLtH89j7jBEbeBYwMqxg1ilOLylKLdI0s9ZKKMtMzSnITM3N0DQ2M9XJTi4sT01N zEpOK9ZLzczcxAkOinoGBcQdj016/Q4ySHExKorwpuiURQnxJ+SmVGYnFGfFFpTmpxYcYZTg4 lCR4q/qBcoJFqempFWmZOcDghElLcPAoifBuB0nzFhck5hZnpkOkTjEqSonzBoIkBEASGaV5c G2wiLjEKCslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZi3GWQKT2ZeCdz0V0CLmYAWR9oVgywuSU RISTUw5kb7/e6P/r0/0SNV2bxJa/baeBf1NJWbi2xD/nPOWv9V8ck61ntf70fne/Xw54XMMvw p81BLe8+iYzO2xtu+5rkal75QfM8KZy9zr9f3L9nrT/5lydRtfurM28K0zT9UvxyTENHYx8i7 NNM6l/274ssld63j7qqcKvdr6wqf8FnJMbVlOpO7EktxRqKhFnNRcSIAsJHPF4MCAAA= X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1484034191!48884458!4 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6905 invoked from network); 10 Jan 2017 07:43:22 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-11.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 10 Jan 2017 07:43:22 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 09 Jan 2017 23:43:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,343,1477983600"; d="scan'208";a="211582986" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.63]) by fmsmga004.fm.intel.com with ESMTP; 09 Jan 2017 23:43:18 -0800 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Tue, 10 Jan 2017 15:42:22 +0800 Message-Id: <1484034155-4521-4-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484034155-4521-1-git-send-email-yi.y.sun@linux.intel.com> References: <1484034155-4521-1-git-send-email-yi.y.sun@linux.intel.com> Cc: wei.liu2@citrix.com, he.chen@linux.intel.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, Yi Sun , jbeulich@suse.com, chao.p.peng@linux.intel.com Subject: [Xen-devel] [RFC 03/16] x86: change 'cbm_type' to 'psr_val_type' to make it general. 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch changes 'cbm_type' to 'psr_val_type' to make it general. Then, we can reuse this for every psr allocation feature. Signed-off-by: Yi Sun --- xen/arch/x86/domctl.c | 16 +++++----- xen/arch/x86/psr.c | 80 +++++++++++++++++++++++------------------------ xen/arch/x86/sysctl.c | 6 ++-- xen/include/asm-x86/psr.h | 16 +++++----- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 3b6534b..1f83ab2 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1372,52 +1372,52 @@ long arch_do_domctl( case XEN_DOMCTL_PSR_CAT_OP_SET_L3_CBM: ret = psr_set_val(d, domctl->u.psr_alloc_op.target, domctl->u.psr_alloc_op.data, - PSR_CBM_TYPE_L3); + PSR_VAL_TYPE_L3); break; case XEN_DOMCTL_PSR_CAT_OP_SET_L3_CODE: ret = psr_set_val(d, domctl->u.psr_alloc_op.target, domctl->u.psr_alloc_op.data, - PSR_CBM_TYPE_L3_CODE); + PSR_VAL_TYPE_L3_CODE); break; case XEN_DOMCTL_PSR_CAT_OP_SET_L3_DATA: ret = psr_set_val(d, domctl->u.psr_alloc_op.target, domctl->u.psr_alloc_op.data, - PSR_CBM_TYPE_L3_DATA); + PSR_VAL_TYPE_L3_DATA); break; case XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM: ret = psr_set_val(d, domctl->u.psr_alloc_op.target, domctl->u.psr_alloc_op.data, - PSR_CBM_TYPE_L2); + PSR_VAL_TYPE_L2); break; case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM: ret = psr_get_val(d, domctl->u.psr_alloc_op.target, &domctl->u.psr_alloc_op.data, - PSR_CBM_TYPE_L3); + PSR_VAL_TYPE_L3); copyback = 1; break; case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CODE: ret = psr_get_val(d, domctl->u.psr_alloc_op.target, &domctl->u.psr_alloc_op.data, - PSR_CBM_TYPE_L3_CODE); + PSR_VAL_TYPE_L3_CODE); copyback = 1; break; case XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA: ret = psr_get_val(d, domctl->u.psr_alloc_op.target, &domctl->u.psr_alloc_op.data, - PSR_CBM_TYPE_L3_DATA); + PSR_VAL_TYPE_L3_DATA); copyback = 1; break; case XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM: ret = psr_get_val(d, domctl->u.psr_alloc_op.target, &domctl->u.psr_alloc_op.data, - PSR_CBM_TYPE_L2); + PSR_VAL_TYPE_L2); copyback = 1; break; diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index ed1ec2f..2c69cc0 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -118,11 +118,11 @@ struct feat_ops { /* get_max_cos_max is used to get feature's cos_max. */ unsigned int (*get_max_cos_max)(const struct feat_node *feat); /* get_feat_info is used to get feature HW info. */ - bool (*get_feat_info)(const struct feat_node *feat, enum cbm_type type, + bool (*get_feat_info)(const struct feat_node *feat, enum psr_val_type type, uint32_t dat[], uint32_t array_len); /* get_val is used to get feature COS register value. */ bool (*get_val)(const struct feat_node *feat, unsigned int cos, - enum cbm_type type, uint64_t *val); + enum psr_val_type type, uint64_t *val); /* * get_cos_num is used to get the COS registers amount used by the * feature for one setting, e.g. CDP uses 2 COSs but CAT uses 1. @@ -150,14 +150,14 @@ struct feat_ops { int (*set_new_val)(uint64_t val[], const struct feat_node *feat, unsigned int old_cos, - enum cbm_type type, + enum psr_val_type type, uint64_t m); /* * get_cos_max_from_type is used to get the cos_max value of the feature * according to input type. */ unsigned int (*get_cos_max_from_type)(const struct feat_node *feat, - enum cbm_type type); + enum psr_val_type type); /* * compare_val is used in set value process to compare if the * input value array can match all the features' COS registers values @@ -350,10 +350,10 @@ static unsigned int l3_cat_get_max_cos_max(const struct feat_node *feat) } static bool l3_cat_get_feat_info(const struct feat_node *feat, - enum cbm_type type, + enum psr_val_type type, uint32_t dat[], uint32_t array_len) { - if ( !dat || 3 > array_len || type != PSR_CBM_TYPE_L3 ) + if ( !dat || 3 > array_len || type != PSR_VAL_TYPE_L3 ) return false; dat[CBM_LEN] = feat->info.l3_cat_info.cbm_len; @@ -364,9 +364,9 @@ static bool l3_cat_get_feat_info(const struct feat_node *feat, } static bool l3_cat_get_val(const struct feat_node *feat, unsigned int cos, - enum cbm_type type, uint64_t *val) + enum psr_val_type type, uint64_t *val) { - if ( type != PSR_CBM_TYPE_L3 ) + if ( type != PSR_VAL_TYPE_L3 ) return false; if ( cos > feat->info.l3_cat_info.cos_max ) @@ -401,10 +401,10 @@ static int l3_cat_get_old_val(uint64_t val[], static int l3_cat_set_new_val(uint64_t val[], const struct feat_node *feat, unsigned int old_cos, - enum cbm_type type, + enum psr_val_type type, uint64_t m) { - if ( type != PSR_CBM_TYPE_L3 ) + if ( type != PSR_VAL_TYPE_L3 ) /* L3 CAT uses one COS. Skip it. */ return 1; @@ -418,9 +418,9 @@ static int l3_cat_set_new_val(uint64_t val[], } static unsigned int l3_cat_get_cos_max_from_type(const struct feat_node *feat, - enum cbm_type type) + enum psr_val_type type) { - if ( type != PSR_CBM_TYPE_L3 ) + if ( type != PSR_VAL_TYPE_L3 ) return 0; return feat->info.l3_cat_info.cos_max; @@ -557,11 +557,11 @@ static unsigned int l3_cdp_get_max_cos_max(const struct feat_node *feat) } static bool l3_cdp_get_feat_info(const struct feat_node *feat, - enum cbm_type type, + enum psr_val_type type, uint32_t dat[], uint32_t array_len) { if ( !dat || 3 > array_len || - ( type != PSR_CBM_TYPE_L3_DATA && type != PSR_CBM_TYPE_L3_CODE) ) + ( type != PSR_VAL_TYPE_L3_DATA && type != PSR_VAL_TYPE_L3_CODE) ) return false; dat[CBM_LEN] = feat->info.l3_cdp_info.cbm_len; @@ -572,16 +572,16 @@ static bool l3_cdp_get_feat_info(const struct feat_node *feat, } static bool l3_cdp_get_val(const struct feat_node *feat, unsigned int cos, - enum cbm_type type, uint64_t *val) + enum psr_val_type type, uint64_t *val) { - if ( type != PSR_CBM_TYPE_L3_DATA && type != PSR_CBM_TYPE_L3_CODE ) + if ( type != PSR_VAL_TYPE_L3_DATA && type != PSR_VAL_TYPE_L3_CODE ) return false; if ( cos > feat->info.l3_cdp_info.cos_max ) /* Use default value. */ cos = 0; - if ( type == PSR_CBM_TYPE_L3_DATA ) + if ( type == PSR_VAL_TYPE_L3_DATA ) *val = get_cdp_data(feat, cos); else *val = get_cdp_code(feat, cos); @@ -614,17 +614,17 @@ static int l3_cdp_get_old_val(uint64_t val[], static int l3_cdp_set_new_val(uint64_t val[], const struct feat_node *feat, unsigned int old_cos, - enum cbm_type type, + enum psr_val_type type, uint64_t m) { - if ( type != PSR_CBM_TYPE_L3_DATA && type != PSR_CBM_TYPE_L3_CODE ) + if ( type != PSR_VAL_TYPE_L3_DATA && type != PSR_VAL_TYPE_L3_CODE ) /* CDP uses two COSs. Skip them outside. */ return 2; if ( !psr_check_cbm(feat->info.l3_cdp_info.cbm_len, m) ) return -EINVAL; - if ( type == PSR_CBM_TYPE_L3_DATA ) + if ( type == PSR_VAL_TYPE_L3_DATA ) val[0] = m; else val[1] = m; @@ -634,9 +634,9 @@ static int l3_cdp_set_new_val(uint64_t val[], } static unsigned int l3_cdp_get_cos_max_from_type(const struct feat_node *feat, - enum cbm_type type) + enum psr_val_type type) { - if ( type != PSR_CBM_TYPE_L3_DATA && type != PSR_CBM_TYPE_L3_CODE ) + if ( type != PSR_VAL_TYPE_L3_DATA && type != PSR_VAL_TYPE_L3_CODE ) return 0; return feat->info.l3_cdp_info.cos_max; @@ -775,10 +775,10 @@ static unsigned int l2_cat_get_max_cos_max(const struct feat_node *feat) } static bool l2_cat_get_feat_info(const struct feat_node *feat, - enum cbm_type type, + enum psr_val_type type, uint32_t dat[], uint32_t array_len) { - if ( !dat || 2 > array_len || type != PSR_CBM_TYPE_L2 ) + if ( !dat || 2 > array_len || type != PSR_VAL_TYPE_L2 ) return false; dat[CBM_LEN] = feat->info.l2_cat_info.cbm_len; @@ -788,9 +788,9 @@ static bool l2_cat_get_feat_info(const struct feat_node *feat, } static bool l2_cat_get_val(const struct feat_node *feat, unsigned int cos, - enum cbm_type type, uint64_t *val) + enum psr_val_type type, uint64_t *val) { - if ( type != PSR_CBM_TYPE_L2 ) + if ( type != PSR_VAL_TYPE_L2 ) return false; if ( cos > feat->info.l2_cat_info.cos_max ) @@ -824,10 +824,10 @@ static int l2_cat_get_old_val(uint64_t val[], static int l2_cat_set_new_val(uint64_t val[], const struct feat_node *feat, unsigned int old_cos, - enum cbm_type type, + enum psr_val_type type, uint64_t m) { - if ( type != PSR_CBM_TYPE_L2 ) + if ( type != PSR_VAL_TYPE_L2 ) return 1; if ( !psr_check_cbm(feat->info.l2_cat_info.cbm_len, m) ) @@ -840,9 +840,9 @@ static int l2_cat_set_new_val(uint64_t val[], } static unsigned int l2_cat_get_cos_max_from_type(const struct feat_node *feat, - enum cbm_type type) + enum psr_val_type type) { - if ( type != PSR_CBM_TYPE_L2 ) + if ( type != PSR_VAL_TYPE_L2 ) return 0; return feat->info.l2_cat_info.cos_max; @@ -1134,7 +1134,7 @@ static struct psr_socket_info *get_socket_info(unsigned int socket) return socket_info + socket; } -int psr_get_info(unsigned int socket, enum cbm_type type, +int psr_get_info(unsigned int socket, enum psr_val_type type, uint32_t dat[], uint32_t array_len) { struct psr_socket_info *info = get_socket_info(socket); @@ -1151,7 +1151,7 @@ int psr_get_info(unsigned int socket, enum cbm_type type, } int psr_get_val(struct domain *d, unsigned int socket, - uint64_t *val, enum cbm_type type) + uint64_t *val, enum psr_val_type type) { const struct psr_socket_info *info = get_socket_info(socket); unsigned int cos = d->arch.psr_cos_ids[socket]; @@ -1187,7 +1187,7 @@ static int get_old_set_new(uint64_t *val, uint32_t array_len, const struct psr_socket_info *info, unsigned int old_cos, - enum cbm_type type, + enum psr_val_type type, uint64_t m) { const struct feat_node *feat_tmp; @@ -1226,7 +1226,7 @@ static int get_old_set_new(uint64_t *val, } static int find_cos(const uint64_t *val, uint32_t array_len, - enum cbm_type type, + enum psr_val_type type, const struct psr_socket_info *info) { unsigned int cos; @@ -1309,7 +1309,7 @@ static bool exceeds_cos_max(const uint64_t *val, static int alloc_new_cos(const struct psr_socket_info *info, const uint64_t *val, uint32_t array_len, unsigned int old_cos, - enum cbm_type type) + enum psr_val_type type) { unsigned int cos; unsigned int cos_max = 0; @@ -1419,7 +1419,7 @@ static int write_psr_msr(unsigned int socket, unsigned int cos, } int psr_set_val(struct domain *d, unsigned int socket, - uint64_t val, enum cbm_type type) + uint64_t val, enum psr_val_type type) { unsigned int old_cos; int cos, ret; @@ -1434,14 +1434,14 @@ int psr_set_val(struct domain *d, unsigned int socket, /* Judge if feature is enabled. */ switch ( type ) { - case PSR_CBM_TYPE_L3: + case PSR_VAL_TYPE_L3: flag = PSR_SOCKET_L3_CAT; break; - case PSR_CBM_TYPE_L3_DATA: - case PSR_CBM_TYPE_L3_CODE: + case PSR_VAL_TYPE_L3_DATA: + case PSR_VAL_TYPE_L3_CODE: flag = PSR_SOCKET_L3_CDP; break; - case PSR_CBM_TYPE_L2: + case PSR_VAL_TYPE_L2: flag = PSR_SOCKET_L2_CAT; break; default: diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index cff56bb..739909b 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -179,7 +179,7 @@ long arch_do_sysctl( { uint32_t dat[3]; ret = psr_get_info(sysctl->u.psr_alloc_op.target, - PSR_CBM_TYPE_L3, dat, 3); + PSR_VAL_TYPE_L3, dat, 3); if ( !ret ) { @@ -194,7 +194,7 @@ long arch_do_sysctl( * output values to CDP's if it is enabled. */ ret = psr_get_info(sysctl->u.psr_alloc_op.target, - PSR_CBM_TYPE_L3_CODE, dat, 3); + PSR_VAL_TYPE_L3_CODE, dat, 3); if ( !ret ) { sysctl->u.psr_alloc_op.u.l3_info.cbm_len = dat[CBM_LEN]; @@ -211,7 +211,7 @@ long arch_do_sysctl( { uint32_t dat[2]; ret = psr_get_info(sysctl->u.psr_alloc_op.target, - PSR_CBM_TYPE_L2, dat, 2); + PSR_VAL_TYPE_L2, dat, 2); if ( ret ) break; diff --git a/xen/include/asm-x86/psr.h b/xen/include/asm-x86/psr.h index ee65fe5..4d52918 100644 --- a/xen/include/asm-x86/psr.h +++ b/xen/include/asm-x86/psr.h @@ -52,11 +52,11 @@ struct psr_cmt { struct psr_cmt_l3 l3; }; -enum cbm_type { - PSR_CBM_TYPE_L3, - PSR_CBM_TYPE_L3_CODE, - PSR_CBM_TYPE_L3_DATA, - PSR_CBM_TYPE_L2, +enum psr_val_type { + PSR_VAL_TYPE_L3, + PSR_VAL_TYPE_L3_CODE, + PSR_VAL_TYPE_L3_DATA, + PSR_VAL_TYPE_L2, }; extern struct psr_cmt *psr_cmt; @@ -70,12 +70,12 @@ int psr_alloc_rmid(struct domain *d); void psr_free_rmid(struct domain *d); void psr_ctxt_switch_to(struct domain *d); -int psr_get_info(unsigned int socket, enum cbm_type type, +int psr_get_info(unsigned int socket, enum psr_val_type type, uint32_t dat[], uint32_t array_len); int psr_get_val(struct domain *d, unsigned int socket, - uint64_t *val, enum cbm_type type); + uint64_t *val, enum psr_val_type type); int psr_set_val(struct domain *d, unsigned int socket, - uint64_t val, enum cbm_type type); + uint64_t val, enum psr_val_type type); int psr_domain_init(struct domain *d); void psr_domain_free(struct domain *d);