Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1034323pxk; Fri, 18 Sep 2020 01:58:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymso1QhMIwOEwo/hi5InYJ4c3I9YFVnxiyIrtfmf4GYcin/16lEhtmLJ356SweLF9AW9kh X-Received: by 2002:aa7:c9c7:: with SMTP id i7mr1632895edt.336.1600419483954; Fri, 18 Sep 2020 01:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600419483; cv=none; d=google.com; s=arc-20160816; b=AYyKJXHe+fiHnj7FNojxHnMi1Mlw2qFhVr3DYQUGWVXchfsPTxp+MCM5wgxNktaKsx En3LnFa/9uXrt18/5Wpccp0hLvSIul1RWZBjpDV68XlNjz5L0UgWtxWWJQqkjY+qN6i6 5AkSXBt5BFtIvJxDZE2yxbEdsuUGXIOxPaJzIr9LSU/dEsKd9b+fYiH0zYh65bZgKf28 eel5VSpRkX9YMuMCBrDr6xjTKTZXzWI23UsEXoMgpmLHZUtnNSytSHJPT5VHf+ba0S2E 0raLfYw+UDAs06EzZlHEYhBHM179apALy1PSYHcwCwNnEvaMPx/3RhDH4EpLIjsmqLX9 3qOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=7LngM4PCiSPfETQP5RL9PAM/1PFWv/+BoMDfPoBHt1U=; b=GN9ZLAGJuFb47UrbWMV8HfIEOhP7dNx9tLorU53JyEGEIxUBNbKHFKhejCdmjaSi3w fjI47GDWX+q58b59QXsFJxNFJhzfBwVv9nbIidtWTq/vWV32kus+ZznzQIJMC/jwLJFf J9QD9umTSuC8LSrc5Wcd04hlPwjIHe5Nw42bbKr9yHc0kEcU4Ep7qSyK8QbSMRIO6I60 VbRBaUkGlauXzg9LURC8etLYvUGnSZjbZKuwKkgfgOk+uOQLNUJxPajP1gJwPjSH40tH vJcx03xC+yhg8aiRakzHxWeXQpitsJIgh65V4uaXnT/4zPrPddweTQ+rf+2f+CO2S0MF 8vQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si1677316ejx.520.2020.09.18.01.57.40; Fri, 18 Sep 2020 01:58:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726199AbgIRI4M (ORCPT + 99 others); Fri, 18 Sep 2020 04:56:12 -0400 Received: from smtp2207-205.mail.aliyun.com ([121.197.207.205]:46043 "EHLO smtp2207-205.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbgIRI4M (ORCPT ); Fri, 18 Sep 2020 04:56:12 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.1160887|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.00896768-0.00102384-0.990008;FP=0|0|0|0|0|-1|-1|-1;HT=e01a16368;MF=liush@allwinnertech.com;NM=1;PH=DS;RN=12;RT=12;SR=0;TI=SMTPD_---.IYnLyfc_1600419360; Received: from localhost.localdomain(mailfrom:liush@allwinnertech.com fp:SMTPD_---.IYnLyfc_1600419360) by smtp.aliyun-inc.com(10.147.42.16); Fri, 18 Sep 2020 16:56:07 +0800 From: liush To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, akpm@linux-foundation.org, peterx@redhat.com, daniel.m.jordan@oracle.com, walken@google.com, vbabka@suse.cz, rppt@kernel.org Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, liush Subject: [V2] riscv: fix pfn_to_virt err in do_page_fault(). Date: Fri, 18 Sep 2020 16:55:58 +0800 Message-Id: <1600419358-21446-1-git-send-email-liush@allwinnertech.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The argument to pfn_to_virt() should be pfn not the value of CSR_SATP. Signed-off-by: liush --- arch/riscv/mm/fault.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c index 716d64e..3e560ec13 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -198,6 +198,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs) pmd_t *pmd, *pmd_k; pte_t *pte_k; int index; + unsigned long pfn; /* User mode accesses just cause a SIGSEGV */ if (user_mode(regs)) @@ -212,7 +213,8 @@ asmlinkage void do_page_fault(struct pt_regs *regs) * of a task switch. */ index = pgd_index(addr); - pgd = (pgd_t *)pfn_to_virt(csr_read(CSR_SATP)) + index; + pfn = csr_read(CSR_SATP) & SATP_PPN; + pgd = (pgd_t *)pfn_to_virt(pfn) + index; pgd_k = init_mm.pgd + index; if (!pgd_present(*pgd_k)) -- 2.7.4