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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B9C3C982D2 for ; Thu, 17 Sep 2026 18:13:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 143746B0096; Thu, 17 Sep 2026 14:13:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 11B386B0098; Thu, 17 Sep 2026 14:13:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 058266B0099; Thu, 17 Sep 2026 14:13:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D57216B0096 for ; Thu, 17 Sep 2026 14:13:32 -0400 (EDT) Received: from smtpin16.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 06DEE120454 for ; Thu, 17 Sep 2026 18:13:32 +0000 (UTC) X-FDA: 85224051864.16.E5F8B5D Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf19.hostedemail.com (Postfix) with ESMTP id 2B8801A000F for ; Thu, 17 Sep 2026 18:13:30 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=arm.com header.s=foss header.b=aYA7qe3T; spf=pass (imf19.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1789668810; b=a5X3awK7RvBh9irsTkfW6/JBH1xjfdUDZio3lSEPvfje+rFUG5/SuFPNY2R57CtBrikuyO I0LlkzB7z5fOUX1A+aYxkqsijntC2/5UO3mZV1occVi8yZXe0UEG914KKlsUvSq5PNtY2g 4u7qgSx5Ap8PpxdkjHhG71NGoaBK5dw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=arm.com header.s=foss header.b=aYA7qe3T; spf=pass (imf19.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1789668810; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QAr23lhx8wGsXT6yVi+oXiSZp/vetZhFYtO/kqi1324=; b=nfeUxg+TXFT8SR+degDzBo8XiBDzeLGcP+8ORHn3tpEVt4Wb3m55Igeh6S4XLuKvSZusRn 7XXl5m8n1sEbgswCj8KVLSvcZvLVKbXjsIN3XuI2q96scCLX9i4qkulperxpIH59F/BnpN Idi544xLRPS58EE36FsRdcFqoiR6xlQ= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AB24D1F91; Thu, 17 Sep 2026 11:13:25 -0700 (PDT) Received: from [10.57.7.135] (unknown [10.57.7.135]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D69F63F86F; Thu, 17 Sep 2026 11:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1789668809; bh=QAr23lhx8wGsXT6yVi+oXiSZp/vetZhFYtO/kqi1324=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=aYA7qe3TJmI5eXy7zuCDNvjC424BNkx9TqHpOMlyNEkNvwpgRn5lsECsH9o7hC0RG 5jIxS0q8ZHaQOP2dIWzY39HZw+w/QDzFAaZ5etprv7QyoTOG2UkZgMUVBbr0E0ztmK wHMiHRGdA5HaFJ3DgcETN41w6QqxGhhxvHgViRbE= Message-ID: <685fa7b1-af6d-4dc0-8764-5bcb169b39ae@arm.com> Date: Thu, 17 Sep 2026 20:13:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 5/6] mm/execmem: use VM_FLUSH_RESET_PERMS for ROX cache allocations To: "Mike Rapoport (Microsoft)" , 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 , 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 References: <20260903-execmem-set-vm-perms-v0-2-v3-0-949b64a9f755@kernel.org> <20260903-execmem-set-vm-perms-v0-2-v3-5-949b64a9f755@kernel.org> From: Kevin Brodsky Content-Language: en-GB In-Reply-To: <20260903-execmem-set-vm-perms-v0-2-v3-5-949b64a9f755@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2B8801A000F X-Rspam-User: X-Stat-Signature: grtnsrpym617jqrhrc4tfaaex334qn4b X-HE-Tag: 1789668810-248290 X-H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//hVirv4zDGjWf2kSPghoNc12T0sZP8GJNH38xG43zyD2a9styubhccdzr6sijIb4TLqEA40iqWSjQIrtKRz2nGiQmX+FmLcmbrdldZfeUsBlwsQqTaxRj1iYDbQoTct0R7yuqv85yHaBDPD1WWrFI65vFNLJ7SmhntbXJEWty4GoZIU68i7LZXz8jOXc70B1IyI2gLj7IKLT2yzYhAKzQKxgVj35RLTnqjJ0E908wkxgUNp1j7EVVFTwNQ21WsoaSWSwHI7FeyRQiPWRzpbMv+BiE+LTRA9R0bwYS0= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 03/09/2026 11:28, Mike Rapoport (Microsoft) wrote: > Initially execmem completely removed direct map alias for the memory > allocated for the ROX cache in PMD_SIZE chunks. When that memory was > freed, its direct map was restored also in PMD_SIZE chunks to avoid > fragmentation of the direct map caused by vmalloc::vm_reset_perms(). > > This required execmem to implement the wrappers for set_direct_map APIs for > proper sequencing of removal and restoration of the direct map aliases. > > Since then x86's CPA gained support for collapsing the direct map page > tables for ROX pages and execmem switched from removing ROX caches from the > direct map to making them ROX there, so execmem only needs to update direct > map alias permissions when freeing the ROX cache memory. > > vmalloc already handles those updates for areas with VM_FLUSH_RESET_PERMS > set and vmalloc::vm_reset_perms() does not force split of the direct map > for PMD_SIZE chunks. > > Set the area permissions with set_vm_flush_reset_perms() when populating > the execmem cache just before flipping the area to ROX. > > This way freeing an allocated area on an error path won't incur two > updates of the direct map alias of that area and TLB flushing in > vm_reset_perms(). > > Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Kevin Brodsky 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 20CBAC982D2 for ; Thu, 17 Sep 2026 18:13:49 +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:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3ePFPw+PQ3mvB5J8ctUp5sb7dFOQj8NMjKERnOe2xWs=; b=i0set+tBNnuCkk x9giT6jvSCYgS4tRH0Jekxo+eluJY8BCsbGsmmrXAMYH32tlmdIm3fjyhvUJ6VKbhkqRhjH3HCOXH XuZSRMRm+CHud35nVyrs6TPUp+BMAOO7GY/3/IxFSmdQ8wDmUgBMGKA1IcKvpz43GdMGMK5anDfuZ eDtaTlEzNfn8mG19G8dwtJTo9R28TR6xQcrJ+ptFwKEhUYEdSN5xNSps+ekCizckL+MSAeMA29Bv2 Cei3A4M0FKhvzEAX43lBiUVog6JwQDoku1OYBmLRom2xIRhiyZKd7pr9o0OPrd5Qf24tWMKTxspLy 0qhniNSNsa60N9QoNotw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x7Gc4-0000000CC4Y-1wGL; Thu, 17 Sep 2026 18:13:36 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x7Gc2-0000000CC3w-2mvV; Thu, 17 Sep 2026 18:13:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=QAr23lhx8wGsXT6yVi+oXiSZp/vetZhFYtO/kqi1324=; b=pWn0euMqbr6+SOQwdN2z09hjYk eVeiJEsWykWVYO4yrkjOng1RjNzFV+T+A/kVqOQGYfxhtpFO2ZOV/2SfDj3sPlsTLtgaAjfNTPs5E sqJgRtdo97rqiX1AqhajpGR9a9/VyVZG54Xe9UyKsslL4wklUQd+BlSLqutS4SS5hYeegWVyIhwqh qT8mQ6TOZPbE49QzFJus5g8F8k+Sv+Y690d/Ue7z52sZb4Mz9ig+4agaFePZGjgboE5i0XPzWWL4/ Q11HlpKEA7MBVCNDQjpFStNHPBhlcIyiDzXPjJIcFBrnkoN/1seOjFINScY13QOKn5aC83HMmWpcZ pmc6nXrg==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.99.2 #2 (Red Hat Linux)) id 1x7Gbz-000000099NJ-0Rsu; Thu, 17 Sep 2026 18:13:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AB24D1F91; Thu, 17 Sep 2026 11:13:25 -0700 (PDT) Received: from [10.57.7.135] (unknown [10.57.7.135]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D69F63F86F; Thu, 17 Sep 2026 11:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1789668809; bh=QAr23lhx8wGsXT6yVi+oXiSZp/vetZhFYtO/kqi1324=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=aYA7qe3TJmI5eXy7zuCDNvjC424BNkx9TqHpOMlyNEkNvwpgRn5lsECsH9o7hC0RG 5jIxS0q8ZHaQOP2dIWzY39HZw+w/QDzFAaZ5etprv7QyoTOG2UkZgMUVBbr0E0ztmK wHMiHRGdA5HaFJ3DgcETN41w6QqxGhhxvHgViRbE= Message-ID: <685fa7b1-af6d-4dc0-8764-5bcb169b39ae@arm.com> Date: Thu, 17 Sep 2026 20:13:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 5/6] mm/execmem: use VM_FLUSH_RESET_PERMS for ROX cache allocations To: "Mike Rapoport (Microsoft)" , 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 , 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 References: <20260903-execmem-set-vm-perms-v0-2-v3-0-949b64a9f755@kernel.org> <20260903-execmem-set-vm-perms-v0-2-v3-5-949b64a9f755@kernel.org> From: Kevin Brodsky Content-Language: en-GB In-Reply-To: <20260903-execmem-set-vm-perms-v0-2-v3-5-949b64a9f755@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260917_191331_544109_70E97BE4 X-CRM114-Status: GOOD ( 14.09 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On 03/09/2026 11:28, Mike Rapoport (Microsoft) wrote: > Initially execmem completely removed direct map alias for the memory > allocated for the ROX cache in PMD_SIZE chunks. When that memory was > freed, its direct map was restored also in PMD_SIZE chunks to avoid > fragmentation of the direct map caused by vmalloc::vm_reset_perms(). > > This required execmem to implement the wrappers for set_direct_map APIs for > proper sequencing of removal and restoration of the direct map aliases. > > Since then x86's CPA gained support for collapsing the direct map page > tables for ROX pages and execmem switched from removing ROX caches from the > direct map to making them ROX there, so execmem only needs to update direct > map alias permissions when freeing the ROX cache memory. > > vmalloc already handles those updates for areas with VM_FLUSH_RESET_PERMS > set and vmalloc::vm_reset_perms() does not force split of the direct map > for PMD_SIZE chunks. > > Set the area permissions with set_vm_flush_reset_perms() when populating > the execmem cache just before flipping the area to ROX. > > This way freeing an allocated area on an error path won't incur two > updates of the direct map alias of that area and TLB flushing in > vm_reset_perms(). > > Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Kevin Brodsky _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv