From patchwork Thu Mar 16 11:08:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9627861 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 D24F560522 for ; Thu, 16 Mar 2017 11:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CADAC28573 for ; Thu, 16 Mar 2017 11:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF4572857D; Thu, 16 Mar 2017 11:16:02 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 56A5228644 for ; Thu, 16 Mar 2017 11:16:02 +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 1coTML-0004fq-KY; Thu, 16 Mar 2017 11:14:21 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coTMK-0004eL-E9 for xen-devel@lists.xenproject.org; Thu, 16 Mar 2017 11:14:20 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 5E/81-00609-B837AC85; Thu, 16 Mar 2017 11:14:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsVywNwkVre7+FS Ewf417Bbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aaf5tYCr4qVNxcMY+xgfGPaBcjFweLwC0m ibWNL5m7GDk5hASmMUoc6ygAsSUEeCWOLJvB2sXIAWT7S+x6qQ1SLyTQwChxadl0NpAaNgF1i cdfe5hAbBEBJYl7qyYzgRQxC+xkklh3+jszSLOwgK9E+59KkBoWAVWJq+u/ge3iFfCQWLz9EB PELjmJk8cms4LYnEDxj+3trBD3uEu82/CXfQIj3wJGhlWMGsWpRWWpRbqGJnpJRZnpGSW5iZk 5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIFhwgAEOxhXbPc8xCjJwaQkylv+40SEEF9SfkplRmJx RnxRaU5q8SFGGQ4OJQneI0onI4QEi1LTUyvSMnOAAQuTluDgURLhzQVJ8xYXJOYWZ6ZDpE4xK kqJ814ASQiAJDJK8+DaYFFyiVFWSpiXEegQIZ6C1KLczBJU+VeM4hyMSsK8m0Gm8GTmlcBNfw W0mAlo8dsPJ0AWlyQipKQaGMV2rRfwr/gxWbLrd9q7NclGbQlL1r25luka4Bhx9vPXJw9awlu MOq7GrW6erOqbmLd22lwFxpLvB7uU06b/qyid3eR/zuac6ePJAYEvJ+TLtthcfyP72eL5Xwat /ezVe/tusTa1f0l6GvoqVP7By95bT+p71dykuAWjy4/Y5loYNi9Rt6tarMRSnJFoqMVcVJwIA H6WZiSNAgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1489662818!78881615!14 X-Originating-IP: [192.55.52.93] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjkzID0+IDMyNDY2NQ==\n X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10994 invoked from network); 16 Mar 2017 11:14:18 -0000 Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by server-2.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 16 Mar 2017 11:14:18 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489662858; x=1521198858; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=0WWxObv4nM5Io3elUOPByJsVas/P9HOmYTBup66IlOg=; b=n9UBBw+u8HuLWr5X4WN2HecHCpa707Ps035p9AjQpEayPTX7u/I2hIFJ 6dTpyn68VVxZTvZp2QRGfMH2nIxm5A==; Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2017 04:14:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,172,1486454400"; d="scan'208";a="944976620" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.63]) by orsmga003.jf.intel.com with ESMTP; 16 Mar 2017 04:14:15 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Thu, 16 Mar 2017 19:08:05 +0800 Message-Id: <1489662495-5375-16-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1489662495-5375-1-git-send-email-yi.y.sun@linux.intel.com> References: <1489662495-5375-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, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v9 15/25] 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. It also changes sysctl function to make it work for CDP. With this patch, 'psr-hwinfo' can work for L3 CDP. Signed-off-by: Yi Sun --- 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 | 16 ++++++++++++++++ xen/arch/x86/sysctl.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index e2a2643..ba5c7a4 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -275,6 +275,10 @@ static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type) case PSR_CBM_TYPE_L3: feat_type = PSR_SOCKET_L3_CAT; break; + case PSR_CBM_TYPE_L3_DATA: + case PSR_CBM_TYPE_L3_CODE: + feat_type = PSR_SOCKET_L3_CDP; + break; default: feat_type = PSR_SOCKET_UNKNOWN; break; @@ -506,8 +510,20 @@ static const struct feat_ops l3_cat_ops = { }; /* L3 CDP ops */ +static bool l3_cdp_get_feat_info(const struct feat_node *feat, + uint32_t data[], uint32_t array_len) +{ + if ( !cat_get_feat_info(feat, data, array_len) ) + return false; + + data[PSR_INFO_IDX_FLAG] |= XEN_SYSCTL_PSR_CAT_L3_CDP; + + return true; +} + struct feat_ops l3_cdp_ops = { .get_cos_max = cat_get_cos_max, + .get_feat_info = l3_cdp_get_feat_info, }; static void __init parse_psr_bool(char *s, char *value, char *feature, diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index aab3d2d..3bf51a4 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -180,10 +180,36 @@ long arch_do_sysctl( ret = psr_get_info(sysctl->u.psr_cat_op.target, PSR_CBM_TYPE_L3, data, ARRAY_SIZE(data)); - - sysctl->u.psr_cat_op.u.l3_info.cbm_len = data[PSR_INFO_IDX_CBM_LEN]; - sysctl->u.psr_cat_op.u.l3_info.cos_max = data[PSR_INFO_IDX_COS_MAX]; - sysctl->u.psr_cat_op.u.l3_info.flags = data[PSR_INFO_IDX_FLAG]; + if ( !ret ) + { + sysctl->u.psr_cat_op.u.l3_info.cbm_len = + data[PSR_INFO_IDX_CBM_LEN]; + sysctl->u.psr_cat_op.u.l3_info.cos_max = + data[PSR_INFO_IDX_COS_MAX]; + sysctl->u.psr_cat_op.u.l3_info.flags = + data[PSR_INFO_IDX_FLAG]; + } + else + { + /* + * Check if CDP is enabled. + * + * Per spec, L3 CAT and CDP cannot co-exist. So, we need replace + * output values to CDP's if it is enabled. + */ + ret = psr_get_info(sysctl->u.psr_cat_op.target, + PSR_CBM_TYPE_L3_CODE, data, + ARRAY_SIZE(data)); + if ( !ret ) + { + sysctl->u.psr_cat_op.u.l3_info.cbm_len = + data[PSR_INFO_IDX_CBM_LEN]; + sysctl->u.psr_cat_op.u.l3_info.cos_max = + data[PSR_INFO_IDX_COS_MAX]; + sysctl->u.psr_cat_op.u.l3_info.flags = + data[PSR_INFO_IDX_FLAG]; + } + } if ( !ret && __copy_field_to_guest(u_sysctl, sysctl, u.psr_cat_op) ) ret = -EFAULT;