From patchwork Thu Sep 21 16:20:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13394010 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 7EFD8E71093 for ; Thu, 21 Sep 2023 16:20:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 116CD6B0209; Thu, 21 Sep 2023 12:20:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C7616B020B; Thu, 21 Sep 2023 12:20:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAA086B020C; Thu, 21 Sep 2023 12:20:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D89F16B0209 for ; Thu, 21 Sep 2023 12:20:49 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AF9041CA021 for ; Thu, 21 Sep 2023 16:20:49 +0000 (UTC) X-FDA: 81261118218.04.AFD003C Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf22.hostedemail.com (Postfix) with ESMTP id 8AABAC002D for ; Thu, 21 Sep 2023 16:20:47 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695313247; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dzUffe4GGQ8UncNqgjGcAoM9QB0C02k3oGzHg6Pvf7M=; b=rgSidG36wrMscSe3PQX2yYKwWGODhZzrxpA5c1PrAwG1+FUGoEci0jmUrIqZe3ZZIPWvFV HxHTxs2Lt5RPdzHvVE65QShKd0Qkk/UItWrxO/EQKFNhhnnVKWvHJHUSJkmbCxzlL9mLhp 9S8fjM0e6xhHDOGw8YQoRnczRUyfTzc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695313247; a=rsa-sha256; cv=none; b=XdaS2nN7RCzcIL4Kb1FilDGoi6lji4AircS4cc8MQ8alk020kAd6wITxiQ8kfd5AKALXcI /OvFBgXTWCf27dUJILtp2cpRRtgHAk82yDQeqMUO0P+jG/8tQOdrU+Mc40YyVPxGxbmmjU peEgqI/z4XA2UdNHHWARibZCTnnDtz4= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=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 F07FB175D; Thu, 21 Sep 2023 09:21:23 -0700 (PDT) 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 84F093F59C; Thu, 21 Sep 2023 09:20:42 -0700 (PDT) From: Ryan Roberts To: Catalin Marinas , Will Deacon , "James E.J. Bottomley" , Helge Deller , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Gerald Schaefer , "David S. Miller" , Arnd Bergmann , Mike Kravetz , Muchun Song , SeongJae Park , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Anshuman Khandual , Peter Xu , Axel Rasmussen , Qi Zheng Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org Subject: [PATCH v1 5/8] sparc: hugetlb: Convert set_huge_pte_at() to take vma Date: Thu, 21 Sep 2023 17:20:04 +0100 Message-Id: <20230921162007.1630149-6-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230921162007.1630149-1-ryan.roberts@arm.com> References: <20230921162007.1630149-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8AABAC002D X-Rspam-User: X-Stat-Signature: jk6gatb4hk1mknazcf4ciizwwxkizk9b X-Rspamd-Server: rspam03 X-HE-Tag: 1695313247-373261 X-HE-Meta: U2FsdGVkX1+Ts7Ey80uBoYbYAbFmSY8m71qX0yNde0MsqXONnfW04MCLtKUS6ZFZK+cD5S45R+f+R7d6kcUQfmYVDZCe01FidEyT/ea/yC6avgCMyLlPr8GlqSWz93/d1aW1Shq7UBCixNzU0x2qc0FR6ezdE258xg5fmvtRUGhCi18y9jEvJZxqCb60AmOM/4glMYTG/r4hFVaXjS7q5xNe0fHOB2nQrPsRkk86aLUD+1lyiy1J1HAKHz1TM+zfNzlYr+o0sA/RctMsIz5zOQnDXgFLPnEkXSfAEJQCg14R0jUyHQLq6n2j1ppqh/m5+HI0KNsj5+H2pvt3b27QEwpAn/7fXfEJyAdtU1+nPPY5jsAm4ZdpsYMW/fnGvhVf+GTGKQMMff9Yh9FDK5E9tm6PXDAH7DzSKbbXDlX7YEXhzlK3mrXCYi/q0eZJ/nQP6/lyBcJNXdkEa1+5gxn9fg9NeSk0FT+ZsJxSbUW107+YSCWtQn4fXfEFPQ9LA3RO4RMt7cOmNq5KD0QKFVBTq7EzASSlxLu51cvTrRwmYuwPRXk0Ttg/JSK7M35PlZIN9IHju/1Immz60gDBhmw5/dNI5+AmbitRyAw0kthIi5GOEa45JcOdTRfQ7+yEKxWoWVfa6o2T+z1dszi/9L8dtpVXZkBUp+t8UF/jRQ0hQMcm6pvWU2oJQgwx3B+sxFOfsNqjLR16VkbpxIS9G1llhlv7V4HTehWzCjTDBj0QqdCbGIUJyjXBsGMDH6IlZwSfBT2gsCJfGxiyAkakDQFcMQrqH8wj33XR5xExpaTSP2JDF54VDICzjY4S0B6m9iFlxT6l3iD1uswI4rojCdqzYACab1UT6bNjqfXG5f0/GxMtJx+lgxe+iNFFqh/PmtSqDQ9Tx4ZXMc9oJ3hsw2Y2qSStLYFJ2GQobhNeEVv2UWWeEzUGj8Q3IG2v+q6XIDRtKLbXOstG7MiDeYaeLC3 mVo0C0XL P0jwrhi0hBIQtKRRXZ5aRJy2y6a30k5fvMyIgmaqlM5cj7pm8YCff3awoDRmEjo9iyi0vNzfE0z/0X7zbyBma4XiequQp/YbouZ6/NSr9nE9Npost08gUjcNO8XeGzLkjSu3o33b66jeuP50KsYuot4tH+Sq+GksuNOy5Vqs73j0m9CMRYiqqZNxhVI2gwbXbtOsQKmG6rsNV00g= 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: In order to fix a bug, arm64 needs access to the vma inside it's implementation of set_huge_pte_at(). Provide for this by converting the mm parameter to be a vma. Any implementations that require the mm can access it via vma->vm_mm. This commit makes the required sparc modifications. Separate commits update the other arches and core code, before the actual bug is fixed in arm64. No behavioral changes intended. Signed-off-by: Ryan Roberts --- arch/sparc/include/asm/hugetlb.h | 8 +++++--- arch/sparc/mm/hugetlbpage.c | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/sparc/include/asm/hugetlb.h b/arch/sparc/include/asm/hugetlb.h index 0a26cca24232..14a71b735bb8 100644 --- a/arch/sparc/include/asm/hugetlb.h +++ b/arch/sparc/include/asm/hugetlb.h @@ -13,7 +13,9 @@ extern struct pud_huge_patch_entry __pud_huge_patch, __pud_huge_patch_end; #endif #define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT -void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, +void set_huge_pte_at(struct vm_area_struct *vma, unsigned long addr, + pte_t *ptep, pte_t pte); +void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte); #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR @@ -32,7 +34,7 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { pte_t old_pte = *ptep; - set_huge_pte_at(mm, addr, ptep, pte_wrprotect(old_pte)); + __set_huge_pte_at(mm, addr, ptep, pte_wrprotect(old_pte)); } #define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS @@ -42,7 +44,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, { int changed = !pte_same(*ptep, pte); if (changed) { - set_huge_pte_at(vma->vm_mm, addr, ptep, pte); + __set_huge_pte_at(vma->vm_mm, addr, ptep, pte); flush_tlb_page(vma, addr); } return changed; diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index d7018823206c..05267b72103f 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -328,7 +328,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, return pte_offset_huge(pmd, addr); } -void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, +void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t entry) { unsigned int nptes, orig_shift, shift; @@ -364,6 +364,12 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, orig_shift); } +void set_huge_pte_at(struct vm_area_struct *vma, unsigned long addr, + pte_t *ptep, pte_t entry) +{ + __set_huge_pte_at(vma->vm_mm, addr, ptep, entry); +} + pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) {