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

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


  • To: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 13 May 2022 14:37:31 +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=iCfx29mOBuSVuS8/K9JiopkQUCRSD+KNA3QEAlApLYY=; b=EPe0pTLSFMlUbFltH1tTuPhZg24jnA/e9EaUG6EHyDmeJERO+uMHsOliHLwD2TWSy/DkN3r1FcyQuMvWF9hhIH1jOc/4SuUfdYGGn3LfMPZtPU8dU24wGkeh3+TeiIsU1PjF/5p5d+y5cb5Vj9POSuNQkYgf6hkizMjGb1pKZozQR/jWVgkW5iFvJyfo6wFcAXXkZTDztKhEb7b3XzSEvBNaKjpwG/9O0ZNtz7YGUOg2Ni3P93+XE5g8Cy6MZ0WXL6xbCGI4l+1SOpfhYT2VdZNCGPmvodRqsOcqXo/Ony5uIM4tUXfhTKZ+zbHbmKI3UkBv1ARRrUr8CXjcbrwq+A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ekAvpseGNtStvbcOa9xT+aUrziPCUc4XQ38BL2CoxA3ivalXSygCGr85gBpoV93waLLnFxhSaADjTLtl4ouPgF9w+SX9L9s30N7a5VTJeusjnho6AXFd2Pmi7hDo8wLDjzGLV97X7piOxaekbd+u1DKESRiLJfWkRrzguacvpjWf7PqN0DIDy8XXMr/BIK3n4gx0qbndQyYKzYvsxImFYQBEg2bNE9+uSxXVKc5tV0yKCmT9wXh3hFd8Z6y1tuEvLxP1Pp75viqQD55HuxOYvvp/Wz44EByQmayZnCl7pm5huxEh7Rfa0/zvbhgL5aJAereSGJYgpiLG6BMIQ/MNFg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 13 May 2022 12:37:45 +0000
  • Ironport-data: A9a23:cwrTIa6O2uefei954Hk+tAxRtEzGchMFZxGqfqrLsTDasY5as4F+v moXX2jQOK3ea2ujLtxwbIux9ksC78eHytFqHFZurH02Hi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuVGuG96yE6j8lkf5KkYAL+EnkZqTRMFWFw0HqPp8Zj2tQy2YXgWFvU0 T/Pi5a31GGNimYc3l08s8pvmDs31BglkGpF1rCWTakjUG72zxH5PrpGTU2CByKQrr1vNvy7X 47+IISRpQs1yfuP5uSNyd4XemVSKlLb0JPnZnB+A8BOiTAazsA+PzpS2FPxpi67hh3Q9+2dx umhurSfciIvLqHL39hCEAVWCCpmJIQBoZ7udC3XXcy7lyUqclPK6tA3VAQaGNNd/ex6R2ZT6 fYfNTYBKAiZgP67y666Te8qgdk/KM7sP8UUvXQIITPxVK56B8ycBfiao4YAgF/chegXdRraT 9AeZjd1KgzJfjVEO0sNCYJ4l+Ct7pX6W2IB8gzN+PVpi4TV5AhV6fv0GujyQcCTdc4ItGiWp FDLxmusV3n2M/Tak1Jp6EmEluLJ2C/2Ro8WPLm57eJxxk2ewHQJDx8bXkf9puO24ma8Ud9CL 00f+gI1sLM/skesS7HVQBmQsHOC+BkGVLJt//YS7QiMzu/Y5lifD21dFjpZMoV+6IkxWCAg0 UKPk5XxHztzvbaJSHWbsLCJsTe1PitTJmgHDcMZcTY4DxDYiNlbpnryohxLScZZUvWd9enM/ g23
  • Ironport-hdrordr: A9a23:DAfpiqhLxLn/jbc2jrlvzC2WH3BQX5R23DAbv31ZSRFFG/FwyP rBoB1L73DJYWgqNE3IwerwRJVpQRvnhPpICPoqTMiftWjdySSVxeRZjLcKrAeQYxEWmtQtt5 uINpIOdeEYbmIKw/oSgjPIaOrIqePvmMvD6IeurEuFDzsaEZ2IhD0JbTpzZ3cGPTWucqBJcq Z0iPA3wgaISDAyVICWF3MFV+/Mq5ngj5T9eyMLABYh9U2nkS6owKSSKWnY4j4uFxd0hZsy+2 nMlAL0oo+5teug9xPa32jPq7xLhdrazMdZDsDksLlUFtyssHfqWG1SYczGgNkHmpDq1L/sqq iKn/4UBbUw15oWRBDynfKi4Xi47N9k0Q6d9bbRuwqTnSW+fkNjNyKE7rgpKCcwLCEbzYpBOe twrhKknosSAhXakCvn4d/UExlsi0qvuHIn1fUelnpFTOIlGfRsRKEkjQpo+a07bWrHAUEcYZ 1TJdCZ4OwTfUKRbnjfsGUqyNuwXm4rFhPDRkQZoMSa3zVfgXg8liIjtYEit2ZF8Ih4R4hP5u zCPKgtnLZSTtUOZaY4AOsaW8O4BmHEXBqJaAupUBjaPbBCP2iIp4/84b0z6u3vcJsUzIEqkJ CEVF9Dr2Y9d0/nFMXL1pxW9RLGRnm7QF3Wu4tjzok8vqe5SKvgMCWFRlxrm8y8o+8HCsmeQP q3MII+OY6UEYIvI/c/4+TTYeghFZBFarxnhj8SYSP6nv72
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, May 13, 2022 at 11:18:47AM +0000, Andrew Cooper wrote:
> On 13/05/2022 11:35, Roger Pau Monne wrote:
> > 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;
> > +        }
> > +}
> 
> Please could we see about using x86_match_cpu() rather than basically
> opencoding it?  Linux's bug.c has some fairly comprehensive examples of
> how to do tables like this with it.

Yes, I know about x86_match_cpu().  I've used this open-coded form
because of the conditional extra checking of the stepping which is not
handled by x86_match_cpu().  I didn't feel like extending struct
x86_cpu_id and x86_match_cpu() just for this use-case, but I could do
it.

> Also, can we use our shiny new intel-family.h names?
> 
> The stepping checks guidance seems suspect.  Lemme ping some people
> about that.  I suspect that means "we checked the production CPUs but
> didn't look at the pre-prod hardware" which in practice means we don't
> care about steppings listed.

OK, that would help quite a lot, as then I could just use plain
x86_match_cpu().

Thanks, Roger.



 


Rackspace

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