From patchwork Wed May 17 02:21:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13244070 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 F2093C7EE24 for ; Wed, 17 May 2023 02:21:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D62B900004; Tue, 16 May 2023 22:21:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 560A9900003; Tue, 16 May 2023 22:21:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 400F7900004; Tue, 16 May 2023 22:21:26 -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 2D755900003 for ; Tue, 16 May 2023 22:21:26 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F099A1C6D23 for ; Wed, 17 May 2023 02:21:25 +0000 (UTC) X-FDA: 80798145330.11.C15EE31 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf13.hostedemail.com (Postfix) with ESMTP id 4A6C420009 for ; Wed, 17 May 2023 02:21:24 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=KUAjUFSP; spf=pass (imf13.hostedemail.com: domain of 3IzpkZAMKCFI9ww08805y.w86527EH-664Fuw4.8B0@flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3IzpkZAMKCFI9ww08805y.w86527EH-664Fuw4.8B0@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684290084; a=rsa-sha256; cv=none; b=20HiHoVZ+2TfqVA6mjGrUGhpEGB+jOCbsdv3xjremM8Dlta5pFBZ3ovBKKwWIR70LZ/1Fz xJqXcB6exbW83fID+pTfagvo3dBrz9+g3fsGn22e7QDRH/l22W0CgFpMtINwj4qPFsyAFv KOW6mrkaN7tG4usthK8Ol/wKda4Ba7E= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=KUAjUFSP; spf=pass (imf13.hostedemail.com: domain of 3IzpkZAMKCFI9ww08805y.w86527EH-664Fuw4.8B0@flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3IzpkZAMKCFI9ww08805y.w86527EH-664Fuw4.8B0@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684290084; 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=DbvIotRGfeUI08jv8AEiwlw+JO4JY4xCfZlRx6U3EOo=; b=vuudEKcmK6hrYSFC4jUWODQn8cFPSGIq/KgPV34FfMaH1OeBxKmBnUvn8qinHoiih2PZ4D dcLbajW8Scx6h1G9/N95UN80snFhimDDVSuVTwvWzLiD/ygf5z4Eu9I2iMawy3x/96UEgz XC+C5YPIxlIiuMo4w+GU6weKeXo730E= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-ba81b37d9d2so220629276.3 for ; Tue, 16 May 2023 19:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684290083; x=1686882083; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=DbvIotRGfeUI08jv8AEiwlw+JO4JY4xCfZlRx6U3EOo=; b=KUAjUFSPrTObC3hg/4eFzGEAYHdVyshHZdyrXJc5KM2+ApESlbodJxFclR3YXvSKuy kLOT6ZdR4Ohc4e6WLZv+NG13YniC23eIgKsDzKhXjT4gOGcOJ2uRdUt0pqfkKLiCkksk lkw8+v3lrxIgT5X4LzGBewpBv4Dud1I+wY37cJ3oSnYl/yPDUDK/Up98aTyjDQ04NhMP jTiiQChMP2VXsYI8jCvRhbkJjo5tai4Kx77eSn2JI3ORttioIag8vv05s95dP3/TmsMw MbTWpSFmhHnKx78X/4B6zv31Tl0ERVcNveLr1aTw7w/wCj644yKhpI3JdT9AtVh1ISco lYhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684290083; x=1686882083; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DbvIotRGfeUI08jv8AEiwlw+JO4JY4xCfZlRx6U3EOo=; b=K/AUJxGei3GPHDtWD+pkyHQmMCxxgZz24WXq4P3LLMDEtlSkQYFx4ppazn7uAH+Psx 4WluKoI/xJaxUMyonJnG/zx76xFXRgRwHrjxoXWuxy/IaPnskPMv1amUBHWsTN+mTRvm oDNVo+li3j9e0xIXuPdQEdYR/TiHXkUankAn6CVtk8ia3mX4UQTURprzZw42Pj4NBQDl Ws3JICXdf9ebX3DP8E53V8fQQ9pDTy1VMRl4sdHnYwMQm0tMKRFNaTdTyf3val+11e2z 3IugLznQb6LObYzM5UiFtTOgfAY80WY6royTFDTNpX0nwsEOK1BrTEydN7IhNXb3zj0a Enug== X-Gm-Message-State: AC+VfDyOaTUgP/7pYR/nE+NFiZ76EWSvdy05sWqtk2NyanmaC+LlxFTD XA7MbeDEKQigTAwNFlFROletDrc= X-Google-Smtp-Source: ACHHUZ4fdjqimU4JmDpRktxQF9oQ9T6d7e3Yb7VykHUg7Ik7O9Au34ajlZWnInBmmASi8g9Q5p5F+oI= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:b3a7:7c59:b96b:adaa]) (user=pcc job=sendgmr) by 2002:a25:7708:0:b0:ba8:1b23:8e66 with SMTP id s8-20020a257708000000b00ba81b238e66mr1996246ybc.9.1684290083311; Tue, 16 May 2023 19:21:23 -0700 (PDT) Date: Tue, 16 May 2023 19:21:10 -0700 Message-Id: <20230517022115.3033604-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Subject: [PATCH v3 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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 4A6C420009 X-Stat-Signature: tidnqrm1wnbr58nbu9r8r8eeqax56689 X-HE-Tag: 1684290084-269079 X-HE-Meta: U2FsdGVkX1+Jiy78HamKQLDnxBtGgAHwy1BH4xQceXuM7E/juDp29Fy3zW50X8N0Ugp0zWjSJLK6zjOEwvAymFxd9khsp1c1Brkz1C8B3pWrClvGwritntbjUEc4E6nKK0XZoJSEt7QwnLfxNh1oH9Fe9r7fAJNwTam/ujrQSrEUKYeDCMCxbPwhN59hpGIiA0qmlLbWBmuwBi6IrdF9v18LEegv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YiOQhYaqsaGvZNBr/qJr0wYilxKGgKri2Ccm5T8wmWcXWI3CnNdtRMrYx91uPLUTmJe9PbWERZkMc+Prhle/Gm51we4Nd7H6vksHhJMX8DcYFCe3lwKMWVWcBEcmnM0Rla1O5DbmxHqY6qBVc26HnqP3RX3jTT9o0R7NDYIOuI3ScDC8SbmcBkvgxk89FCj7dmYrtomaZc70FCx+CmTmuazMEDBnor7Z3JdduZSEEP+z9pTucOOoBKI+sCscOfjPoCN9LShJr2LzvE1x91huP4anI40DKQzASAGorEScQl2X2hCQmDjdqycknRtyAzzkoF6AoInNwT+16XXbnuj5nE9CGddNJpjEIFHLLDXnisfr5iyaCliu0Kam6ctEqgS5c38MZnnAEliqjAEKvxmM+BPXJlOm2UCo4VjQ2nhiQl 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/ 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 ++++++-------------------------- arch/arm64/mm/mteswap.c | 7 +++--- mm/memory.c | 7 ++++++ mm/swapfile.c | 7 ++++++ 6 files changed, 28 insertions(+), 48 deletions(-)