From patchwork Sat Jul 15 00:31:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9841859 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 6BEB060212 for ; Sat, 15 Jul 2017 00:49:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CA7328798 for ; Sat, 15 Jul 2017 00:49:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 518AC287B3; Sat, 15 Jul 2017 00:49:00 +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 78371287AE for ; Sat, 15 Jul 2017 00:48:58 +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 1dWBEU-0007R2-Tp; Sat, 15 Jul 2017 00:46:54 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dWBEU-0007Ph-Cf for xen-devel@lists.xenproject.org; Sat, 15 Jul 2017 00:46:54 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 1A/89-01995-6E569695; Sat, 15 Jul 2017 00:46:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsVywNxEW/dpama kwed3Bhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b02z3MBS9FKtY+DW1gfMDfxcjJISRQIfHv 0RoWEFtCgFfiyLIZrBC2v8S2hwuZuxi5gGoaGCUeb7jCCJJgE1CXePy1hwnEFhFQkri3ajITS BGzwHwmidfnHzCDJIQF/CSavh8GK2IRUJXYsukymM0r4CHxc/dkdogNchInj00G28YJFJ+6rw 0ozgG0zV2iZXb5BEbeBYwMqxg1ilOLylKLdI0N9JKKMtMzSnITM3N0DQ2M9XJTi4sT01NzEpO K9ZLzczcxAoOhnoGBcQdj5wm/Q4ySHExKorzvbmdECvEl5adUZiQWZ8QXleakFh9ilOHgUJLg 5QcGl5BgUWp6akVaZg4wLGHSEhw8SiK8s1KA0rzFBYm5xZnpEKlTjLocryb8/8YkxJKXn5cqJ c57CqRIAKQoozQPbgQsRi4xykoJ8zIyMDAI8RSkFuVmlqDKv2IU52BUEuadDzKFJzOvBG7TK6 AjmICOaMvKADmiJBEhJdXAyPrvnavQa4l9G2e5n6xplDSfYb6zMOW3W4cfz8bakIpDB9Nztmy 4LlUdlvWYVWypd45ZCd/UtmrNkyy9HeJlQdKJxRdZD+z/sGrORserqoaiko9VrleEHZR+xtsl LcexoqnmIuPy3m8mra/1+sMnaVdnvxDJKAuNVOb35zy3adUWrpLaYDklluKMREMt5qLiRAAlc 9dojAIAAA== X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1500079549!66978060!15 X-Originating-IP: [192.55.52.43] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37700 invoked from network); 15 Jul 2017 00:46:29 -0000 Received: from mga05.intel.com (HELO mga05.intel.com) (192.55.52.43) by server-6.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Jul 2017 00:46:29 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 14 Jul 2017 17:46:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,360,1496127600"; d="scan'208";a="111534893" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.80]) by orsmga002.jf.intel.com with ESMTP; 14 Jul 2017 17:46:26 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Sat, 15 Jul 2017 08:31:47 +0800 Message-Id: <1500078716-5928-15-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1500078716-5928-1-git-send-email-yi.y.sun@linux.intel.com> References: <1500078716-5928-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 v14 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 35b78f6..a9e1b56 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)