Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp686591rdb; Fri, 2 Feb 2024 00:12:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUB+JWh+4zNOejYQbMeRAzDiL6VrD82rY+AK1aEpH7MVDf7PqhexnJT9YTfSvZYGqtT5ZN X-Received: by 2002:a17:906:32d7:b0:a37:ea:bfd2 with SMTP id k23-20020a17090632d700b00a3700eabfd2mr795701ejk.73.1706861573363; Fri, 02 Feb 2024 00:12:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706861573; cv=pass; d=google.com; s=arc-20160816; b=FcAdYBm4gMGnSOeMDxxiIPH0eW73uH42/QrijcovE29ftIJ6tIM9Y2j2euY7VnBX4C e0iakGzaCEUaBT1/npLS/p1ag0I/qPBcBR/I5impWzXKOoI8iMzs51KXjuWoqvr1uxCd GwHZHwUW8B0FJlv9Gi8ysgIX0bfmJb0mVfeyl4PL1D5OOSrYwXKAHUlq3IWD0+GmXF3f vXjj6vVv8BW671h9k2KK84DYMn6xj4lxeUdqlckbUOPUOt1OKwA5azZLKzGNec1ntcsX SGAIJOyplb43fA9nU31geXyAAz9m2sP7yGhgGN2qvjOQIxOMvh5r0+qWcEYcEAA3J5RV YhqQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=n5ldPMFAPklGXLjzR2u+4xIeNMfWz8XyKASMmqWuzUc=; fh=mfhluDl+QHObORKXXHTpN3+0khlOf1uF00k2R+3Up74=; b=uq+TaJrBEpe0PM0biJSjTZcCpUw3NKKGax2Mj2atuiNr29BouRAmUC90EmLQOu7wZ7 89fQjGioDNZafWCRQQ/7/992F3Lgl3GAko1NmUGV8sRXPCi/eCxxvaSYdC3HxSqYCbJv 1fvzsqVNoOPxB2hNwtVJL/BPkcKxgGP37Cut6cAJCfOffFTPi/e4QdfHjmW/zNXEO+P8 o2Z11osykejn7NWdv/9tyIS4daZZ2QDs8Aq+sG2EReoXRqvw9PtG3X5cRA/aNmH5igPg NjUS+oJJAagPNNx2NY4YZxTG/QgMZNOybPspYMZ1NqzJAEDkoOKNJxSx8kT7mPCjZOy1 ZZiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-49428-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49428-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCWaOGVFEKqIPMppWwmGgzRcueb1MLD6kq11XbhR7UBNBb+kzKzuyfSve7/0RjlPf3p1A5gVojrr3ROByag+uI2xwbonM49PXgLwkxMWbA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c3-20020a170906340300b00a36834939e3si560123ejb.650.2024.02.02.00.12.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:12:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49428-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-49428-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49428-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1F6EA1F21F42 for ; Fri, 2 Feb 2024 08:12:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C257B4879F; Fri, 2 Feb 2024 08:09:16 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A1394878F for ; Fri, 2 Feb 2024 08:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861356; cv=none; b=fBynZ4Zml/IsL/fML4K3oqjT0EmDKrkmo80Tp2kiVOdMX4YoFTe5LIsIMz5X1E6hIgVdonufVp/mKYVa/7sEc0Jga1PTM6dbJJLMz61vwlDsgHfQjAweuBQ15wtZaJmTtBTa2RtNf+DePcX1Z42hiDVtq0fOZ+d7lapesTdaiSk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861356; c=relaxed/simple; bh=L8OR5Yo+BhLvUxEQHYat8c5+gAgt6YHYoztuuBWx1DI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=POyAwqEo1g4bBaX88mD32J8g01gXZb3kHycetOst8S27OEWDYANRc3QkU/vcfmVE//cfTkFwqatnvVluXyt58bRPtWZspP+2RGLByPQtoTiwxF//VWSwcsP1Zb9HO7m8Fbsv7lR6O39fXawgUklBOjsWs2QPERwWBy8GS6+ZVDY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DB9861AED; Fri, 2 Feb 2024 00:09:55 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EFF383F5A1; Fri, 2 Feb 2024 00:09:09 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 15/25] arm64/mm: ptep_set_wrprotect(): New layer to manage contig bit Date: Fri, 2 Feb 2024 08:07:46 +0000 Message-Id: <20240202080756.1453939-16-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240202080756.1453939-1-ryan.roberts@arm.com> References: <20240202080756.1453939-1-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Create a new layer for the in-table PTE manipulation APIs. For now, The existing API is prefixed with double underscore to become the arch-private API and the public API is just a simple wrapper that calls the private API. The public API implementation will subsequently be used to transparently manipulate the contiguous bit where appropriate. But since there are already some contig-aware users (e.g. hugetlb, kernel mapper), we must first ensure those users use the private API directly so that the future contig-bit manipulations in the public API do not interfere with those existing uses. Tested-by: John Hubbard Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 10 ++++++---- arch/arm64/mm/hugetlbpage.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 2870bc12f288..4c2d6c483390 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -970,11 +970,11 @@ static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ /* - * ptep_set_wrprotect - mark read-only while trasferring potential hardware + * __ptep_set_wrprotect - mark read-only while trasferring potential hardware * dirty status (PTE_DBM && !PTE_RDONLY) to the software PTE_DIRTY bit. */ -#define __HAVE_ARCH_PTEP_SET_WRPROTECT -static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long address, pte_t *ptep) +static inline void __ptep_set_wrprotect(struct mm_struct *mm, + unsigned long address, pte_t *ptep) { pte_t old_pte, pte; @@ -992,7 +992,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long address, pmd_t *pmdp) { - ptep_set_wrprotect(mm, address, (pte_t *)pmdp); + __ptep_set_wrprotect(mm, address, (pte_t *)pmdp); } #define pmdp_establish pmdp_establish @@ -1139,6 +1139,8 @@ void vmemmap_update_pte(unsigned long addr, pte_t *ptep, pte_t pte); #define ptep_test_and_clear_young __ptep_test_and_clear_young #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH #define ptep_clear_flush_young __ptep_clear_flush_young +#define __HAVE_ARCH_PTEP_SET_WRPROTECT +#define ptep_set_wrprotect __ptep_set_wrprotect #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 7e74e7b67107..f6612f3e1c07 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -493,7 +493,7 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm, pte_t pte; if (!pte_cont(READ_ONCE(*ptep))) { - ptep_set_wrprotect(mm, addr, ptep); + __ptep_set_wrprotect(mm, addr, ptep); return; } -- 2.25.1