From patchwork Mon Dec 12 06:55:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qinglin Pan X-Patchwork-Id: 13070760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D033C4332F for ; Mon, 12 Dec 2022 06:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fwnyd54U3zmM9TGDl3+Ug/JCyz7/JxaJ82wKfi4zKr0=; b=NYNU6M1JCXdAgQ oDzsGO7oauTbHv54AI+ou4d/VBr/q/tJfC9wrBfA/IRfEDoEMsMuz4QtDvDpmXxDwOJIlbMgUDynO 0bd1XvC41Ex1pEksF8ZSrvb5MSxL1mAEbmfnOwP2tO29wByWa5IG8GfJWm6lKVstOTuozh6SvTHJO 3mgZOACF4lheB41NPlFH7sGnyfj/Fn/siBoy7JymiVhwuyD0rlLW54f2zeNPZBy7nCnTDsq3wFAiU tSZa8zqLBtTKwFaoMN6r9zmYFklEciafQzIWSJt+/3gDl9A2XhBrMcOPsD9qw2JsaubbVRppxFRkB +a5RBt1CNGIAU7NsGoMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4cjF-0096bz-9m; Mon, 12 Dec 2022 06:55:57 +0000 Received: from smtp84.cstnet.cn ([159.226.251.84] helo=cstnet.cn) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4cj8-0096OQ-B9 for linux-riscv@lists.infradead.org; Mon, 12 Dec 2022 06:55:54 +0000 Received: from localhost.localdomain (unknown [124.16.141.248]) by APP-05 (Coremail) with SMTP id zQCowADn7Oxo0JZjZRqoBg--.60491S2; Mon, 12 Dec 2022 14:55:36 +0800 (CST) From: panqinglin2020@iscas.ac.cn To: palmer@dabbelt.com, linux-riscv@lists.infradead.org Cc: jeff@riscv.org, xuyinan@ict.ac.cn, conor@kernel.org, ajones@ventanamicro.com, Qinglin Pan Subject: [PATCH v10 0/3] riscv, mm: detect svnapot cpu support at runtime Date: Mon, 12 Dec 2022 14:55:23 +0800 Message-Id: <20221212065526.805233-1-panqinglin2020@iscas.ac.cn> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 X-CM-TRANSID: zQCowADn7Oxo0JZjZRqoBg--.60491S2 X-Coremail-Antispam: 1UD129KBjvJXoWxWFWrAF1DKF4xKrWrGFW3Wrg_yoW5Gry7pF W5Grn3GF98Ar93GF13ur9F9r1rJw4rKFWaqw1fJ34UAwsxJayjvws0kF98C3WkXFWfXa10 yF45ZFy7ua4qv37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9q14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr 1j6rxdM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVAC Y4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJV W8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI2 0VAGYxC7M4kE6xkIj40Ew7xC0wCY02Avz4vE14v_GF1l42xK82IYc2Ij64vIr41l4I8I3I 0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWU GVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI 0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0 rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r 4UJbIYCTnIWIevJa73UjIFyTuYvjfUeAwIDUUUU X-Originating-IP: [124.16.141.248] X-CM-SenderInfo: 5sdq1xpqjox0asqsiq5lvft2wodfhubq/1tbiCQASDGOWle+uBAAAsy X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221211_225550_810632_93271951 X-CRM114-Status: GOOD ( 10.33 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Qinglin Pan Svnapot is a RISC-V extension for marking contiguous 4K pages as a non-4K page. This patch set is for using Svnapot in hugetlb fs and huge vmap. This patchset adds a Kconfig item for using Svnapot in "Platform type"->"SVNAPOT extension support". Its default value is on, and people can set it off if they don't allow kernel to detect Svnapot hardware support and leverage it. Tested on: - qemu rv64 with "Svnapot support" off and svnapot=true. - qemu rv64 with "Svnapot support" on and svnapot=true. - qemu rv64 with "Svnapot support" off and svnapot=false. - qemu rv64 with "Svnapot support" on and svnapot=false. Changes in v2: - detect Svnapot hardware support at boot time. Changes in v3: - do linear mapping again if has_svnapot Changes in v4: - fix some errors/warns reported by checkpatch.pl, thanks @Conor Changes in v5: - modify code according to @Conor and @Heiko Changes in v6: - use static key insead of alternative errata Changes in v7: - add napot_cont_order for possible more napot order in the future - remove linear mapping related code from this patchset to another patch - refactor hugetlb code for svnapot according to thanks @Andrew @Conor - use tools/testing/selftests/vm/map_hugetlb as hugetlb testing program - support svnapot in huge vmap on newer for-next branch Changes in v8: - fix compilation errors in rv32_defconfig - insert some lines of whitespace according to @Conor's suggestion Changes in v9: - use alternative to avoid using static branches inside heavily used inline functions - change napot_cont_mask definition - post test_vmalloc modification about testing vmalloc_huge Changes in v10: - fix some nits caught by @Andrew - collect Reviewed-by/Acked-by - add memory leak warning in KConfig text - replace test_vmalloc patch link with the standard one Qinglin Pan (3): riscv: mm: modify pte format for Svnapot riscv: mm: support Svnapot in hugetlb page riscv: mm: support Svnapot in huge vmap arch/riscv/Kconfig | 20 +- arch/riscv/include/asm/errata_list.h | 15 +- arch/riscv/include/asm/hugetlb.h | 34 ++- arch/riscv/include/asm/hwcap.h | 2 +- arch/riscv/include/asm/page.h | 5 - arch/riscv/include/asm/pgtable-64.h | 34 +++ arch/riscv/include/asm/pgtable.h | 43 +++- arch/riscv/include/asm/vmalloc.h | 61 +++++- arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 15 ++ arch/riscv/mm/hugetlbpage.c | 301 +++++++++++++++++++++++++++ 11 files changed, 518 insertions(+), 13 deletions(-)