From patchwork Sun Oct 8 04:22:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 9991725 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 7756260364 for ; Sun, 8 Oct 2017 04:45:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61579286E3 for ; Sun, 8 Oct 2017 04:45:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5379E286F1; Sun, 8 Oct 2017 04:45:11 +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 87460286E3 for ; Sun, 8 Oct 2017 04:45:10 +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 1e13Py-0003mf-8C; Sun, 08 Oct 2017 04:42:22 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e13Pw-0003mZ-SY for xen-devel@lists.xenproject.org; Sun, 08 Oct 2017 04:42:20 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 60/8C-02216-CACA9D95; Sun, 08 Oct 2017 04:42:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAIsWRWlGSWpSXmKPExsXS1tbhqLt6zc1 Ig427+C2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxnP+6zF1xQrLi26wxrA2ObRBcjJ4eQwDRG iTurBEFsCQFeiSPLZrBC2AESBzu2s3UxcgHVNDBKnHzxkR0kwSagLvH4aw8TiC0ioCRxb9VkJ pAiZoHvjBKXHtwE6xYWcJc4ee4+C4jNIqAq8XzJGzCbFyj+b/UdZogNchInj00Gq+cU8JCYNG M6I8RF7hJTP9yEqheUODnzCZDNAbRAXWL9PCGQMLOAvETz1tnMExgFZiGpmoVQNQtJ1QJG5lW M6sWpRWWpRbqGeklFmekZJbmJmTm6hgamermpxcWJ6ak5iUnFesn5uZsYgaFZz8DAuIOxqdf5 EKMkB5OSKG/Q6puRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4M0BygkWp6akVaZk5wCiBSUtw8 CiJ8D5ZCZTmLS5IzC3OTIdInWLU5ei4efcPkxBLXn5eqpQ4bwXIDAGQoozSPLgRsIi9xCgrJc zLyMDAIMRTkFqUm1mCKv+KUZyDUUmYlxVkCk9mXgncpldARzABHcFYfAPkiJJEhJRUA+PMGv2 pF/5M+1tiNjVbwG9ndvGaMy4TBQo5fPtOvK0TOqmt/PpM/Dmrzp/9jh2HD7+XP2ifnX03ellt wg/7fWncHD5stbGhHa8buMTinEz08lwyBW5mTU3c+m2d2Sz7hvYvwgvuPGkLtmvbHP6c+cTtb d97CqqOxnn9OG3RsM+0WuPV1S5mWSWW4oxEQy3mouJEABC9fQLTAgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1507437737!90080119!1 X-Originating-IP: [134.134.136.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10681 invoked from network); 8 Oct 2017 04:42:18 -0000 Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Oct 2017 04:42:18 -0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Oct 2017 21:42:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,492,1500966000"; d="scan'208"; a="1179794627" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.75]) by orsmga001.jf.intel.com with ESMTP; 07 Oct 2017 21:42:13 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Sun, 8 Oct 2017 12:22:00 +0800 Message-Id: <1507436520-5629-1-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507281180-5101-1-git-send-email-yi.y.sun@linux.intel.com> References: <1507281180-5101-1-git-send-email-yi.y.sun@linux.intel.com> MIME-Version: 1.0 Cc: Yi Sun , Andrew Cooper , Julien Grall , Jan Beulich , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [Xen-devel] [PATCH v2] x86: psr: support co-exist features' values setting 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 It changes the memebers in 'cos_write_info' to transfer the feature array, feature properties array and value array. Then, we can write all features values on the cos id into MSRs. Because multiple features may co-exist, we need handle all features to write values of them into a COS register with new COS ID. E.g: 1. L3 CAT and L2 CAT co-exist. 2. Dom1 and Dom2 share the same COS ID (2). The L3 CAT CBM of Dom1 is 0x1ff, the L2 CAT CBM of Dom1 is 0x1f. 3. User wants to change L2 CBM of Dom1 to be 0xf. Because COS ID 2 is used by Dom2 too, we have to pick a new COS ID 3. The values of Dom1 on COS ID 3 are all default values as below: --------- | COS 3 | --------- L3 CAT | 0x7ff | --------- L2 CAT | 0xff | --------- 4. After setting, the L3 CAT CBM value of Dom1 should be kept and the new L2 CAT CBM is set. So, the values on COS ID 3 should be below. --------- | COS 3 | --------- L3 CAT | 0x1ff | --------- L2 CAT | 0xf | --------- Signed-off-by: Yi Sun --- CC: Jan Beulich CC: Andrew Cooper CC: Wei Liu CC: Roger Pau Monné CC: Julien Grall --- xen/arch/x86/psr.c | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index daa2aeb..dbf7a4c 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -1111,25 +1111,43 @@ static unsigned int get_socket_cpu(unsigned int socket) struct cos_write_info { unsigned int cos; - struct feat_node *feature; + struct feat_node **features; const uint32_t *val; - const struct feat_props *props; + unsigned int array_len; }; static void do_write_psr_msrs(void *data) { const struct cos_write_info *info = data; - struct feat_node *feat = info->feature; - const struct feat_props *props = info->props; - unsigned int i, cos = info->cos, cos_num = props->cos_num; + unsigned int i, index = 0, cos = info->cos; - for ( i = 0; i < cos_num; i++ ) + /* + * Iterate all featuers to write different value (not same as MSR) for + * each feature. + */ + for ( i = 0; i < ARRAY_SIZE(feat_props); i++ ) { - if ( feat->cos_reg_val[cos * cos_num + i] != info->val[i] ) + struct feat_node *feat = info->features[i]; + const struct feat_props *props = feat_props[i]; + unsigned int cos_num, j; + + if ( !feat || !props ) + continue; + + cos_num = props->cos_num; + if ( info->array_len < index + cos_num ) + return; + + for ( j = 0; j < cos_num; j++ ) { - feat->cos_reg_val[cos * cos_num + i] = info->val[i]; - props->write_msr(cos, info->val[i], props->type[i]); + if ( feat->cos_reg_val[cos * cos_num + j] != info->val[index + j] ) + { + feat->cos_reg_val[cos * cos_num + j] = info->val[index + j]; + props->write_msr(cos, info->val[index + j], props->type[j]); + } } + + index += cos_num; } } @@ -1137,30 +1155,18 @@ static int write_psr_msrs(unsigned int socket, unsigned int cos, const uint32_t val[], unsigned int array_len, enum psr_feat_type feat_type) { - int ret; struct psr_socket_info *info = get_socket_info(socket); struct cos_write_info data = { .cos = cos, - .feature = info->features[feat_type], - .props = feat_props[feat_type], + .features = info->features, + .val = val, + .array_len = array_len, }; if ( cos > info->features[feat_type]->cos_max ) return -EINVAL; - /* Skip to the feature's value head. */ - ret = skip_prior_features(&array_len, feat_type); - if ( ret < 0 ) - return ret; - - val += ret; - - if ( array_len < feat_props[feat_type]->cos_num ) - return -ENOSPC; - - data.val = val; - if ( socket == cpu_to_socket(smp_processor_id()) ) do_write_psr_msrs(&data); else