Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp352338pxx; Mon, 26 Oct 2020 09:59:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLh9cqK9KVLkLUpCeDMx5kvCKA/pOfjSVfGjO2IODSnJ6tVsw0gFAtSU22GxKsm8xTCOIZ X-Received: by 2002:a17:906:f90a:: with SMTP id lc10mr16947448ejb.272.1603731577261; Mon, 26 Oct 2020 09:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603731577; cv=none; d=google.com; s=arc-20160816; b=Alu7bg8khqyVUOrJs6SDUxNwWS2OvrSmOLOx1gdoRLn+9SAve0HWRJhZ+D1UUs+PLn vee9/+qmAst/uV1PIaaM8g81o9Ji0NJbcyK+MASKNY4T8CjLxLmnAbJu8jWNXmy/ytym IO+fYGhuCsh0TbOJaPA635KosIIGgFMhbbFQZWhgSVQerhS/SrXXx2GR6IYPCmqF4LSl zYOw7AsKQ8mFs6v7g4Q+IaCAgo9RxdyJWaRbD9EreQSIkHu9sYYZScDd6oxGVjitHD6k Unj09zqSu4ipfrGUiX8LXIj7K3QdZWex8KNDlL5w2v1VQsIJsogcI5ZDoPDRXPmH6UuL SZiQ== 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=1l8VfnNYDNrzFl2qPXALhiec9zMN5OROqVWiNZZR0K4=; b=ruEVVNEwtgla+rENxOpkJeDk8PzCnMaDDLrcEz4yY2+psP4wVaR8TJATNdf2rSmMkZ VyVq8wMP1PODPt50O0RtqZKYdjon+qv6yX6RdUlgrSELroV/eO9xQdTDTs7ShUh68OXv SkFSHapsbn2mJGRJeI6C65BJJyM8JIz/KqHyw5NBbiQaofZltOXdse9ziWybLe5ASPiF APHHUwAfIkMFRdMD2b9DiJZlYKjQ2fI5Am/JzgccTJHIkFDrngLeoNgWSFoYimIIuhZ8 X0Ivr2+U+4J93nCTRq+mSc1cSECcU2TVW8miJW44KszC+2/x2vOJKsLqrqibknd70Eur tLuQ== 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 h34si5088015edd.264.2020.10.26.09.59.13; Mon, 26 Oct 2020 09:59:37 -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 S1775394AbgJZMqg (ORCPT + 99 others); Mon, 26 Oct 2020 08:46:36 -0400 Received: from smtp2207-205.mail.aliyun.com ([121.197.207.205]:38153 "EHLO smtp2207-205.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1775388AbgJZMqf (ORCPT ); Mon, 26 Oct 2020 08:46:35 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08028037|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0175674-0.00702877-0.975404;FP=2159615626745500650|1|1|10|0|-1|-1|-1;HT=ay29a033018047205;MF=liush@allwinnertech.com;NM=1;PH=DS;RN=11;RT=11;SR=0;TI=SMTPD_---.IodzosZ_1603716370; Received: from localhost.localdomain(mailfrom:liush@allwinnertech.com fp:SMTPD_---.IodzosZ_1603716370) by smtp.aliyun-inc.com(10.147.40.233); Mon, 26 Oct 2020 20:46:14 +0800 From: liush To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, penberg@kernel.org, akpm@linux-foundation.org, peterx@redhat.com, vbabka@suse.cz, walken@google.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Shaohua Liu Subject: [PATCH v4] riscv: fix pfn_to_virt err in do_page_fault(). Date: Mon, 26 Oct 2020 20:46:08 +0800 Message-Id: <1603716368-29896-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 From: Shaohua Liu The argument to pfn_to_virt() should be pfn not the value of CSR_SATP. Reviewed-by: Palmer Dabbelt Reviewed-by: Anup Patel 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 1359e21..3c8b9e4 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -86,6 +86,7 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a 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)) @@ -100,7 +101,8 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a * 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