[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 6/8] x86: Derive XEN_MSR_PAT from its individual entries
- To: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
- Date: Tue, 6 Dec 2022 11:32:16 +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=JjUYSVyH0tA5nppj98/TjOV1I1SvOk2ZvH7PUo6C4BY=; b=XiA0PBRGNicC9W6629yBCBeRj8xtUZI3rP6WfGlSrmMO2LVlgECcQo+y9df9jhTGiNqHihO/3H17YdV5AEQJOK0SFgse71A00ySzh3XPw8sa3DZ7kjxoVT6hLo6sE14vTuNzRulWZr4XAaJ4y3d9b6su5HD6ZsHi9xAAzXbPSb9dhs9Q35Ytt1+g7Y2GNCaNXUUqocZJ8XQE71hNOu+ykXR/Gf7KbLZO1ujsEHpoqNI2L1boB1Wxu7JgGzP2SjltI2OPthOw38j3df/JgN6wxMF9qiZkoj+BRv951ox97i5qqCYvZNvA8l/wT1UASNPIfN1pUVAISqT98KaDUrix3A==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B6lxCMgGDnsPLtgJr4E042qVx33a80kMkJGyK26cV7Yw67d/JRr0El0mzgPM4JvaFGbxYUc70eFvkWit8YF5OJWJAcfrLXXB3MTX1nmPvoUpwO46mIhqTNbK9lpcxBGV0XUJ3cGPNOo//9yS48jOZqqCnVm7PJQufk8Ms0R81LqOo+eUMsdWre68XNbXLBg2qi7SMkEI5zntkSm4DCmwfJzt7cphE44+u1NUGPj4t4KvsknhzyY/PlubQiLzLKhjJR2tfmppOF3HfLlIv6PcoM6g5FrS7DWejDxg0mryek3JREaUgHdbshX07byX/JXbit+eA4qZjgkkHD/iqlfqXQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxx>, "Tim (Xen.org)" <tim@xxxxxxx>
- Delivery-date: Tue, 06 Dec 2022 11:32:47 +0000
- Ironport-data: A9a23:wMMOVa3gjmuJ039lWvbD5SVwkn2cJEfYwER7XKvMYLTBsI5bp2EFx zMfCGCAafjZM2ugLY0lbI+/o05VvJGBydMwQQVkpC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK5ULSfUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8tuTS9nuDgNyo4GlC5wZmO6gR1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfASZ8x OA9IzI3NiuDxNiH55yUV9FSv5F2RCXrFNt3VnBI6xj8VK9ja7aTBqLA6JlfwSs6gd1IEbDGf c0FZDFzbRPGJRpSJlMQD5F4l+Ct7pX9W2QA9BTJ+uxqsy6Kkl0ZPLvFabI5fvSjQ8lPk1nej WXB52njWTkRNcCF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isrPxSbL3OWnbIWpe2feIsrEaGInWSv yzMJVZD7vqKnbvA59A20n7V4NJIXcTXcUJspIwWk6IoMjMNor239arO8r7Nf7oC3IpS2n/Cn wMUHz6I9hB9FmiXjvijB3YSxrWCzvCFFJLYdznFsQoufsw39d3w3koYHyCl7G2ACwHtLAqd0 1jJ76imr+npACNjBP101k=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHZCSwLt8pWvQpnJE2aMagXMCMCdq5gunAA
- Thread-topic: [PATCH 6/8] x86: Derive XEN_MSR_PAT from its individual entries
On 06/12/2022 04:33, Demi Marie Obenour wrote:
> This avoids it being a magic constant that is difficult for humans to
> decode. Use a _Static_assert to check that the old and new values are
> identical.
>
> Signed-off-by: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
> ---
> xen/arch/x86/include/asm/processor.h | 22 +++++++++++++++++++++-
> 1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/include/asm/processor.h
> b/xen/arch/x86/include/asm/processor.h
> index
> 8e2816fae9b97bd4e153a30cc3802971fe0355af..64b75e444947c64e2e5eba457deec92a873d7a63
> 100644
> --- a/xen/arch/x86/include/asm/processor.h
> +++ b/xen/arch/x86/include/asm/processor.h
> @@ -92,13 +92,33 @@
> X86_EFLAGS_NT|X86_EFLAGS_DF|X86_EFLAGS_IF| \
> X86_EFLAGS_TF)
>
> +/* Individual entries in IA32_CR_PAT */
> +#define MSR_PAT_UC _AC(0x00, ULL)
> +#define MSR_PAT_WC _AC(0x01, ULL)
> +#define MSR_PAT_RESERVED_1 _AC(0x02, ULL)
> +#define MSR_PAT_RESERVED_2 _AC(0x03, ULL)
> +#define MSR_PAT_WT _AC(0x04, ULL)
> +#define MSR_PAT_WP _AC(0x05, ULL)
> +#define MSR_PAT_WB _AC(0x06, ULL)
> +#define MSR_PAT_UCM _AC(0x07, ULL)
This isn't really correct. Constants for MSRs typically live in
msr-index.h, but these are architectural x86 memory types.
These ought be
#define X86_MT_$X ... (skipping the two reserved values)
in x86-defns.h, and the PAT_TYPE_*, MTRR_TYPE_* and EPT_EMT_* constants
want removing.
There are two minor restrictions (EPT can't have UCM, MTRR can't have
WC), but they are all operating in terms of architectural memory type
values, and the code ought to reflect this.
> +
> /*
> * Host IA32_CR_PAT value to cover all memory types. This is not the default
> * MSR_PAT value, and is an ABI with PV guests.
> */
> -#define XEN_MSR_PAT _AC(0x050100070406, ULL)
> +#define XEN_MSR_PAT (MSR_PAT_WB << 0x00 | \
> + MSR_PAT_WT << 0x08 | \
> + MSR_PAT_UCM << 0x10 | \
> + MSR_PAT_UC << 0x18 | \
> + MSR_PAT_WC << 0x20 | \
> + MSR_PAT_WP << 0x28 | \
> + MSR_PAT_UC << 0x30 | \
> + MSR_PAT_UC << 0x38 | \
> + 0)
>
> #ifndef __ASSEMBLY__
> +_Static_assert(XEN_MSR_PAT == 0x050100070406ULL,
> + "wrong XEN_MSR_PAT breaks PV guests");
This wants to be in the build_assertions() that you introduce in the
next patch, and a BUILD_BUG_ON(). We still support compilers which
don't know _Static_assert().
~Andrew
|