Skip to content

Commit bcacf5f

Browse files
nezha-d1palmer-dabbelt
authored andcommitted
riscv: fix pfn_to_virt err in do_page_fault().
The argument to pfn_to_virt() should be pfn not the value of CSR_SATP. Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com> Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: liush <liush@allwinnertech.com> Reviewed-by: Pekka Enberg <penberg@kernel.org> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
1 parent 79605f1 commit bcacf5f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

arch/riscv/mm/fault.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
8686
pmd_t *pmd, *pmd_k;
8787
pte_t *pte_k;
8888
int index;
89+
unsigned long pfn;
8990

9091
/* User mode accesses just cause a SIGSEGV */
9192
if (user_mode(regs))
@@ -100,7 +101,8 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
100101
* of a task switch.
101102
*/
102103
index = pgd_index(addr);
103-
pgd = (pgd_t *)pfn_to_virt(csr_read(CSR_SATP)) + index;
104+
pfn = csr_read(CSR_SATP) & SATP_PPN;
105+
pgd = (pgd_t *)pfn_to_virt(pfn) + index;
104106
pgd_k = init_mm.pgd + index;
105107

106108
if (!pgd_present(*pgd_k)) {

0 commit comments

Comments
 (0)