From patchwork Tue Aug 1 08:48:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9873911 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 1F45860365 for ; Tue, 1 Aug 2017 09:07:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26F412582C for ; Tue, 1 Aug 2017 09:07:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BC0A28670; Tue, 1 Aug 2017 09:07:21 +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 BC8CA2582C for ; Tue, 1 Aug 2017 09:07:20 +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 1dcT6h-0005NW-9u; Tue, 01 Aug 2017 09:04:51 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcT6f-0005Lq-W6 for xen-devel@lists.xenproject.org; Tue, 01 Aug 2017 09:04:50 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id 01/0B-01712-13440895; Tue, 01 Aug 2017 09:04:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGLMWRWlGSWpSXmKPExsXS1tYhoqvn0hB p8O24gcX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvHwU3jBS5GKw63z2RsYH/B3MXJyCAlMY5R4 3F4BYksI8EocWTaDtYuRA8j2lzi5sbiLkQuopIFR4uTNQywgNWwC6hKPv/YwgdgiAkoS91ZNZ gIpYhaYzyTx+vwDZpCEsICfRPfSDjYQm0VAVWL6vomMIEN5BTwk7t3nhdglJ3Hy2GRWEJsTKL zj5g1mkBIhAXeJnTMTJzDyLmBkWMWoXpxaVJZapGuql1SUmZ5RkpuYmaNraGCql5taXJyYnpq TmFSsl5yfu4kRGAYMQLCD8Uu/8yFGSQ4mJVFexZ76SCG+pPyUyozE4oz4otKc1OJDjDIcHEoS vBLODZFCgkWp6akVaZk5wICESUtw8CiJ8F5wAkrzFhck5hZnpkOkTjHqcrya8P8bkxBLXn5eq pQ470WQIgGQoozSPLgRsOi4xCgrJczLCHSUEE9BalFuZgmq/CtGcQ5GJWHe+yBTeDLzSuA2vQ I6ggnoCMnSWpAjShIRUlINjGbtJ7n3KM2ZIHLl6KP7P3I+avnqeLJ9NqxZKmygVJf70v/Lju1 1Qgx9flLHqjzN5Pbm59p5bKrsdJ6vM9HvTccO6S6hDW/v155d/8h684IHYYo6ewPWf5u34Ldn lpSFSvK0f8yWIvf0zMybeu4bvV3Mf8xk5xPBbV97rZ//3ep9Rq7Zcu3eciWW4oxEQy3mouJEA J2OaBiJAgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1501578248!89431283!15 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 53066 invoked from network); 1 Aug 2017 09:04:46 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 1 Aug 2017 09:04:46 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Aug 2017 02:04:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,305,1498546800"; d="scan'208";a="118061631" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.80]) by orsmga002.jf.intel.com with ESMTP; 01 Aug 2017 02:04:43 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Tue, 1 Aug 2017 16:48:45 +0800 Message-Id: <1501577334-7431-15-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501577334-7431-1-git-send-email-yi.y.sun@linux.intel.com> References: <1501577334-7431-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, ian.jackson@eu.citrix.com, Yi Sun , mengxu@cis.upenn.edu, jbeulich@suse.com, chao.p.peng@linux.intel.com, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v15 14/23] x86: refactor psr: CDP: implement get hw info 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 HW info flow for CDP including L3 CDP callback function. The flow is almost same as L3 CAT. With this patch, 'psr-hwinfo' can work for L3 CDP. Signed-off-by: Yi Sun Reviewed-by: Jan Beulich --- v12: - remove input parameter 'info' in 'psr_cbm_type_to_feat_type'. Use 'feat_props' array to check. (suggested by Jan Beulich) v11: - modify 'psr_get_info' flow to make it simple to cover CDP case. v10: - update renamed macros used by psr_get_info. (suggested by Jan Beulich) - change 'psr_get_info' flow to cover CDP case to make codes in sysctl more simple. (suggested by Jan Beulich) - remove sysctl redundant codes after applying above changes. (suggested by Jan Beulich) v9: - modify commit message to explain flow more clearly. - reuse 'cat_get_feat_info' for CDP to reduce redundant codes. (suggested by Roger Pau) - fix coding style issues. (suggested by Wei Liu and Roger Pau) - rename macros used by psr_get_info to make them meaningful. (suggested by Jan Beulich) v5: - rename 'dat[]' to 'data[]'. (suggested by Jan Beulich) - remove type check in callback function. (suggested by Jan Beulich) v4: - create this patch to make codes easier to understand. (suggested by Jan Beulich) --- xen/arch/x86/psr.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 083e253..6a2f802 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -222,7 +222,21 @@ static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type) { case PSR_CBM_TYPE_L3: feat_type = FEAT_TYPE_L3_CAT; + + /* + * If type is L3 CAT but we cannot find it in feat_props array, + * try CDP. + */ + if ( !feat_props[feat_type] ) + feat_type = FEAT_TYPE_L3_CDP; + + break; + + case PSR_CBM_TYPE_L3_DATA: + case PSR_CBM_TYPE_L3_CODE: + feat_type = FEAT_TYPE_L3_CDP; break; + default: ASSERT_UNREACHABLE(); } @@ -350,7 +364,12 @@ static const struct feat_props l3_cat_props = { static bool l3_cdp_get_feat_info(const struct feat_node *feat, uint32_t data[], uint32_t array_len) { - return false; + if ( !cat_get_feat_info(feat, data, array_len) ) + return false; + + data[PSR_INFO_IDX_CAT_FLAG] |= XEN_SYSCTL_PSR_CAT_L3_CDP; + + return true; } static void l3_cdp_write_msr(unsigned int cos, uint32_t val, enum cbm_type type)