Skip to content

Commit 7e381c0

Browse files
kvaneeshmpe
authored andcommitted
powerpc/mm/radix: Add mmu context handling callback for radix
Signed-off-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent d2adba3 commit 7e381c0

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

arch/powerpc/include/asm/mmu_context.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
3737
extern void set_context(unsigned long id, pgd_t *pgd);
3838

3939
#ifdef CONFIG_PPC_BOOK3S_64
40+
extern void radix__switch_mmu_context(struct mm_struct *prev,
41+
struct mm_struct *next);
4042
static inline void switch_mmu_context(struct mm_struct *prev,
4143
struct mm_struct *next,
4244
struct task_struct *tsk)
4345
{
46+
if (radix_enabled())
47+
return radix__switch_mmu_context(prev, next);
4448
return switch_slb(tsk, next);
4549
}
4650

arch/powerpc/mm/mmu_context_hash64.c

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ int __init_new_context(void)
5858
return index;
5959
}
6060
EXPORT_SYMBOL_GPL(__init_new_context);
61+
static int radix__init_new_context(struct mm_struct *mm, int index)
62+
{
63+
unsigned long rts_field;
64+
65+
/*
66+
* set the process table entry,
67+
*/
68+
rts_field = 3ull << PPC_BITLSHIFT(2);
69+
process_tb[index].prtb0 = cpu_to_be64(rts_field | __pa(mm->pgd) | RADIX_PGD_INDEX_SIZE);
70+
return 0;
71+
}
6172

6273
int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
6374
{
@@ -67,13 +78,18 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
6778
if (index < 0)
6879
return index;
6980

70-
/* The old code would re-promote on fork, we don't do that
71-
* when using slices as it could cause problem promoting slices
72-
* that have been forced down to 4K
73-
*/
74-
if (slice_mm_new_context(mm))
75-
slice_set_user_psize(mm, mmu_virtual_psize);
76-
subpage_prot_init_new_context(mm);
81+
if (radix_enabled()) {
82+
radix__init_new_context(mm, index);
83+
} else {
84+
85+
/* The old code would re-promote on fork, we don't do that
86+
* when using slices as it could cause problem promoting slices
87+
* that have been forced down to 4K
88+
*/
89+
if (slice_mm_new_context(mm))
90+
slice_set_user_psize(mm, mmu_virtual_psize);
91+
subpage_prot_init_new_context(mm);
92+
}
7793
mm->context.id = index;
7894
#ifdef CONFIG_PPC_ICSWX
7995
mm->context.cop_lockp = kmalloc(sizeof(spinlock_t), GFP_KERNEL);
@@ -144,8 +160,19 @@ void destroy_context(struct mm_struct *mm)
144160
mm->context.cop_lockp = NULL;
145161
#endif /* CONFIG_PPC_ICSWX */
146162

163+
if (radix_enabled())
164+
process_tb[mm->context.id].prtb1 = 0;
165+
else
166+
subpage_prot_free(mm);
147167
destroy_pagetable_page(mm);
148168
__destroy_context(mm->context.id);
149-
subpage_prot_free(mm);
150169
mm->context.id = MMU_NO_CONTEXT;
151170
}
171+
172+
#ifdef CONFIG_PPC_RADIX_MMU
173+
void radix__switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
174+
{
175+
mtspr(SPRN_PID, next->context.id);
176+
asm volatile("isync": : :"memory");
177+
}
178+
#endif

0 commit comments

Comments
 (0)