From mboxrd@z Thu Jan 1 00:00:00 1970 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 0ABCAC5DF8C for ; Sun, 23 Aug 2026 11:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To: Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject: 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=Lrb3AaG5i4+pyOfjbgQo+jz5A6PG6nAPFo2gdyz4uew=; b=lDGItIe/SV4Rkx tTOzsy43kO/G8LOn635tcEpBGpQO0YdWt70RZrEpSkQGYKqw/PPFha9N0IstRv1qPK93HxsIJbEIz QobNNHK2QE1KK85PLaQJ5zW0XUoRC4RjKytOELmyBsvldD16R8ySl4f0pFd2bCkvlaupgDb+bnaHV xB3dmDrhue/+c5v9AtuY6+eqMfgfCgbPepqmqXAhPXHOgScjZf33W+71tW5nE6/GVQFII9JpUdpYt QCvSII12eodtyePHnBUtK1Ii/cnWbPC8JCzYToC+qUs/fQ1EI6PSLRMJ3TDjFOEQ1E59BH3FES6zl w5+FT30yUHBUwXt/4bdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wy6el-0000000FI3h-1kin; Sun, 23 Aug 2026 11:46:31 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wy6ej-0000000FI3W-2QlY; Sun, 23 Aug 2026 11:46:29 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 6C8AE60052; Sun, 23 Aug 2026 11:46:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD03A1F000E9; Sun, 23 Aug 2026 11:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787485588; bh=Lrb3AaG5i4+pyOfjbgQo+jz5A6PG6nAPFo2gdyz4uew=; h=From:Subject:Date:To:Cc; b=KxsWQ55VlofiuDkDqLgek/1eVhKQq7dlOrawBrJveRKSZ1yGnkgnqiGKv46o2hZM0 1f20ZKFiMj+1fxQNOTXgRAyLxU2lfST+kmfN/+1qWuc+RAy6F0PaDSCzoCbeQS5vHo LSPO3vI0V7PtU3PthwkC+vp2ll5Q1rwMpxKdF+mluTuDJZ1prHz/55dPjwK5+lHlts RBZlLhx4emUfToOGA/bT35i9FhDMh5qEWu7LHj8Q7lPVdPY4MUGzRJqPcWoki4Vf+b 3igd+UgVgyQ0xUwwiiKuXFOAflN/AhFVsnUUeSYuG8OoCfanjQms6d3jJWtydQaeV+ kI8IOB9eqYv8A== From: "Mike Rapoport (Microsoft)" Subject: [PATCH v2 0/6] arch, mm/execmem: resolve confusion about set_direct_map_valid_noflush() Date: Sun, 23 Aug 2026 14:46:11 +0300 Message-Id: <20260823-execmem-set-vm-perms-v0-2-v2-0-b013a37d84b3@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/42OQQ7CIBBFr2JYO0orqdWV9zAuAIcWdWjDUKIxv btFL+Dy/fz/8t+CMXpkcVy9RcTs2Q9hgXq9ErbXoUPw14VFLetGtlUD+ERLSMCYIBOMGIkhS6j BaGzVXivXKCeW/RjR+efXfb78mCdzQ5uKsDSMZgQTdbB9iYiGRFsimAInbR5YOr3nNMTX92Cui uufL7kCCQd5UErv9FXt3OmOMeBjM8ROXOZ5/gChQWkL+QAAAA== X-Change-ID: 20260816-execmem-set-vm-perms-v0-2-bae847a4f64f To: Andrew Morton Cc: =?utf-8?q?Adrian_Barna=C5=9B?= , Albert Ou , Alexander Gordeev , Alexandre Ghiti , Andy Lutomirski , Borislav Petkov , Brendan Jackman , Catalin Marinas , Christian Borntraeger , Dave Hansen , David Hildenbrand , Gerald Schaefer , Heiko Carstens , Huacai Chen , Ingo Molnar , Len Brown , Mike Rapoport , Palmer Dabbelt , Paul Walmsley , Pavel Machek , Peter Zijlstra , "H. Peter Anvin" , "Rafael J. Wysocki" , Ryan Roberts , Sven Schnelle , Thomas Gleixner , Uladzislau Rezki , Vasily Gorbik , WANG Xuerui , Will Deacon , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, loongarch@lists.linux.dev X-Mailer: b4 0.17-dev 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 Recent discussion about implementation of execmem's ROX caches on arm64 revealed a confusion about how set_direct_map_valid_noflush() implemented on different architectures. On arm64 it sets or clears the PTE_VALID bit marking a PTE as present or not present. On other architectures it's a range version of set_direct_map_invalid_noflush() and set_direct_map_default_noflush() Unlike arm64::set_direct_map_valid_noflush(), set_direct_map_default_noflush() not only marks PTE as present, but also sets its default protection mode. Other than that, initial design of execmem ROX caches didn't rely on restoration of large mappings that's now available on x86, but completely removed the memory allocated for the ROX cache from the direct map to ensure that large mappings are not split. This precluded usage of VM_FLUSH_RESET_PERMS for the ROX cache allocations and required execmem to implement manipulation of the direct map alias. Current implementation of ROX caches does not remove the direct map alias but simply calls set_memory_rox() that updates the permissions in both vmalloc address space and the direct map and relies on collapse_large_pages() in x86 CPA to keep large mappings. This allow using VM_FLUSH_RESET_PERMS for execmem ROX cache allocations with small adjustments to set_direct_map APIs and vmalloc::reset_perms() behaviour: adding number of pages parameter to set_direct_map APIs and making resetting of the direct map permissions in vmalloc VMAP_HUGE friendly. Implement these adjustments, make execmem always use VM_FLUSH_RESET_PERMS and revert set_direct_map_valid_noflush() changes. [1] https://lore.kernel.org/all/20260611130144.1385343-4-abarnas@google.com --- v2 changes: * move setting of VM area order back to __vmalloc_area_node() * add tags, thanks! v1: https://patch.msgid.link/20260816-execmem-set-vm-perms-v0-2-v1-0-90944a3ad43f@kernel.org --- Mike Rapoport (Microsoft) (6): set_memory: add number of pages parameter to set_direct_map APIs mm/vmalloc: set area's page_order after allocation succeeds mm/vmalloc: constify vm parameter of get_vm_area_page_order() mm/vmalloc: make set_area_direct_map HUGE_VMAP friendly mm/execmem: use VM_FLUSH_RESET_PERMS for ROX cache allocations Revert "arch: introduce set_direct_map_valid_noflush()" arch/arm64/include/asm/set_memory.h | 5 ++-- arch/arm64/mm/pageattr.c | 24 ++++--------------- arch/loongarch/include/asm/set_memory.h | 5 ++-- arch/loongarch/mm/pageattr.c | 27 ++++----------------- arch/riscv/include/asm/set_memory.h | 5 ++-- arch/riscv/mm/pageattr.c | 23 ++++-------------- arch/s390/include/asm/set_memory.h | 5 ++-- arch/s390/mm/pageattr.c | 20 ++++------------ arch/x86/include/asm/set_memory.h | 5 ++-- arch/x86/mm/pat/set_memory.c | 16 ++++--------- include/linux/set_memory.h | 12 ++++------ kernel/power/snapshot.c | 4 ++-- mm/execmem.c | 42 ++++++--------------------------- mm/secretmem.c | 6 ++--- mm/vmalloc.c | 26 ++++++++++---------- mm/vmalloc.h | 2 +- 16 files changed, 61 insertions(+), 166 deletions(-) --- base-commit: 1029098ee3275ea5b78e329ce132262affa2f8cc change-id: 20260816-execmem-set-vm-perms-v0-2-bae847a4f64f -- Sincerely yours, Mike.