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

Re: [PATCH 3/3] x86/msr: Fix Solaris and turbostat following XSA-351


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 19 Mar 2021 13:23:03 +0000
  • 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-SenderADCheck; bh=IfG1W2Ad7ubJ7si/eLmP7oml4UMH9F+7v2uWsAC/LRw=; b=OT7LvHnpnsNwDfDTsNHFiPwceeFsKUOB5G/C6YFIfMZ6y0Q790gqR7o7XujYFRMm3xr0eIhJ87MfNcqbUxrwmGVxMVCSR0tzqW1VQAhTWJmmGerOBDUCOdsKp5w1716SJzfkrC+WLhiV3iLV4RsrOQgeqKvgxLO4K9QpuMsrwBOOZgtXoF3vcgCP5UaJvC2NzMkgI2uwuhbQBaXIt1hhCXC3tgkEyMpqN72BGBc8km7GWwN8g/Nv+al6/rSwST/FRG58968EW/kxDMgZU85jhoDhHhEwR7XNRITTjc3h6SwDehJk3TeoLwc9WDjx96tsvAM4B0PKO3QL1WGlRQnJ9A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XOmqEcKnSNYJhZenmWo4p8+gF6c4dAEYSsFgrB8OLD0GiBz/GVY0ewm39FtMJMYDbElYLeKzsspEuPDZLFHozHQAYt4OMzYpO/rFMejFMMSTSsm3buJIFfViyV2rf95Rvueb4cgOQG8gpgWv0m+tgzp5VafRsggybC268NiVb4RdB2ERPYJTgzP3I3aO1VvEVxclvU/SqEggvn8FmsfM4D/wQvw4c6kN+AT4XVyen0xnLCFrMnp0qKtKUzytfYJlJoBTtzwrtTw5I9CKxiiG4s32rwpGG5dD3QnynFoaiFcTCYUK2zB4LnAe5K02dX2PKk8L++jzgq0vTjadOjO39w==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>
  • Delivery-date: Fri, 19 Mar 2021 13:24:12 +0000
  • Ironport-hdrordr: A9a23:jhDf6aFVsfqG1mOQpLqFRZTXdLJzesId70hD6mlYcjYQWtCEls yogfQQ3QL1jjFUY307hdWcIsC7Lk/03aVepa0cJ62rUgWjgmunK4l+8ZDvqgeNJwTXzcQY76 tpdsFFZeHYJURmjMr8/QmzG8shxt7Cy6yzmeLC1R5WLD1CQYsI1XYcNi+wFEpqSA5aQb8wE5 SB7sRKzgDQBkg/RMK9G3UDQqz/vNXNjp3relorABQg5QmIg1qTmcLHOjKf2QoTVC4K/Kc6/Q H+4nHEz4iAk9X+8B/T0GfP849b8eGO9vJvDNGB4/JlUgnEpR2vYO1aKtu/lRAz5Nqi8VM71O TLyi1QRfhbz1P0UiWLrQD22w/muQxemEPK7VODm3PsrYjYaVsBerN8rLlUeBfY9EYs1esUuM kgvxP7xu9qJCjNkyjn69/DWwsCrDvSnVMYnfMOlHsaaIMCadZq3Pwi1XlIG5QNFj+S0vFELM BSCqjnlZNrWG+BY2uclmdix8HEZAVJIj62BmIGusCTzgFMmmF4w0Yy1KUk7wY93aN4ZJ9e6+ veNKN00JlIU88NdKp4QNwMWM2tFwX2MF3xGVPXBW6iOLAMOnrLpZKyyLIp5NuycJhN6Jcpgp zOXH5RqGZaQTOhNeS+mLlwtjzdSmS0WjrgjutE4YJih7H6TL33dQWeVVEHiaKb0rYiK/yef8 z2FINdAvflI2er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ze/piahpMUbVlmp4wPON0fjr1dX9Dx3ewlKOXtVBT0UYv yUWe9mVkuVYCEik+TbkW3CE4SVLt2DD1Q/9lJ4ehTXD4sBYmWp6hy/tl5QtKBAAm9LLWfSWD31 vAd2DBYtd+c7sf2ofgFNO0+lkvcjZHdhmFoxUMdZQo9qfYmfsONI8hhE+518kbTHkl8KExJyFN woFXW76mzpKoUWUtgiFUExeNt4aAhVpLQ3uiVsmjbraCBt/DDibsZszUikfutganUEg+gl/kWE Y58=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 17/03/2021 08:32, Roger Pau Monné wrote:
