From patchwork Thu Mar 16 13:17:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 13177728 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 B91ECC6FD19 for ; Thu, 16 Mar 2023 14:31:47 +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=jx+MI64O96D3aUgdGvKyZcCaD1bfuYBueIcWvox7l90=; b=3aAp2aB7a2lAMY 6QBpYqSlidvuPeUfA6cTasCA/G1U6c5x8vgYueHPWL67VgZttcr9fFkQNljtLX5vDbyeEj4KD5y/y sL1L1qfERdlOHKKVRI+T1PnGieFiH97JU1CTohFDr7x7Fl9ukyldfeniG9Vd7EbSZ/R1/FWHGu5kD sKyYwAmmbjYoz5bZwPeuy/lzPNBw12pryMPXsC690Kw8RFDX5DAcOuiAtoPAxTRApe6w8P1gdLUO4 cyyjhSAaWNqEI9/+lghFTU8F2LyRB/pPjEXlFEidHOvojCweJY8yldBagSJ/KCSf55WMF83MkT7Ib vQs/+MqVSuqCYK3t1NsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcodF-00GgwO-34; Thu, 16 Mar 2023 14:31:05 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pcnTt-00GUoy-0Q for linux-arm-kernel@lists.infradead.org; Thu, 16 Mar 2023 13:17:23 +0000 Received: by mail-wm1-x32e.google.com with SMTP id p23-20020a05600c1d9700b003ead4835046so3461258wms.0 for ; Thu, 16 Mar 2023 06:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1678972636; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yb0JNi6cRDb5cM5WC9CEwD00CUTLKwtDAX0RcxE9c8c=; b=2Ev7aL6Z6zhWHuGqPE5WRugL+grtCgf1Rw+DE5yPncJqWsJZHaCBhlqpfyHHzrwI1D IUpoT5Oj2+AxeGLsJn0E0MGbjKM4v8gxIxDStGUIXy02nc+EgqABDoYG/hOTYXCiYSOG iJXRweRTFhgYGpwr8xQprpP8UgTS76aclNF9Q88Vn0eLPUVtmLtJpd6cV7LoVTHbBvrh 1q5XhWPVPnaXpKPzJ2vWiPfcyS8XnUsHIEUE5rYpgUMCG70N6PMSUo4+vx3GXuGIPvt/ V4QCyObIV+J3zkqwYafQgaQwhM6mcbbbhcaBTGh3Ec5hqKIhtCwzq3Y8iM8EHnAJ0VUh gAdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678972636; 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=yb0JNi6cRDb5cM5WC9CEwD00CUTLKwtDAX0RcxE9c8c=; b=aqa5vz+iW9VFEN3MGZPMAqMGuwnETSsws0Lebzi/427A/M7y2Yl8ykl2+1Mg3pN6Ew EnV5AfgytvHLDgRRVH7vK3/Jzi9bWDfo51nTUv5siWs2j0nTQI6/Zevie8ffykyL71KK dVzQfSMc9c0IgqfQJRkhTA2eyGrxX2tCZNaWEyX9owF8k+4cQ2+5dBGKA5JdD3aJdj8l ps7LNqAYr4U6IIKudmf4u0qKJQX5YCvFzAeOVwIZE8lh6aDnvA87VtP9DfKvDWp7pxjy dSrQ0iauAll/UZ4JLZcWcGB+hztykTnQ30YZ2sw79XFcnk+I66S7tCpbAdj34yufpCZ8 PVmg== X-Gm-Message-State: AO0yUKUjr8Bb1m1nHcA3ULGe8Pk4yH0y4JC2AvDlIFNLkmg3uR74ya0F 5kUtZW4FVN4NO7SoDUw3metOpQ== X-Google-Smtp-Source: AK7set/fhVDeuPDPVeUXVE63TtFOQa0R+UvB04ejBiBb1VAkOz3jRjT1WOxKNz9X4Jff53YqrdofPA== X-Received: by 2002:a7b:ca41:0:b0:3ea:f75d:4626 with SMTP id m1-20020a7bca41000000b003eaf75d4626mr21011181wml.38.1678972636633; Thu, 16 Mar 2023 06:17:16 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com (238.174.185.81.rev.sfr.net. [81.185.174.238]) by smtp.gmail.com with ESMTPSA id a6-20020a1cf006000000b003ed4f6c6234sm1963364wmb.23.2023.03.16.06.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 06:17:16 -0700 (PDT) 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 v8 0/4] riscv: Use PUD/P4D/PGD pages for the linear mapping Date: Thu, 16 Mar 2023 14:17:07 +0100 Message-Id: <20230316131711.1284451-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-20230316_061721_387358_56B0EBFE X-CRM114-Status: GOOD ( 18.03 ) 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 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 (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 | 25 +++++++++++------ arch/riscv/include/asm/page.h | 19 +++++++++++-- arch/riscv/mm/init.c | 53 ++++++++++++++++++++++++++++------- arch/riscv/mm/physaddr.c | 16 +++++++++++ drivers/of/fdt.c | 11 ++++---- include/linux/memblock.h | 1 + mm/memblock.c | 20 +++++++++++++ 7 files changed, 119 insertions(+), 26 deletions(-)