From patchwork Wed Jun 14 01:12:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9785133 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 E30D660384 for ; Wed, 14 Jun 2017 01:27:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D55C126E75 for ; Wed, 14 Jun 2017 01:27:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C96C628520; Wed, 14 Jun 2017 01:27:59 +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 4012026E75 for ; Wed, 14 Jun 2017 01:27:59 +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 1dKx4a-00084b-9d; Wed, 14 Jun 2017 01:26:16 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKx4Z-00083Z-FZ for xen-devel@lists.xenproject.org; Wed, 14 Jun 2017 01:26:15 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 05/9D-01992-6B090495; Wed, 14 Jun 2017 01:26:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPLMWRWlGSWpSXmKPExsVywNykWHfzBId IgzM3pCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oylG3ayF3QoVNz92M/YwPhYoouRi0NIYBqj xNODu9m7GDk5JAR4JY4sm8HaxcgBZPtJXJyZD1HTwCjR17OAEaSGTUBd4vHXHiYQW0RASeLeq slMIEXMAjuZJNad/s4MkhAWcJRY+OYS2FAWAVWJo9d+gdm8Ap4SN28uZIRYJidx8thkVhCbEy je/foZ2FAhAQ+Jn1emMk1g5F3AyLCKUaM4tagstUjXyFAvqSgzPaMkNzEzR9fQwFQvN7W4ODE 9NScxqVgvOT93EyMwIOoZGBh3MN6d7HeIUZKDSUmUd4mdQ6QQX1J+SmVGYnFGfFFpTmrxIUYZ Dg4lCd43fUA5waLU9NSKtMwcYGjCpCU4eJREeGvbgNK8xQWJucWZ6RCpU4yKUuK8p0D6BEASG aV5cG2weLjEKCslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZj3eD/QFJ7MvBK46a+AFjMBLb5+xQ ZkcUkiQkqqgVF9ovBOpuVq5QwPd9VNOGB/rLSt0cBv/Rp5Fs2IP6aFMZ3nroRlyKlZ3F8l27u ybYH5apkg1oYj0o+iHB3kJc4F5H5atWLW53fKO/6svRAdv7Y8zce/5HBnPtsHh/SYyQVyjAX3 wr+e4pzy94vQPtvJ09tidqWsenJ72m6FdmmFhYeur+Y4FKPEUpyRaKjFXFScCABtXHlRggIAA A== X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1497403511!87398197!20 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56772 invoked from network); 14 Jun 2017 01:26:11 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Jun 2017 01:26:11 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jun 2017 18:26:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,340,1493708400"; d="scan'208";a="99174046" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.64]) by orsmga002.jf.intel.com with ESMTP; 13 Jun 2017 18:26:06 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Wed, 14 Jun 2017 09:12:52 +0800 Message-Id: <1497402776-22348-20-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497402776-22348-1-git-send-email-yi.y.sun@linux.intel.com> References: <1497402776-22348-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 v12 19/23] x86: L2 CAT: implement set value 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 L2 CAT set value related callback function and domctl interface. Signed-off-by: Yi Sun Reviewed-by: Jan Beulich --- v11: - remove 'domctl->u.psr_cat_op.data' check because it has been moved into 'psr_set_val'. (suggested by Jan Beulich) - move 'feat->cos_reg_val' assignment and value comparison in 'write_msr' callback function out as generic codes. (suggested by Jan Beulich) v10: - check input data and remove cast in domctl. (suggested by Jan Beulich) - remove some hooks assignment due to previous patches changes. (suggested by Jan Beulich) - remove cast in 'l2_cat_write_msr'. (suggested by Jan Beulich) - remove 'return in 'l2_cat_write_msr'. (suggested by Jan Beulich) v9: - reuse some CAT common functions for L2 CAT to reduce redundant codes. (suggested by Roger Pau) - remove parameter 'found' from 'cat_compare_val' and modify the return values to let caller know if the id is found or not. These things are done in patch "x86: refactor psr: set value: implement cos finding flow." (suggested by Roger Pau and Dario Faggioli) - remove 'get_cos_num' related codes. (suggested by Jan Beulich) - modify 'l2_cat_write_msr' according to previous patch change. - changes about 'uint64_t' to 'uint32_t'. (suggested by Jan Beulich) v8: - modify 'l2_cat_write_msr' to 'void'. v5: - remove type check in callback function. (suggested by Jan Beulich) - modify return value of callback functions because we do not need them to return number of entries the feature uses. In caller, we call 'get_cos_num' to get the number of entries the feature uses. (suggested by Jan Beulich) - remove 'l2_cat_get_cos_max_from_type'. (suggested by Jan Beulich) - rename 'l2_cat_exceeds_cos_max' to 'l2_cat_fits_cos_max'. (suggested by Jan Beulich) v4: - create this patch because of codes architecture change. (suggested by Jan Beulich) --- --- xen/arch/x86/domctl.c | 6 ++++++ xen/arch/x86/psr.c | 6 ++++++ xen/include/public/domctl.h | 1 + 3 files changed, 13 insertions(+) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 2970118..b5a892a 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1428,6 +1428,12 @@ long arch_do_domctl( PSR_CBM_TYPE_L3_DATA); break; + case XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM: + ret = psr_set_val(d, domctl->u.psr_cat_op.target, + domctl->u.psr_cat_op.data, + PSR_CBM_TYPE_L2); + break; + case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM: ret = psr_get_val(d, domctl->u.psr_cat_op.target, &val32, PSR_CBM_TYPE_L3); diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 22de787..ac7697b 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -387,10 +387,16 @@ static const struct feat_props l3_cdp_props = { }; /* L2 CAT props */ +static void l2_cat_write_msr(unsigned int cos, uint32_t val, enum cbm_type type) +{ + wrmsrl(MSR_IA32_PSR_L2_MASK(cos), val); +} + static const struct feat_props l2_cat_props = { .cos_num = 1, .type[0] = PSR_CBM_TYPE_L2, .get_feat_info = cat_get_feat_info, + .write_msr = l2_cat_write_msr, }; static void __init parse_psr_bool(char *s, char *value, char *feature, diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 16c08c0..a06c6c5 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1132,6 +1132,7 @@ struct xen_domctl_psr_cat_op { #define XEN_DOMCTL_PSR_CAT_OP_SET_L3_DATA 3 #define XEN_DOMCTL_PSR_CAT_OP_GET_L3_CODE 4 #define XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA 5 +#define XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM 6 #define XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM 7 uint32_t cmd; /* IN: XEN_DOMCTL_PSR_CAT_OP_* */ uint32_t target; /* IN */