Skip to content

Commit 37c3a64

Browse files
committed
mm/x86: support large pfn mappings
jira LE-3557 Rebuild_History Non-Buildable kernel-5.14.0-570.26.1.el9_6 commit-author Peter Xu <[email protected]> commit 7518202 Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-5.14.0-570.26.1.el9_6/75182022.failed Helpers to install and detect special pmd/pud entries. In short, bit 9 on x86 is not used for pmd/pud, so we can directly define them the same as the pte level. One note is that it's also used in _PAGE_BIT_CPA_TEST but that is only used in the debug test, and shouldn't conflict in this case. One note is that pxx_set|clear_flags() for pmd/pud will need to be moved upper so that they can be referenced by the new special bit helpers. There's no change in the code that was moved. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Peter Xu <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Alex Williamson <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Gavin Shan <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Niklas Schnelle <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Will Deacon <[email protected]> Cc: Zi Yan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> (cherry picked from commit 7518202) Signed-off-by: Jonathan Maple <[email protected]> # Conflicts: # arch/x86/Kconfig
1 parent 7eb43fb commit 37c3a64

File tree

1 file changed

+179
-0
lines changed

1 file changed

+179
-0
lines changed
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
mm/x86: support large pfn mappings
2+
3+
jira LE-3557
4+
Rebuild_History Non-Buildable kernel-5.14.0-570.26.1.el9_6
5+
commit-author Peter Xu <[email protected]>
6+
commit 75182022a0439788415b2dd1db3086e07aa506f7
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-5.14.0-570.26.1.el9_6/75182022.failed
10+
11+
Helpers to install and detect special pmd/pud entries. In short, bit 9 on
12+
x86 is not used for pmd/pud, so we can directly define them the same as
13+
the pte level. One note is that it's also used in _PAGE_BIT_CPA_TEST but
14+
that is only used in the debug test, and shouldn't conflict in this case.
15+
16+
One note is that pxx_set|clear_flags() for pmd/pud will need to be moved
17+
upper so that they can be referenced by the new special bit helpers.
18+
There's no change in the code that was moved.
19+
20+
Link: https://lkml.kernel.org/r/[email protected]
21+
Signed-off-by: Peter Xu <[email protected]>
22+
Cc: Thomas Gleixner <[email protected]>
23+
Cc: Ingo Molnar <[email protected]>
24+
Cc: Borislav Petkov <[email protected]>
25+
Cc: Dave Hansen <[email protected]>
26+
Cc: Alexander Gordeev <[email protected]>
27+
Cc: Alex Williamson <[email protected]>
28+
Cc: Aneesh Kumar K.V <[email protected]>
29+
Cc: Catalin Marinas <[email protected]>
30+
Cc: Christian Borntraeger <[email protected]>
31+
Cc: David Hildenbrand <[email protected]>
32+
Cc: Gavin Shan <[email protected]>
33+
Cc: Gerald Schaefer <[email protected]>
34+
Cc: Heiko Carstens <[email protected]>
35+
Cc: Jason Gunthorpe <[email protected]>
36+
Cc: Matthew Wilcox <[email protected]>
37+
Cc: Niklas Schnelle <[email protected]>
38+
Cc: Paolo Bonzini <[email protected]>
39+
Cc: Ryan Roberts <[email protected]>
40+
Cc: Sean Christopherson <[email protected]>
41+
Cc: Sven Schnelle <[email protected]>
42+
Cc: Vasily Gorbik <[email protected]>
43+
Cc: Will Deacon <[email protected]>
44+
Cc: Zi Yan <[email protected]>
45+
Signed-off-by: Andrew Morton <[email protected]>
46+
(cherry picked from commit 75182022a0439788415b2dd1db3086e07aa506f7)
47+
Signed-off-by: Jonathan Maple <[email protected]>
48+
49+
# Conflicts:
50+
# arch/x86/Kconfig
51+
diff --cc arch/x86/Kconfig
52+
index a5a59118efe4,d4dbe9717e96..000000000000
53+
--- a/arch/x86/Kconfig
54+
+++ b/arch/x86/Kconfig
55+
@@@ -28,7 -28,7 +28,11 @@@ config X86_6
56+
select ARCH_HAS_GIGANTIC_PAGE
57+
select ARCH_SUPPORTS_INT128 if CC_HAS_INT128
58+
select ARCH_SUPPORTS_PER_VMA_LOCK
59+
++<<<<<<< HEAD
60+
+ select ARCH_SUPPORTS_RT
61+
++=======
62+
+ select ARCH_SUPPORTS_HUGE_PFNMAP if TRANSPARENT_HUGEPAGE
63+
++>>>>>>> 75182022a043 (mm/x86: support large pfn mappings)
64+
select HAVE_ARCH_SOFT_DIRTY
65+
select MODULES_USE_ELF_RELA
66+
select NEED_DMA_MAP_STATE
67+
* Unmerged path arch/x86/Kconfig
68+
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
69+
index 8149afec43a4..c5bc120fade8 100644
70+
--- a/arch/x86/include/asm/pgtable.h
71+
+++ b/arch/x86/include/asm/pgtable.h
72+
@@ -121,6 +121,34 @@ extern pmdval_t early_pmd_flags;
73+
#define arch_end_context_switch(prev) do {} while(0)
74+
#endif /* CONFIG_PARAVIRT_XXL */
75+
76+
+static inline pmd_t pmd_set_flags(pmd_t pmd, pmdval_t set)
77+
+{
78+
+ pmdval_t v = native_pmd_val(pmd);
79+
+
80+
+ return native_make_pmd(v | set);
81+
+}
82+
+
83+
+static inline pmd_t pmd_clear_flags(pmd_t pmd, pmdval_t clear)
84+
+{
85+
+ pmdval_t v = native_pmd_val(pmd);
86+
+
87+
+ return native_make_pmd(v & ~clear);
88+
+}
89+
+
90+
+static inline pud_t pud_set_flags(pud_t pud, pudval_t set)
91+
+{
92+
+ pudval_t v = native_pud_val(pud);
93+
+
94+
+ return native_make_pud(v | set);
95+
+}
96+
+
97+
+static inline pud_t pud_clear_flags(pud_t pud, pudval_t clear)
98+
+{
99+
+ pudval_t v = native_pud_val(pud);
100+
+
101+
+ return native_make_pud(v & ~clear);
102+
+}
103+
+
104+
/*
105+
* The following only work if pte_present() is true.
106+
* Undefined behaviour if not..
107+
@@ -310,6 +338,30 @@ static inline int pud_devmap(pud_t pud)
108+
}
109+
#endif
110+
111+
+#ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
112+
+static inline bool pmd_special(pmd_t pmd)
113+
+{
114+
+ return pmd_flags(pmd) & _PAGE_SPECIAL;
115+
+}
116+
+
117+
+static inline pmd_t pmd_mkspecial(pmd_t pmd)
118+
+{
119+
+ return pmd_set_flags(pmd, _PAGE_SPECIAL);
120+
+}
121+
+#endif /* CONFIG_ARCH_SUPPORTS_PMD_PFNMAP */
122+
+
123+
+#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
124+
+static inline bool pud_special(pud_t pud)
125+
+{
126+
+ return pud_flags(pud) & _PAGE_SPECIAL;
127+
+}
128+
+
129+
+static inline pud_t pud_mkspecial(pud_t pud)
130+
+{
131+
+ return pud_set_flags(pud, _PAGE_SPECIAL);
132+
+}
133+
+#endif /* CONFIG_ARCH_SUPPORTS_PUD_PFNMAP */
134+
+
135+
static inline int pgd_devmap(pgd_t pgd)
136+
{
137+
return 0;
138+
@@ -480,20 +532,6 @@ static inline pte_t pte_mkdevmap(pte_t pte)
139+
return pte_set_flags(pte, _PAGE_SPECIAL|_PAGE_DEVMAP);
140+
}
141+
142+
-static inline pmd_t pmd_set_flags(pmd_t pmd, pmdval_t set)
143+
-{
144+
- pmdval_t v = native_pmd_val(pmd);
145+
-
146+
- return native_make_pmd(v | set);
147+
-}
148+
-
149+
-static inline pmd_t pmd_clear_flags(pmd_t pmd, pmdval_t clear)
150+
-{
151+
- pmdval_t v = native_pmd_val(pmd);
152+
-
153+
- return native_make_pmd(v & ~clear);
154+
-}
155+
-
156+
/* See comments above mksaveddirty_shift() */
157+
static inline pmd_t pmd_mksaveddirty(pmd_t pmd)
158+
{
159+
@@ -588,20 +626,6 @@ static inline pmd_t pmd_mkwrite_novma(pmd_t pmd)
160+
pmd_t pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma);
161+
#define pmd_mkwrite pmd_mkwrite
162+
163+
-static inline pud_t pud_set_flags(pud_t pud, pudval_t set)
164+
-{
165+
- pudval_t v = native_pud_val(pud);
166+
-
167+
- return native_make_pud(v | set);
168+
-}
169+
-
170+
-static inline pud_t pud_clear_flags(pud_t pud, pudval_t clear)
171+
-{
172+
- pudval_t v = native_pud_val(pud);
173+
-
174+
- return native_make_pud(v & ~clear);
175+
-}
176+
-
177+
/* See comments above mksaveddirty_shift() */
178+
static inline pud_t pud_mksaveddirty(pud_t pud)
179+
{

0 commit comments

Comments
 (0)