[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] x86/cpuid: set MCDT_NO for non-affected models


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Fri, 13 May 2022 12:35:00 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xnAVvmktKCaV9DrPCyu46JyVh4QfkUF3mikDDEyic9U=; b=l16zDjWeG9Cm0gMVAtrHUInUcOKnlo9axOI68UKB6yzmkPUJbvWJyBPYpBmfPNpoDZCwlPfjs7XyazGhJnQjCK3gtHUi1SzKkQ+gxpBeaz3I+EwXwYUeTY1WHuSzu4WrWnLrWEyHuZdyRzH51IcGomFVLeaH90iuvVhzS9qZmZgp6hYCUFURUluZkOuu6AtJ6PWZDYA1ho01ywTXaBZFjnU2qaL6GwUZ2V347WWREHH9Mlb/ZKQOAjVot7o0C1ClFsDktWpKlwyadWPDr7buh8hllGsg15lXK9usUTZLU88SI8o0hyZ+/YcGnzf270kqtRY7ED8tfU1l/Zq6E4sx3w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ctqs3a4ifXq1KPAcbzNjOkFU7dx7UEAJGAN5MLhX/TwFFhGljgYFRqoxBZod1Y38vv1SMtHijxLBogHzVQGGMMicPKF74x+Ys0qyiu3r1/AVneG5PvTnZgKJv3w3Dh8SM9jo8XX1SEgXjrrbv21trTuLRy1D52iJHcINZkDtS2BMpQDXSFwTDCuoX3cf1q9ZNIIMVYmtsID5gxJVz+o0DQuEEKeABxBNen2lAP/SxxnQ6dTv1p8ESyuB3GeRDh/Cr2WsG0IWsLlJlhdRmqjEqeSorLGA6qOgcUlcwABpV0wRxJhZeMFXYCytZKbZbfgKF2EST6uTtLAiGX2tuE/Chw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 13 May 2022 10:35:52 +0000
  • Ironport-data: A9a23:kMtb1a5s7PuMHHtROlF3EgxRtEzGchMFZxGqfqrLsTDasY5as4F+v jQYXGHXPfaMZTD0eoxwat/g8h4OupfSnIM1TgppqyA9Hi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuVGuG96yE6j8lkf5KkYAL+EnkZqTRMFWFw0HqPp8Zj2tQy2YXgWFvU0 T/Pi5a31GGNimYc3l08s8pvmDs31BglkGpF1rCWTakjUG72zxH5PrpGTU2CByKQrr1vNvy7X 47+IISRpQs1yfuP5uSNyd4XemVSKlLb0JPnZnB+A8BOiTAazsA+PzpS2FPxpi67hh3Q9+2dx umhurSRW1wsNbCLyd8MSjt9SDhbOfFLwL3+dC3XXcy7lyUqclPK6tA3VgQaGNNd/ex6R2ZT6 fYfNTYBKAiZgP67y666Te8qgdk/KM7sP8UUvXQIITPxVK56B8ycBfibo4YGjF/chegXdRraT 9AeZjd1KgzJfjVEO0sNCYJ4l+Ct7pX6W2IB8gnI/PBvi4TV5CV0j7LcG8LJQf6PfYZVjEuz/ 2D+rmusV3n2M/Tak1Jp6EmEluLJ2C/2Ro8WPLm57eJxxk2ewHQJDx8bXkf9puO24ma8Ud9CL 00f+gI1sLM/skesS7HVQBmQsHOC+BkGVLJt//YS7QiMzu/Y5lifD21dFDpZMoV45IkxWCAg0 UKPk5XxHztzvbaJSHWbsLCJsTe1PitTJmgHDcMZcTY4DxDYiNlbpnryohxLScZZUvWd9enM/ g23
  • Ironport-hdrordr: A9a23:xxzw7qvzHZ/3HnGxNaIBl+RY7skC5IMji2hC6mlwRA09TyXGra 2TdaUgvyMc1gx7ZJhBo7+90We7MBHhHPlOkPMs1NaZLXLbUQ6TQL2KgrGSpwEIdxefygcZ79 YYT0EcMqyOMbEFt7ec3ODQKb9Jrri6GeKT9J/jJh9WPH1XgspbnmJE42igYy5LrF4sP+tFKH PQ3LsPmxOQPVAsKuirDHgMWObO4/XNiZLdeBYDQzoq8hOHgz+E4KPzV0Hw5GZUbxp/hZMZtU TVmQ3w4auu99m91x/nzmfWq7BbgsHoxNdvDNGFzuIVNjLvoAC1Y5kJYczLgBkF5MWUrHo6mt jFpBkte+x19nPqZ2mw5SDg3gHxuQxen0PK+Bu9uz/OsMb5TDU1B45qnoRCaCbU7EImoZVVzL 9L93jxjesZMTrw2ADGo/TYXRBjkUS55VA4l/QIsnBZWYwCLJdMsI0k+l9PGptoJlO31GkeKp guMCjg3ocXTbvDBEqp/VWHgebcE0jbJy32DHTr4aeuonprdHMQ9Tps+CVQpAZEyHsHceg02w 31CNUXqFhwdL5nUUsEPpZmfSKWMB27ffueChPlHbzYfJt3SE7lmtrQ3Igfwt2MVdgh8KYS8a 6xIm+w81RCMX7TNQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Some CPU models don't exhibit MCDT behavior, but also don't expose
