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: 13251309 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 F1497C77B75 for ; Tue, 23 May 2023 00:44:15 +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:Cc:To:From:Subject:Mime-Version: Message-Id:Date: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=jFmZSMOG69zfMogoIeIJSKWxylS24AhGUL4tj7PYV34=; b=1Oj RHB4L9MafXAcTNTlATDvsqHAEyFNgEwhgc07Ic9+hB8Z/eL/pLBBughDPNCiURNbkUR3HXVb3x8bw 4yipz5dKrOJeqc2k1cB6D9mRYukJXuwVdqeV0GqcSmTRSHaOiiozKymHOIlP8giV1HzMpi5d8PxRw DxtUbcPg0f6ecNNFq6yLiGAdP5+jG8v6vCaKDJM23yn66ZmGfSHXuQy+4WQT5eHcLemgVzxOQLUqt 69ml+Zr1UEiHeCb4o1gwdgMHwaevptPe/i/XIbNWxUdW2V84xP8WaXTRCxmU1Ymvajh9fWf1WT4Yd OGtFzPTYOQdmaPXWdlYwTBz3OhjtNXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1G7W-008V9B-2k; Tue, 23 May 2023 00:43:22 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1G7S-008V7j-2a for linux-arm-kernel@lists.infradead.org; Tue, 23 May 2023 00:43:20 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-561d565cb0aso69025947b3.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=FO3hzTeUXh70AZuO01JsDJ47b7Hq3IjW4d16JqYgCzrhzx55EaNf+EBcdhCb9DPtW5 wEv9uw8629RdrnCHf/V4EVrYeOdhTSNIoWCCPkamgQDMNkiBvephooYhgxhx7fV3aG6u QLuOLW0Eslb40QIAzVuDgMq0c1tsBY0Dp8tAt+9V1Xdx8xwdaTdymmqDDD4QP020SRHT KqEx1iznE3jSGAQtjq7uAvxKSdc8TVinFZoMiJ7YLJapFG8wR03Z1ax/u+3zgbzfR1Ww BCMa4Yqo1Kzv343j9ey1XBViylkjPnCaHmm/sveQmGRDgImRKbIn8Ka/fcwqB2DNqkM1 ZlaA== X-Gm-Message-State: AC+VfDzjK1Qss9l9UZe5+fo0qHxOvOK25SSwC0/vTgDpPOA0Lw2gbUtZ XNWugKUFjroqNfhQud7gkRQOJ7M= 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230522_174318_841080_FE03152E X-CRM114-Status: GOOD ( 10.54 ) 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 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(-)