From patchwork Sat Nov 19 11:22:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qinglin Pan X-Patchwork-Id: 13049689 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 8BA9FC43219 for ; Sat, 19 Nov 2022 11:23:52 +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=+E+zQ/NF0OKcGtot9PWyaxwUxyEY1qam1zazpqqn5dY=; b=A1y03vIbvYeg+Q UGwijvh018wlZEUY54pZdIYAjzya+D/FtMTdxiz1EXatWvEvQOUwQZdNhpMUdYXadCB8YnWSBrOBr lMMCXv0vJXB/tIEhqlEzktp55HqkHzOuAjD5g3v+yC3wURUCV52KgushexN7PfAbAbdL6ykbGtX9Q YJiwz9guEjf1dAGmveJR6BqJEZcSETnVO7hOY/aHbzYU8KgVbxH72Hrs5wrtQbkBTuCHnKI/BB4oD J5sbRC7A3jMSGBQAZV+wjafAqs4d7c0rYcWB/exugHa9B7IWf1sUyUlko76ZuP7RUqpTVPdm1y3Tl Q7Y0R8Yzdvbaz8jgJU6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1owLwb-00DEsN-5m; Sat, 19 Nov 2022 11:23:33 +0000 Received: from smtp21.cstnet.cn ([159.226.251.21] helo=cstnet.cn) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1owLwX-00DEr7-DZ for linux-riscv@lists.infradead.org; Sat, 19 Nov 2022 11:23:32 +0000 Received: from localhost.localdomain (unknown [124.16.141.248]) by APP-01 (Coremail) with SMTP id qwCowAC3Oe2jvHhjlVkXAA--.8243S2; Sat, 19 Nov 2022 19:23:16 +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 v7 0/3] riscv, mm: detect svnapot cpu support at runtime Date: Sat, 19 Nov 2022 19:22:39 +0800 Message-Id: <20221119112242.3593646-1-panqinglin2020@iscas.ac.cn> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 X-CM-TRANSID: qwCowAC3Oe2jvHhjlVkXAA--.8243S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Kw1rZw1UJw43Jr13WrW3Jrb_yoW8ZF4DpF W5Krn3GF98Ar93GF1furyDurn5Jw1rKayaqw1xJ34UAwnxJFWUZ390yFnxC3WkXFWfXw4I kF45ZFW3ua4DZ37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvq14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4j 6r4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAac4AC62xK8xCEY4vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC 0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr 1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IE rcIFxwAKzVCY07xG64k0F24l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr 1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE 14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7 IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E 87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0x ZFpf9x0JUBSoJUUUUU= X-Originating-IP: [124.16.141.248] X-CM-SenderInfo: 5sdq1xpqjox0asqsiq5lvft2wodfhubq/1tbiBwcPDGN4L+ztbgAAsY X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221119_032329_870226_085AFD22 X-CRM114-Status: UNSURE ( 9.18 ) X-CRM114-Notice: Please train this message. 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 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 | 16 +- arch/riscv/include/asm/hugetlb.h | 34 +++- arch/riscv/include/asm/hwcap.h | 4 + arch/riscv/include/asm/page.h | 5 - arch/riscv/include/asm/pgtable-64.h | 34 ++++ arch/riscv/include/asm/pgtable.h | 32 +++- arch/riscv/include/asm/vmalloc.h | 61 +++++- arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 1 + arch/riscv/mm/hugetlbpage.c | 278 +++++++++++++++++++++++++++- 10 files changed, 456 insertions(+), 10 deletions(-)