MCDT_NO.  Set the MCDT_NO bit for CPUs known to not exhibit the
behavior, so guests can get this information, as using
family/model/stepping detection when running virtualized is not to be
relied.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/cpu/intel.c | 70 ++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/cpuid.c     | 10 ++++++
 2 files changed, 80 insertions(+)

diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index dc6a0c7807..d821f460ae 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -518,6 +518,73 @@ static void intel_log_freq(const struct cpuinfo_x86 *c)
     printk("%u MHz\n", (factor * max_ratio + 50) / 100);
 }
 
+void update_mcdt_no(struct cpuinfo_x86 *c)
+{
+#define FAM6_MODEL(m, s, c) { 6, m, s, c }
+    /*
+     * List of models that do not exhibit MCDT behavior, but might not
+     * advertise MCDT_NO on CPUID.
+     */
+    static const struct {
+        uint8_t family;
+        uint8_t model;
+        uint8_t stepping;
+        bool check_stepping;
+    } mcdt_no[] = {
+        /* Haswell Server EP, EP4S. */
+        FAM6_MODEL(0x3f, 2, true),
+        /* Elkhart Lake. */
+        FAM6_MODEL(0x3f, 4, true),
+        /* Cherryview. */
+        FAM6_MODEL(0x4c, 0, false),
+        /* Broadwell Server E, EP, EP4S, EX. */
+        FAM6_MODEL(0x4f, 0, false),
+        /* Broadwell DE V2, V3. */
+        FAM6_MODEL(0x56, 3, true),
+        /* Broadwell DE Y0. */
+        FAM6_MODEL(0x56, 4, true),
+        /* Broadwell DE A1, Hewitt Lake. */
+        FAM6_MODEL(0x56, 5, true),
+        /* Anniedale. */
+        FAM6_MODEL(0x5a, 0, false),
+        /* Apollo Lake. */
+        FAM6_MODEL(0x5c, 9, true),
+        FAM6_MODEL(0x5c, 0xa, true),
+        /* Denverton. */
+        FAM6_MODEL(0x5f, 1, true),
+        /* XMM7272. */
+        FAM6_MODEL(0x65, 0, false),
+        /* Cougar Mountain. */
+        FAM6_MODEL(0x6e, 0, false),
+        /* Butter. */
+        FAM6_MODEL(0x75, 0, false),
+        /* Gemini Lake. */
+        FAM6_MODEL(0x7a, 1, true),
+        FAM6_MODEL(0x7a, 8, true),
+        /* Snowridge. */
+        FAM6_MODEL(0x86, 4, true),
+        FAM6_MODEL(0x86, 5, true),
+        FAM6_MODEL(0x86, 7, true),
+        /* Lakefield B-step. */
+        FAM6_MODEL(0x8a, 1, true),
+        /* Elkhart Lake. */
+        FAM6_MODEL(0x96, 1, true),
+        /* Jasper Lake. */
+        FAM6_MODEL(0x9c, 0, true),
+        { }
+    };
+#undef FAM6_MODEL
+    const typeof(mcdt_no[0]) *m;
+
+    for (m = mcdt_no; m->family | m->model | m->stepping; m++)
+        if ( c->x86 == m->family && c->x86_model == m->model &&
+             (!m->check_stepping || c->x86_mask == m->stepping) )
+        {
+            __set_bit(X86_FEATURE_MCDT_NO, c->x86_capability);
+            break;
+        }
+}
+
 static void cf_check init_intel(struct cpuinfo_x86 *c)
 {
        /* Detect the extended topology information if available */
@@ -556,6 +623,9 @@ static void cf_check init_intel(struct cpuinfo_x86 *c)
        if ((opt_cpu_info && !(c->apicid & (c->x86_num_siblings - 1))) ||
            c == &boot_cpu_data )
                intel_log_freq(c);
+
+       if (!cpu_has(c, X86_FEATURE_MCDT_NO))
+               update_mcdt_no(c);
 }
 
 const struct cpu_dev intel_cpu_dev = {
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 66be1a8015..ca2ed44149 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -360,6 +360,16 @@ static void __init calculate_host_policy(void)
 
     p->basic.max_leaf =
         min_t(uint32_t, p->basic.max_leaf,   ARRAY_SIZE(p->basic.raw) - 1);
+
+    /*
+     * For Intel hardware MCDT_NO might be set by Xen for models that don't
+     * exhibit MCDT behavior but also don't have the MCDT_NO bit set in
+     * CPUID.  Extend feat.max_subleaf beyond what hardware supports to include
+     * the feature leaf containing this information.
+     */
+    if ( boot_cpu_has(X86_FEATURE_MCDT_NO) )
+        p->feat.max_subleaf = max(p->feat.max_subleaf, 2u);
+
     p->feat.max_subleaf =
         min_t(uint32_t, p->feat.max_subleaf, ARRAY_SIZE(p->feat.raw) - 1);
 
-- 
2.36.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.