Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4792026rdb; Tue, 12 Dec 2023 09:23:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPBtWOc705/1CyYczuqgBAKN16cYayZtQ2tL6h/ASSKBoYzelpPDn1LszmJd4xsSVQPgAF X-Received: by 2002:a05:6a00:2191:b0:6cd:fa30:f52 with SMTP id h17-20020a056a00219100b006cdfa300f52mr8110412pfi.9.1702401779665; Tue, 12 Dec 2023 09:22:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702401779; cv=none; d=google.com; s=arc-20160816; b=XaG0km6bLKNYFG5/qgOkR6L5SeyAMsGnQoIfXMbaDr7935BvH41Xni8r/qou+N8fks WeaqPQGZBCwNlne8rI6nvnKc15w7klW5twejiRLk5+a8Qp//1vHMwA+iRynC5TD4tlOf 5YM0W76yIdSZM+NAjyIHfkpX6cy/NZLgnuCyE5zme2yfT06kTVSxsE8CPOnVn8S17pxx j3EZS1JShI9RKqP1mMlwsmgM8IdS2LQsvj1iYBJll7DW8+Aq564rY5rWP1mn7fZROAuu ahuCRNEH2lDHosqVRO9SGFabxrSnArU9oknmyJ91pNaFI4mkC6XP/onLRVaE+5/O58EI VSAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PNXEoSCmxWPDl4w2YRtRZWjOVcIl1MNDmuvCchhC0kE=; fh=0263zMU6Kc4coG/bcj8+ovoTlMnS8NLBeu4ye90n/+4=; b=czdsxdTlTPFxxGc0N7J9ACxi4/HGNK/c6PKUvqBnGZKcgeBgAa9oq2hjj/ZkUkNsYd MH24IuzX6+bRbsJZ8n68fqp4W+tqV7lAxQ8bjS1EWQZAkODiEBoLdlOuKRYAESJDpO9v dNsY/FyXo5WG5gcyzrWzrIUbj4e9SEwA3j1I/3yvORVXBIFdtFZZ8WD/gX7COnGoZyDc 2E66nlYe2NPuPPSN4Ia4Ar7hIVjPcQz3rpolETuU5zdbly+UNIwLBewpbR9i/+SqJ7u8 xNmuIxLkSZajEXB58oDHG2Aak7VP37afix+CTmcFV/X54FcusUesz6RT5PxIZZnlymLZ /w5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id j7-20020a654287000000b00578d3f8d4d4si8025730pgp.448.2023.12.12.09.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 09:22:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3C14580A5661; Tue, 12 Dec 2023 09:22:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376558AbjLLRWe (ORCPT + 99 others); Tue, 12 Dec 2023 12:22:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376438AbjLLRWc (ORCPT ); Tue, 12 Dec 2023 12:22:32 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75CAE8F for ; Tue, 12 Dec 2023 09:22:39 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FF92C433C7; Tue, 12 Dec 2023 17:22:37 +0000 (UTC) From: Catalin Marinas To: Steve Capper , Will Deacon , Andrew Morton , James Houghton Cc: Mike Kravetz , Anshuman Khandual , Ryan Roberts , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song Subject: Re: (subset) [PATCH 0/2] arm64: hugetlb: Fix page fault loop for sw-dirty/hw-clean contiguous PTEs Date: Tue, 12 Dec 2023 17:22:34 +0000 Message-Id: <170240171502.947884.1971452020621917745.b4-ty@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231204172646.2541916-1-jthoughton@google.com> References: <20231204172646.2541916-1-jthoughton@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Tue, 12 Dec 2023 09:22:57 -0800 (PST) On Mon, 04 Dec 2023 17:26:44 +0000, James Houghton wrote: > It is currently possible for a userspace application to enter a page > fault loop when using HugeTLB pages implemented with contiguous PTEs > when HAFDBS is not available. This happens because: > 1. The kernel may sometimes write PTEs that are sw-dirty but hw-clean > (PTE_DIRTY | PTE_RDONLY | PTE_WRITE). > 2. If, during a write, the CPU uses a sw-dirty, hw-clean PTE in handling > the memory access on a system without HAFDBS, we will get a page > fault. > 3. HugeTLB will check if it needs to update the dirty bits on the PTE. > For contiguous PTEs, it will check to see if the pgprot bits need > updating. In this case, HugeTLB wants to write a sequence of > sw-dirty, hw-dirty PTEs, but it finds that all the PTEs it is about > to overwrite are all pte_dirty() (pte_sw_dirty() => pte_dirty()), > so it thinks no update is necessary. > > [...] Applied to arm64 (for-next/fixes), thanks! [2/2] arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify https://git.kernel.org/arm64/c/3c0696076aad I only picked up the second patch and added the description from the cover letter into the commit log. -- Catalin