Skip to content

Commit 7da9ca3

Browse files
Chuanhua Hanpalmer-dabbelt
authored andcommitted
riscv: mm: Remove the copy operation of pmd
Since all processes share the kernel address space, we only need to copy pgd in case of a vmalloc page fault exception, the other levels of page tables are shared, so the operation of copying pmd is unnecessary. Signed-off-by: Chuanhua Han <hanchuanhua@oppo.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 3123109 commit 7da9ca3

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

arch/riscv/mm/fault.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ static inline void bad_area(struct pt_regs *regs, struct mm_struct *mm, int code
102102
static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long addr)
103103
{
104104
pgd_t *pgd, *pgd_k;
105-
pud_t *pud, *pud_k;
106-
p4d_t *p4d, *p4d_k;
107-
pmd_t *pmd, *pmd_k;
105+
pud_t *pud_k;
106+
p4d_t *p4d_k;
107+
pmd_t *pmd_k;
108108
pte_t *pte_k;
109109
int index;
110110
unsigned long pfn;
@@ -132,14 +132,12 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
132132
}
133133
set_pgd(pgd, *pgd_k);
134134

135-
p4d = p4d_offset(pgd, addr);
136135
p4d_k = p4d_offset(pgd_k, addr);
137136
if (!p4d_present(*p4d_k)) {
138137
no_context(regs, addr);
139138
return;
140139
}
141140

142-
pud = pud_offset(p4d, addr);
143141
pud_k = pud_offset(p4d_k, addr);
144142
if (!pud_present(*pud_k)) {
145143
no_context(regs, addr);
@@ -150,13 +148,11 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
150148
* Since the vmalloc area is global, it is unnecessary
151149
* to copy individual PTEs
152150
*/
153-
pmd = pmd_offset(pud, addr);
154151
pmd_k = pmd_offset(pud_k, addr);
155152
if (!pmd_present(*pmd_k)) {
156153
no_context(regs, addr);
157154
return;
158155
}
159-
set_pmd(pmd, *pmd_k);
160156

161157
/*
162158
* Make sure the actual PTE exists as well to

0 commit comments

Comments
 (0)