From patchwork Tue Sep 5 09:32:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9938325 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 BF493601EB for ; Tue, 5 Sep 2017 09:53:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B205B28908 for ; Tue, 5 Sep 2017 09:53:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6ADE2890C; Tue, 5 Sep 2017 09:53:30 +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 41FD628908 for ; Tue, 5 Sep 2017 09:53:30 +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 1dpAVt-00073n-LJ; Tue, 05 Sep 2017 09:51:21 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dpAVs-00072h-1Y for xen-devel@lists.xenproject.org; Tue, 05 Sep 2017 09:51:20 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 30/30-03610-7937EA95; Tue, 05 Sep 2017 09:51:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRWlGSWpSXmKPExsXS1taRojuteF2 kwcS/chbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b5+0vYC1YoV3z5sIipgbFJqouRk0NIoFLi 5Lq3bCC2hACvxJFlM1ghbH+J50d7geJcQDUNjBKzZj9mB0mwCahLPP7awwRiiwgoSdxbNZkJp IhZ4ByTxJ6PO4AcDg5hAUeJhz9jQGpYBFQl9q55B7aAV8BdYm7fexaIBXISJ49NZgUp5xTwkF h6rQ7iHneJP9vuskKUC0qcnPmEBaSEGWjt+nlCIGFmAXmJ5q2zmScwCsxCUjULoWoWkqoFjMy rGDWKU4vKUot0DQ31kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECA5MBCHYwfloW cIhRkoNJSZQ3NHFdpBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3ltFQDnBotT01Iq0zBxgjMCkJ Th4lER4z4GkeYsLEnOLM9MhUqcYFaXEeY+DJARAEhmleXBtsLi8xCgrJczLCHSIEE9BalFuZg mq/CtGcQ5GJWHeJSBTeDLzSuCmvwJazAS0uOrlGpDFJYkIKakGxhU+37d+W5ry5d6VnzGvZ6i am++c8z/4QKiWpO91HvUdKqGrRdZf6jb56HvhbrV21DEbrybDyMXzGTaebnm/7v+uirk+gfWX 9eI7T623eGBnoqq2n3u/kN+LuBdLT6s2vn6iaKUo8cSqeI3LaaMJAjHvFtS/4iit0qwQttA1S e+RnZf/urtumhJLcUaioRZzUXEiAF8ucjXGAgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1504605073!62289035!2 X-Originating-IP: [134.134.136.100] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41389 invoked from network); 5 Sep 2017 09:51:17 -0000 Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 5 Sep 2017 09:51:17 -0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP; 05 Sep 2017 02:51:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,479,1498546800"; d="scan'208";a="897185202" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.80]) by FMSMGA003.fm.intel.com with ESMTP; 05 Sep 2017 02:51:11 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Tue, 5 Sep 2017 17:32:27 +0800 Message-Id: <1504603957-5389-6-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1504603957-5389-1-git-send-email-yi.y.sun@linux.intel.com> References: <1504603957-5389-1-git-send-email-yi.y.sun@linux.intel.com> MIME-Version: 1.0 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, dgdegra@tycho.nsa.gov, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v3 05/15] 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: , 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 --- v3: - replace 'PSR_VAL_TYPE_MBA' to 'PSR_TYPE_MBA_THRTL'. (suggested by Roger Pau Monné) v2: - use 'XEN_SYSCTL_PSR_MBA_LINEAR' to set MBA feature HW info. (suggested by Chao Peng) 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 | 17 ++++++++++++++++- xen/arch/x86/sysctl.c | 19 +++++++++++++++++++ xen/include/asm-x86/psr.h | 2 ++ xen/include/public/sysctl.h | 8 ++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 10776d2..0486d2d 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -263,6 +263,10 @@ static enum psr_feat_type psr_type_to_feat_type(enum psr_type type) feat_type = FEAT_TYPE_L2_CAT; break; + case PSR_TYPE_MBA_THRTL: + feat_type = FEAT_TYPE_MBA; + break; + default: ASSERT_UNREACHABLE(); } @@ -491,7 +495,18 @@ 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.thrtl_max; + + if ( feat->mba.linear ) + data[PSR_INFO_IDX_MBA_FLAG] |= XEN_SYSCTL_PSR_ALLOC_MBA_LINEAR; + else + data[PSR_INFO_IDX_MBA_FLAG] &= ~XEN_SYSCTL_PSR_ALLOC_MBA_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 1d3dbd0..4634cad 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_ALLOC_get_mba_info: + { + ret = psr_get_info(sysctl->u.psr_alloc.target, + PSR_TYPE_MBA_THRTL, data, ARRAY_SIZE(data)); + if ( ret ) + break; + + sysctl->u.psr_alloc.u.mba_info.cos_max = + data[PSR_INFO_IDX_COS_MAX]; + sysctl->u.psr_alloc.u.mba_info.thrtl_max = + data[PSR_INFO_IDX_MBA_THRTL_MAX]; + sysctl->u.psr_alloc.u.mba_info.flags = + data[PSR_INFO_IDX_MBA_FLAG]; + + if ( __copy_field_to_guest(u_sysctl, sysctl, u.psr_alloc) ) + ret = -EFAULT; + break; + } + default: ret = -EOPNOTSUPP; break; diff --git a/xen/include/asm-x86/psr.h b/xen/include/asm-x86/psr.h index 9d14264..084ae97 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 4759b10..0cfe02d 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_ALLOC_get_l3_info 0 #define XEN_SYSCTL_PSR_ALLOC_get_l2_info 1 +#define XEN_SYSCTL_PSR_ALLOC_get_mba_info 2 struct xen_sysctl_psr_alloc { uint32_t cmd; /* IN: XEN_SYSCTL_PSR_CAT_* */ uint32_t target; /* IN */ @@ -755,6 +756,13 @@ struct xen_sysctl_psr_alloc { #define XEN_SYSCTL_PSR_ALLOC_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_ALLOC_MBA_LINEAR (1u << 0) + uint32_t flags; /* OUT: MBA flags */ + } mba_info; } u; }; typedef struct xen_sysctl_psr_alloc xen_sysctl_psr_alloc_t;