From patchwork Wed Feb 15 08:49: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: 9573585 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 BB4AF60493 for ; Wed, 15 Feb 2017 08:55:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD44E28448 for ; Wed, 15 Feb 2017 08:55:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1F082844C; Wed, 15 Feb 2017 08:55:37 +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 193A728448 for ; Wed, 15 Feb 2017 08:55:37 +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 1cdvKs-0007KK-TS; Wed, 15 Feb 2017 08:53:14 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cdvKr-0007JK-Jr for xen-devel@lists.xenproject.org; Wed, 15 Feb 2017 08:53:13 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 03/AB-29440-9F614A85; Wed, 15 Feb 2017 08:53:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPLMWRWlGSWpSXmKPExsXS1tYhoftDbEm EwZ0Lohbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bPhUb2ghe6FR/+dTM1MO5X6GLk4hASmMYo sWj2VpYuRk4OCQFeiSPLZrBC2AESb+cuZoMoamCUOL92HhNIgk1AXeLx1x4wW0RASeLeqslMI EXMAouYJFZM+s4GkhAWcJOY8Osd2FQWAVWJX1/fgTXwCrhLnG68ywyxQU7i5LHJYNs4BTwkjl 2YA2YLAdUc7ZnGNIGRdwEjwypG9eLUorLUIl0zvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKR iveT83E2MwIBgAIIdjPNO+B9ilORgUhLlZTu2OEKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBC8T MMCEBItS01Mr0jJzgKEJk5bg4FES4f0pCpTmLS5IzC3OTIdInWJUlBLn/QiSEABJZJTmwbXB4 uESo6yUMC8j0CFCPAWpRbmZJajyrxjFORiVhHn/g0zhycwrgZv+CmgxE9Bi1riFIItLEhFSUg 2ME6/2i5pMnL6x+x3r480TJpQ/1uncLlmylD3m4KnMiElZty7VzDE/fP/nMb3loi8cvrDqtUf png++3Rk1iU/wXYez0eF3xxnz/VTfnewzXP/z8En+d9c8PpZoPziny8z6/9j+8vIbZ6cenj75 0cSTj1nvqPVXH+zTSVG/Pqfl9WVNqTXiFjxZGkosxRmJhlrMRcWJAHXwYkuCAgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1487148772!76852937!8 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25919 invoked from network); 15 Feb 2017 08:53:11 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-8.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Feb 2017 08:53:11 -0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2017 00:53:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.35,165,1484035200"; d="scan'208"; a="1094969684" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.63]) by orsmga001.jf.intel.com with ESMTP; 15 Feb 2017 00:53:08 -0800 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Wed, 15 Feb 2017 16:49:22 +0800 Message-Id: <1487148579-7243-8-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1487148579-7243-1-git-send-email-yi.y.sun@linux.intel.com> References: <1487148579-7243-1-git-send-email-yi.y.sun@linux.intel.com> Cc: kevin.tian@intel.com, wei.liu2@citrix.com, andrew.cooper3@citrix.com, dario.faggioli@citrix.com, he.chen@linux.intel.com, ian.jackson@eu.citrix.com, Yi Sun , mengxu@cis.upenn.edu, jbeulich@suse.com, chao.p.peng@linux.intel.com Subject: [Xen-devel] [PATCH v8 07/24] x86: refactor psr: implement get value flow. 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 implements get value flow including L3 CAT callback function. It also changes domctl interface to make it more general. With this patch, 'psr-cat-show' can work for L3 CAT but not for L3 code/data which is implemented in patch "x86: refactor psr: implement get value flow for CDP.". Signed-off-by: Yi Sun Reviewed-by: Konrad Rzeszutek Wilk --- xen/arch/x86/domctl.c | 18 +++++++++--------- xen/arch/x86/psr.c | 43 ++++++++++++++++++++++++++++++++++++++----- xen/include/asm-x86/psr.h | 4 ++-- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 8e5259f..098e399 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1440,23 +1440,23 @@ long arch_do_domctl( break; case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM: - ret = psr_get_l3_cbm(d, domctl->u.psr_cat_op.target, - &domctl->u.psr_cat_op.data, - PSR_CBM_TYPE_L3); + ret = psr_get_val(d, domctl->u.psr_cat_op.target, + &domctl->u.psr_cat_op.data, + PSR_CBM_TYPE_L3); copyback = 1; break; case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CODE: - ret = psr_get_l3_cbm(d, domctl->u.psr_cat_op.target, - &domctl->u.psr_cat_op.data, - PSR_CBM_TYPE_L3_CODE); + ret = psr_get_val(d, domctl->u.psr_cat_op.target, + &domctl->u.psr_cat_op.data, + PSR_CBM_TYPE_L3_CODE); copyback = 1; break; case XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA: - ret = psr_get_l3_cbm(d, domctl->u.psr_cat_op.target, - &domctl->u.psr_cat_op.data, - PSR_CBM_TYPE_L3_DATA); + ret = psr_get_val(d, domctl->u.psr_cat_op.target, + &domctl->u.psr_cat_op.data, + PSR_CBM_TYPE_L3_DATA); copyback = 1; break; diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 8af59d9..c1afd36 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -116,6 +116,9 @@ struct feat_ops { /* get_feat_info is used to get feature HW info. */ bool (*get_feat_info)(const struct feat_node *feat, uint32_t data[], unsigned int 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); }; /* @@ -260,9 +263,22 @@ static bool l3_cat_get_feat_info(const struct feat_node *feat, return true; } +static bool l3_cat_get_val(const struct feat_node *feat, unsigned int cos, + enum cbm_type type, uint64_t *val) +{ + if ( cos > feat->info.l3_cat_info.cos_max ) + /* Use default value. */ + cos = 0; + + *val = feat->cos_reg_val[cos]; + + return true; +} + static const struct feat_ops l3_cat_ops = { .get_cos_max = l3_cat_get_cos_max, .get_feat_info = l3_cat_get_feat_info, + .get_val = l3_cat_get_val, }; static void __init parse_psr_bool(char *s, char *value, char *feature, @@ -482,12 +498,14 @@ 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, - uint32_t data[], unsigned int array_len) +static int psr_get(unsigned int socket, enum cbm_type type, + uint32_t data[], unsigned int array_len, + struct domain *d, uint64_t *val) { const struct psr_socket_info *info = get_socket_info(socket); const struct feat_node *feat; enum psr_feat_type feat_type; + unsigned int cos; if ( IS_ERR(info) ) return PTR_ERR(info); @@ -498,6 +516,15 @@ int psr_get_info(unsigned int socket, enum cbm_type type, if ( feat->feature != feat_type ) continue; + if ( d ) + { + cos = d->arch.psr_cos_ids[socket]; + if ( feat->ops.get_val(feat, cos, type, val) ) + return 0; + else + break; + } + if ( feat->ops.get_feat_info(feat, data, array_len) ) return 0; else @@ -507,10 +534,16 @@ int psr_get_info(unsigned int socket, enum cbm_type type, return -ENOENT; } -int psr_get_l3_cbm(struct domain *d, unsigned int socket, - uint64_t *cbm, enum cbm_type type) +int psr_get_info(unsigned int socket, enum cbm_type type, + uint32_t data[], unsigned int array_len) +{ + return psr_get(socket, type, data, array_len, NULL, NULL); +} + +int psr_get_val(struct domain *d, unsigned int socket, + uint64_t *val, enum cbm_type type) { - return 0; + return psr_get(socket, type, NULL, 0, d, val); } int psr_set_l3_cbm(struct domain *d, unsigned int socket, diff --git a/xen/include/asm-x86/psr.h b/xen/include/asm-x86/psr.h index 0342a80..569e7df 100644 --- a/xen/include/asm-x86/psr.h +++ b/xen/include/asm-x86/psr.h @@ -70,8 +70,8 @@ void psr_ctxt_switch_to(struct domain *d); int psr_get_info(unsigned int socket, enum cbm_type type, uint32_t data[], unsigned int array_len); -int psr_get_l3_cbm(struct domain *d, unsigned int socket, - uint64_t *cbm, enum cbm_type type); +int psr_get_val(struct domain *d, unsigned int socket, + uint64_t *val, enum cbm_type type); int psr_set_l3_cbm(struct domain *d, unsigned int socket, uint64_t cbm, enum cbm_type type);