From patchwork Fri Oct 6 09:13: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: 9988793 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 8BC7160247 for ; Fri, 6 Oct 2017 09:35:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7213628372 for ; Fri, 6 Oct 2017 09:35:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66FAF28D9F; Fri, 6 Oct 2017 09:35:46 +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 D5BC928372 for ; Fri, 6 Oct 2017 09:35:45 +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 1e0P0J-0005lG-1f; Fri, 06 Oct 2017 09:33:11 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e0P0H-0005lA-9c for xen-devel@lists.xenproject.org; Fri, 06 Oct 2017 09:33:09 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 82/E2-03428-4DD47D95; Fri, 06 Oct 2017 09:33:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRWlGSWpSXmKPExsXS1tYhonvZ93q kwbqdZhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bH1ytsBZOVKqZ0/WduYDwr0cXIxSEkMJ1R 4uqJDsYuRk4OCQFeiSPLZrBC2P4SrztfskIUNTBKLH+4mR0kwSagLvH4aw8TiC0ioCRxb9VkJ pAiZoHvjBKXHtwE6uDgEBZwl5j72wCkhkVAVeLurhNgC3iBwjvOX2GDWCAncfLYZFaIuKDEyZ lPWEBamYHmr58nBBJmFpCXaN46m3kCI98sJFWzEKpmIalawMi8ilGjOLWoLLVI18hML6koMz2 jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMNgYgGAH45kFgYcYJTmYlER5z3tdjxTiS8pP qcxILM6ILyrNSS0+xCjDwaEkwXvOBygnWJSanlqRlpkDDHuYtAQHj5IIryUw9IV4iwsSc4sz0 yFSpxh1OTpu3v3DJMSSl5+XKiXOawdSJABSlFGaBzcCFoOXGGWlhHkZgY4S4ilILcrNLEGVf8 UozsGoJMzLAjKFJzOvBG7TK6AjmICOmNN0BeSIkkSElFQDY35M04K/W99cWx/1MShwn0DwlXv KvLpiH/LOC1qK+mikRasd+dlySDf3U5Jp98Zsro5n6+9xBwrusgo8OcHx46Sbbwon//YxSf01 ub9+kfotb971Nh1dzp6J96VckvZ5tD70XSsdulZRXvWFSozPDtkVq6uXXLjh91OC6crf2+7y+ 3wnZ+odU2Ipzkg01GIuKk4EAMKKPp28AgAA X-Env-Sender: yi.y.sun@linux.intel.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1507282385!76684836!1 X-Originating-IP: [134.134.136.20] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjAgPT4gMzU1MzU4\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54919 invoked from network); 6 Oct 2017 09:33:07 -0000 Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by server-7.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 6 Oct 2017 09:33:07 -0000 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Oct 2017 02:33:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,482,1500966000"; d="scan'208";a="160132238" Received: from vmmmba-s2600wft.bj.intel.com ([10.240.193.75]) by fmsmga006.fm.intel.com with ESMTP; 06 Oct 2017 02:33:03 -0700 From: Yi Sun To: xen-devel@lists.xenproject.org Date: Fri, 6 Oct 2017 17:13:00 +0800 Message-Id: <1507281180-5101-1-git-send-email-yi.y.sun@linux.intel.com> X-Mailer: git-send-email 1.9.1 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 v1] 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 a 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 | --------- So, we should write all features values into their MSRs. That requires the feature array, feature properties array and value array are input. 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 | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c index daa2aeb..596b0ca 100644 --- a/xen/arch/x86/psr.c +++ b/xen/arch/x86/psr.c @@ -1111,25 +1111,40 @@ 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; + const uint32_t *val_array = info->val; - for ( i = 0; i < cos_num; i++ ) + 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] != val_array[index + j] ) + { + feat->cos_reg_val[cos * cos_num + j] = val_array[index + j]; + props->write_msr(cos, val_array[index + j], props->type[j]); + } } + + index += cos_num; } } @@ -1137,30 +1152,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