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

Re: [PATCH v2] x86/amd: do not expose HWCR.TscFreqSel to guests


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 14 Sep 2023 15:39:49 +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=gTdcss+sCU2l/qJ8aznC7WhZQ7oNyMt7z3sJdla2ll0=; b=AML36a2nvsbhmcOQ/lwVQ5hREfG8/Y6Ruy8MSiksd6vTDa6MoaG97dVgapimfl+vZGmh42OdBeri2M36CATPretktAaIe2VsDsSXiU8vJoGzmJrMpZ3JA0cYiAZCAnitVuqKkR1AFLPKxnyaoRDp7RR94tpnOQnxSu2ujKc2acXPX5y7o9OkAaTqv76ixxjfb2ZFKiLU42Rqum41Nkkkjej0jl5Bg8SWj2YNM9WoaPIbakkwadCX/iTf+RQ4xGyJqiJrdVGbCkBjN7R4ndlWrN75/563AWVBPpGt7Me79fQicu9xhLd86S/a3ZwBbIJN6jEPCmoNlTaSWUCufaCZuA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IcwKgIoP7VuVu8lCLIHKDuoJ74zBSudXM58UUIpSZAqZTR4QesWFuK2flX3PsJovfKo+9I/Qp8ca+qDXKIdA38te+IgXaJc/tU1go4Ccd2YZX94G9bpHi+CHvrnzZLDnzfE/EKxY7z2gQtat0TDDBnmYFtto6keMWXrrk8jT4CkKq7EnR1+tiN+nUhitmoQT2Wyjwy8UXxxaQXDUjN0LnbP08H6wqcV/lNZX3096vWlaCpqHCk1f3s+VrwfEJncMRmlRauTMCitJBIjSTzryY6gkguLzhwuhSZC4d1uUdoYROEwrG0I/YgLbhuGLnT9csunf94a3mvWP1ib0yg/d0w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Solène Rapenne <solene@xxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 14 Sep 2023 13:40:22 +0000
  • Ironport-data: A9a23:8cJ4cqok1A+qvcTTlrZONDdpDtZeBmIlZBIvgKrLsJaIsI4StFCzt garIBmAO/rYNmH1KdEga9u+oUIEvMLUyYBkGwI6/C0zQn4V85uZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbOCYmYpA1Y8FE/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GlwUmAWP6gR5wePziVNV/rzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXADs0MTqTitm5/JXlbvNvmO1kdfPlZZxK7xmMzRmBZRonabbqZvyQoPV+jHI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jeWraYWOEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTAdhLROzoqKY76LGV7mpMKEUEXmW1nf6410GGVMtwC 11T3BN7+MDe82TuFLERRSaQonSJoxodUNp4CPAh5UeGza+8yxmdLngJSHhGctNOnNQxQTEs2 3eOh97vDydj9rqPRhq15rqS6D+/JyURBWsDfjMfCxsI5cH5p4M+hQ6JScxseJNZlfXwEDD0h jqM/C43guxJidZRjvrgu1fanziru57FCBYv4RnaVX6k6QU/Y5O5Y4uv6h7Q6vMowJulc2Rtd UMsw6C2hN3ix7nXzERhnM1l8GmV2su4
  • Ironport-hdrordr: A9a23:owzrRKGM5fWaEHqDpLqE18eALOsnbusQ8zAXPo5KOGVom62j5r iTdZEgvyMc5wxhPU3I9erwWpVoBEmslqKdgrNxAV7BZniDhILAFugLhrcKgQeBJ8SUzJ876U 4PSdkZNDQyNzRHZATBjTVQ3+xO/DBPys6Vuds=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Sep 14, 2023 at 03:16:40PM +0200, Jan Beulich wrote:
> On 14.09.2023 14:57, Roger Pau Monné wrote:
> > On Thu, Sep 14, 2023 at 02:49:45PM +0200, Jan Beulich wrote:
> >> On 14.09.2023 14:37, Roger Pau Monné wrote:
> >>> On Thu, Sep 14, 2023 at 07:52:33AM +0200, Jan Beulich wrote:
> >>>> On 13.09.2023 16:52, Roger Pau Monne wrote:
> >>>>> OpenBSD 7.3 will unconditionally access HWCR if the TSC is reported as
> >>>>> Invariant, and it will then attempt to also unconditionally access 
> >>>>> PSTATE0 if
> >>>>> HWCR.TscFreqSel is set (currently the case on Xen).
> >>>>>
> >>>>> The relation between HWCR.TscFreqSel and PSTATE0 is not clearly written 
> >>>>> down in
> >>>>> the PPR, but it's natural for OSes to attempt to fetch the P0 frequency 
> >>>>> if the
> >>>>> TSC increments at the P0 frequency.
> >>>>>
> >>>>> Exposing PSTATEn (PSTATE0 at least) with all zeroes is not a suitable 
> >>>>> solution
> >>>>> because the PstateEn bit is read-write, and OSes could legitimately 
> >>>>> attempt to
> >>>>> set PstateEn=1 which Xen couldn't handle.
> >>>>>
> >>>>> In order to fix expose an empty HWCR, which is an architectural MSR and 
> >>>>> so must
> >>>>> be accessible.
> >>>>>
> >>>>> Note it was not safe to expose the TscFreqSel bit because it is not
> >>>>> architectural, and could change meaning between models.
> >>>>
> >>>> This imo wants (or even needs) extending to address the aspect of then
> >>>> exposing, on newer families, a r/o bit with the wrong value.
> >>>
> >>> We could always be exposing bits with the wrong values on newer
> >>> (unreleased?) families, I'm not sure why it needs explicit mentioning
> >>> here.
> >>
> >> Hmm, yes, that's one way to look at things. Yet exposing plain zero is
> >> pretty clearly not within spec here,
> > 
> > As I understand it, the fact that HWCR.TscFreqSel is read-only doesn't
> > exclude the possibility of it changing using other means (iow: we
> > should consider that a write to a different register could have the
> > side effect of toggling the bit).
> > 
> > The PPR I'm reading doesn't mention that the bit must be 1, just that
> > it's 1 on reset and read-only.
> 
> Sure; the PPR being incomplete doesn't help here. My interpretation, based
> on the bit having been r/w in earlier families, is that AMD wanted to retain
> its meaning without allowing it to be configurable anymore. Possibly a sign
> of it remaining so going forward.

What about:

"Note it was not safe to expose the TscFreqSel bit because it is not
architectural, and could change meaning between models.  Since HWCR
contains both architectural and non-architectural bits, going forward
care must be taken to assert the exposed value is correct on newer
CPU families."

Thanks, Roger.



 


Rackspace

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