From patchwork Mon Feb 13 06:32:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9568895 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 B69806045D for ; Mon, 13 Feb 2017 06:38:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A43F92818E for ; Mon, 13 Feb 2017 06:38:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99186281DB; Mon, 13 Feb 2017 06:38:39 +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 28F912818E for ; Mon, 13 Feb 2017 06:38:39 +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 1cdAF0-00062C-DH; Mon, 13 Feb 2017 06:36:02 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cdAEz-000621-Dt for xen-devel@lists.xenproject.org; Mon, 13 Feb 2017 06:36:01 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id F2/44-00888-0D351A85; Mon, 13 Feb 2017 06:36:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPLMWRWlGSWpSXmKPExsXS1tbhqHsheGG EQet2JovvWyYzOTB6HP5whSWAMYo1My8pvyKBNePEjG0sBdP1KlZs72duYHys0MXIxSEkMJ1R 4vHTa8xdjJwcEgK8EkeWzWCFsP0lOq5MZoQoamCUeH3qMDtIgk1AXeLx1x4mEFtEQEni3qrJT CBFzAKLmCRWTPrOBpIQFnCTeHGjF2wqi4CqRMetJ2BxXgF3iTVbT7JBbJCTOHlsMtg2TgEPiS OH3jOC2EJANf27NrFMYORdwMiwilG9OLWoLLVI11AvqSgzPaMkNzEzR9fQwFgvN7W4ODE9NSc xqVgvOT93EyMwIBiAYAfj8o9OhxglOZiURHmr7RdGCPEl5adUZiQWZ8QXleakFh9ilOHgUJLg XRsElBMsSk1PrUjLzAGGJkxagoNHSYQ3BSTNW1yQmFucmQ6ROsWoKCXOuxgkIQCSyCjNg2uDx cMlRlkpYV5GoEOEeApSi3IzS1DlXzGKczAqCfNuApnCk5lXAjf9FdBiJqDFrg/mgiwuSURIST UwTupKPcYj3Pes+MeU7veykx7zHDhivXT+oRu2xv9NOhIEoraXq3/u2LXapO+QlEu2SeuK/Qp rpr87/G5yo1lDEd+y5PM1F6MNvFJOyKw8afM/Z+WUpGtJ55unzFv/PuZglfrraQsqY872i3bE +2U6/uLT75z6Yqbp7/9PJwpMbDFj+x9vxy7XrMRSnJFoqMVcVJwIAAedisWCAgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1486967747!81195535!6 X-Originating-IP: [134.134.136.65] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11651 invoked from network); 13 Feb 2017 06:35:59 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-15.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 13 Feb 2017 06:35:59 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2017 22:35:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,155,1484035200"; d="scan'208";a="224551632" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.63]) by fmsmga004.fm.intel.com with ESMTP; 12 Feb 2017 22:35:56 -0800 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Mon, 13 Feb 2017 14:32:19 +0800 Message-Id: <1486967556-3702-8-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486967556-3702-1-git-send-email-yi.y.sun@linux.intel.com> References: <1486967556-3702-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 v7 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 --- v7: - rename '__psr_get' to 'psr_get'. --- 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 79014f9..4ad801a 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); }; /* @@ -257,9 +260,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, @@ -479,12 +495,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); @@ -495,6 +513,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 @@ -504,10 +531,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);