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