From patchwork Wed Apr 5 14:25:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13201848 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 1DD03C76188 for ; Wed, 5 Apr 2023 14:26:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7625D6B0075; Wed, 5 Apr 2023 10:26:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 711F06B0078; Wed, 5 Apr 2023 10:26:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DA656B007B; Wed, 5 Apr 2023 10:26:05 -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 501846B0075 for ; Wed, 5 Apr 2023 10:26:05 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 260371411FD for ; Wed, 5 Apr 2023 14:26:05 +0000 (UTC) X-FDA: 80647561890.06.4131D92 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 4EFBBC0021 for ; Wed, 5 Apr 2023 14:26:03 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TKhQVo1Z; spf=pass (imf28.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680704763; 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=wA9vrEua4SxGH0U8touKUeIrkMHHDv7b7I0B36bB+wM=; b=MVF5B7Sb/au3KPVuG693Y28LG5Si1KK4cTTG6sF+SNAYoNqQkPPXs+6F0IOgrMXoMgeMHe +W1qFWngyaM6DMmt8k1CpYGE8EMvISd03otc7cjvVjFehVsYLhA7FY38F5ITQKsOxAuRRM 3ZooPr3FGeeGBsbRbFwUra5tDO8j+M4= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TKhQVo1Z; spf=pass (imf28.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680704763; a=rsa-sha256; cv=none; b=DIREMH8wDv+oZx7Bqhs5BO467zo/5U8vO1igUg5DXlA9H3RRlvxqT4eV5RKLpXzq1dgDp4 fqaDXS13EvaeuJi5e1PBE6xt6Wq5Ec1dkHFRp+NgSUpZSLmxudIOWX6QdBaiAzcOdk8lGh UxI+40YzTrKaQc1uN6H4TVWPHv4KDYg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680704762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wA9vrEua4SxGH0U8touKUeIrkMHHDv7b7I0B36bB+wM=; b=TKhQVo1ZNoSQ9fTDDw0QJVoAbYXsJt1gHLJI2UfUdva9S8PRE6zwOok8axJDuqOlDL878+ sVaQw+0i/OAvekZngUDkAsL285IDM8SdeFaMZ+JgdOa0L4yrS1Yklsvhzv1GiEYsHr1mkB b3LdGL6xGDYQLa42NC6q2a3aBy86fFw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-343-mYpZFFrRMw-fpnIzPwp4dg-1; Wed, 05 Apr 2023 10:25:42 -0400 X-MC-Unique: mYpZFFrRMw-fpnIzPwp4dg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A9C68996E4; Wed, 5 Apr 2023 14:25:38 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55334400F57; Wed, 5 Apr 2023 14:25:37 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Peter Xu , Muhammad Usama Anjum , stable@vger.kernel.org Subject: [PATCH v1 1/2] mm/userfaultfd: fix uffd-wp handling for THP migration entries Date: Wed, 5 Apr 2023 16:25:34 +0200 Message-Id: <20230405142535.493854-2-david@redhat.com> In-Reply-To: <20230405142535.493854-1-david@redhat.com> References: <20230405142535.493854-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 4EFBBC0021 X-Stat-Signature: 45986arf1pgswnibbhzw58d4atn1tzdg X-HE-Tag: 1680704763-525160 X-HE-Meta: U2FsdGVkX197OdSK05gcsjs3MENis/9lH+vfOmGsiTLHOLVC8PcOBUYmIhIbm+9pD7kg+HxCtNqfDBWs606yUboOJ8XQQE762N0XPQBshYeEqCnbhhqzupVR17oYFIQLThke0RhmuXaby+ccsqR5sRPIPUKpRJIQEcMtGIlQQlBhMbiGphAkdaaWVisfeJouc+XSp5P8wF/ri0Z+6CNJpguyXNbqyUDRnZBWMLKlcqG3W7K5yteJCadnFlFZvEM2ph7dTl+lOftpmxqqeHLcWlnDc+sJfXptCahuT1YKF0u5RSJCLMxHgTdSAAy5YHTVVztp11DnMbOHQdC3FJwFtDUK4MMrNWKo4JLaIo7b6tuH7mgWzjzmueiurRmtcnja9rSR2hT5tUuRXY4jhstpAGG+r9w36CYm39j4btGQEvdhPiTB4JmiO3B3Q2/79u5gnpnakj1NIqqvY9lvbzy5Qk1Xm2OdP9L8RyJcgK8qmI63lvCrA0mJ80ExZn8QzxiGHOJQrAKwtqCe2Ui+IwF861HUtds3GkLPNJZuV8Hn8ZBUw8BVU1kdxvdd842DuWbdhPeUNi2aY43em/W4w4r9OGxPT8XIsCEf3Ox4Ai7X5IbRzpsKhjeDupCHaIvUwLstDpcPCxd8hk0b0Ri9nky1gK46Q79n9gztRPdACQkA6e2UaPhPrIrTWN/FxNxtBAlJStmOJaSRCuhhYSlutlb+TRueXGbQWNBjDWhIDuVdze+TWP619aJnRuFfPnNipK2TsZhmfGZkBBC8Q221wPaEeOWxLdj9L/PzUIDOMaRmDncAqmK/AA16m+kCpoR0d7f3nqSv0NWOBDL5073Tfdt8/KvaJrJFEx+Q9AvX3WSSBeDMYDODdpBORTszNgEK6G3DekcoxNym6IZcdYoHmeNwPQKzkQRibN5L14oZiwjuH8bCk+ST/fvG1jmPJszC6ZvsvZ424H+oBMFtLRZ3lkW fu7T7I9D 7P8mZxD93R7HH/71K2YkwzVOrmkupvFOmrdhuL2zv/fzbc60zbElUfreVPDyI/x9vtkSsA8DMmptw5GCQ4Py/kB/4szySUItke3NRTscqtpTnbSWZ63lF+ScDOlWIOU3zXp7qeQqbxTSWh/AKvUyoNg0ucigFsWkk4vOT3rXxRLSNr1flftmhrR3cMYyAM0yowLzLAopz3uaPVMtScRbF1hCPLYr5C0MbtZZcUEePCiY0KZJd4zR2BWovEQ== 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: Looks like what we fixed for hugetlb in commit 44f86392bdd1 ("mm/hugetlb: fix uffd-wp handling for migration entries in hugetlb_change_protection()") similarly applies to THP. Setting/clearing uffd-wp on THP migration entries is not implemented properly. Further, while removing migration PMDs considers the uffd-wp bit, inserting migration PMDs does not consider the uffd-wp bit. We have to set/clear independently of the migration entry type in change_huge_pmd() and properly copy the uffd-wp bit in set_pmd_migration_entry(). Verified using a simple reproducer that triggers migration of a THP, that the set_pmd_migration_entry() no longer loses the uffd-wp bit. Fixes: f45ec5ff16a7 ("userfaultfd: wp: support swap and page migration") Cc: stable@vger.kernel.org Signed-off-by: David Hildenbrand Reviewed-by: Peter Xu --- mm/huge_memory.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 032fb0ef9cd1..bdda4f426d58 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1838,10 +1838,10 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, if (is_swap_pmd(*pmd)) { swp_entry_t entry = pmd_to_swp_entry(*pmd); struct page *page = pfn_swap_entry_to_page(entry); + pmd_t newpmd; VM_BUG_ON(!is_pmd_migration_entry(*pmd)); if (is_writable_migration_entry(entry)) { - pmd_t newpmd; /* * A protection check is difficult so * just be safe and disable write @@ -1855,8 +1855,16 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, newpmd = pmd_swp_mksoft_dirty(newpmd); if (pmd_swp_uffd_wp(*pmd)) newpmd = pmd_swp_mkuffd_wp(newpmd); - set_pmd_at(mm, addr, pmd, newpmd); + } else { + newpmd = *pmd; } + + if (uffd_wp) + newpmd = pmd_swp_mkuffd_wp(newpmd); + else if (uffd_wp_resolve) + newpmd = pmd_swp_clear_uffd_wp(newpmd); + if (!pmd_same(*pmd, newpmd)) + set_pmd_at(mm, addr, pmd, newpmd); goto unlock; } #endif @@ -3251,6 +3259,8 @@ int set_pmd_migration_entry(struct page_vma_mapped_walk *pvmw, pmdswp = swp_entry_to_pmd(entry); if (pmd_soft_dirty(pmdval)) pmdswp = pmd_swp_mksoft_dirty(pmdswp); + if (pmd_swp_uffd_wp(*pvmw->pmd)) + pmdswp = pmd_swp_mkuffd_wp(pmdswp); set_pmd_at(mm, address, pvmw->pmd, pmdswp); page_remove_rmap(page, vma, true); put_page(page); From patchwork Wed Apr 5 14:25:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13201847 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 A5BE1C761A6 for ; Wed, 5 Apr 2023 14:25:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2805B6B0074; Wed, 5 Apr 2023 10:25:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2309E6B0075; Wed, 5 Apr 2023 10:25:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F8866B0078; Wed, 5 Apr 2023 10:25:46 -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 023D86B0074 for ; Wed, 5 Apr 2023 10:25:46 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C4AF2A04CF for ; Wed, 5 Apr 2023 14:25:45 +0000 (UTC) X-FDA: 80647561050.13.59DC145 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 177B08000F for ; Wed, 5 Apr 2023 14:25:43 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="i5DT0Dc/"; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680704744; 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=TfnoP0pltBdlQ2w25u609J1/Ey8g4v+Lfk8iXG6YZhs=; b=x4GlNSd6iFCkssKMjFVD3A5qzHpk2piBGhiL2UKGTfIQNg5eNcO3kXfKLG827lgI3ZMXZo fsM3TUS17YL/FSi+G7XVgdmwLXg1XkUlqC9NPCx6cowTw3X9czVcFJ5Ui7/k+1Q0DkRbqS eoVzKhpVYKiNwdSiU57+jzKrXiL7Qm8= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="i5DT0Dc/"; spf=pass (imf30.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680704744; a=rsa-sha256; cv=none; b=LORzESrlMRDWzRBgg3PxEAtawGIAbUwHDkNZCMsNhUfJ43k7lJVfxDKv8qN3ifsclryBbF P11rT0NB6+t8ds7kRZNmvFNxdjA0Z+HPJBIUaG2zaRLiTD1jv1uPuYO9ZrwRDOgLiw8po/ VKkREeSpcHgkw4EHyPDmI/9PAPeVCLc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680704743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TfnoP0pltBdlQ2w25u609J1/Ey8g4v+Lfk8iXG6YZhs=; b=i5DT0Dc/aj6dSP6M3cMcpZ9F6seUb8oEM2Gk3vFfvOvXAZ1PLR+hEtt+/mRyAXlYwjG4QT uuOBoDNgKt4Q3X1+l0pcq2zcwiPS0+zyZyHF6vU9V+xWV3odFLzpTpjbrzLgoWIA9AoP0d MaaJn/vRt/jn1u7ywrtQfu/3z5Hfb9g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-6Ct0lQxHOJy1mzCYccsCPQ-1; Wed, 05 Apr 2023 10:25:40 -0400 X-MC-Unique: 6Ct0lQxHOJy1mzCYccsCPQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C035B858289; Wed, 5 Apr 2023 14:25:39 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3DF7400F57; Wed, 5 Apr 2023 14:25:38 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Peter Xu , Muhammad Usama Anjum Subject: [PATCH v1 2/2] mm/userfaultfd: don't consider uffd-wp bit of writable migration entries Date: Wed, 5 Apr 2023 16:25:35 +0200 Message-Id: <20230405142535.493854-3-david@redhat.com> In-Reply-To: <20230405142535.493854-1-david@redhat.com> References: <20230405142535.493854-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 177B08000F X-Stat-Signature: jwset8gf9su79bsxc16bhmtnussnhiat X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1680704743-309635 X-HE-Meta: U2FsdGVkX1+taMiwL0jBxoQ5/NlkS7O4JWyAV4Xr1fkMrzmQUXCQwzDPA2NgUREIoSdxvagTqMX36HbrpPR4bcyBPFmYXmEF2hLq9NLkxzopxDZ/IyaDd33QlSzrRKSFWeQ+f1y/Y0mY12v2CTlc2xu9VNgTbZ4IoWyuIcAZDwQXsGxW1fhH52ipTMUebiFA/G0p509mXX8wPYRtVHnCj7dSoAXKpVZSzDqtDFc33E5w1HdZDe1R/lUneeTkvkz7B7Wji7BkjVgHSEEQs5mNLjDAgqnzhfVtv66ChSY762X1VEkOlufxRcowmq7pizA6gBMoYhPRp0BRSGZCmG7jTlm7BgJWDqeb2aTq9douo5RPgFwEEk/FTi8pgj2OIMLhSuE+pVyaW5dLeqq/dMr04KLQ4PtmE/xSQ47pm552Vu7N1eo5pW5kKYsmB5nH4rdu+mfpXQTJ4Z0KXlE2hKFsSGmLbwFxoXSFD/Pets7c/2/tJG0ql5qqSSTyj9EvO9rtMqr8QOz1UvGzbfIiF2qQtdgJnLihv6zlhpfTIgaKAtZwL9JnFJq27hi3tKhSUjSra5f+JcVuJvQqZAyu9/sN6Timwwrg6YNxOR7N1ogIJrTcPhyyDNRLN3S5l2QhM6mGnlAfqxaqb6iNDPL6D+Q+RIh8g2OAFqFFrB1zivJcRWijuE7bdm0Kq8lXZuIe31Ge6S8yIcPeKggwWpOK52mjCssDeF/yW3BYfcTdQp8tVdJ7MaLPohnl50GBh+/F1PZv8rOzM8h8fMRXwCcrAvUW/OX97Y6ibNQs/7kxXpwhcK/53KHTdltGmRKqvHpxiTSB1u/Qn3D1oE0sb5DqjijQBHN+HRPu9125V0QtCmjT6cIk2G0QR/eQnfSBvWEwmkZ15NdFR1iDCZLeUunrbfw9UQDI+APDgum7YQNjouwQu2JkAF/drQo3z1FQ0oXdQrZW/UPxkrwiGVIDb3rVkAd rfo2yAhO JMm212poA9JyHDY70/nJZNhvbRi1WnJLZFJMwcLIhh9FFfsc0+kAxgs8IMtX6pNkTwClhqWMe+b3vmeoJ4KaYvh9UG1i3QhcyulkUm0IrAovD3XrRCQ09cAyXY/Sd2SEIMy6vdXc6D9fSz7xb/cXLt9iKGruPE/Ao4n4pXQ3wf3qP5BjspBbpDyhPfA== 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: If we end up with a writable migration entry that has the uffd-wp bit set, we already messed up: the source PTE/PMD was writable, which means we could have modified the page without notifying uffd first. Setting the uffd-wp bit always implies converting migration entries to !writable migration entries. Commit 8f34f1eac382 ("mm/userfaultfd: fix uffd-wp special cases for fork()") documents that "3. Forget to carry over uffd-wp bit for a write migration huge pmd entry", but it doesn't really say why that should be relevant. So let's remove that code to avoid hiding an eventual underlying issue (in the future, we might want to warn when creating writable migration entries that have the uffd-wp bit set -- or even better when turning a PTE writable that still has the uffd-wp bit set). This now matches the handling for hugetlb migration entries in hugetlb_change_protection(). In copy_huge_pmd()/copy_nonpresent_pte()/copy_hugetlb_page_range(), we still transfer the uffd-bit also for writable migration entries, but simply because we have unified handling for "writable" and "readable-exclusive" migration entries, and we care about transferring the uffd-wp bit for the latter. Signed-off-by: David Hildenbrand Reviewed-by: Peter Xu --- mm/huge_memory.c | 2 -- mm/mprotect.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index bdda4f426d58..f977c965fdad 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1853,8 +1853,6 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, newpmd = swp_entry_to_pmd(entry); if (pmd_swp_soft_dirty(*pmd)) newpmd = pmd_swp_mksoft_dirty(newpmd); - if (pmd_swp_uffd_wp(*pmd)) - newpmd = pmd_swp_mkuffd_wp(newpmd); } else { newpmd = *pmd; } diff --git a/mm/mprotect.c b/mm/mprotect.c index 13e84d8c0797..e04e9ea62ae7 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -223,8 +223,6 @@ static long change_pte_range(struct mmu_gather *tlb, newpte = swp_entry_to_pte(entry); if (pte_swp_soft_dirty(oldpte)) newpte = pte_swp_mksoft_dirty(newpte); - if (pte_swp_uffd_wp(oldpte)) - newpte = pte_swp_mkuffd_wp(newpte); } else if (is_writable_device_private_entry(entry)) { /* * We do not preserve soft-dirtiness. See