Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1326879rwl; Fri, 24 Mar 2023 09:05:54 -0700 (PDT) X-Google-Smtp-Source: AKy350YHEmlqA4Zwvo7QEkDcklDx+1eABkxyPilprTEpAM8zhZOE+61Ka5qZS9PfQnolxFlQYKKb X-Received: by 2002:aa7:d582:0:b0:4fd:14d5:bb47 with SMTP id r2-20020aa7d582000000b004fd14d5bb47mr3352054edq.38.1679673954652; Fri, 24 Mar 2023 09:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679673954; cv=none; d=google.com; s=arc-20160816; b=iB3X6R8YykEO3LdPZvVxU3NWQumYx6UIfj/KShYdEoqWtetTxASzfuLmnYi6sNZGuS L1gdLEdWZnhF3YwFtwazyA5liNMLZvwhCi+yyc1gN2Zu7XxXPje+5EYSMdgb+Cqt8Q2d gCmpijUgWzJ50LP4HqRK9FF3SQRn0WIUeZtxulaSedoS+Q0rtFpK2fHgZJE1ax6tOVgX FxHDLSRip8f9OYO0t8R4S7PzJvuCW2MlueIfblpvchZd/NwtpRPKZajBugtyGjLH+cXO /eH2fpwBNSGv1G3CoOD3xqOL+H3mGukpO4HtDufTfzUSAzE0WcW5Ln1EnfMRdcHrHl+b V7MA== 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:dkim-signature; bh=b6Ngv7vLHp3FF75hEwebNFD1hG5vOf7sA7KcWcOgjlU=; b=oW9kUn1LkTF3l54QwcIerXosqJkpcZ+Q/nox2uxG4/IFWlWAAgR7I4swyQfCu05ZHg FqWL3rt8pqTO9cTr/8ns+nlap7ocQlXeAiIOo2ujnMZYtxRR/QJPQHcVi7G9k3H3YGO8 3c5s2p5nFCiziQkzbg9avJ09UWiXD0d7L2gtcUcCFO2whETZq3Q4T4ibiPI/9xSIHbO7 ur9Vsv6FljPvM9VpT4IRO9Mm2wLIZuXZUZPX60rd4yoQcIf57P/ecPB/eRoi+jAPGxKV UfuHQycnBn/f7KVJD5ZOVLSRDfgWEhE3uoJrZoFp7t2VU9D//Aq9kMErNsgICTwZX7o8 o83Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b="Hxv6mt7/"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d18-20020a056402079200b004af5fff1c7asi20253557edy.214.2023.03.24.09.05.29; Fri, 24 Mar 2023 09:05:54 -0700 (PDT) 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; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b="Hxv6mt7/"; 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 S230192AbjCXPye (ORCPT + 99 others); Fri, 24 Mar 2023 11:54:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229938AbjCXPyc (ORCPT ); Fri, 24 Mar 2023 11:54:32 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C630D18ABC for ; Fri, 24 Mar 2023 08:54:30 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id i9so2309783wrp.3 for ; Fri, 24 Mar 2023 08:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1679673269; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=b6Ngv7vLHp3FF75hEwebNFD1hG5vOf7sA7KcWcOgjlU=; b=Hxv6mt7/oyXVS542hr3tqu/KjMizfnZiF3ALCk/BGy17uinbxGYwY4yRdCGwqIKNhL VkVy6Thgx2At9vVvRGgE9qgzmQ5mR/xjCpmN/bHeww50tZUpfmYSR1kbB74EgvyACQwZ OmRB8HrsCvaHz5Csly8l0V0FF647Nl0tPNl0iFimG4bJrfgO5zp+dKX4G+9qmROVWYl8 p6K30LzQV9ghXpJYXaTI8z7oPHA+DjAGwrcjK4KnXvlhRylYVpU/w0vItaMNJERluM6k ErUIUVFSgf+Vsq7TLLx0tF2uMMcURF3enyxnN7GCJ3qSZyLIBR/dk6+HddWxeS4A0Bok Pp/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679673269; 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=b6Ngv7vLHp3FF75hEwebNFD1hG5vOf7sA7KcWcOgjlU=; b=2SEXgjj1dm8BZLYjI1oFeOLTCkQfLBlJZByS3qyio4CAwF+uYq32RJLUx58626rKXP IoMbRzTlY6vk5WJOICbiYEh7yYonWN1xLBWee8sNzxYmje+uW3Kw95GLnbkb9b5lkUzf NmFJLEKXZHN+/sumzPsT+XvkXiMhVFEx8o35LVWec4zGgg3jDg5Mjij3QJBGo3xe2wRv Yd7P/X3KgHAcaynEqC2osNRHFTPKreSkl9/ZhRCbp9tOdSscYKAFK50rpKyc+CUt9ogh VfVuctDEs8j3ttxBkG7GBoawVWFGL9MsJC+Qz4vOS1VAPOdKvKp07kDBYNJSPWPEgYnf R8qQ== X-Gm-Message-State: AAQBX9dDA1OCW8/FqiWZ5XOR+995eHt1XARLpRGE7R3VjHZUdscIEpY3 gvIPFx+2Ovyc5HnZAVUjksP6SA== X-Received: by 2002:adf:e3cd:0:b0:2cf:f467:54d9 with SMTP id k13-20020adfe3cd000000b002cff46754d9mr2664167wrm.53.1679673269318; Fri, 24 Mar 2023 08:54:29 -0700 (PDT) Received: from alex-rivos.home (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id p5-20020a5d4e05000000b002d75909c76esm11767972wrt.73.2023.03.24.08.54.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 08:54:29 -0700 (PDT) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Rob Herring , Frank Rowand , Andrew Jones , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH v9 0/3] riscv: Use PUD/P4D/PGD pages for the linear mapping Date: Fri, 24 Mar 2023 16:54:18 +0100 Message-Id: <20230324155421.271544-1-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 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 the same way as arm64 by using the memblock nomap API which isolates those regions and re-merge them afterwards thus avoiding any issue with the system resources tree creation. base-commit-tag: v6.3-rc1 v9: - Remove new API and arm64 patches as it created more issues than it solved, thanks Anup for reporting those bugs! - Add a patch that moves the linear mapping creation outside of setup_vm_final - Use nomap API like arm64 - Removed RB from Andrew and Anup as the patch changed its logic - Fix kernel rodata size computation v8: - Fix rv32, as reported by Anup - Do not modify memblock_isolate_range and fixes comment, as suggested by Mike - Use the new memblock API for crash kernel too in arm64, as suggested by Andrew - Fix arm64 double mapping (which to me did not work in v7), but ends up not being pretty at all, will wait for comments from arm64 reviewers, but this patch can easily be dropped if they do not want it. 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 (3): riscv: Get rid of riscv_pfn_base variable riscv: Move the linear mapping creation in its own function riscv: Use PUD/P4D/PGD pages for the linear mapping arch/riscv/include/asm/page.h | 19 ++++++- arch/riscv/mm/init.c | 102 ++++++++++++++++++++++++++-------- arch/riscv/mm/physaddr.c | 16 ++++++ drivers/of/fdt.c | 11 ++-- 4 files changed, 118 insertions(+), 30 deletions(-) -- 2.37.2