Skip to content

Commit e3e8cd9

Browse files
Jason Andryukjgross1
authored andcommitted
x86/kernel: Move page table macros to header
The PVH entry point will need an additional set of prebuild page tables. Move the macros and defines to pgtable_64.h, so they can be re-used. Signed-off-by: Jason Andryuk <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Acked-by: Dave Hansen <[email protected]> Message-ID: <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent b464b46 commit e3e8cd9

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

arch/x86/include/asm/pgtable_64.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,26 @@ static inline bool gup_fast_permitted(unsigned long start, unsigned long end)
271271

272272
#include <asm/pgtable-invert.h>
273273

274-
#endif /* !__ASSEMBLY__ */
274+
#else /* __ASSEMBLY__ */
275+
276+
#define l4_index(x) (((x) >> 39) & 511)
277+
#define pud_index(x) (((x) >> PUD_SHIFT) & (PTRS_PER_PUD - 1))
278+
279+
L4_PAGE_OFFSET = l4_index(__PAGE_OFFSET_BASE_L4)
280+
L4_START_KERNEL = l4_index(__START_KERNEL_map)
281+
282+
L3_START_KERNEL = pud_index(__START_KERNEL_map)
283+
284+
#define SYM_DATA_START_PAGE_ALIGNED(name) \
285+
SYM_START(name, SYM_L_GLOBAL, .balign PAGE_SIZE)
286+
287+
/* Automate the creation of 1 to 1 mapping pmd entries */
288+
#define PMDS(START, PERM, COUNT) \
289+
i = 0 ; \
290+
.rept (COUNT) ; \
291+
.quad (START) + (i << PMD_SHIFT) + (PERM) ; \
292+
i = i + 1 ; \
293+
.endr
294+
295+
#endif /* __ASSEMBLY__ */
275296
#endif /* _ASM_X86_PGTABLE_64_H */

arch/x86/kernel/head_64.S

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
* We are not able to switch in one step to the final KERNEL ADDRESS SPACE
3333
* because we need identity-mapped pages.
3434
*/
35-
#define l4_index(x) (((x) >> 39) & 511)
36-
#define pud_index(x) (((x) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
37-
38-
L4_PAGE_OFFSET = l4_index(__PAGE_OFFSET_BASE_L4)
39-
L4_START_KERNEL = l4_index(__START_KERNEL_map)
40-
41-
L3_START_KERNEL = pud_index(__START_KERNEL_map)
4235

4336
__HEAD
4437
.code64
@@ -577,9 +570,6 @@ SYM_CODE_START_NOALIGN(vc_no_ghcb)
577570
SYM_CODE_END(vc_no_ghcb)
578571
#endif
579572

580-
#define SYM_DATA_START_PAGE_ALIGNED(name) \
581-
SYM_START(name, SYM_L_GLOBAL, .balign PAGE_SIZE)
582-
583573
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
584574
/*
585575
* Each PGD needs to be 8k long and 8k aligned. We do not
@@ -601,14 +591,6 @@ SYM_CODE_END(vc_no_ghcb)
601591
#define PTI_USER_PGD_FILL 0
602592
#endif
603593

604-
/* Automate the creation of 1 to 1 mapping pmd entries */
605-
#define PMDS(START, PERM, COUNT) \
606-
i = 0 ; \
607-
.rept (COUNT) ; \
608-
.quad (START) + (i << PMD_SHIFT) + (PERM) ; \
609-
i = i + 1 ; \
610-
.endr
611-
612594
__INITDATA
613595
.balign 4
614596

@@ -708,8 +690,6 @@ SYM_DATA_START_PAGE_ALIGNED(level1_fixmap_pgt)
708690
.endr
709691
SYM_DATA_END(level1_fixmap_pgt)
710692

711-
#undef PMDS
712-
713693
.data
714694
.align 16
715695

0 commit comments

Comments
 (0)