From patchwork Fri Mar 10 09:45:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 13169057 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 64092C64EC4 for ; Fri, 10 Mar 2023 09:46:45 +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=gQr2q+kfvgDNVyW+O/9Qs+5diuNeuE7lWKPUENEPc5I=; b=e0uBj/fxEDtO/n K2pcofM4Lso8AVgM6ELieNrVrvYLGdML3oZoLr18j6O593Ttpzmm0VZtsBe0jpEw7uumZ1nBHHwaQ tNdBZ23TMWOsM6RpGOQ58zsHLGbFh9HWc3SoaYuHIcaiY9O7g9Il1A3pK3cZaTHVlaaObfLE7K4aC U3jWKCHHuNXjR1N++AJ31EkBuVS5p1tXBTe9hG59IKCI0kGrD+WTmDyX3jh65RvgBMtYLAf7kAx6V j9TiNQk/jye9RJj5vROH9a7XLqdzQWEeMCGBzjjKQ96TkGZWzoDQ5ZxPQI90M4ZWzln9k/wsEyyxk Av0Ae+MCuUq2gySojCqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1paZJx-00E0qo-BH; Fri, 10 Mar 2023 09:45:53 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1paZJt-00E0oh-1F for linux-arm-kernel@lists.infradead.org; Fri, 10 Mar 2023 09:45:50 +0000 Received: by mail-wr1-x42d.google.com with SMTP id q16so4468270wrw.2 for ; Fri, 10 Mar 2023 01:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1678441544; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UftmAx9eMUlUVZ1zG+blrWbVPdUhF6IePoR+esHHRyE=; b=mw/JcuakIGznshhAisrjTRMD8Po1tDitbLm42cReJ+D5WwLSfKHow3B63jzrH5HNzg im0RBmwfWgltbaAWUJfikpey3379n7iZgcZV1xayELAh3GVtZKo9jw2i4oYXXL0/h3FX vnKMl9pnCxls1xtoHkwRsxR73kAA1NnZ0Uvi9JFZokS5Oul8vNx2CdfxWCg25vVTzULy /bL073+f9A0eCN03cbNr92x9ZQW1JVyhrVWHsaHy3G8YR4nIjwpNNqi8F/5MyxOjpXv8 IaWEpDsI+7aC3l8hLqSbbjhgSsESc6VIiplKe/ZqliiM6bRlTKclTHaj6U36MU59E2zp tHjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678441544; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UftmAx9eMUlUVZ1zG+blrWbVPdUhF6IePoR+esHHRyE=; b=0vIE0RWIkG7dUseQXjbTMy3EbSFUs/5yYqu/DtHy2VVdXhPXh+kAmJWwtY2KVLz1jc ETaFubRjoFugLQK3r/4NOfucANHR3VyyGiKhxuR2bAjVXxEpWlm/bWc+Fu7w4KPZ/1/k dODTjoVBPgtR1GGNLtCsEWgsvSankCfIbL0pMFcCI8MVLJFmSC0kFnn46UrM8eZ7zG1P +kY4/ICdVrFtSHOOGcPFDndSR2EQY2dghx5SpT+SXtQGCsOD7fhhyYaH0LzxD+gDwZwB Z8SPpzcN0VxhpKzCRpiagywFq+12PzPunbhSc05wjpmoBZyRdHPjPaPfQas3bevHVg5Y ILjQ== X-Gm-Message-State: AO0yUKWd+QvGqb4XfAEmvMzrxltk0t7e1mR1mBMKbBQaT4/a705PykMD 0ia6yKw5Y35S4VitO6MVWgVY+g== X-Google-Smtp-Source: AK7set+348Cnhg9OopXRYq6mmFzZ+O41Mzkm9zWAs2amuAeiaWL8WS531F/GY1Nq+XByYlhgrJNy4g== X-Received: by 2002:adf:fbcc:0:b0:2c7:bb13:e23f with SMTP id d12-20020adffbcc000000b002c7bb13e23fmr16291966wrs.24.1678441544476; Fri, 10 Mar 2023 01:45:44 -0800 (PST) Received: from alex-rivos.ba.rivosinc.com (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id r7-20020a0560001b8700b002c7163660a9sm1646775wru.105.2023.03.10.01.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 01:45:44 -0800 (PST) From: Alexandre Ghiti To: Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , Rob Herring , Frank Rowand , Mike Rapoport , Andrew Morton , Anup Patel , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-mm@kvack.org Cc: Alexandre Ghiti Subject: [PATCH v7 0/4] riscv: Use PUD/P4D/PGD pages for the linear mapping Date: Fri, 10 Mar 2023 10:45:35 +0100 Message-Id: <20230310094539.764357-1-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230310_014549_311774_A9C25F47 X-CRM114-Status: GOOD ( 17.18 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patchset intends to improve tlb utilization by using hugepages for the linear mapping. As reported by Anup in v6, when STRICT_KERNEL_RWX is enabled, we must take care of isolating the kernel text and rodata so that they are not mapped with a PUD mapping which would then assign wrong permissions to the whole region: it is achieved by introducing a new memblock API. Another patch makes use of this new API in arm64 which used some sort of hack to solve this issue: it was built/boot tested successfully. base-commit-tag: v6.3-rc1 v7: - Fix Anup bug report by introducing memblock_isolate_memory which allows us to split the memblock mappings and then avoid to map the the PUD which contains the kernel as read only - Add a patch to arm64 to use this newly introduced API v6: - quiet LLVM warning by casting phys_ram_base into an unsigned long v5: - Fix nommu builds by getting rid of riscv_pfn_base in patch 1, thanks Conor - Add RB from Andrew v4: - Rebase on top of v6.2-rc3, as noted by Conor - Add Acked-by Rob v3: - Change the comment about initrd_start VA conversion so that it fits ARM64 and RISCV64 (and others in the future if needed), as suggested by Rob v2: - Add a comment on why RISCV64 does not need to set initrd_start/end that early in the boot process, as asked by Rob Alexandre Ghiti (4): riscv: Get rid of riscv_pfn_base variable mm: Introduce memblock_isolate_memory arm64: Make use of memblock_isolate_memory for the linear mapping riscv: Use PUD/P4D/PGD pages for the linear mapping arch/arm64/mm/mmu.c | 4 ++-- arch/riscv/include/asm/page.h | 19 +++++++++++++++-- arch/riscv/mm/init.c | 39 ++++++++++++++++++++++++++--------- arch/riscv/mm/physaddr.c | 16 ++++++++++++++ drivers/of/fdt.c | 11 +++++----- include/linux/memblock.h | 1 + mm/memblock.c | 22 +++++++++++++++++++- 7 files changed, 92 insertions(+), 20 deletions(-) Reviewed-by: Anup Patel Tested-by: Anup Patel