From patchwork Wed Feb 8 08:15:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9561925 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 D7A8F60236 for ; Wed, 8 Feb 2017 08:21:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB06628441 for ; Wed, 8 Feb 2017 08:21:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFF1128446; Wed, 8 Feb 2017 08:21:48 +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 57AE728495 for ; Wed, 8 Feb 2017 08:21:48 +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 1cbNTJ-0005qK-Vf; Wed, 08 Feb 2017 08:19:25 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbNTI-0005p1-J0 for xen-devel@lists.xenproject.org; Wed, 08 Feb 2017 08:19:24 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 4E/0B-01943-B84DA985; Wed, 08 Feb 2017 08:19:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsXS1tbhqNt9ZVa EwYQdHBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bcRTfZCxbqV7xe8I25gXGfYhcjJ4eQQKXE 1YWHWEBsCQFeiSPLZrBC2H4SZ589Ze9i5AKqaWCU+Hivkw0kwSagLvH4aw8TiC0ioCRxb9VkJ pAiZoFFTBIrJn0HKxIWcJNYuWMX2FQWAVWJyT9Og03lFXCXuLJ1C9QGOYmTxyYD2RwcnAIeEm sWyEEc5C5x/eQMlgmMvAsYGVYxahSnFpWlFukaGuolFWWmZ5TkJmbm6BoamOrlphYXJ6an5iQ mFesl5+duYgSGAwMQ7GBc2e58iFGSg0lJlJfx1KwIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8 bMDwEhIsSk1PrUjLzAEGJkxagoNHSYT38GWgNG9xQWJucWY6ROoUo6KUOERCACSRUZoH1waLh kuMslLCvIxAhwjxFKQW5WaWoMq/YhTnYFQS5g0HmcKTmVcCN/0V0GImoMXXT4MtLklESEk1MK 5575a6YJJgjP2p6wHBJv+KLsxov/NNd9eZnvRD82RmZdf+vbj/0mKJSu2LS4L4j+v8WRfLIXa T/f4syb1zyp/qB/JKbfnPUpV4/VxU5Ikdi751bJUMPleuZBV0xzzifoemk7o2c7ZSzRZr3l+2 Pf7zQ9a5JPVpXpN6520gs2TyjbW6R0XeJSixFGckGmoxFxUnAgC2KJtrgQIAAA== X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1486541945!83610550!8 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 62411 invoked from network); 8 Feb 2017 08:19:22 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-6.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Feb 2017 08:19:22 -0000 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP; 08 Feb 2017 00:19:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,346,1477983600"; d="scan'208";a="63203429" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.63]) by fmsmga006.fm.intel.com with ESMTP; 08 Feb 2017 00:19:19 -0800 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Wed, 8 Feb 2017 16:15:59 +0800 Message-Id: <1486541776-8406-8-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486541776-8406-1-git-send-email-yi.y.sun@linux.intel.com> References: <1486541776-8406-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 v6 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 --- v6: - modify commit message to make it clearer. - remove one extra space in code. - write a helper function to move get info and get val functions into it. Because most codes of 'get_info' and 'get_val' are same. --- 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 d4a9003..0cb9971 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);