|
| 1 | +From 7f3f94f443f652e4a59c111d4cf8b5fb3b771612 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Demi Marie Obenour < [email protected]> |
| 3 | +Date: Sun, 4 Dec 2022 07:57:44 -0500 |
| 4 | +Subject: [PATCH] x86: Use Linux's PAT |
| 5 | + |
| 6 | +This is purely for testing, to see if it works around a bug in i915. It |
| 7 | +is not intended to be merged. |
| 8 | + |
| 9 | +NOT-signed-off-by: DO NOT MERGE |
| 10 | +--- |
| 11 | + xen/arch/x86/include/asm/page.h | 4 ++-- |
| 12 | + xen/arch/x86/include/asm/processor.h | 10 +++++----- |
| 13 | + xen/arch/x86/mm.c | 8 -------- |
| 14 | + 3 files changed, 7 insertions(+), 15 deletions(-) |
| 15 | + |
| 16 | +diff --git a/xen/arch/x86/include/asm/page.h b/xen/arch/x86/include/asm/page.h |
| 17 | +index 350d1fb1100f..2624cc6bdae5 100644 |
| 18 | +--- a/xen/arch/x86/include/asm/page.h |
| 19 | ++++ b/xen/arch/x86/include/asm/page.h |
| 20 | +@@ -333,11 +333,11 @@ void efi_update_l4_pgtable(unsigned int l4idx, l4_pgentry_t l4e); |
| 21 | + |
| 22 | + /* Memory types, encoded under Xen's choice of MSR_PAT. */ |
| 23 | + #define _PAGE_WB ( 0) |
| 24 | +-#define _PAGE_WT ( _PAGE_PWT) |
| 25 | ++#define _PAGE_WC ( _PAGE_PWT) |
| 26 | + #define _PAGE_UCM ( _PAGE_PCD ) |
| 27 | + #define _PAGE_UC ( _PAGE_PCD | _PAGE_PWT) |
| 28 | +-#define _PAGE_WC (_PAGE_PAT ) |
| 29 | + #define _PAGE_WP (_PAGE_PAT | _PAGE_PWT) |
| 30 | ++#define _PAGE_WT (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT) |
| 31 | + |
| 32 | + /* |
| 33 | + * Debug option: Ensure that granted mappings are not implicitly unmapped. |
| 34 | +diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/asm/processor.h |
| 35 | +index c26ef9090c3a..ec881b880d4d 100644 |
| 36 | +--- a/xen/arch/x86/include/asm/processor.h |
| 37 | ++++ b/xen/arch/x86/include/asm/processor.h |
| 38 | +@@ -65,16 +65,16 @@ |
| 39 | + |
| 40 | + /* |
| 41 | + * Host IA32_CR_PAT value to cover all memory types. This is not the default |
| 42 | +- * MSR_PAT value, and is an ABI with PV guests. |
| 43 | ++ * MSR_PAT value, and is needed by the Linux i915 driver. |
| 44 | + */ |
| 45 | + #define XEN_MSR_PAT ((_AC(X86_MT_WB, ULL) << 0x00) | \ |
| 46 | +- (_AC(X86_MT_WT, ULL) << 0x08) | \ |
| 47 | ++ (_AC(X86_MT_WC, ULL) << 0x08) | \ |
| 48 | + (_AC(X86_MT_UCM, ULL) << 0x10) | \ |
| 49 | + (_AC(X86_MT_UC, ULL) << 0x18) | \ |
| 50 | +- (_AC(X86_MT_WC, ULL) << 0x20) | \ |
| 51 | ++ (_AC(X86_MT_WB, ULL) << 0x20) | \ |
| 52 | + (_AC(X86_MT_WP, ULL) << 0x28) | \ |
| 53 | +- (_AC(X86_MT_UC, ULL) << 0x30) | \ |
| 54 | +- (_AC(X86_MT_UC, ULL) << 0x38)) |
| 55 | ++ (_AC(X86_MT_UCM, ULL) << 0x30) | \ |
| 56 | ++ (_AC(X86_MT_WT, ULL) << 0x38)) |
| 57 | + |
| 58 | + #ifndef __ASSEMBLY__ |
| 59 | + |
| 60 | +diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c |
| 61 | +index 702c76a879e5..b30453b9de11 100644 |
| 62 | +--- a/xen/arch/x86/mm.c |
| 63 | ++++ b/xen/arch/x86/mm.c |
| 64 | +@@ -6365,14 +6365,6 @@ unsigned long get_upper_mfn_bound(void) |
| 65 | + */ |
| 66 | + static void __init __maybe_unused build_assertions(void) |
| 67 | + { |
| 68 | +- /* |
| 69 | +- * If this trips, any guests that blindly rely on the public API in xen.h |
| 70 | +- * (instead of reading the PAT from Xen, as Linux 3.19+ does) will be |
| 71 | +- * broken. Furthermore, live migration of PV guests between Xen versions |
| 72 | +- * using different PATs will not work. |
| 73 | +- */ |
| 74 | +- BUILD_BUG_ON(XEN_MSR_PAT != 0x050100070406ULL); |
| 75 | +- |
| 76 | + /* |
| 77 | + * _PAGE_WB must be zero for several reasons, not least because Linux |
| 78 | + * assumes it. |
| 79 | +-- |
| 80 | +2.44.0 |
| 81 | + |
0 commit comments