[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: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 17 Mar 2021 09:32:20 +0100
  • 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=2bAnlotiP0mzCSlLRX4b0h1kwvlfLAQmOZuMy8axsTA=; b=PdwAr7gzij1X//XwMcGzkYD4uKWcsKno5P7i8BGycCQqcz1AfjWKoUujrc1nZqv2t6G7izQFjgvgPZhOOK0sjwUU0aQmXkm7aJvbgtx9rk3y1Gg1+ueufIofYTf/cDTZMWgh+FQBXPOHIjRd7ZaQSP2rgWYPrSJMFdaW87VUXK9ya6IhRCShvejTGdzIynTySGRGKFhKv5oFyNxmAnsJQvL+3aqJFZ+JqjwzuG7uTfe2KVbdeU5T3C7tHy85owegcF4y7GIycSX1kH+CrRDcUyGkDNKkkQjRW49yjGIDPSWxgfVM8TNXUnawAh+8mZXwMi9RIFDXA7z7O1aliABxow==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ESOjIKVOOa1TwZeituf2ZPETd7UoC1uRxnJ50j5zzI9dns6tLnWH3P2RrBXWrZ1CVxTU+EgLksGZDIhNwTORk0s/HYDWbISWnXCgn6pbaSPSkheBcKEldajTwtXCdOR/5OmY7yoOanRI7QxHgY32Fq3wQVjIOg+aTvMCoS7YolQ2jK/Kku582OxsaZcZNgGqdEEUun2dFc6vcaGAtqK8mWu90/Y0lj9i3zlgeKjAKYPsYi8KGmSESGU5xGSIghOaS5j4mps8ZGl4XQDA7c11gD0Sb2H3dVLpH6iUv4DtAryATfa4n4/JhErBfq0O4pgf5rjKobBz1YVKce3G1vIbbQ==
  • Authentication-results: esa5.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: Wed, 17 Mar 2021 08:32:56 +0000
  • Ironport-hdrordr: A9a23:rMRnOK2Q8/qdkGbdyrD5NgqjBQJ3eYIsi2QD101hICF9Wvez0+ izgfUW0gL1gj4NWHcm3euNIrWEXGm0z/FIyKErF/OHUBP9sGWlaLtj44zr3iH6F0TFmtJ1/Z xLN5JzANiYNzVHpO7n/Qi1FMshytGb8KauwdzT1WtpUBsCUcBdxi1SYzzrdXFebg9AGJY/Cd 6w5tBfoSChZHQQaa2AdwM4dsLEoMDGk4+jXAUPAAQp5BLLoTSj7rP7FBbw5GZibxpkx7A+/W /Z1zHo/6nLiYDB9jbw9U/2q65Xltzo18dZCKW35PQ9Bz3whm+TFeZccpKYujRdmpDL1H8Ll5 32rw4kL4BP7RrqDx2IiD/M/yWl7zo08X/lzjaj8AveiOj0XigzBcYEpa8xSGqh12MasNtx0L 1G0gui3vI9Z3Ow/1WO2/HyWx5njUayq3Y5+NRj90B3aocCdKRX6bUW4UI9KuZwIAvB9IslHO NyZfusgsp+TFXyVQG8gkBfhPaoXng1Ay6cRFkDtsG/w1Ft7Q5E5npd68oFknga8pUhD7FC+u TfK6xt0IpDV8kMcMtGdas8aPryLlaIbQPHMWqUL1iiPKYbO0jVo5qyxLku/umldLEB0ZNaou WPbHpo8UoJP27+A8yH25NGtjrXRn+mYDjrwsZCo7Bkp7zVXtPQQG2+YWFrt/Hlj+QUA8XdVf r2EolRGeXf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H+GbQF9 Cup1YhaXKX3X0xQ/HIJkEt15iSM+617gdfA4ivcKEurM0fZAU2kyIeURnixPPQvq3R3lp3+ohL HjkQe4+A/AXr6+HmWuTPYThM33aggjf0x7QWAA6SXSD4Wu6UipN/GwJxzQH1zWOvb2LPzZ89r+ Ax5nK+u1Dc8q/dE/zihs+x9vcuiLILyji9s7cTqTSYfiwrFysMw4rPt+N7CG+GxsUWGA4+MkEZ /zY=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

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.

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

Thanks.



 


Rackspace

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