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

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


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 13 Sep 2023 11:16:59 +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=T+4dj7WbiFp1ZrHRLEU8/l0JflKZAxi0+5xhEhqH5Dc=; b=YmOJWK0UuUW9veuzAtsBqhzNcUoZRLrHNV2RCrfzE0V3GI1aTMSU0mhX4IeeUXgP2/IxFGQ+mIe9CEreOSB/cG4flWTi4fvkvVhk0KODzZyOHD85mCcsq/IRXNImrvo42xeJKSjK2pHstI3jzbTeB0KLluupKCgseumCQOLihsDrtdDLZEp04PkjwXR9gVUCSOkvyxK51jBXRwmX5EWr7erb+mxxzDhiviq/fr4Hq9p0XYPPOAFNI6mtnbKWXnEBFtqNFU/U9YaT29XCBIQbyARhkJEu2yI45BJjy5zEgMoVGPaCQQkgvF1UxP5INaqmGSW9niJ2OZZvCoQp+KtBaA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lvRQB+nZ0Ly3jPF5F2eS+/CyfYvVeURJCB52MPeHaQ6Mpt6NfVFNrBKttUZJcLj+ecvDpm/lLE1EO8znstQimodPF5+5dotZwJWU1Te0t2IAbkHUl2x/XXIs8AFRx3y1FMjXI0hD/cu4NBpBxeokJIwJWrtm3Mg1tW3v2yV6RvsBrCA5m8BTHlDXdwY5rlbH4lH09dGlcEAztbH1V2Ot1nyDdVbwbVSczqqN4yxc2xOnwBxSgwkh8bf6diRg+/BHCi8nx8GZ8MjfM07j7YpnMyvgjWhve+VhJCfI8+VhCiirdbIS+cztfgO3oXAvp0x34xWQOhJM1PhrTtCoX57wZg==
  • 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>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 13 Sep 2023 09:17:44 +0000
  • Ironport-data: A9a23:e0i+xK98od7nDQmP7VdCDrUDp3+TJUtcMsCJ2f8bNWPcYEJGY0x3z mROX2iFMvmOY2r0Ko9+YYmz/RhS6seAm4BjHVM9pS88E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjVAOK6UKidYnwZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ird7ks11BjOkGlA5AdmNKkQ5Aa2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDkkS5 f4xdy0nTinTpNC1zoCaE8A9jO0seZyD0IM34hmMzBn/JNN+G9XvZv6P4tVVmjAtmspJAPDSI dIDbiZiZwjBZBsJPUoLDJU5n6GjgXyXnz9w8QrJ4/ZopTWNilAtuFTuGIO9ltiiX8Jak1zev mvb12/4HgsbJJqUzj/tHneE37WWxH+kCdpNfFG+3vl1skea934xMkAtWkmBjcG1uHaPB/sKf iT4/QJr98De7neDTNPwQhm5q36spQMHVpxbFOhSwB6J4rrZ5UCeHGdsZi5MbpkqudE7QRQu1 0SVhJX5CDp3qrqXRHmBsLCOoluP1TM9KGYDYWoISFAD6ty7+oUr1EqTEpBkDbK/icDzFXfo2 TeWoSMihrIVy8kWy6G8+lOBiDWpznTUcjMICszsdjrNxmtEiESNOORENXCzAS58Ebuk
  • Ironport-hdrordr: A9a23:hZ7zq6812FfMdU4/Icduk+AcI+orL9Y04lQ7vn2ZKSY5TiX4rb HKoB1/73XJYVkqN03I9ervBEDiewK/yXcW2+ks1N6ZNWGLhILBFupfBODZsl7d8kPFl9K01c 1bAtJD4N+bNykGsS4tijPIb+rJw7O8gd+Vbf+19QYIcenzAZsQlzuQDGygYypLbTgDP7UVPr yG6PFKojKxEE5nFfhSVhE+Lo7+T8SgruOeXSI7
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Sep 13, 2023 at 10:35:17AM +0200, Jan Beulich wrote:
> On 13.09.2023 10:20, Roger Pau Monné wrote:
> > On Wed, Sep 13, 2023 at 08:14:46AM +0200, Jan Beulich wrote:
> >> On 12.09.2023 18:23, Roger Pau Monne wrote:
> >>> OpenBSD will attempt to unconditionally access PSTATE0 if HWCR.TscFreqSel 
> >>> is
> >>> set, and will also attempt to unconditionally access HWCR if the TSC is
> >>> reported as Invariant.
> >>>
> >>> The reasoning for exposing HWCR.TscFreqSel was to avoid Linux from 
> >>> printing a
> >>> (bogus) warning message, but doing so at the cost of OpenBSD not booting 
> >>> is not
> >>> a suitable solution.
> >>
> >> Why is the warning bogus? The PPR doesn't even state what the bit being
> >> clear means; it's a r/o one. On respective families it cannot possibly
> >> be correct to expose it clear.
> > 
> > There are other bits in the same MSR that only state the meaning of
> > one value and are not r/o, so my take is that being clear means "The
> > TSC doesn't increment at the P0 frequency".
> > 
> > Since it's model specific, it should be possible for some models to
> > have the bit clear.
> 
> The code that's in there right now already has a family >= 0x10 check.
> The Fam10 BKDG says (among other things) "BIOS should program this bit
> to 1." That, imo, doesn't leave much room for the bit being clear once
> an OS (or hypervisor) gains control from firmware.
> 
> >>> In order to fix expose an empty HWCR.
> >>>
> >>> Fixes: 14b95b3b8546 ('x86/AMD: expose HWCR.TscFreqSel to guests')
> >>> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> >>> ---
> >>> Not sure whether we want to expose something when is_cpufreq_controller() 
> >>> is
> >>> true, seeing as there's a special wrmsr handler for the same MSR in that 
> >>> case.
> >>> Likely should be done for PV only, but also likely quite bogus.
> >>
> >> Well, keying to is_cpufreq_controller() is indeed questionable, but is
> >> there any reason to not minimally expose the bit correctly when a
> >> domain cannot migrate?
> > 
> > We would then also need to expose PSTATE0 at least to make OpenBSD
> > happy (and any otehr guest that makes the connection between
> > TscFreqSel and getting the P0 frequency from PSTATE0.
> 
> If any such OSes can be used as Dom0, yes.

OpenBSD can't be used as dom0, but QubesOS does use the nomigrate flag
for domUs.

> And as said before, I view
> exposing PSTATE0 (with zero value) as a viable alternative to your
> partial revert anyway. What varies across families is how many PSTATEn
> there are, but at least starting from Fam10 PSTATE0 looks to always be
> there, with the top bit indicating validity of the other defined bits.

I did consider this, but it seemed to just dig us deeper into exposing
non-architectural MSRs, which in the long run is more likely to be
troublesome if newer models change the meaning of bits in PSTATEn.

Thanks, Roger.



 


Rackspace

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