From patchwork Fri Feb 24 10:40:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Jhong X-Patchwork-Id: 61274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp840192wrd; Fri, 24 Feb 2023 03:07:44 -0800 (PST) X-Google-Smtp-Source: AK7set+ZiUG9A/ay4dl4UyHoDFLRhpFBfRtvDs8FvAl7aW8VgKSPUyKbz3Uh5HRIcvrMDN5cJhxc X-Received: by 2002:a05:6402:4024:b0:4af:6227:763b with SMTP id d36-20020a056402402400b004af6227763bmr9489865eda.18.1677236864814; Fri, 24 Feb 2023 03:07:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677236864; cv=none; d=google.com; s=arc-20160816; b=GCmRiVR9vosoDlxZNQiWdcxc+QN/Hiun1xYZhhNTmR0f2Lo/PL6sQIBx6EHFn2Gn5f 6SCwPlYnWgk/TzaASwYDlU13wwSNvO6BTcjcoYsrhv8jAVfLRroHZiMebqZOB0yg7tmY m0qQFdvhicr/+t1ZPsyZSOe70HYBzKnvlZyHf0v6FhYz3FBeaRsRRjOiBhuz+VFnTKiy Ir6Ia9/7hZ4zAKkhd3jq6fbE1k0AHbIFeqJsxAmKvtUDBaq6cptHWB/e2MKrRLZHS2B/ K9vFHq4wuxRZ3Y2eJordIMThq5bS6HzgN62VOR2wJ4NiQ6sWCOFkwkXxvSMseq3WoOZX Xrfw== 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=xoJu5pMkCqiPcgKvH52UNtlDR679BrOZiiYAs+R2KqY=; b=PtW1ZrMOgdL1+43oaZnP8pIVgQ9m4R+HKezYZROAWT299sMnmysyiT2neYk4StUp6g tNLOIBuEkNFz6hiuP0klzP2WDoe4ZWJ0NZMJCw8Z6xgIaNYd3Op84ieDdrF05GJvxE9P ppXJpDsOcx+j1SY8sivceiYicbz2ZcT/rJiLDjC97/mYPC8duSJHc3b2oWIzqp228m5v qhMQgv9mcI8vUCZaam14yhiQfbW7Q3HnySPWMucyUsgTH1oezt4OngS5AnG3hlBcEtMs R6pdJyFHnYW0ld4+789+0BVaRPojM3R/dxDTDMOQpHEBSKFMv7FCQJvzyeVssv1LcGq0 kJbA== 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 vw17-20020a170907059100b008d2606e415dsi14671429ejb.708.2023.02.24.03.07.21; Fri, 24 Feb 2023 03:07:44 -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 S230343AbjBXLCZ (ORCPT + 99 others); Fri, 24 Feb 2023 06:02:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbjBXLCA (ORCPT ); Fri, 24 Feb 2023 06:02:00 -0500 X-Greylist: delayed 1212 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 24 Feb 2023 03:00:33 PST 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 A233425297 for ; Fri, 24 Feb 2023 03:00:33 -0800 (PST) Received: from Atcsqr.andestech.com (localhost [127.0.0.2] (may be forged)) by Atcsqr.andestech.com with ESMTP id 31OAeLfr055962 for ; Fri, 24 Feb 2023 18:40:21 +0800 (+08) (envelope-from dylan@andestech.com) Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 31OAe6bd055911; Fri, 24 Feb 2023 18:40:06 +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, 24 Feb 2023 18:40:05 +0800 From: Dylan Jhong To: , CC: , , , , , , , , , , , , , , Dylan Jhong Subject: [PATCH] RISC-V: mm: Support huge page in vmalloc_fault() Date: Fri, 24 Feb 2023 18:40:01 +0800 Message-ID: <20230224104001.2743135-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 31OAeLfr055962 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?1758710322954017608?= X-GMAIL-MSGID: =?utf-8?q?1758710322954017608?= RISC-V supports ioremap() with huge page (pud/pmd) mapping, but vmalloc_fault() assumes that the vmalloc range is limited to pte mappings. Add huge page support to complete the vmalloc_fault() function. Fixes: 310f541a027b ("riscv: Enable HAVE_ARCH_HUGE_VMAP for 64BIT") Signed-off-by: Dylan Jhong Reviewed-by: Alexandre Ghiti --- 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); }