Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp318432pxx; Mon, 26 Oct 2020 09:14:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEqEQObBXbz+65td8vQ8DqFpgdWBMDfBYwPGGJgGDSmEIW9B+rWFOKc2Rln4D9qlZSDuQZ X-Received: by 2002:a17:906:68a:: with SMTP id u10mr5810208ejb.507.1603728894194; Mon, 26 Oct 2020 09:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603728894; cv=none; d=google.com; s=arc-20160816; b=WNQ7QcTfwa6hOc40kH81aHJbEoyB2k7+1RMY8/mt8isuOZlkS4bDsECd0Sc6lRvlHf cBqMnEM9cNEzL1b5h/xbHd1E5Entpo8q3qdKUCpQQrzYJcHumeYTM7YUjArS9+ZFPlys T6aHYXc6Z1rEAWaD28pAJ3vnnrlRwJyEhFiz63vl5Jy9p1DA/DZxAblbVbvA9zIIJTpO pyRjF6DQW4Wo54YykxQ976Kt5jNwObcEhDG8EeVNgTLbSWqFH6Fy9/0BQV0Ej0CYZ529 FHSpAG/OkJwM/WwK8VqgimLtKgzvl9cKztO83sqqXhB4YUbTUc6EPUgUtCSW2GDsNXZv JxpA== 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=P5KVqXLt5HjkEJi3+UIClK4kf9tUwjBnrzMp6H4MTzQ=; b=P2ceHtnKgBA4m8AfX6iGAn2hEwIXoiqd5MtYf/U6T/MSVuHstkHn94kNr6FKqHhljZ AAVJaQcasMVuoT6O/yFbgAuLiOj2KSWnGY0Ttsz60IDd8fVKNqBHERzw9Rl5LFNkFGjd nM1Akon9LXansxR8DkMuDetQIO8aac/J/xQ9D1vSn2RlurMZiqnv7l+C0mY0vVQGdQxo 1WgI+/AtZVMX4TVGJzSqmRKjdXjLl7m1ourgz4lmdl9nRGaP4bVWlVZBlz+C5k1ZhNfk q43+jIWbMcj/I33HW7DKQJg97auQg8iJCM1KtlSWfU9QHzpemmvEE5WlLN1rV2j/H4y5 5J3g== 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 w12si6619826edf.351.2020.10.26.09.14.31; Mon, 26 Oct 2020 09:14:54 -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 S1775102AbgJZM1L (ORCPT + 99 others); Mon, 26 Oct 2020 08:27:11 -0400 Received: from smtp2207-205.mail.aliyun.com ([121.197.207.205]:35736 "EHLO smtp2207-205.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1775098AbgJZM1I (ORCPT ); Mon, 26 Oct 2020 08:27:08 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08011946|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0174674-0.00699969-0.975533;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047207;MF=liush@allwinnertech.com;NM=1;PH=DS;RN=11;RT=11;SR=0;TI=SMTPD_---.Iode2WR_1603715216; Received: from localhost.localdomain(mailfrom:liush@allwinnertech.com fp:SMTPD_---.Iode2WR_1603715216) by smtp.aliyun-inc.com(10.147.40.7); Mon, 26 Oct 2020 20:27:01 +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, Liu Shaohua Subject: [PATCH v3] riscv: fix pfn_to_virt err in do_page_fault(). Date: Mon, 26 Oct 2020 20:26:54 +0800 Message-Id: <1603715214-29082-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: Liu Shaohua 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