From patchwork Fri Mar 10 07:42:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Jhong X-Patchwork-Id: 67259 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp742802wrd; Fri, 10 Mar 2023 00:06:12 -0800 (PST) X-Google-Smtp-Source: AK7set8CRdAheWHNOUsqlcxXbwqSDKRFLjjqqzvjk1sqOS+EYiNUKNYEOlJoIZ7Hdi+VlJn7LDSI X-Received: by 2002:a17:902:ebc4:b0:19d:461:9628 with SMTP id p4-20020a170902ebc400b0019d04619628mr27298784plg.34.1678435572584; Fri, 10 Mar 2023 00:06:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678435572; cv=none; d=google.com; s=arc-20160816; b=aYqPkoqhRhQdnzJrT9wJJBfjZg+3WnYrs+gXbYgJEAIIQmhA3EC7QWuZUpilVICGME j0jDjbP/+Ux1x1w0vLuzWCxTRlE7BO9SZzGYMpn7C5Etafw3ptbHkf/zplpZZ9AfvT9F No4gRPlkqJM4Tth9zKET8Cw/iBTy8NyXnzPa7DYEUdJGYBqS+StIwO3Za6hSIoZ2h98B DBrGlYHLe5Cd8pkepcieJDsuPTXSyamxAHvLrUeE2QjBWd+JahtBpmBTdagYaJXPvmWz A/vDI/A8D706i5XWPqU0vXsaNqk0unRdJm2YUHp3Mh2d3VtewPLVEt3LPenkFjTC4W2U YFzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=0MerH8W3aAbjq2lWnecIpQ6rv5mWZ/GI7826R1k62jw=; b=Z7qK+hkYZLIsW9hZCEBQl7ZgugKz0wN3C7K/UywJVIYkDOEiZVm/Ap+cBV9nf8myNP UVLSlhJaHgJOF0tem2IaZRg4A6i75wXaz1/vPplLBSV88VfUzwBV/J3Af+y/K31Z1qwy l6jkEu3DDQp8sCvB4kjzbCNIUE6XyK/LNRxqEl2YNuhjx6s/C94y5VHhWFJ/N6Atvnc5 57SuYMiUjs6jKZa6BH/QcyZ7+tqY36L59UA4TzgB1Rg489mJctjqFNtr9w9yZAsg68wN ZeXA8caGfcKZLb9PFLowLd/t79ND2DapS8VTqB3iUeAdPQU82cJIhkV085MbZoiZhmNG gM4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kt4-20020a170903088400b0019e9e57f92esi1458716plb.571.2023.03.10.00.05.54; Fri, 10 Mar 2023 00:06:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230444AbjCJHpU (ORCPT + 99 others); Fri, 10 Mar 2023 02:45:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231168AbjCJHo5 (ORCPT ); Fri, 10 Mar 2023 02:44:57 -0500 Received: from Atcsqr.andestech.com (60-248-80-70.hinet-ip.hinet.net [60.248.80.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA174F691F for ; Thu, 9 Mar 2023 23:43:31 -0800 (PST) Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 32A7gvni045789; Fri, 10 Mar 2023 15:42:57 +0800 (+08) (envelope-from dylan@andestech.com) Received: from atctrx.andestech.com (10.0.15.173) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Fri, 10 Mar 2023 15:42:54 +0800 From: Dylan Jhong To: , CC: , , , , , , , , , , , , , , Dylan Jhong , Dylan Jhong , Alexandre Ghiti Subject: [PATCH v2] RISC-V: mm: Support huge page in vmalloc_fault() Date: Fri, 10 Mar 2023 15:42:52 +0800 Message-ID: <20230310074252.3853262-1-dylan@andestech.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.0.15.173] X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: Atcsqr.andestech.com 32A7gvni045789 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,PDS_RDNS_DYNAMIC_FP, RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759967258833449689?= X-GMAIL-MSGID: =?utf-8?q?1759967258833449689?= Since RISC-V supports ioremap() with huge page (pud/pmd) mapping, However, vmalloc_fault() assumes that the vmalloc range is limited to pte mappings. To complete the vmalloc_fault() function by adding huge page support. Fixes: 310f541a027b ("riscv: Enable HAVE_ARCH_HUGE_VMAP for 64BIT") Signed-off-by: Dylan Jhong Reviewed-by: Alexandre Ghiti --- Changes in v2: - Fix format of commit message --- arch/riscv/mm/fault.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c index eb0774d9c03b..4b9953b47d81 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -143,6 +143,8 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a no_context(regs, addr); return; } + if (pud_leaf(*pud_k)) + goto flush_tlb; /* * Since the vmalloc area is global, it is unnecessary @@ -153,6 +155,8 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a no_context(regs, addr); return; } + if (pmd_leaf(*pmd_k)) + goto flush_tlb; /* * Make sure the actual PTE exists as well to @@ -172,6 +176,7 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a * ordering constraint, not a cache flush; it is * necessary even after writing invalid entries. */ +flush_tlb: local_flush_tlb_page(addr); }