From patchwork Mon Aug 12 08:26:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 13760290 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 B858BC52D7C for ; Mon, 12 Aug 2024 08:26:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F70D6B00C6; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 389AB6B00CA; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E7DD6B00C8; Mon, 12 Aug 2024 04:26:17 -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 EEE676B00C5 for ; Mon, 12 Aug 2024 04:26:16 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 93C6E121B1F for ; Mon, 12 Aug 2024 08:26:16 +0000 (UTC) X-FDA: 82442911152.03.6547F2D Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by imf07.hostedemail.com (Postfix) with ESMTP id 8D87C40003 for ; Mon, 12 Aug 2024 08:26:14 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=ellerman.id.au header.s=201909 header.b=fhxsz34w; dmarc=none; spf=pass (imf07.hostedemail.com: domain of michael@ellerman.id.au designates 150.107.74.76 as permitted sender) smtp.mailfrom=michael@ellerman.id.au ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723451124; a=rsa-sha256; cv=none; b=larYuczYjCqWj/LVfYc8uFgSOthPqDWIrBKYOTUpNGvLIECo8Vfr0T1KH0Uwy2IaFORdaE pvN5/LpMI2lEuuIvwxF1ubre4puCxjB8Zl+vgraPbm6h8vhCQMEIOjUCTG+EHz1+VE64C+ pmgwFuak2uWuZUk8u1mcWkAm4Dj/PRc= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=ellerman.id.au header.s=201909 header.b=fhxsz34w; dmarc=none; spf=pass (imf07.hostedemail.com: domain of michael@ellerman.id.au designates 150.107.74.76 as permitted sender) smtp.mailfrom=michael@ellerman.id.au ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723451124; 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=VDTeFKG0tWsaWgY5r4pEV0pX09s9ysckDeAKLLaIFRs=; b=6wTS5iW+K7XLik0+OVFwINOPOyudrYXP5Kr3PAmQJgehlUs4oRk7rpB4U7+6nOzEv9MVTN I726aTOGRCxOD5Gp1v9Dxg8TTQrGnoESUS0H820XjBMz/5esXirQHbP5drA8KfG9a8wSZ1 xtOR2WO43UVRE+lEwevPxGtLvT2ZErA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1723451171; bh=VDTeFKG0tWsaWgY5r4pEV0pX09s9ysckDeAKLLaIFRs=; h=From:To:Cc:Subject:Date:From; b=fhxsz34wOUUSnbdDDauItzNL8KbrPOk7aPwcBLdQypYkobErRlI50imsAL30scp4Z eXKETdiRr+U+E3qiwMLaSxlWuSJnrNmrmKLNCTA/G2NJ8867qYNafCfX9VWbnZZCnL uPOtIF7r8dFU2DF48vSD8LhCKd3cqpi6Jkg8gIQIXnXkrpkXF3Msyqsu1VO+DKOgD/ tQ1jxVLo0FWhKB1XV4icEInoLMAkmCr33AojWOhDDEtuQwrvFO0s0DjemBcYFg1Xce 5qVFHDIj1hYHLlHTIwAg5HBTIhtv9w+LTNZKa4gPH8+QUvKzS/5Myj08LAvTEMjTrx 5Xk7bT1INhDYA== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Wj6zk6yjDz4x8Q; Mon, 12 Aug 2024 18:26:10 +1000 (AEST) From: Michael Ellerman To: Cc: , torvalds@linux-foundation.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, jeffxu@google.com, Liam.Howlett@oracle.com, linux-kernel@vger.kernel.org, npiggin@gmail.com, oliver.sang@intel.com, pedro.falcato@gmail.com Subject: [PATCH v2 1/4] mm: Add optional close() to struct vm_special_mapping Date: Mon, 12 Aug 2024 18:26:02 +1000 Message-ID: <20240812082605.743814-1-mpe@ellerman.id.au> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 8D87C40003 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: pe3ofqstdcmgebkdnrmqk94epggimtnc X-HE-Tag: 1723451174-923293 X-HE-Meta: U2FsdGVkX1/srPvSknhYQaVk/KemyOwNLERTCS5njEMKMf7B30+m82QZG6Rc6FhB6x8Q1K42dAn5DlCl6KA17ykerTdEp0f6q1v54rS6hrTqxtfUwbvW/MgMP3+zgBQQQa41wa+GBht6spRqtQn0J9XrObvjS0pEddA1oZ0eHhWD0jE2jsZAow5aYgqyhDrmsfpXpqTMWbOvTUT5q2n8ZeZelc+CVhJlSbX0IEmVHUscXGIwtBCbs1+mBp1agAghjDjNRD/z8Isx8wFJOgpeFSkHKiba9WSoZwM7mwhQ4wjqbxMj9+X81Qy2Jc9frHdtb98+yCwccH/8gWWEx9LY5B2cycdeV706y5d6H30XPL/z16kell+k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esSTL1mtK+1JEe7RDQ3PuKv9bssm8ZIiw1E60krKCtQF56XPG40e8nZikI/DVG9fc9e53b3ttauiUfLxS9QUlfL1HsbJnbcCCZEpdboAAlFxW+LlLITo5pXG8OZCSI5ZoaLzIs0oXjk/w8NyQ5MK5kP4COIBopFBj0BR8eU35KC5lK8rgkCNb4ZeF7MM8ZKxE1Nd6VWkiT4eAakMJ7H0XHReAm5YvtfOmuqvvPhOTuBKR68VffwdNGNGmptYKqNaAsscelRVbjscQbl+OKo37Puh0VkGV/ztMien3aTAeGeOKAA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add an optional close() callback to struct vm_special_mapping. It will be used, by powerpc at least, to handle unmapping of the VDSO. Although support for unmapping the VDSO was initially added for CRIU[1], it is not desirable to guard that support behind CONFIG_CHECKPOINT_RESTORE. There are other known users of unmapping the VDSO which are not related to CRIU, eg. Valgrind [2] and void-ship [3]. The powerpc arch_unmap() hook has been in place for ~9 years, with no ifdef, so there may be other unknown users that have come to rely on unmapping the VDSO. Even if the code was behind an ifdef, major distros enable CHECKPOINT_RESTORE so users may not realise unmapping the VDSO depends on that configuration option. It's also undesirable to have such core mm behaviour behind a relatively obscure CONFIG option. Longer term the unmap behaviour should be standardised across architectures, however that is complicated by the fact the VDSO pointer is stored differently across architectures. There was a previous attempt to unify that handling [4], which could be revived. See [5] for further discussion. [1]: commit 83d3f0e90c6c ("powerpc/mm: tracking vDSO remap") [2]: https://sourceware.org/git/?p=valgrind.git;a=commit;h=3a004915a2cbdcdebafc1612427576bf3321eef5 [3]: https://github.com/insanitybit/void-ship [4]: https://lore.kernel.org/lkml/20210611180242.711399-17-dima@arista.com/ [5]: https://lore.kernel.org/linuxppc-dev/shiq5v3jrmyi6ncwke7wgl76ojysgbhrchsk32q4lbx2hadqqc@kzyy2igem256 Suggested-by: Linus Torvalds Signed-off-by: Michael Ellerman Reviewed-by: David Hildenbrand Reviewed-by: Liam R. Howlett Tested-by: Rob Landley --- include/linux/mm_types.h | 3 +++ mm/mmap.c | 6 ++++++ 2 files changed, 9 insertions(+) v2: - Add some blank lines as requested. - Expand special_mapping_close() comment. - Add David's reviewed-by. - Expand change log to capture review discussion. diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 485424979254..78bdfc59abe5 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -1313,6 +1313,9 @@ struct vm_special_mapping { int (*mremap)(const struct vm_special_mapping *sm, struct vm_area_struct *new_vma); + + void (*close)(const struct vm_special_mapping *sm, + struct vm_area_struct *vma); }; enum tlb_flush_reason { diff --git a/mm/mmap.c b/mm/mmap.c index d0dfc85b209b..af4dbf0d3bd4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -3620,10 +3620,16 @@ void vm_stat_account(struct mm_struct *mm, vm_flags_t flags, long npages) static vm_fault_t special_mapping_fault(struct vm_fault *vmf); /* + * Close hook, called for unmap() and on the old vma for mremap(). + * * Having a close hook prevents vma merging regardless of flags. */ static void special_mapping_close(struct vm_area_struct *vma) { + const struct vm_special_mapping *sm = vma->vm_private_data; + + if (sm->close) + sm->close(sm, vma); } static const char *special_mapping_name(struct vm_area_struct *vma) From patchwork Mon Aug 12 08:26:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 13760293 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 D2FF0C3DA7F for ; Mon, 12 Aug 2024 08:26:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D51DD6B00C8; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C3D096B00CC; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 81E706B00C8; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5CDE66B00CB for ; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 16A6B121B7F for ; Mon, 12 Aug 2024 08:26:17 +0000 (UTC) X-FDA: 82442911194.25.B1B582C Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by imf03.hostedemail.com (Postfix) with ESMTP id 0604920025 for ; Mon, 12 Aug 2024 08:26:14 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=ellerman.id.au header.s=201909 header.b=fFPHXE1d; spf=pass (imf03.hostedemail.com: domain of michael@ellerman.id.au designates 150.107.74.76 as permitted sender) smtp.mailfrom=michael@ellerman.id.au; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723451106; 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:in-reply-to:references:references:dkim-signature; bh=90PGWBEPImYbqdKWstTCR2/CnGQLSesaZNbFieveKuE=; b=cZJGZO4JbLNPPHeIvqZRl8vMfaZ0oc94KrDbVvvUYWKH/BRF4eJlIWMecnsqu6JypqxRGW pmo/hXpkl5yCBQJtypkmr+8fi15X2QaXALkFYsYARPopM2S1Y/8cq9VWS7oPf9mBn4ZSyf NWoYQJMLVyumsYbfU7qbvwjtCP2kWZ8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723451106; a=rsa-sha256; cv=none; b=FVcu4ZpkNIyypalMHof9MIC1O5aorSNtLNGGA08IHegdUe0BppojtNFtJ4P+GePtgO3nWl S890uwHOdyNLxzOugZ/O6JstXbOoISlAd7zXbAEq9JG36r/EXoWLHMU/rQAilcFVbWQPYE LXn0ZUj2Nar/lRBuGOO/OkIfZ24ipcA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=ellerman.id.au header.s=201909 header.b=fFPHXE1d; spf=pass (imf03.hostedemail.com: domain of michael@ellerman.id.au designates 150.107.74.76 as permitted sender) smtp.mailfrom=michael@ellerman.id.au; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1723451171; bh=90PGWBEPImYbqdKWstTCR2/CnGQLSesaZNbFieveKuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFPHXE1dOvj+bKatKB56csNqaldo10qmfdXwB1reponcEmik+TvrSRPKhatzXSHSx wSbXA5pkgkbvxhDr6zSSvFQvnSDu+1oJErPK+JPOsOUZur2lv/ndnIqPxMc8HyxMjH XN95VVCbSnJRNpFyLmuBWBUzmwADAyxkNtqaWmYpunfu4p5z7Zg0u5fPeMVuH5Hok/ mFcKZgybv4Zx8Q8guL83cj7gAwLZmUwBrL9ZzgTi64YSYhfhdZdn+TRgNvBMhtEpRn oUYqRjmf0fWRjTlu2BtTD5vHgOShzNnppXzHKFJvbRd7ZradwBPOHQNgO/ABDbGAKX nKLrIq6sdYBhQ== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Wj6zl3y2Sz4x8w; Mon, 12 Aug 2024 18:26:11 +1000 (AEST) From: Michael Ellerman To: Cc: , torvalds@linux-foundation.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, jeffxu@google.com, Liam.Howlett@oracle.com, linux-kernel@vger.kernel.org, npiggin@gmail.com, oliver.sang@intel.com, pedro.falcato@gmail.com Subject: [PATCH v2 2/4] powerpc/mm: Handle VDSO unmapping via close() rather than arch_unmap() Date: Mon, 12 Aug 2024 18:26:03 +1000 Message-ID: <20240812082605.743814-2-mpe@ellerman.id.au> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812082605.743814-1-mpe@ellerman.id.au> References: <20240812082605.743814-1-mpe@ellerman.id.au> MIME-Version: 1.0 X-Stat-Signature: fww595p5cbucrb8ojtwd4fgocrjaezj3 X-Rspamd-Queue-Id: 0604920025 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1723451174-546237 X-HE-Meta: U2FsdGVkX18lk+NYWmzK0alQvhe0CAi2J/8Duu2B8X2rUXoJ5Z/r1LbUSoXScCdd4t0+kv0B+PK66IIaWugnWzRKGXBW4uGvycEztfCH045E1nUoeOhsZnL57zpX/1TBdYS4wdXzP41Fkgl/136heYt2ZF/71vkLc/3hEVn1UvqIOxJB08R1Ka9gvl9TMUUyc2aJ6wwUMupFuvIbZEApTZGGyF8PN2hjpjAsAYM1jXn+3WNKXhqXLslwSos1SdQBFcPQ2rQ6WydB2xQ7pjxfmP8OP9FTqOPoGvS0w74xIv5Mq9W8yv/W02abEDCLd9d2NX+L9F97BEHN8XiDLxAcYF3FYU3nOYao+h+ias3E7+TN8wWwfTmqcIHZg9LuRMnmrU+l9Yu7/upcYbdAUDKTQOk2LGL5/r8Q7xsGx5SgRQzpr2s97ckw/tzk8LnlJDlGbd29uXpG4MLWrzfDQG+6HsKStBXn3MFoOuAp/cp5kvCsShSMGXJXytGKCrpVAImAxvqNCwouTdAotN5TsP5xiMHCRQPQVA634eUGG66QCReNfS1SNlOl+WMcEHRg83gkftP5PZjHvd27Hx5XWYxMQpRHxzonG5PavUOA/Gt2gUauNBtq8N3Y5owy/xQBMThFgnOrT4kASfGFwme23ryQEqByx7/wAsnVYrhrwk5HL6oehLiH0uB5Up34KBXVaESZ/NmDJKYXKgojxE9lKr+mad2hTFIBRHm7NPwkqqgFA1HnXCPkGnsk0AgU5JR6cnO72kktv/j8PcHXlupf94vm7u83SqGskqy+zUaWFzN0ZNauByl9w28PVDRVNjePWWiLVkhEkjjZn7VpoJR5Gys4tgktaHoqLM5BwOzCKI4AdaQBYRpmUHNIpdAjpJ7iJXebrMK9OPNbevx67gQU+tAb+FMKB+srj/se9nz8q2b18huWUExV+jJMxWJ1r105tXSRU+im4PjwXgmM7ap5360 SlM89jz7 tJit46IEME551vuuERtnuhx9BwOl/XzjKlDDGTx6hztlqmGsOrRTKx9BfzYDxURTcS6xWxwZWoCMcqeor95m8xGkCQHpCTkaRoep0ZYLP0JEcOLKCh0hKj0nzjE3iEHaq2Y2pySYoGhTSOHRVpyH4o0mIBTVDzaLefDM0to9fqf4aMWJEFPgzZPj2LMtSqLAsJSbfK565dxjgwLqMZg6Kjt2wJ6P0TdcdjvUK4BW1GvZoJm1rPZVBdmth2tWEo/qmEITgvcjuXhfWCmqDHeNkZH1IRh1xffZSKHxqklhpgdwEkRBaGUDLoTpKlTfCx1IKNJTl+eEWwf0u/4Q4OdEwDX/AB/lvKW7KIn4wlm7oM2LSwS+fl2iC7ATliq0WI9MMFRnYC+2GpX4bDYqGVHaycwqzwSr1Mxeb563cf7cDiIHmiGQ8KqP/15w0Z2zibl99xKSmuyGDHmJ+LqxHcdtuNmeABn+CBLyopc2auxVydLNk3viTHmPAbqKBspFJS3PTaJxjGH6R8CyY6zzFFkMbiSym+4JqCkCQBgHfYVTGtGUTezQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a close() callback to the VDSO special mapping to handle unmapping of the VDSO. That will make it possible to remove the arch_unmap() hook entirely in a subsequent patch. Suggested-by: Linus Torvalds Signed-off-by: Michael Ellerman Reviewed-by: David Hildenbrand --- arch/powerpc/include/asm/mmu_context.h | 4 ---- arch/powerpc/kernel/vdso.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) v2: Unchanged except for collecting tags. diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h index 37bffa0f7918..9b8c1555744e 100644 --- a/arch/powerpc/include/asm/mmu_context.h +++ b/arch/powerpc/include/asm/mmu_context.h @@ -263,10 +263,6 @@ extern void arch_exit_mmap(struct mm_struct *mm); static inline void arch_unmap(struct mm_struct *mm, unsigned long start, unsigned long end) { - unsigned long vdso_base = (unsigned long)mm->context.vdso; - - if (start <= vdso_base && vdso_base < end) - mm->context.vdso = NULL; } #ifdef CONFIG_PPC_MEM_KEYS diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c index 7a2ff9010f17..220a76cae7c1 100644 --- a/arch/powerpc/kernel/vdso.c +++ b/arch/powerpc/kernel/vdso.c @@ -81,6 +81,21 @@ static int vdso64_mremap(const struct vm_special_mapping *sm, struct vm_area_str return vdso_mremap(sm, new_vma, &vdso64_end - &vdso64_start); } +static void vdso_close(const struct vm_special_mapping *sm, struct vm_area_struct *vma) +{ + struct mm_struct *mm = vma->vm_mm; + + /* + * close() is called for munmap() but also for mremap(). In the mremap() + * case the vdso pointer has already been updated by the mremap() hook + * above, so it must not be set to NULL here. + */ + if (vma->vm_start != (unsigned long)mm->context.vdso) + return; + + mm->context.vdso = NULL; +} + static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, struct vm_area_struct *vma, struct vm_fault *vmf); @@ -92,11 +107,13 @@ static struct vm_special_mapping vvar_spec __ro_after_init = { static struct vm_special_mapping vdso32_spec __ro_after_init = { .name = "[vdso]", .mremap = vdso32_mremap, + .close = vdso_close, }; static struct vm_special_mapping vdso64_spec __ro_after_init = { .name = "[vdso]", .mremap = vdso64_mremap, + .close = vdso_close, }; #ifdef CONFIG_TIME_NS From patchwork Mon Aug 12 08:26:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 13760292 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 A7C3DC531DD for ; Mon, 12 Aug 2024 08:26:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB7D86B00C7; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1EBE6B00C9; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 743FE6B00CA; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) 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 330B56B00C7 for ; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B6944A7B12 for ; Mon, 12 Aug 2024 08:26:16 +0000 (UTC) X-FDA: 82442911152.23.E930BF4 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by imf23.hostedemail.com (Postfix) with ESMTP id 9641114000B for ; Mon, 12 Aug 2024 08:26:14 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=ellerman.id.au header.s=201909 header.b=SFMnKaw9; spf=pass (imf23.hostedemail.com: domain of michael@ellerman.id.au designates 150.107.74.76 as permitted sender) smtp.mailfrom=michael@ellerman.id.au; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723451120; 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:in-reply-to:references:references:dkim-signature; bh=84M21vyUGQcGCjX/ARQkrZuqRB4Zx/d2+mbl6H4Q7ow=; b=FaFh1niXpoqT5NJmWfoAKDzTnb38yCldA8lMg6eHAmA8fmQvanEi506ghwNLNQ+NRQKUAh vHDP2m6cw2UCP88dYQY/g2lkrjFeNw7kTAw4BmyJZ7IvDb6owB0qeEkn9LR6HZ1cyHtgBL pF6UKSJnKhX+vlav6ipqNLUYL73R1/s= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=ellerman.id.au header.s=201909 header.b=SFMnKaw9; spf=pass (imf23.hostedemail.com: domain of michael@ellerman.id.au designates 150.107.74.76 as permitted sender) smtp.mailfrom=michael@ellerman.id.au; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723451120; a=rsa-sha256; cv=none; b=TuipA39RnTJux00U9oJwbCEeL8Lf48cwxXwE93cuIKjd8DVN/eokb1Qo+9ZF1ZYmxePwM0 AR+UHiygMJLKZmH0DP8COFcxnnMz9qpMjTtS06FjPZ+V8oI+lec18ofUZk2S2JQzEv8yrP 2QtlHeQTiehbIoYNIE1PXEl+2byUrts= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1723451172; bh=84M21vyUGQcGCjX/ARQkrZuqRB4Zx/d2+mbl6H4Q7ow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SFMnKaw9wh079Fm21LEZE2EP0FiNYPA6cxjvDY/X293d4Kw0ckMkqmByMFqK9pO5G jznvvg9zyPSEe8BR8lfLSrnywK78obH4o25/CtyUdQGY1T3yS/FPKTiIMBfkOzhZlw lpSQgClEL38ZD8l3i3fEsLw54el67bLM2qmxSfgbx2tt0O5ky7Q5lIgDfS0JyY/38p kRq3QyEWeizG93x51mx9p3qZzdUdxvad09CfVa4yp9B1vxA3gxqJ/ZU1myIJGRQyjQ RZrZb/0mmAAYc9M4x9/2YDVAuQIX5RleBOohv8WkqB1JVrJYmyQfEinFNEbbQwBQgb d62LsD0PLHWsA== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Wj6zm00Kgz4x8x; Mon, 12 Aug 2024 18:26:11 +1000 (AEST) From: Michael Ellerman To: Cc: , torvalds@linux-foundation.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, jeffxu@google.com, Liam.Howlett@oracle.com, linux-kernel@vger.kernel.org, npiggin@gmail.com, oliver.sang@intel.com, pedro.falcato@gmail.com Subject: [PATCH v2 3/4] mm: Remove arch_unmap() Date: Mon, 12 Aug 2024 18:26:04 +1000 Message-ID: <20240812082605.743814-3-mpe@ellerman.id.au> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812082605.743814-1-mpe@ellerman.id.au> References: <20240812082605.743814-1-mpe@ellerman.id.au> MIME-Version: 1.0 X-Stat-Signature: p61usxsbjuoffmbqp466y4hbugcnhtwt X-Rspam-User: X-Rspamd-Queue-Id: 9641114000B X-Rspamd-Server: rspam02 X-HE-Tag: 1723451174-394814 X-HE-Meta: U2FsdGVkX18oUio7jK+705rtxoXgX8EmJVSNdMFkzB1pKDiiKmLxz4XU5mp5HkW1J/WeHxZyx5zKUd1hwb9BljCJg8vDmBRmMWCH2mXsyxBX0jVY7qW+3YdmzgvU6uEWWstZJwioMuLQyZcFtARjybCR81nI6YB9yrHSP1Lg95dh20SAPOgyGSgsPn/eIyTepWhJStlxm2Edsi5k1FkRqTlX7ssLjg9K7LbcggbqvAjG5FUhOfY74+uXjHr0JC+HZyhi74W/OILyc4GF7oeJ3yBo/5HH0R3S4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/UnlR2aIm5IECpIZAFEJgKscxgDNCP4I/BPu1BwjOkRG6eT+3+IynJXXhH8L+PGBKbRMly6u0cOyyUf+OrhBBFnE8NFfLJ7BPD6c6nBbsQekSIs8/1z8h3OOxTW5JxYhkHHL8MdQOYnMOe9hZKR84edkPLeCSIR8nGgvwxbHdkxzLlkNBtITByZeMxfjI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Now that powerpc no longer uses arch_unmap() to handle VDSO unmapping, there are no meaningful implementions left. Drop support for it entirely, and update comments which refer to it. Suggested-by: Linus Torvalds Signed-off-by: Michael Ellerman Acked-by: David Hildenbrand Reviewed-by: Thomas Gleixner --- arch/powerpc/include/asm/mmu_context.h | 5 ----- arch/x86/include/asm/mmu_context.h | 5 ----- include/asm-generic/mm_hooks.h | 11 +++-------- mm/mmap.c | 12 +++--------- 4 files changed, 6 insertions(+), 27 deletions(-) v2: Unchanged except for collecting tags. diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h index 9b8c1555744e..a334a1368848 100644 --- a/arch/powerpc/include/asm/mmu_context.h +++ b/arch/powerpc/include/asm/mmu_context.h @@ -260,11 +260,6 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, extern void arch_exit_mmap(struct mm_struct *mm); -static inline void arch_unmap(struct mm_struct *mm, - unsigned long start, unsigned long end) -{ -} - #ifdef CONFIG_PPC_MEM_KEYS bool arch_vma_access_permitted(struct vm_area_struct *vma, bool write, bool execute, bool foreign); diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 8dac45a2c7fc..80f2a3187aa6 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -232,11 +232,6 @@ static inline bool is_64bit_mm(struct mm_struct *mm) } #endif -static inline void arch_unmap(struct mm_struct *mm, unsigned long start, - unsigned long end) -{ -} - /* * We only want to enforce protection keys on the current process * because we effectively have no access to PKRU for other diff --git a/include/asm-generic/mm_hooks.h b/include/asm-generic/mm_hooks.h index 4dbb177d1150..6eea3b3c1e65 100644 --- a/include/asm-generic/mm_hooks.h +++ b/include/asm-generic/mm_hooks.h @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Define generic no-op hooks for arch_dup_mmap, arch_exit_mmap - * and arch_unmap to be included in asm-FOO/mmu_context.h for any - * arch FOO which doesn't need to hook these. + * Define generic no-op hooks for arch_dup_mmap and arch_exit_mmap + * to be included in asm-FOO/mmu_context.h for any arch FOO which + * doesn't need to hook these. */ #ifndef _ASM_GENERIC_MM_HOOKS_H #define _ASM_GENERIC_MM_HOOKS_H @@ -17,11 +17,6 @@ static inline void arch_exit_mmap(struct mm_struct *mm) { } -static inline void arch_unmap(struct mm_struct *mm, - unsigned long start, unsigned long end) -{ -} - static inline bool arch_vma_access_permitted(struct vm_area_struct *vma, bool write, bool execute, bool foreign) { diff --git a/mm/mmap.c b/mm/mmap.c index af4dbf0d3bd4..a86aa58ca37b 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2789,7 +2789,7 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, * * This function takes a @mas that is either pointing to the previous VMA or set * to MA_START and sets it up to remove the mapping(s). The @len will be - * aligned and any arch_unmap work will be preformed. + * aligned. * * Return: 0 on success and drops the lock if so directed, error and leaves the * lock held otherwise. @@ -2809,16 +2809,12 @@ int do_vmi_munmap(struct vma_iterator *vmi, struct mm_struct *mm, return -EINVAL; /* - * Check if memory is sealed before arch_unmap. - * Prevent unmapping a sealed VMA. + * Check if memory is sealed, prevent unmapping a sealed VMA. * can_modify_mm assumes we have acquired the lock on MM. */ if (unlikely(!can_modify_mm(mm, start, end))) return -EPERM; - /* arch_unmap() might do unmaps itself. */ - arch_unmap(mm, start, end); - /* Find the first overlapping VMA */ vma = vma_find(vmi, end); if (!vma) { @@ -3232,14 +3228,12 @@ int do_vma_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma, struct mm_struct *mm = vma->vm_mm; /* - * Check if memory is sealed before arch_unmap. - * Prevent unmapping a sealed VMA. + * Check if memory is sealed, prevent unmapping a sealed VMA. * can_modify_mm assumes we have acquired the lock on MM. */ if (unlikely(!can_modify_mm(mm, start, end))) return -EPERM; - arch_unmap(mm, start, end); return do_vmi_align_munmap(vmi, vma, mm, start, end, uf, unlock); } From patchwork Mon Aug 12 08:26:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 13760291 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 9B0ACC3DA7F for ; Mon, 12 Aug 2024 08:26:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6548A6B00C5; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ABA76B00C9; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D8616B00C5; Mon, 12 Aug 2024 04:26:17 -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 12DA16B00C6 for ; Mon, 12 Aug 2024 04:26:17 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BE419A13DB for ; Mon, 12 Aug 2024 08:26:16 +0000 (UTC) X-FDA: 82442911152.21.2224EEA Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by imf20.hostedemail.com (Postfix) with ESMTP id A1AD41C000B for ; Mon, 12 Aug 2024 08:26:14 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=ellerman.id.au header.s=201909 header.b=GxaYRoj1; dmarc=none; spf=pass (imf20.hostedemail.com: domain of michael@ellerman.id.au designates 150.107.74.76 as permitted sender) smtp.mailfrom=michael@ellerman.id.au ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723451119; a=rsa-sha256; cv=none; b=tU4xo9IB4vphb7ch4dlaVDvwH58CW+zhlXm21hxCoiJlqy39WzUCYd78/iyTCQCKf13PLE k77ilAgAlLVw5KyySl3PG3HqQxOURPhEGbS0w5bEx0KmGsC5m4k3Q/V3bV+Dm4hblixxFx 8thFAcEO8gCBeBGP1q68ZKYbq4ydyWA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=ellerman.id.au header.s=201909 header.b=GxaYRoj1; dmarc=none; spf=pass (imf20.hostedemail.com: domain of michael@ellerman.id.au designates 150.107.74.76 as permitted sender) smtp.mailfrom=michael@ellerman.id.au ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723451119; 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:in-reply-to:references:references:dkim-signature; bh=pcjuiNWGJBthoyZQ3qFWTiFyzLganh8gT8cFhrjWhRE=; b=Uxh8IQVhkOeGxEEbVTGfVKrVConCssruyHp0oCoNbKebjWiA5TvMt6N/jdcXKT/sjn2cth ibZgfY4soBfB8DicUgLZRE4sInb4wTRVbYpI5JH6VkRu2f/bc6vyX350ztJo0dfhTh9hKK coLGeJo9sZacSzBIcdA3Jj3U1acOHFM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1723451172; bh=pcjuiNWGJBthoyZQ3qFWTiFyzLganh8gT8cFhrjWhRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxaYRoj1O/6aMLky2vBn7var5Mtg8nUn123C1LWdhey7cpaSrl22XRNgO3S74rjOT ZVdnqLzZpTrwc5zGQPLVlpOLrV5GY8SC9oNSfrz6d6o5hXos8HivWGEF5KH8y5yQ4H GgVBKrX93hPoPl2fq849JAdVmKJBjG7vY6KadJcvD56pHe4eEttCoqzO5swg8CnXL0 ci2cttEjTH/LdvJLKjKx1S5N8dD1O7LZL/N4R3yoAvnR2ZhhqRe4tMosg/0GMwVeGR 0w54rRaOGgz1DilunTkuNlHaC9cVrV+nI3hApdE0h+e32H+p10/bHiY7vuGu4w/lrR b5pZFaVZL6dVg== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Wj6zm3CHMz4x92; Mon, 12 Aug 2024 18:26:12 +1000 (AEST) From: Michael Ellerman To: Cc: , torvalds@linux-foundation.org, akpm@linux-foundation.org, christophe.leroy@csgroup.eu, jeffxu@google.com, Liam.Howlett@oracle.com, linux-kernel@vger.kernel.org, npiggin@gmail.com, oliver.sang@intel.com, pedro.falcato@gmail.com Subject: [PATCH v2 4/4] powerpc/vdso: Refactor error handling Date: Mon, 12 Aug 2024 18:26:05 +1000 Message-ID: <20240812082605.743814-4-mpe@ellerman.id.au> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812082605.743814-1-mpe@ellerman.id.au> References: <20240812082605.743814-1-mpe@ellerman.id.au> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A1AD41C000B X-Stat-Signature: k4efkozu58egzayzubrcfoxjwgu1s3zg X-Rspam-User: X-HE-Tag: 1723451174-724638 X-HE-Meta: U2FsdGVkX1/tbgSO/+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tCZUWlRH9eJKQRCWVhaISJpxYCtbeJURsaAFoNOBUEWeufli7eNxaFSSN1NUfLWEif4qz7a9Poeh1q5SLWe2RlCeoLoAiTmKqdB1kLS5PoN+R8qqGcp1hwCS18lx9xmoxq7JMLW7XIyKaRmcSdXhEiA5wTf+gTHiPqK+QB8+AMLOxe1o4C/ExQs1zU5Huvef/bIq8yFsrxBEmDOh1+g3pUz+JOl1vjQUO07dJ5sBle30p5ZwPzu5AyGPhpURDamIFVfsFRRUgKyfFtXDa5q/2Gz/wDRrP3LNi1qvw/iM2Q5q7zcuc7al1Nfha X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Linus noticed that the error handling in __arch_setup_additional_pages() fails to clear the mm VDSO pointer if _install_special_mapping() fails. In practice there should be no actual bug, because if there's an error the VDSO pointer is cleared later in arch_setup_additional_pages(). However it's no longer necessary to set the pointer before installing the mapping. Commit c1bab64360e6 ("powerpc/vdso: Move to _install_special_mapping() and remove arch_vma_name()") reworked the code so that the VMA name comes from the vm_special_mapping.name, rather than relying on arch_vma_name(). So rework the code to only set the VDSO pointer once the mappings have been installed correctly, and remove the stale comment. Depends-on: c1bab64360e6 ("powerpc/vdso: Move to _install_special_mapping() and remove arch_vma_name()") Signed-off-by: Michael Ellerman --- arch/powerpc/kernel/vdso.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) v2: Unchanged. diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c index 220a76cae7c1..ee4b9d676cff 100644 --- a/arch/powerpc/kernel/vdso.c +++ b/arch/powerpc/kernel/vdso.c @@ -214,13 +214,6 @@ static int __arch_setup_additional_pages(struct linux_binprm *bprm, int uses_int /* Add required alignment. */ vdso_base = ALIGN(vdso_base, VDSO_ALIGNMENT); - /* - * Put vDSO base into mm struct. We need to do this before calling - * install_special_mapping or the perf counter mmap tracking code - * will fail to recognise it as a vDSO. - */ - mm->context.vdso = (void __user *)vdso_base + vvar_size; - vma = _install_special_mapping(mm, vdso_base, vvar_size, VM_READ | VM_MAYREAD | VM_IO | VM_DONTDUMP | VM_PFNMAP, &vvar_spec); @@ -240,10 +233,15 @@ static int __arch_setup_additional_pages(struct linux_binprm *bprm, int uses_int vma = _install_special_mapping(mm, vdso_base + vvar_size, vdso_size, VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC, vdso_spec); - if (IS_ERR(vma)) + if (IS_ERR(vma)) { do_munmap(mm, vdso_base, vvar_size, NULL); + return PTR_ERR(vma); + } - return PTR_ERR_OR_ZERO(vma); + // Now that the mappings are in place, set the mm VDSO pointer + mm->context.vdso = (void __user *)vdso_base + vvar_size; + + return 0; } int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) @@ -257,8 +255,6 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) return -EINTR; rc = __arch_setup_additional_pages(bprm, uses_interp); - if (rc) - mm->context.vdso = NULL; mmap_write_unlock(mm); return rc;