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

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


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 13 Sep 2023 15:37:37 +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=ZA7t/E9t/cNfydu1d7GFtNZQutZdcGQqfpHO+wJT5F8=; b=adfUZNSfh1FVMiT2GTSjZ4tyfIxV2ARlLyvRaaOPOptYTQsW1PXXpqBmm38HJ7HOmcr8VsjrBN1iwjlt35vu4HAU3GVA2zXNl03YWkwivGgmG0y5YBH39FJJN1VXsSeFEdkbhretfvM5fv5qjL2fBZb9mI+MBdjWsa6wZQKZTFUG5bxxZV7azhVUdNNtZUG2/kToTSZvNbZiuySVLs2SyVd0oCbdIo2r2i3qrHPLEVJh64IhyIsovtU81ePz5K/L62lOMEbTASICO0iwNiG5e7C0Shqn08SAOSQH6Eacffgjgjw4Nf5AWIJ44RIvbIhchcozSDw5TKut5zRFFRaQZw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iNgPffM/2Cf7h+CAXfM6JRocnn2eNYvfVvdBIKeaJb1LBPdxpUNIG/uXQ3N482SNNX12+yFEGMEerl0TNY/8pGnBQqjEwCAQLM14p/6ZcJIIURpi4YGs+6OoMP/KFOOxT9b1/O0YXou3KWrZixcdoLbR6dXuhccJRJ4Mu0jgDgiIeU0mIoaRww+txw/ksOF2/aIvBGnQxLvAKoAXHZK5uyZcGniKLrZhdIfJycW/ajJGNN4jNdaMDIi18HlZuCNGLV1n040mystNcxXMndeMHJzB2z/h7cbPeZ7yTRxjxSXR5kblkYfp4Q/SlmO7s9vhLgv/3cF/GHagaz2qXtC9vw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wl@xxxxxxx>, solene@xxxxxxxxxxx, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, the arch/x86 maintainers <x86@xxxxxxxxxx>
  • Delivery-date: Wed, 13 Sep 2023 13:37:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 13.09.2023 13:02, Andrew Cooper wrote:
> On 13/09/2023 7:18 am, Jan Beulich wrote:
>> On 12.09.2023 18:35, Andrew Cooper wrote:
>>> On 12/09/2023 5:23 pm, Roger Pau Monne wrote:
>>>> --- a/xen/arch/x86/msr.c
>>>> +++ b/xen/arch/x86/msr.c
>>>> @@ -240,8 +240,12 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, 
>>>> uint64_t *val)
>>>>      case MSR_K8_HWCR:
>>>>          if ( !(cp->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
>>>>              goto gp_fault;
>>>> -        *val = get_cpu_family(cp->basic.raw_fms, NULL, NULL) >= 0x10
>>>> -               ? K8_HWCR_TSC_FREQ_SEL : 0;
>>>> +        /*
>>>> +         * OpenBSD 7.3 accesses HWCR unconditionally if the TSC is 
>>>> reported as
>>>> +         * Invariant.  Do not set TSC_FREQ_SEL as that would trigger 
>>>> OpenBSD to
>>>> +         * also poke at PSTATE0.
>>>> +         */
>>> While this is true, the justification for removing this is because
>>> TSC_FREQ_SEL is a model specific bit, not an architectural bit in HWCR.
>>>
>>> Also because it's addition without writing into the migration stream was
>>> bogus irrespective of the specifics of the bit.
>>>
>>> I'm still of the opinion that it's buggy for OpenBSD to be looking at
>>> model specific bits when virtualised, but given my latest reading of the
>>> AMD manuals, I think OpenBSD *is* well behaved looking at PSTATE0 if it
>>> can see TSC_FREQ_SEL.
>> I'm afraid I'm still at a loss seeing what wording in which PPR makes you
>> see a connection. If there was a connection, I'd like to ask that we at
>> least properly consider exposing PSTATE0 (or if necessary all PSTATEn) as
>> well, with zero value (i.e. in particular with the valid bit clear),
>> rather than exposing a r/o bit with the wrong value, upsetting Linux.
> 
> This mess is caused by the erroneous advertising of a model specific
> bit, and there's no way in hell that giving the guest even more model
> specific data is going to fix it.
> 
> The PSTATE MSRs are entirely model specific, fully read/write, and the
> Enable bit is not an enable bit; its a "not valid yet" bit that firmware
> is required to adjust to be consistent across the coherency fabric.
> 
> Linux is simply wrong with it's printk() under virt, and wants adjusting.

Assuming Roger agrees with this statement, then I think this is another
item wanting mentioning in the description. I then still wouldn't ack
the change, but I also wouldn't object to it anymore.

Jan



 


Rackspace

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