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

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


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 13 Sep 2023 10:35:17 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=Q1bQXTDcRQIo49K1nvAhUTynBFFpslOn+50ptg0j/eo=; b=D42LbD4HLObhUCXsVPXKWyUuK35XhUiaqmITFfZBWtoUXihzDvGyw4IJr6OWhK08KQtrfBshmKGQKGhsbfW2+0z4vo5JmnF5w230e06edga5E28nLs6pj47VOMas+c/XfejNIxrGvIWopq2lCdSTz6FgyNNEesphzaJSlV0goWb0ZEqTU4IgPrhFK5ddAfHeRfQFPckvBsvd0cliUqi2rHJYjgm8AQ4nPhuFVOFE9HZagwxAxrW1DkeGFmxMS1ma35/+IK0yE2vcql4JktpSyu1XeHAdCS+mX8HIUse0TNVfgmzZkDqpL7nV97IntRVTxk5+YFWFyi1GSoc9zXaQTA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LvEaghUNuCUNf6scBtcxAbkj2yNhyxUJ0DeO3D1VH++/QDGZnO1taoA3uZr5KY6Gay4Sobv8EcGA7/VXc0vV5NNUTMxNLyYPwFZN/Mpa4GGRYQgPE7+3nRvxKYqObIaFgbfY/x6+kIqp9GMxJ8HRuHFnNR7VALCu/xgRlGiQ7M7iMc5Se9I/7Pr/Acgd3Fu/EtK5OWlTuzhOZHOl+GT1kDKyEZ39UrttvNfTNN1Gwabwurd/j2Wtx+JvIqcLBFg0tmdKHcU+wKG8sESy2bon40AbJc6XUBZqypQYa0gW7Nailhjy3Wt43xHB1L+84h9Fubfps4HYpfxpsn4Wzlpv/w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 13 Sep 2023 08:35:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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. 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.

Jan



 


Rackspace

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