From patchwork Thu Mar 16 11:08:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9627877 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 D3BF06048C for ; Thu, 16 Mar 2017 11:16:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC0E428573 for ; Thu, 16 Mar 2017 11:16:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0E7E285B5; Thu, 16 Mar 2017 11:16:13 +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 45F9B28573 for ; Thu, 16 Mar 2017 11:16:13 +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 1coTMc-00051v-AX; Thu, 16 Mar 2017 11:14:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coTMb-0004zy-KG for xen-devel@lists.xenproject.org; Thu, 16 Mar 2017 11:14:37 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id E1/92-19998-C937AC85; Thu, 16 Mar 2017 11:14:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsVywNwkVndO8ak IgzcrZSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyvr7qYCmbLVuxru8nUwHhIrIuRi4NF4BaT xN/bM5lBHCGBaYwS15ZPYuxi5OSQEOCVOLJsBiuE7S9xqvEVE0RRA6PEkq/HmEASbALqEo+/9 oDZIgJKEvdWTQYrYhbYySSx7vR3ZpCEsICDxOYpa1i6GDmA9qlK/HkUAxLmFfCQuPF5GzvEAj mJk8cmgy3jBIp/bG8Hs4UE3CXebfjLPoGRbwEjwypGjeLUorLUIl1DE72kosz0jJLcxMwcXUM DY73c1OLixPTUnMSkYr3k/NxNjMBQYQCCHYwrtnseYpTkYFIS5S3/cSJCiC8pP6UyI7E4I76o NCe1+BCjDAeHkgTvEaWTEUKCRanpqRVpmTnAoIVJS3DwKInw5oKkeYsLEnOLM9MhUqcYFaXEe S+AJARAEhmleXBtsEi5xCgrJczLCHSIEE9BalFuZgmq/CtGcQ5GJWHezSBTeDLzSuCmvwJazA S0+O2HEyCLSxIRUlINjBvUp9gvE+pvOT3z/ZPFSvnCBWuexustyBYQcD/BIWqn9nf3LjWfCTd WFy11ccqMt/QK1fv3ePpOZU6x5B2CplN1kkxCYw/fdDp28kpySXT3nyw2Rr+ynLrr958te7Wk V1i4tGdX6U8up1WR1XHHL7Us9mtZy7L/2zvu+0abDPZyrUkJdAvkV2Ipzkg01GIuKk4EALBGx 7OPAgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1489662818!78881615!20 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 14584 invoked from network); 16 Mar 2017 11:14:36 -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:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489662876; x=1521198876; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=1Uq5SdERg9oeNQeQniaOKwUsr+TaBJGm0s78Qw/GsqE=; b=fGa415t6j2naM2dDk5Sbdp60gBuy4tfD6kZHG5v1arS2WmH+EnPbaCFY EMdpYFyWjmkzJ7fROVMVSCzQqIDssg==; 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:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,172,1486454400"; d="scan'208";a="944976788" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.63]) by orsmga003.jf.intel.com with ESMTP; 16 Mar 2017 04:14:32 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Thu, 16 Mar 2017 19:08:11 +0800 Message-Id: <1489662495-5375-22-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 21/25] 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 functions and domctl interface. Signed-off-by: Yi Sun --- 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 | 17 +++++++++++++++++ xen/include/public/domctl.h | 1 + 3 files changed, 24 insertions(+) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 7f55cfd..e732b99 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -1454,6 +1454,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, + (uint32_t)domctl->u.psr_cat_op.data, + PSR_CBM_TYPE_L2); + break; + case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM: domctl->u.psr_cat_op.data = 0; ret = psr_get_val(d, domctl->u.psr_cat_op.target, diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index 4cbcbe0..4059bbb 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -636,10 +636,27 @@ struct feat_ops l3_cdp_ops = { }; /* L2 CAT ops */ +static void l2_cat_write_msr(unsigned int cos, uint32_t val, + enum cbm_type type, struct feat_node *feat) +{ + if ( feat->cos_reg_val[cos] != val ) + { + feat->cos_reg_val[cos] = val; + wrmsrl(MSR_IA32_PSR_L2_MASK(cos), (uint64_t)val); + } + + return; +} + struct feat_ops l2_cat_ops = { .get_cos_max = cat_get_cos_max, .get_feat_info = cat_get_feat_info, .get_val = cat_get_val, + .get_old_val = cat_get_old_val, + .set_new_val = cat_set_new_val, + .compare_val = cat_compare_val, + .fits_cos_max = cat_fits_cos_max, + .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 8c183ba..523a2cd 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1138,6 +1138,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 */