Skip to content

Commit e72421a

Browse files
chleroympe
authored andcommitted
powerpc: Define swapper_pg_dir[] in C
Don't duplicate swapper_pg_dir[] in each platform's head.S Define it in mm/pgtable.c Define MAX_PTRS_PER_PGD because on book3s/64 PTRS_PER_PGD is not a constant. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/5e3f1b8a4695c33ccc80aa3870e016bef32b85e1.1623063174.git.christophe.leroy@csgroup.eu
1 parent 45b30fa commit e72421a

File tree

10 files changed

+10
-81
lines changed

10 files changed

+10
-81
lines changed

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ extern unsigned long __pmd_frag_size_shift;
232232
#define PTRS_PER_PUD (1 << PUD_INDEX_SIZE)
233233
#define PTRS_PER_PGD (1 << PGD_INDEX_SIZE)
234234

235+
#define MAX_PTRS_PER_PGD (1 << (H_PGD_INDEX_SIZE > RADIX_PGD_INDEX_SIZE ? \
236+
H_PGD_INDEX_SIZE : RADIX_PGD_INDEX_SIZE))
237+
235238
/* PMD_SHIFT determines what a second-level page table entry can map */
236239
#define PMD_SHIFT (PAGE_SHIFT + PTE_INDEX_SIZE)
237240
#define PMD_SIZE (1UL << PMD_SHIFT)

arch/powerpc/include/asm/pgtable.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ struct mm_struct;
4141

4242
#ifndef __ASSEMBLY__
4343

44+
#ifndef MAX_PTRS_PER_PGD
45+
#define MAX_PTRS_PER_PGD PTRS_PER_PGD
46+
#endif
47+
4448
/* Keep these as a macros to avoid include dependency mess */
4549
#define pte_page(x) pfn_to_page(pte_pfn(x))
4650
#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))

arch/powerpc/kernel/asm-offsets.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,6 @@ int main(void)
354354
DEFINE(BUG_ENTRY_SIZE, sizeof(struct bug_entry));
355355
#endif
356356

357-
#ifdef CONFIG_PPC_BOOK3S_64
358-
DEFINE(PGD_TABLE_SIZE, (sizeof(pgd_t) << max(RADIX_PGD_INDEX_SIZE, H_PGD_INDEX_SIZE)));
359-
#else
360-
DEFINE(PGD_TABLE_SIZE, PGD_TABLE_SIZE);
361-
#endif
362357
DEFINE(PTE_SIZE, sizeof(pte_t));
363358

364359
#ifdef CONFIG_KVM

arch/powerpc/kernel/head_40x.S

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -701,14 +701,3 @@ _GLOBAL(abort)
701701
mfspr r13,SPRN_DBCR0
702702
oris r13,r13,DBCR0_RST_SYSTEM@h
703703
mtspr SPRN_DBCR0,r13
704-
705-
/* We put a few things here that have to be page-aligned. This stuff
706-
* goes at the beginning of the data segment, which is page-aligned.
707-
*/
708-
.data
709-
.align 12
710-
.globl sdata
711-
sdata:
712-
.globl swapper_pg_dir
713-
swapper_pg_dir:
714-
.space PGD_TABLE_SIZE

arch/powerpc/kernel/head_44x.S

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,23 +1233,8 @@ head_start_common:
12331233
isync
12341234
blr
12351235

1236-
/*
1237-
* We put a few things here that have to be page-aligned. This stuff
1238-
* goes at the beginning of the data segment, which is page-aligned.
1239-
*/
1240-
.data
1241-
.align PAGE_SHIFT
1242-
.globl sdata
1243-
sdata:
1244-
1245-
/*
1246-
* To support >32-bit physical addresses, we use an 8KB pgdir.
1247-
*/
1248-
.globl swapper_pg_dir
1249-
swapper_pg_dir:
1250-
.space PGD_TABLE_SIZE
1251-
12521236
#ifdef CONFIG_SMP
1237+
.data
12531238
.align 12
12541239
temp_boot_stack:
12551240
.space 1024

arch/powerpc/kernel/head_64.S

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -997,18 +997,3 @@ start_here_common:
997997
0: trap
998998
EMIT_BUG_ENTRY 0b, __FILE__, __LINE__, 0
999999
.previous
1000-
1001-
/*
1002-
* We put a few things here that have to be page-aligned.
1003-
* This stuff goes at the beginning of the bss, which is page-aligned.
1004-
*/
1005-
.section ".bss"
1006-
/*
1007-
* pgd dir should be aligned to PGD_TABLE_SIZE which is 64K.
1008-
* We will need to find a better way to fix this
1009-
*/
1010-
.align 16
1011-
1012-
.globl swapper_pg_dir
1013-
swapper_pg_dir:
1014-
.space PGD_TABLE_SIZE

arch/powerpc/kernel/head_8xx.S

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -786,15 +786,3 @@ _GLOBAL(mmu_pin_tlb)
786786
mtspr SPRN_SRR1, r10
787787
mtspr SPRN_SRR0, r11
788788
rfi
789-
790-
/*
791-
* We put a few things here that have to be page-aligned.
792-
* This stuff goes at the beginning of the data segment,
793-
* which is page-aligned.
794-
*/
795-
.data
796-
.globl sdata
797-
sdata:
798-
.globl swapper_pg_dir
799-
swapper_pg_dir:
800-
.space PGD_TABLE_SIZE

arch/powerpc/kernel/head_book3s_32.S

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,14 +1208,4 @@ setup_usbgecko_bat:
12081208
blr
12091209
#endif
12101210

1211-
/*
1212-
* We put a few things here that have to be page-aligned.
1213-
* This stuff goes at the beginning of the data segment,
1214-
* which is page-aligned.
1215-
*/
12161211
.data
1217-
.globl sdata
1218-
sdata:
1219-
.globl swapper_pg_dir
1220-
swapper_pg_dir:
1221-
.space PGD_TABLE_SIZE

arch/powerpc/kernel/head_fsl_booke.S

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,15 +1212,3 @@ _GLOBAL(restore_to_as0)
12121212
*/
12131213
3: mr r3,r5
12141214
bl _start
1215-
1216-
/*
1217-
* We put a few things here that have to be page-aligned. This stuff
1218-
* goes at the beginning of the data segment, which is page-aligned.
1219-
*/
1220-
.data
1221-
.align 12
1222-
.globl sdata
1223-
sdata:
1224-
.globl swapper_pg_dir
1225-
swapper_pg_dir:
1226-
.space PGD_TABLE_SIZE

arch/powerpc/mm/pgtable.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <asm/hugetlb.h>
2929
#include <asm/pte-walk.h>
3030

31+
pgd_t swapper_pg_dir[MAX_PTRS_PER_PGD] __page_aligned_bss;
32+
3133
static inline int is_exec_fault(void)
3234
{
3335
return current->thread.regs && TRAP(current->thread.regs) == 0x400;

0 commit comments

Comments
 (0)