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

Re: [PATCH v2 4/8] x86: Initial support for WRMSRNS


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Thu, 12 Jan 2023 13:58:40 +0000
  • Accept-language: en-GB, en-US
  • 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=7y/UBF+/73haNmuu4jeuUM3NbyULZc1Ow6fxxc0jvlQ=; b=mQKOOCTiUhEDjJkLRKJLQMg56v5Pu+bpnHiOGS2K45kvHSP3gAFIpirC8en1mUTSJ6VFrQmwVDSnB9z3IWUhsCDYrXlyVAz/47fIcvqIYCyvTENyFldKylHHoIR4HY6vgOVL048R2cusxaFQW7iTNvxyaiydLjOhDKZNJVDvSnQzRRJ9Mm8k4YpoAmt5xAkVf9C+/EvEM2h57QtcS4rBEeFXtH/DrIUbo+S/EpJ3cLMC1vd4r4YGqCdv1FmqOFiCNgItMnZh1fE7aNVSIvw71bkG/a4TqB+rpnh1dlydDsTX5Y4zmBYA4y4vI7Wpf4uBmJdC8Nzv4FR8qJIA8VSnjQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gyneM/E16kIodQQew1AbITyMCEB5ShL9Ub9MRJq86C8g76UVJ08xfBC0uw/VCkrwaIHg0e03EoJrmtAbzUGiwxgnoBkBlvDwej7hNPRoYBheloYDppjotmzFfMJ49v6QenTK+4MLHrFUlgR6gSIiv475nntFmVMhh2biwDQhbxBvKgFnOYNRlFqPIxaTvtn2bFYw/G1oyCh1Kx5Ot4vSh/pCSm1CmUXVA42h2c5liyl7vJRxcXnK8Iz6Srk0pEgMZilYuimS8h3dbqLu6BM46pWY8ZHGbFn7SHoh35cbQNjBawhIEDqjod5wo8S2Gdjp3KCuMYn5a3ofzwdGv/GsXw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 12 Jan 2023 13:59:19 +0000
  • Ironport-data: A9a23:F6R47aP8zWUuQebvrR2HlsFynXyQoLVcMsEvi/4bfWQNrUon3jRVy WtNUWmFaKqIZ2Lyeox1YIWz/B9VuMDXnINkQQto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQA+KmU4YoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGj9Suv3rRC9H5qyo42tB5wZmP5ingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0t4mCG1np PYAFCIQQBuHq6Hv5IKVdtA506zPLOGzVG8ekldJ6GiASNoDH9XESaiM4sJE1jAtgMwIBezZe 8cSdTtoalLHfgFLPVAUTpk5mY9EhFGmK2Ee9A3T+PVxujeKpOBy+OGF3N79U9qGX8hK2G2fo XrL5T/RCRAGLt2PjzGC9xpAg8eexHmnAdNDS9VU8NZQigev1Hc6CCcSbkOFnejmsGq7UfxQf hl8Fi0G6PJaGFaQZtv3UgC8oXWElgUBQNcWGOo/gCmSzoLE7gDfAXILJhZRZdpjuMIoSDgC0 l6Sg8ivFTFpqKeSS3+W6vGTtzzaBMQOBWoLZCtBQQ5b5dDm+dg3lkiWEY8lF7OphNroHz222 yqNsCU1m7QUi4gMyrm/+lfExTmro/AlUzII2+keZUr9hisRWWJvT9bABYTzhRqYELukcw==
  • Ironport-hdrordr: A9a23:qIGhUKz1pVRtdp5GHM7MKrPw871zdoMgy1knxilNoHxuH/Bw8P re+MjztCWE7Qr5PUtLpTnuAsa9qB/nm6KdgrNhX4tKPjOHhILAFugLgbcKqweKJ8SUzJ8/6U 4PSclD4N2bNykBsS75ijPIburJw7O8gdyVbf+19QYLcenzAZsQlDuQDGygYytLrFkvP+tBKH KEjPA33wadRQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZJRefYU5gP8dknEybN3m0hZOPA66awNaAgAAQ7QA=
  • Thread-topic: [PATCH v2 4/8] x86: Initial support for WRMSRNS

On 12/01/2023 12:58 pm, Jan Beulich wrote:
> On 10.01.2023 18:18, Andrew Cooper wrote:
>> WRMSR Non-Serialising is an optimisation intended for cases where an MSR 
>> needs
>> updating, but architectural serialising properties are not needed.
>>
>> In is anticipated that this will apply to most if not all MSRs modified on
>> context switch paths.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
>
> This will allow me to drop half of what the respective emulator patch
> consists of, which I'm yet to post (but which in turn is sitting on
> top of many other already posted emulator patches). Comparing with
> that patch, one nit though:

I did wonder if you had some stuff queued up.  I do need to get back to
reviewing.

>
>> --- a/tools/misc/xen-cpuid.c
>> +++ b/tools/misc/xen-cpuid.c
>> @@ -189,6 +189,7 @@ static const char *const str_7a1[32] =
>>  
>>      [10] = "fzrm",          [11] = "fsrs",
>>      [12] = "fsrcs",
>> +    /* 18 */                [19] = "wrmsrns",
>>  };
> We commonly leave a blank line to indicate dis-contiguous entries.

Oops yes.  Will fix.

>
>> --- a/xen/arch/x86/include/asm/msr.h
>> +++ b/xen/arch/x86/include/asm/msr.h
>> @@ -38,6 +38,18 @@ static inline void wrmsrl(unsigned int msr, __u64 val)
>>          wrmsr(msr, lo, hi);
>>  }
>>  
>> +/* Non-serialising WRMSR, when available.  Falls back to a serialising 
>> WRMSR. */
>> +static inline void wrmsr_ns(uint32_t msr, uint32_t lo, uint32_t hi)
>> +{
>> +    /*
>> +     * WRMSR is 2 bytes.  WRMSRNS is 3 bytes.  Pad WRMSR with a redundant CS
>> +     * prefix to avoid a trailing NOP.
>> +     */
>> +    alternative_input(".byte 0x2e; wrmsr",
>> +                      ".byte 0x0f,0x01,0xc6", X86_FEATURE_WRMSRNS,
>> +                      "c" (msr), "a" (lo), "d" (hi));
>> +}
> No wrmsrl_ns() and/or wrmsr_ns_safe() variants right away?

I still have a branch cleaning up MSR handling, which has been pending
since the Nanjing XenSummit, which makes some of those disappear.

But no - I wasn't planning to introduce helpers ahead of them being needed.

> Do you have any indications towards a CS prefix being the least risky
> one to use here (or in general)?

Yes.

Remember it's the prefix recommended for, and used by,
-mbranches-within-32B-boundaries to work around the Skylake jmp errata.

And based on this justification, its also the prefix we use for padding
on various jmp/call's for retpoline inlining purposes.

~Andrew

 


Rackspace

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