From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E117C4332F for ; Tue, 12 Dec 2023 17:22:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376573AbjLLRWg (ORCPT ); Tue, 12 Dec 2023 12:22:36 -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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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