From patchwork Tue May 23 00:43:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13251299 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 7E504C77B75 for ; Tue, 23 May 2023 00:43:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C881C900002; Mon, 22 May 2023 20:43:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C112E6B0074; Mon, 22 May 2023 20:43:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB1B5900002; Mon, 22 May 2023 20:43:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 985956B0072 for ; Mon, 22 May 2023 20:43:17 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6080BC0522 for ; Tue, 23 May 2023 00:43:17 +0000 (UTC) X-FDA: 80819670834.11.28CDBD6 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf14.hostedemail.com (Postfix) with ESMTP id A71D5100006 for ; Tue, 23 May 2023 00:43:15 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=JF9VmGvn; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of 3IgxsZAMKCBUAxx19916z.x97638FI-775Gvx5.9C1@flex--pcc.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3IgxsZAMKCBUAxx19916z.x97638FI-775Gvx5.9C1@flex--pcc.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684802595; 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:in-reply-to: references:dkim-signature; bh=SK35moxCE6AhlCZl4FimQ53XrewZjdQKUPUW9jfTNhI=; b=5ioJ1O1lYhOM7XtezvK0L3TwjuA8U8+ObIZ1yDVWWAa0bNHXAHy6P5SuuhcFmhdYUB9vP+ HQVcr2KEsz5VZG9DG+Tnzh6Z/Z08ITctneI0aC2D8yHSWL5T5o3PBPp8nyUZy1lCCfJ0zD 6Ndm9/1huW7kucU08U5qXtCXrBoW9FY= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=JF9VmGvn; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of 3IgxsZAMKCBUAxx19916z.x97638FI-775Gvx5.9C1@flex--pcc.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3IgxsZAMKCBUAxx19916z.x97638FI-775Gvx5.9C1@flex--pcc.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684802595; a=rsa-sha256; cv=none; b=5+jELicqVUjgAGi2wq0tfJxjggmaHoUe+BrE8RrLFSWfd8gzQvbop9QPiNTeC9uDnzoVRe L708Zqz1zBTvn/gCRlXrNag2HDT0GCNDMIx8WXKo5hr5N/MiBG3z1pE8KVwASvnrqbpxvw KKACyE0JbpGJoyeyzh2u3N/Y+eVszEE= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-561d565cb0aso69025937b3.3 for ; Mon, 22 May 2023 17:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684802595; x=1687394595; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=SK35moxCE6AhlCZl4FimQ53XrewZjdQKUPUW9jfTNhI=; b=JF9VmGvn6ME+aV3DWd+moD6DHriILl/eHSLrRAVbk557Nfyq2aEPhsaPiGBpDbWYew xfxlvpIcDqTn+OyodXR//4275XAoEeYjxwdP8/SeVRQSlV9QMoEG8a3I0GYpUHbADTXi BO0ai4br/mZs2NpalBibKFHY6KZ4WD2OYLEBP5rVthGV4zZXo73DugZVaCiFg4N10L5J y3ow4VUMSVguwSU9N8aUagGsIBAOX6iR6VVTKqq5fCbzvHjN3f3blh1NFR8W7EXCmsJj sFhkDMgC+eXM3eLCgw3471dz7sjLpCIriVTG3t6mKGIBUQCgosKE3bott3R7ljUVNJdY TnpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684802595; x=1687394595; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=SK35moxCE6AhlCZl4FimQ53XrewZjdQKUPUW9jfTNhI=; b=GunNE/yzRmv0DuoEly1QN/pHENPDUeLcF7Gg2R+FlAQSEd2RFgO9hs77Y0t2Uu/3WT qFx993xZZnSHP9+V6fAUDgL1oTIvJw6vZixNLfNWv+fthoPIOpbVb21Ru/34I9m/+hgE zb71u00Y7grBp354W94f7gfzcg1H1GN8hfipzJFQFOtysf4xThnzp5j1hyIL4XUQiCYd Gy6lBHySvC7vgbmu5eWO3kK2u997MokSpk3VUZLI/RVrY0A704aqoXbubrfGMjmGL/EJ G/SjqKRy0kFAGCasnWW6+UfNKwDrpFeC0G6lDVYpgxCaGRqeMr4BzNw9LnCs6CcADb4/ nSYg== X-Gm-Message-State: AC+VfDyJY1UQeov+OZ1xbIwflDuB52XSiGNbBxny/LnTpTbDrDQtxNoQ bacpwNep7gEHlzfKtnGPGLx4qMY= X-Google-Smtp-Source: ACHHUZ56AYrmc0MsawE025S+h8rVdf9CVXEi3oX5IjzyzrBK6rGupgdJl7OAemYukbnsFVJHjsbsG3s= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:3d33:90fe:6f02:afdd]) (user=pcc job=sendgmr) by 2002:a81:e508:0:b0:552:b607:634b with SMTP id s8-20020a81e508000000b00552b607634bmr7917763ywl.4.1684802594841; Mon, 22 May 2023 17:43:14 -0700 (PDT) Date: Mon, 22 May 2023 17:43:07 -0700 Message-Id: <20230523004312.1807357-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v4 0/3] mm: Fix bug affecting swapping in MTE tagged pages From: Peter Collingbourne To: Catalin Marinas Cc: Peter Collingbourne , " =?utf-8?b?UXVuLXdlaSBMaW4gKA==?= =?utf-8?b?5p6X576k5bS0KQ==?= " , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "surenb@google.com" , "david@redhat.com" , " =?utf-8?b?Q2hpbndlbiBDaGFuZyAo?= =?utf-8?b?5by16Yym5paHKQ==?= " , "kasan-dev@googlegroups.com" , " =?utf-8?b?S3Vhbi1ZaW5nIExlZSAo5p2O5Yag56mOKQ==?= " , " =?utf-8?b?Q2FzcGVyIExpICjmnY7kuK3mpq4p?= " , "gregkh@linuxfoundation.org" , vincenzo.frascino@arm.com, Alexandru Elisei , will@kernel.org, eugenis@google.com, Steven Price X-Rspamd-Queue-Id: A71D5100006 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: b8dss5kyi4zm7kopbgbe17c5c4d6zwj1 X-HE-Tag: 1684802595-222590 X-HE-Meta: U2FsdGVkX1+dZ/19CLzs+HapEhME/5Zo3ZEW1SagfHgCJTeNbKTgTU1Z8A78LIqJBtdESnorpGavrjG0FKsk/rX/7aSebUAeCvLivVLMg1lNBJn8HXX3Ja3S2X3gm4iI4JE+A3X6k8FNkk7X1iF/2sWUaUqZION/2Gyxn/otpIe8Q/G5dk8cu73zaSb7QSUgbeq9McjUUeMQM43Pz6m8ZZppv+FBeX8Z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LN6V6eEDIuxvDz0I6+dqKTXFFFjtsMNBW402LwV+jvmHIKCCpnkl1pjRyeV1cV9bD0YQwJOrROw1iDoGXAWckNMbdTXv4F9c1AoyczcW+H/KifplhcanYxpjqr4EtY7pkNx4CxdsNpSl18ZXDODpCEYW7FXuSoRTQ8PKQsrYwrlFNEYs1LYAZ30OHs1b255ZFsNSr7SVX9F8H7AGOWW2WeulZrzXGjTSYZq5/HXZcfABQqFXQR6W7r6+2edNxGFTyIlYm/DPhdfTjVeuWsilVFya1TYZ8LxchXbep/xQDDhYVFyhQkD+huAuHktQBeuf5a7Idz7Dl2ig3oHi/Dlg7z3ENNt+4RwGX7WPUbm1kzz55yclWP46bA4z6KTsnBkgy+wuMPjPHGx5F6XM9TiJ2KSV5mGqJl2Xc2tsk0oogWsQ 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: This patch series reworks the logic that handles swapping in page metadata to fix a reported bug [1] where metadata can sometimes not be swapped in correctly after commit c145e0b47c77 ("mm: streamline COW logic in do_swap_page()"). - Patch 1 fixes the bug itself, but still requires architectures to restore metadata in both arch_swap_restore() and set_pte_at(). - Patch 2 makes it so that architectures only need to restore metadata in arch_swap_restore(). - Patch 3 changes arm64 to remove support for restoring metadata in set_pte_at(). [1] https://lore.kernel.org/all/5050805753ac469e8d727c797c2218a9d780d434.camel@mediatek.com/ v4: - Rebased onto v6.4-rc3 - Reverted change to arch/arm64/mm/mteswap.c; this change was not valid because swapcache pages can have arch_swap_restore() called on them multiple times v3: - Added patch to call arch_swap_restore() from unuse_pte() - Rebased onto arm64/for-next/fixes v2: - Call arch_swap_restore() directly instead of via arch_do_swap_page() Peter Collingbourne (3): mm: Call arch_swap_restore() from do_swap_page() mm: Call arch_swap_restore() from unuse_pte() arm64: mte: Simplify swap tag restoration logic arch/arm64/include/asm/mte.h | 4 ++-- arch/arm64/include/asm/pgtable.h | 14 ++---------- arch/arm64/kernel/mte.c | 37 ++++++-------------------------- mm/memory.c | 7 ++++++ mm/swapfile.c | 7 ++++++ 5 files changed, 25 insertions(+), 44 deletions(-)