Skip to content

Commit fe1e8c3

Browse files
kirylIngo Molnar
authored andcommitted
x86/mm: Extend headers with basic definitions to support 5-level paging
This patch extends x86 headers to enable 5-level paging support. It's still based on <asm-generic/5level-fixup.h>. We will get to the point where we can have <asm-generic/pgtable-nop4d.h> later. Signed-off-by: Kirill A. Shutemov <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 3e6ef9c commit fe1e8c3

File tree

5 files changed

+53
-6
lines changed

5 files changed

+53
-6
lines changed

arch/x86/include/asm/pgtable-2level_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
typedef unsigned long pteval_t;
88
typedef unsigned long pmdval_t;
99
typedef unsigned long pudval_t;
10+
typedef unsigned long p4dval_t;
1011
typedef unsigned long pgdval_t;
1112
typedef unsigned long pgprotval_t;
1213

arch/x86/include/asm/pgtable-3level_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
typedef u64 pteval_t;
88
typedef u64 pmdval_t;
99
typedef u64 pudval_t;
10+
typedef u64 p4dval_t;
1011
typedef u64 pgdval_t;
1112
typedef u64 pgprotval_t;
1213

arch/x86/include/asm/pgtable.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,17 @@ static inline unsigned long pud_pfn(pud_t pud)
179179
return (pud_val(pud) & pud_pfn_mask(pud)) >> PAGE_SHIFT;
180180
}
181181

182+
static inline unsigned long p4d_pfn(p4d_t p4d)
183+
{
184+
return (p4d_val(p4d) & p4d_pfn_mask(p4d)) >> PAGE_SHIFT;
185+
}
186+
187+
static inline int p4d_large(p4d_t p4d)
188+
{
189+
/* No 512 GiB pages yet */
190+
return 0;
191+
}
192+
182193
#define pte_page(pte) pfn_to_page(pte_pfn(pte))
183194

184195
static inline int pmd_large(pmd_t pte)
@@ -770,6 +781,16 @@ static inline int pud_large(pud_t pud)
770781
}
771782
#endif /* CONFIG_PGTABLE_LEVELS > 2 */
772783

784+
static inline unsigned long pud_index(unsigned long address)
785+
{
786+
return (address >> PUD_SHIFT) & (PTRS_PER_PUD - 1);
787+
}
788+
789+
static inline unsigned long p4d_index(unsigned long address)
790+
{
791+
return (address >> P4D_SHIFT) & (PTRS_PER_P4D - 1);
792+
}
793+
773794
#if CONFIG_PGTABLE_LEVELS > 3
774795
static inline int pgd_present(pgd_t pgd)
775796
{
@@ -788,11 +809,6 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
788809
#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
789810

790811
/* to find an entry in a page-table-directory. */
791-
static inline unsigned long pud_index(unsigned long address)
792-
{
793-
return (address >> PUD_SHIFT) & (PTRS_PER_PUD - 1);
794-
}
795-
796812
static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
797813
{
798814
return (pud_t *)pgd_page_vaddr(*pgd) + pud_index(address);

arch/x86/include/asm/pgtable_64_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
typedef unsigned long pteval_t;
1414
typedef unsigned long pmdval_t;
1515
typedef unsigned long pudval_t;
16+
typedef unsigned long p4dval_t;
1617
typedef unsigned long pgdval_t;
1718
typedef unsigned long pgprotval_t;
1819

arch/x86/include/asm/pgtable_types.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,20 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
272272
return native_pgd_val(pgd) & PTE_FLAGS_MASK;
273273
}
274274

275-
#if CONFIG_PGTABLE_LEVELS > 3
275+
#if CONFIG_PGTABLE_LEVELS > 4
276+
277+
#error FIXME
278+
279+
#else
276280
#include <asm-generic/5level-fixup.h>
277281

282+
static inline p4dval_t native_p4d_val(p4d_t p4d)
283+
{
284+
return native_pgd_val(p4d);
285+
}
286+
#endif
287+
288+
#if CONFIG_PGTABLE_LEVELS > 3
278289
typedef struct { pudval_t pud; } pud_t;
279290

280291
static inline pud_t native_make_pud(pmdval_t val)
@@ -318,6 +329,22 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
318329
}
319330
#endif
320331

332+
static inline p4dval_t p4d_pfn_mask(p4d_t p4d)
333+
{
334+
/* No 512 GiB huge pages yet */
335+
return PTE_PFN_MASK;
336+
}
337+
338+
static inline p4dval_t p4d_flags_mask(p4d_t p4d)
339+
{
340+
return ~p4d_pfn_mask(p4d);
341+
}
342+
343+
static inline p4dval_t p4d_flags(p4d_t p4d)
344+
{
345+
return native_p4d_val(p4d) & p4d_flags_mask(p4d);
346+
}
347+
321348
static inline pudval_t pud_pfn_mask(pud_t pud)
322349
{
323350
if (native_pud_val(pud) & _PAGE_PSE)
@@ -461,6 +488,7 @@ enum pg_level {
461488
PG_LEVEL_4K,
462489
PG_LEVEL_2M,
463490
PG_LEVEL_1G,
491+
PG_LEVEL_512G,
464492
PG_LEVEL_NUM
465493
};
466494

0 commit comments

Comments
 (0)