Skip to content

Commit 4005833

Browse files
chleroympe
authored andcommitted
powerpc: simplify BDI switch
There is no reason to re-read each time the pointer at location 0xf0 as it is fixed and known. Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 36da5ff commit 4005833

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

arch/powerpc/include/asm/mmu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ extern void early_init_mmu_secondary(void);
356356
extern void setup_initial_memory_limit(phys_addr_t first_memblock_base,
357357
phys_addr_t first_memblock_size);
358358
static inline void mmu_early_init_devtree(void) { }
359+
360+
extern void *abatron_pteptrs[2];
359361
#endif /* __ASSEMBLY__ */
360362
#endif
361363

arch/powerpc/kernel/head_32.S

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,9 +1027,8 @@ _ENTRY(switch_mmu_context)
10271027
* The PGDIR is passed as second argument.
10281028
*/
10291029
lwz r4,MM_PGD(r4)
1030-
lis r5, KERNELBASE@h
1031-
lwz r5, 0xf0(r5)
1032-
stw r4, 0x4(r5)
1030+
lis r5, abatron_pteptrs@ha
1031+
stw r4, abatron_pteptrs@l + 0x4(r5)
10331032
#endif
10341033
li r4,0
10351034
isync

arch/powerpc/kernel/head_40x.S

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -953,9 +953,8 @@ _GLOBAL(set_context)
953953
/* Context switch the PTE pointer for the Abatron BDI2000.
954954
* The PGDIR is the second parameter.
955955
*/
956-
lis r5, KERNELBASE@h
957-
lwz r5, 0xf0(r5)
958-
stw r4, 0x4(r5)
956+
lis r5, abatron_pteptrs@ha
957+
stw r4, abatron_pteptrs@l + 0x4(r5)
959958
#endif
960959
sync
961960
mtspr SPRN_PID,r3

arch/powerpc/kernel/head_8xx.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,5 +989,6 @@ swapper_pg_dir:
989989
/* Room for two PTE table poiners, usually the kernel and current user
990990
* pointer to their respective root page table (pgdir).
991991
*/
992+
.globl abatron_pteptrs
992993
abatron_pteptrs:
993994
.space 8

arch/powerpc/mm/8xx_mmu.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,11 @@ void set_context(unsigned long id, pgd_t *pgd)
162162
{
163163
s16 offset = (s16)(__pa(swapper_pg_dir));
164164

165-
#ifdef CONFIG_BDI_SWITCH
166-
pgd_t **ptr = *(pgd_t ***)(KERNELBASE + 0xf0);
167-
168165
/* Context switch the PTE pointer for the Abatron BDI2000.
169166
* The PGDIR is passed as second argument.
170167
*/
171-
*(ptr + 1) = pgd;
172-
#endif
168+
if (IS_ENABLED(CONFIG_BDI_SWITCH))
169+
abatron_pteptrs[1] = pgd;
173170

174171
/* Register M_TWB will contain base address of level 1 table minus the
175172
* lower part of the kernel PGDIR base address, so that all accesses to

0 commit comments

Comments
 (0)