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: 13169044 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03E43C6FD19 for ; Fri, 10 Mar 2023 09:45:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AB226B0072; Fri, 10 Mar 2023 04:45:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 634766B0074; Fri, 10 Mar 2023 04:45:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AE546B0075; Fri, 10 Mar 2023 04:45:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 353CC6B0072 for ; Fri, 10 Mar 2023 04:45:48 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E5D26121334 for ; Fri, 10 Mar 2023 09:45:47 +0000 (UTC) X-FDA: 80552506734.08.816DDA7 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by imf02.hostedemail.com (Postfix) with ESMTP id 11B9180005 for ; Fri, 10 Mar 2023 09:45:45 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b="mw/Jcuak"; dmarc=none; spf=pass (imf02.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678441546; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=UftmAx9eMUlUVZ1zG+blrWbVPdUhF6IePoR+esHHRyE=; b=C+kItq/92u3zmou0dQLMUbyLlRqr8ocJjorz8DsT76qOiIr1Xyz60JgY+gwlDA1CtlrTus dz68L2Vq/roc5R7aWzXpEPeZbta28S+3xOin9vpwFiyQRGnPCyzxbHGhLMLEaHjZ7eJI+h Eb7tsblfzfIbK2w+XLgTYuM0MXpLqog= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b="mw/Jcuak"; dmarc=none; spf=pass (imf02.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678441546; a=rsa-sha256; cv=none; b=0PJt6fDwThZMFcQzsEOJoCxPFKM2JypFBHg9sB8cc7mP8G5Q6YiGwM7zbDZZ3UviGZ19ju qmu5E8TOwoKuG8TZuvjazGeqR9Qfv7nF/Y2OPBVxo72/PwS5v1X2+LoWmfCUSYOH/wGjuO z4ZdXJWrDPdXNXFcWG30s+yzBFK6mxg= Received: by mail-wr1-f48.google.com with SMTP id e13so4441680wro.10 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=burKpiQGYvhMr6+Yi8BUn/TG4Vt1kwo8IlnTBab6EghjfrB6qABd6D/03XiCv6sBfW TL10x03ddX+GpTJEbKwdGa88ny85udApguyNt3kQlXdjpU+6ARBJlqA8mf+3BLCmuxs1 dyKzU31FB/hSIi01HsuJwjsmQEprdFRz9joDjIcVSnv0f5YLKqiPfkoA+BbYl8RxBgIO quctndSTVj/SJmHDyFdCh9QbvibxpS6wP6HQEK9T0FaA1JfwlDpy2a8yTjZY17fuVGAv m+cUt9TJTMKvy8Ccr3JeZnU4QtlPlrNCpO/rlc+V9ieNt2sgSpO1hKDKk7tbR5sFG2ht nQWQ== X-Gm-Message-State: AO0yUKVOq22sovKxPsBVQenWmId2tBDU8QgnvZ8j8C7NVb1WlrPPw6+t YUNQgYV6pkWHPvR+oq94ByS3rg== 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-Rspamd-Queue-Id: 11B9180005 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: jiboidtmfsarfd6jq11tsmxstfwgzyae X-HE-Tag: 1678441545-923112 X-HE-Meta: U2FsdGVkX18zllRyLRgYSJimtv3DAPEYbVRmL8nXp2bl54PrEOWFnMd0Y8Btfdpgi1DMRznnnarlggH1M5yHGHBG4FMRzA7O0Qeyv+p/X6n8UOk9bOXL8+NntHXl9IQ/zV+muDrZVp2JrxGxd8rBkvG4701VxwT1bfbTpkBSG7geXkzqqQj5OpinjSuezEG3zymFahELnZyw5tWlvXzAV64N683PKMuzAcYOZtNA6sw8lVZviOfLbZjXZ01Yc1z1CymJbyjTVJAe28By2rNoGa9nS7zyzacrRxwGvlhSoDwCf+dnY1p1T9ol/DlRe6dvRDq6HOy20tkrcG1LJCXKnaw4p8GTKuaJwB4K5WA8D6jTF0eFSpJ0m6ggV/9GTa2l9Wk8aza7V/F/ijioHcWLVezgfGM/p+s67NyzXH4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.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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