Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2864560rdb; Mon, 4 Dec 2023 09:27:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKfkTc/IxVXpB9dUrMHdWz24L9ERNzP3CT51NXkS/+5nHhzZoPSik20Hz+q6W0Lvj3U1ft X-Received: by 2002:a17:90b:3144:b0:286:71c6:6b70 with SMTP id ip4-20020a17090b314400b0028671c66b70mr59200pjb.43.1701710853096; Mon, 04 Dec 2023 09:27:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701710853; cv=none; d=google.com; s=arc-20160816; b=yMg6hGaQ/Wg0oEOkbAl7h6ALv6+5XLjP8eF5X/drVPuDMSh8swkFprcWSxh2OZ049n OKZmh9r2EACH3sw/gqzTYm+Bq1mChbRMtpI5ThOBZM8bsV0F7raBx5g95hn2bL60L6qV ENAYpv/OOz1wWpVDtRArJeRkTQSBJCr9Y9F93sqohDfuRRccNMZqgOkdaWfMW43vebhW 1aBYF7ZmeswV3OtD9hmAroPa/VmOC6Q1mwpG6bAi6bzd7jlOp782XoRhyCQ1vTp+I/yY Zj766bhot74I6C64sJwYRl1yF7tV0bMBZHxboe0GRGmeEWwYbkml/4op31seVcwv3Zyy jX+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=BIP1VBSrHfriGjh5Ogk9INZtbtmoj9c5sEQfKrkJBSE=; fh=MJxrAMNk1xt5eTwPYlce6LT4l1O5DiRP7H6bsCVP2JY=; b=WgdEiEHKaG45JmoJihDZAqQDp8ieLmVHdk9Ktc7LMB4ftNcd0EAJL1IN02pUbk6nk9 p17uUbuUwM/ML7VMu8UunlHRrQrymboMfWf0kLNWPtNU6NvLoiVahrkXzPwEJpRWEpsy U4ak9vdlGUWIh0SLRGzj8FCYskVO/7ncV+HQkXQRsRKiOFpKOUuL/u+Bzi2Ll4WVPISJ ekBG+jwVg+jiBgd/plNqIhyu3E+OJ3vNXR4u1TP0rrkE3cAUbGWhX7nxZJGLwqZQ/Hx6 kTUS+X2Jd/p6MZkbDVYlPu21XCOHs1izEOUWzdrJaAVo/cXIHX2tBpaimtkNZLCTWvL0 z/CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="m4uH/7hz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id pm9-20020a17090b3c4900b00286b88b108bsi1669357pjb.174.2023.12.04.09.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 09:27:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="m4uH/7hz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 9C689804C21A; Mon, 4 Dec 2023 09:27:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbjLDR1I (ORCPT + 99 others); Mon, 4 Dec 2023 12:27:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbjLDR1G (ORCPT ); Mon, 4 Dec 2023 12:27:06 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA43C0 for ; Mon, 4 Dec 2023 09:27:12 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5d0c4ba7081so78366597b3.0 for ; Mon, 04 Dec 2023 09:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701710832; x=1702315632; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=BIP1VBSrHfriGjh5Ogk9INZtbtmoj9c5sEQfKrkJBSE=; b=m4uH/7hzVu5zigT1huoKtvcvFkWnSAug3GAlEda3+9FUh0K+crF/J5hHQzUHGAt4rl ej3lyThtJQiZunyJaNC8od6dZxLx6rwkT40wY/fwMY+B7TLGEa/fVu4xO6M/KNGnm+sD rBNbNpbOGcoFRpglZ4viyH0DMU1/KrJnD7N2wzTTr5YcHzI+FPQG3SXhraLaBbNdyQNQ 6c2Wxx+98ueDomh7lThK9UM52Ewh0/BMzWkxtC0A/6QZGdUF82kkmgvxSpknTvVf8aUW T1trWAXZclpo1OP63LF7Yaacq9pxr//sppS719lkVKiTquvM2eTH2zy1ZqXzdQBXjlsO I7BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701710832; x=1702315632; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BIP1VBSrHfriGjh5Ogk9INZtbtmoj9c5sEQfKrkJBSE=; b=pQCpQ7NQLtJm+nr9S9imziSyZKEqLU0xcPaptpFgPVdOixN7kcOlg5y4/x+jhSp3aB pcsz//4yXFwmteaeucEqeC/RHmTz6Cq3Bwojf4RH+7Q1wqrrmSLvbblWsgKwL8xRhGCG hfJCJQbLiM/EwHD+iD6dIb8gth87eyzIXznvvpqjMVARLOwtCNp3mj4ARez5uPtk7l46 6YqtpE58zFSHRVEVTUuiATkI86Pl9G958zsl+UYeBzAz4O3uvaDj13CLrQOntfP5Dl7U R9jcBWCl6a2M7ndfWSJaBkKrsM9uLWD6RxK3aWY10N7zJzuvmxM7N1bzxUyCgB9uqPGm V7aQ== X-Gm-Message-State: AOJu0YxJt9qkbLmh7nZCFzH+UrJBwpAB+OnaWWIRw+33mNk1b/BWvFzv iJuEXdCBI8AKSK+Zapt6wzZiylhGLoXUEAY9 X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:690c:2710:b0:5d5:5183:ebd7 with SMTP id dy16-20020a05690c271000b005d55183ebd7mr222984ywb.7.1701710831851; Mon, 04 Dec 2023 09:27:11 -0800 (PST) Date: Mon, 4 Dec 2023 17:26:46 +0000 In-Reply-To: <20231204172646.2541916-1-jthoughton@google.com> Mime-Version: 1.0 References: <20231204172646.2541916-1-jthoughton@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Message-ID: <20231204172646.2541916-3-jthoughton@google.com> Subject: [PATCH 2/2] arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify From: James Houghton To: Steve Capper , Will Deacon , Andrew Morton Cc: Mike Kravetz , Muchun Song , Anshuman Khandual , Catalin Marinas , Ryan Roberts , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 09:27:30 -0800 (PST) Make it impossible to create a sw-dirty, hw-clean PTE with pte_modify. Such a PTE should be impossible to create, and there may be places that assume that pte_dirty() implies pte_hw_dirty(). Signed-off-by: James Houghton diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index b19a8aee684c..79ce70fbb751 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -834,6 +834,12 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) pte = set_pte_bit(pte, __pgprot(PTE_DIRTY)); pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask); + /* + * If we end up clearing hw dirtiness for a sw-dirty PTE, set hardware + * dirtiness again. + */ + if (pte_sw_dirty(pte)) + pte = pte_mkdirty(pte); return pte; } -- 2.43.0.rc2.451.g8631bc7472-goog