From patchwork Thu Sep 21 16:20:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13394007 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 75C8DE71090 for ; Thu, 21 Sep 2023 16:20:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 116F36B0207; Thu, 21 Sep 2023 12:20:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C6AD6B0208; Thu, 21 Sep 2023 12:20:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED1116B0209; Thu, 21 Sep 2023 12:20:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E02C66B0207 for ; Thu, 21 Sep 2023 12:20:35 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B90911203E8 for ; Thu, 21 Sep 2023 16:20:35 +0000 (UTC) X-FDA: 81261117630.28.01CC988 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf02.hostedemail.com (Postfix) with ESMTP id 11F348000E for ; Thu, 21 Sep 2023 16:20:33 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695313234; a=rsa-sha256; cv=none; b=U+SZ7czHZBCu1Vaxdtl349jG4cxa52LEh0Ns23u8qDMuZD9AvvevNxA0Xe+3TOOcX8u39o 2JiDfKL6c7M+Yla1Qn4CMLP3mu65xUARKNz0ObOpDwxqnoMaIYdj5hfxfMh5cDvQmEb6g3 Y0EA0VWc0uQXWS12sh9qNBjRAsSrQFg= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.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=1695313234; 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=5xwQSctMmYFo12y5XzlJUTq3tE56VCa/T5pbiR1D+lI=; b=chjGfQEWDCm3etqoRtFX0+Zc514E1ZMfjOyYUqL/T7FDbNn/mc2+ZK477Qpa5NLfGJxcYP jin3MtYN4THucroBrVkHKgcu40+XvhmW8ZvcEL/Tllv3A+tKSD+cLmm0YAB8/+Y9jaNa1j S4/0RZBnadheLjOXLa7GyQ7oDHzKzH4= 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 735E21756; Thu, 21 Sep 2023 09:21:10 -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 07CC83F59C; Thu, 21 Sep 2023 09:20:28 -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 2/8] powerpc: hugetlb: Convert set_huge_pte_at() to take vma Date: Thu, 21 Sep 2023 17:20:01 +0100 Message-Id: <20230921162007.1630149-3-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 11F348000E X-Stat-Signature: boz7ymo8y1aiibfmmbrangmrrgnhqkro X-HE-Tag: 1695313233-586540 X-HE-Meta: U2FsdGVkX18jdHfny45qnkoHoJcMVC7VDLMx/7jIaWiXbERhHa43gSBp3Ncon31QjRabHFqlesHCrW0Th583L1lDe4sAu/Y76IyfgeF9RSuWUhQE06SegBV+aVwbZIdpRwmcp1gj8cHSWLU3lw1k6YuN5lLNW9BXZpSXSSmOR9vmIwVao60mBMtOwfXsV5mEkHFI8QJ0rHV5K8hp1USWHtnqO2KhCGVg4/4+oJvqP9J+91bDoivbQxRR2rsWuoXdKqRYltU4+afaM5p95oBi9bSyd8wQcDSefPNamt4h3VYvayQwHeVIK7qvSyYT/BsHQ3LggATkfnYPfzBaSmk2oty0eruSTQYpogMWhBwD0OVeVbqqNYXE04gaiokfIfdqDY6LwPLG6yNhnrW7lPyoPA7Kfb/lyz4oL/KYKKpvhbIlE/GoI5/S+2BcWZsGF1uP6BigKhjEyoeIKMj5rnHvoLCO/14lSTKRX2yqFbwzbIxVTR3HNort8bhcbKN6Ef4dOH+XwRF1LwQjswdAGdPJYr9QdbrKoqRP2qTsfxiq3c4K2n1uO+iRkgi0flGy1Nr1fGTy/4cMNqfRNTO0fGJUPH0WHhaDx4nSjhSuM6nrOSHN9kZNSC52/q6oLCM/7GMYRjjzOWCMEIuTWWk1+qMfjIby1rpCG71/QqLvTfs+YI2wQC7ThygvDmwRUPkYXGUZA1a1dIn4fNnsYeXX/h3UBO0Z7otj3YC4s4tsma2xGxw8AradKyL1FuRbJPyoKnNJEHU6dpbVkpYN07WZZyIkxjxumrncmhNog5/Mp3M6FPjPGpTj+G68bRYv/AoFNd8ppGu31GmyYZtj8GWxaUxUn6JGdfImbNc5cYtYA5llPJZ4kztRubH0AsloHoH/Gqh11pG/FMGX0q3xW0nMIcif4EnpIrYLWTcQXyCZ7CVlH5HHu2EoIg1jsJixjAzOqxKpXqSQkLCDOCyWOPe7oit 5WDqeeK5 5GRBx7NlBjqcNT1OnKJxEcdyL2UvZkebmnlT2xDREWry9G1mgb6JIqOXkfg0qIJOs1EhVtNd27XSSzYPdHT9/WmuSYFBHO8xLSfCu68XB1b0IzIilMuXLLMXD4+byjLI9B838nPGPFU28ywaRY/Eh1i8EYknxeE1GsEYcZjaELXuG4QT5667aLNKXAwvj9fmAliUkYGIyARCkQ6o= 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 powerpc 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/powerpc/include/asm/nohash/32/hugetlb-8xx.h | 3 ++- arch/powerpc/mm/book3s64/hugetlbpage.c | 2 +- arch/powerpc/mm/book3s64/radix_hugetlbpage.c | 2 +- arch/powerpc/mm/nohash/8xx.c | 2 +- arch/powerpc/mm/pgtable.c | 7 ++++++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h b/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h index de092b04ee1a..fff8cd726bc7 100644 --- a/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h +++ b/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h @@ -46,7 +46,8 @@ static inline int check_and_get_huge_psize(int shift) } #define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT -void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte); +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_PTE_CLEAR static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, diff --git a/arch/powerpc/mm/book3s64/hugetlbpage.c b/arch/powerpc/mm/book3s64/hugetlbpage.c index 3bc0eb21b2a0..ae7fd7c90eb8 100644 --- a/arch/powerpc/mm/book3s64/hugetlbpage.c +++ b/arch/powerpc/mm/book3s64/hugetlbpage.c @@ -147,7 +147,7 @@ void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr if (radix_enabled()) return radix__huge_ptep_modify_prot_commit(vma, addr, ptep, old_pte, pte); - set_huge_pte_at(vma->vm_mm, addr, ptep, pte); + set_huge_pte_at(vma, addr, ptep, pte); } void __init hugetlbpage_init_defaultsize(void) diff --git a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c index 17075c78d4bc..7cd40a334c3a 100644 --- a/arch/powerpc/mm/book3s64/radix_hugetlbpage.c +++ b/arch/powerpc/mm/book3s64/radix_hugetlbpage.c @@ -58,5 +58,5 @@ void radix__huge_ptep_modify_prot_commit(struct vm_area_struct *vma, atomic_read(&mm->context.copros) > 0) radix__flush_hugetlb_page(vma, addr); - set_huge_pte_at(vma->vm_mm, addr, ptep, pte); + set_huge_pte_at(vma, addr, ptep, pte); } diff --git a/arch/powerpc/mm/nohash/8xx.c b/arch/powerpc/mm/nohash/8xx.c index dbbfe897455d..650a7a8496b6 100644 --- a/arch/powerpc/mm/nohash/8xx.c +++ b/arch/powerpc/mm/nohash/8xx.c @@ -91,7 +91,7 @@ static int __ref __early_map_kernel_hugepage(unsigned long va, phys_addr_t pa, if (new && WARN_ON(pte_present(*ptep) && pgprot_val(prot))) return -EINVAL; - set_huge_pte_at(&init_mm, va, ptep, pte_mkhuge(pfn_pte(pa >> PAGE_SHIFT, prot))); + __set_huge_pte_at(&init_mm, va, ptep, pte_mkhuge(pfn_pte(pa >> PAGE_SHIFT, prot))); return 0; } diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c index 3f86fd217690..9cbcb561a4d8 100644 --- a/arch/powerpc/mm/pgtable.c +++ b/arch/powerpc/mm/pgtable.c @@ -288,7 +288,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, } #if defined(CONFIG_PPC_8xx) -void set_huge_pte_at(struct mm_struct *mm, 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) { pmd_t *pmd = pmd_off(mm, addr); pte_basic_t val; @@ -310,6 +310,11 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_ for (i = 0; i < num; i++, entry++, val += SZ_4K) *entry = val; } + +void set_huge_pte_at(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte) +{ + __set_huge_pte_at(vma->vm_mm, addr, ptep, pte); +} #endif #endif /* CONFIG_HUGETLB_PAGE */