> On Tue, Mar 16, 2021 at 09:20:10PM +0000, Andrew Cooper wrote:
>> On 16/03/2021 16:56, Roger Pau Monné wrote:
>>> On Tue, Mar 16, 2021 at 04:18:44PM +0000, Andrew Cooper wrote:
>>>> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>>> Thanks!
>>>
>>>> ---
>>>> CC: Jan Beulich <JBeulich@xxxxxxxx>
>>>> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>>>> CC: Wei Liu <wl@xxxxxxx>
>>>> CC: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
>>>> CC: Ian Jackson <iwj@xxxxxxxxxxxxxx>
>>>>
>>>> For 4.15 This wants backporting to all security trees, as it is a fix to a
>>>> regression introduced in XSA-351.
>>>>
>>>> Also it means that users don't need msr_relaxed=1 to unbreak Solaris 
>>>> guests,
>>>> which is a strict useability improvement.
>>>> ---
>>>>  xen/arch/x86/msr.c | 13 ++++++++++++-
>>>>  1 file changed, 12 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
>>>> index 5927b6811b..a83a1d7fba 100644
>>>> --- a/xen/arch/x86/msr.c
>>>> +++ b/xen/arch/x86/msr.c
>>>> @@ -188,7 +188,6 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t 
>>>> *val)
>>>>      case MSR_TSX_CTRL:
>>>>      case MSR_MCU_OPT_CTRL:
>>>>      case MSR_RTIT_OUTPUT_BASE ... MSR_RTIT_ADDR_B(7):
>>>> -    case MSR_RAPL_POWER_UNIT:
>>>>      case MSR_PKG_POWER_LIMIT  ... MSR_PKG_POWER_INFO:
>>>>      case MSR_DRAM_POWER_LIMIT ... MSR_DRAM_POWER_INFO:
>>>>      case MSR_PP0_POWER_LIMIT  ... MSR_PP0_POLICY:
>>>> @@ -284,6 +283,18 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, 
>>>> uint64_t *val)
>>>>              goto gp_fault;
>>>>          break;
>>>>  
>>>> +    case MSR_RAPL_POWER_UNIT:
>>>> +        /*
>>>> +         * This MSR is non-architectural.  However, some versions of 
>>>> Solaris
>>>> +         * blindly reads it without a #GP guard, and some versions of
>>>> +         * turbostat crash after expecting a read of /proc/cpu/0/msr not 
>>>> to
>>>> +         * fail.  Read as zero on Intel hardware.
>>>> +         */
>>>> +        if ( !(cp->x86_vendor & X86_VENDOR_INTEL) )
>>>> +            goto gp_fault;
>>> AFAICT from Linux usage this is Intel specific (not present in any of
>>> the clones).
>> Indeed.
>>
>>>> +        *val = 0;
>>>> +        break;
>>> Do we also need to care about MSR_AMD_RAPL_POWER_UNIT (0xc0010299) for
>>> Solaris?
>> AMD has a CPUID bit for this interface, 0x80000007.EDX[14].
> Right, I see now on the manual. I guess I was confused because I don't
> seem to see Linux checking this CPUID bit in:
>
> https://elixir.bootlin.com/linux/latest/source/arch/x86/events/rapl.c#L773
>
> And instead it seems to attach the RAPL driver based on CPU model
> information. That's fine on Linux because accesses are using the _safe
> variants.

Borislav also wants a bugfix for that, seeing as there is a CPUID bit.

>
> The patch looks good to me, I wonder whether you should move the
> "users don't need msr_relaxed=1..." to the commit log, but that might
> be weird if the patch is backported, because it won't make sense for
> any older Xen version.

Will do.

> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks.

~Andrew



 


Rackspace

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