From patchwork Wed Aug 9 07:41:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9889773 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 EB513603F2 for ; Wed, 9 Aug 2017 08:01:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DECE828A48 for ; Wed, 9 Aug 2017 08:01:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1AE928A42; Wed, 9 Aug 2017 08:01:22 +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 F083928A48 for ; Wed, 9 Aug 2017 08:01:21 +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 1dfLsY-0001hd-6k; Wed, 09 Aug 2017 07:58:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfLsW-0001gm-Os for xen-devel@lists.xenproject.org; Wed, 09 Aug 2017 07:58:08 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 66/9E-03612-090CA895; Wed, 09 Aug 2017 07:58:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsXS1tYhodt/oCv SYOZcHYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP5hBamgo8KFYt+9DM2MPZLdDFycQgJTGOU OLl5M0sXIyeHhACvxJFlM1ghbH+J8393sEIUNTBKnNn7ESzBJqAu8fhrDxOILSKgJHFv1WQmk CJmgW1MEu8vv2AHSQgLOEo0TYMoYhFQlbi75wiYzSvgLjFn/UQ2iA1yEiePTQYbyingIbG54w 9YXAio5tuubvYJjLwLGBlWMWoUpxaVpRbpGhvqJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhX rJefnbmIEhgQDEOxgbFoUeIhRkoNJSZR3k3ZnpBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3kv7 uyKFBItS01Mr0jJzgMEJk5bg4FES4S0HSfMWFyTmFmemQ6ROMepyvJrw/xuTEEtefl6qlDjvf pAiAZCijNI8uBGwSLnEKCslzMsIdJQQT0FqUW5mCar8K0ZxDkYlYd5JIFN4MvNK4Da9AjqCCe iICN9OkCNKEhFSUg2Mzj8e8PL4/9hrtPN5/oa6iOtHEyft3mssuiBn3oP9zC6RqYySlUcrGnU FV9aEJJil/Q7s/OivcJyltOXcquWaT6YbHb0e8XSf5wMhMU7P9JwOq7eL38b8F22/6zD5QHu6 VNibuIlxWdWp64SNM1ql5wjWPN29+csJBd3KVXH22xl7shX8j3cqsRRnJBpqMRcVJwIA7OIQR Y8CAAA= X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1502265470!79168193!6 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64535 invoked from network); 9 Aug 2017 07:58:07 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-11.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 9 Aug 2017 07:58:07 -0000 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2017 00:58:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,346,1498546800"; d="scan'208";a="117182953" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.80]) by orsmga004.jf.intel.com with ESMTP; 09 Aug 2017 00:58:03 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Wed, 9 Aug 2017 15:41:44 +0800 Message-Id: <1502264512-4648-6-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502264512-4648-1-git-send-email-yi.y.sun@linux.intel.com> References: <1502264512-4648-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 , julien.grall@arm.com, mengxu@cis.upenn.edu, jbeulich@suse.com, chao.p.peng@linux.intel.com, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v1 05/13] x86: implement get hw info flow for MBA 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 MBA including its callback function and sysctl interface. Signed-off-by: Yi Sun --- v1: - sort 'PSR_INFO_IDX_' macros as feature. (suggested by Chao Peng) - rename 'PSR_INFO_IDX_MBA_LINEAR' to 'PSR_INFO_IDX_MBA_FLAG'. - rename 'linear' in 'struct mba_info' to 'flags' for future extension. (suggested by Chao Peng) --- xen/arch/x86/psr.c | 13 ++++++++++++- xen/arch/x86/sysctl.c | 19 +++++++++++++++++++ xen/include/asm-x86/psr.h | 2 ++ xen/include/public/sysctl.h | 8 ++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index d94a5b1..9455e67 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -264,6 +264,10 @@ static enum psr_feat_type psr_val_type_to_feat_type(enum psr_val_type type) feat_type = FEAT_TYPE_L2_CAT; break; + case PSR_VAL_TYPE_MBA: + feat_type = FEAT_TYPE_MBA; + break; + default: ASSERT_UNREACHABLE(); } @@ -490,7 +494,14 @@ static const struct feat_props l2_cat_props = { static bool mba_get_feat_info(const struct feat_node *feat, uint32_t data[], unsigned int array_len) { - return false; + if ( array_len != PSR_INFO_ARRAY_SIZE ) + return false; + + data[PSR_INFO_IDX_COS_MAX] = feat->cos_max; + data[PSR_INFO_IDX_MBA_THRTL_MAX] = feat->mba_info.thrtl_max; + data[PSR_INFO_IDX_MBA_FLAG] = feat->mba_info.linear; + + return true; } static void mba_write_msr(unsigned int cos, uint32_t val, diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index b4fc1d5..2bf1543 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -214,6 +214,25 @@ long arch_do_sysctl( break; } + case XEN_SYSCTL_PSR_MBA_get_info: + { + ret = psr_get_info(sysctl->u.psr_alloc_op.target, + PSR_VAL_TYPE_MBA, data, ARRAY_SIZE(data)); + if ( ret ) + break; + + sysctl->u.psr_alloc_op.u.mba_info.cos_max = + data[PSR_INFO_IDX_COS_MAX]; + sysctl->u.psr_alloc_op.u.mba_info.thrtl_max = + data[PSR_INFO_IDX_MBA_THRTL_MAX]; + sysctl->u.psr_alloc_op.u.mba_info.flags = + data[PSR_INFO_IDX_MBA_FLAG]; + + if ( !ret && __copy_field_to_guest(u_sysctl, sysctl, u.psr_alloc_op) ) + ret = -EFAULT; + break; + } + default: ret = -EOPNOTSUPP; break; diff --git a/xen/include/asm-x86/psr.h b/xen/include/asm-x86/psr.h index 551ccf3..af7301f 100644 --- a/xen/include/asm-x86/psr.h +++ b/xen/include/asm-x86/psr.h @@ -39,6 +39,8 @@ #define PSR_INFO_IDX_COS_MAX 0 #define PSR_INFO_IDX_CAT_CBM_LEN 1 #define PSR_INFO_IDX_CAT_FLAG 2 +#define PSR_INFO_IDX_MBA_THRTL_MAX 1 +#define PSR_INFO_IDX_MBA_FLAG 2 #define PSR_INFO_ARRAY_SIZE 3 struct psr_cmt_l3 { diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index fcebab1..169e7e6 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -745,6 +745,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_pcitopoinfo_t); #define XEN_SYSCTL_PSR_CAT_get_l3_info 0 #define XEN_SYSCTL_PSR_CAT_get_l2_info 1 +#define XEN_SYSCTL_PSR_MBA_get_info 2 struct xen_sysctl_psr_alloc_op { uint32_t cmd; /* IN: XEN_SYSCTL_PSR_CAT_* */ uint32_t target; /* IN */ @@ -755,6 +756,13 @@ struct xen_sysctl_psr_alloc_op { #define XEN_SYSCTL_PSR_CAT_L3_CDP (1u << 0) uint32_t flags; /* OUT: CAT flags */ } cat_info; + + struct { + uint32_t thrtl_max; /* OUT: Maximum throttle */ + uint32_t cos_max; /* OUT: Maximum COS */ +#define XEN_SYSCTL_PSR_MBA_LINEAR (1u << 0) + uint32_t flags; /* OUT: MBA flags */ + } mba_info; } u; }; typedef struct xen_sysctl_psr_alloc_op xen_sysctl_psr_alloc_op_t;