From patchwork Thu Sep 21 16:20:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13394012 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 3A8DCE71090 for ; Thu, 21 Sep 2023 16:20:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAFA76B020C; Thu, 21 Sep 2023 12:20:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C5F9A6B020D; Thu, 21 Sep 2023 12:20:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B27CF6B020F; Thu, 21 Sep 2023 12:20:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A0B0D6B020C for ; Thu, 21 Sep 2023 12:20:58 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 79D261A0381 for ; Thu, 21 Sep 2023 16:20:58 +0000 (UTC) X-FDA: 81261118596.18.A30B72B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf01.hostedemail.com (Postfix) with ESMTP id B9D1C40015 for ; Thu, 21 Sep 2023 16:20:56 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.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=1695313256; 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=uDoY3OFCzCUrgBPULkVVbTB1+G/+iNF7LD/wFw9wqJU=; b=62wX4oblB05AOI+Oecm2B9zAvFtTqzVziaECoJK1FkToEZqvgh6Xg6n5SHbvq2KtDOE3jS D2ebMoN2ZftyORoa8U/i/wERBfvZYc1NjH7Ig6eKW9q2MmBHkuafhZ6Myljq4B9HwudH+x BCv8scBI6m1u5ImenVDFjF9yOTERFB8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695313256; a=rsa-sha256; cv=none; b=P3nFiZJ0K9qYkeSUtM65DdqXVAbzaNGwmFPr0tUbiOYwZQYd5UI0cdjTf7oUolAcfhPtIf z+l330Ad1cjXoMWnvDMbApAkADeXthtnuiXofhmCryI2R2MQ2vM1rdsy//mhqLcTtEv0Ir c8n6hk2fh+L4+ay/44RFHWwcJi3tY8k= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.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 177461763; Thu, 21 Sep 2023 09:21:33 -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 A068D3F59C; Thu, 21 Sep 2023 09:20:51 -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 7/8] arm64: hugetlb: Convert set_huge_pte_at() to take vma Date: Thu, 21 Sep 2023 17:20:06 +0100 Message-Id: <20230921162007.1630149-8-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: B9D1C40015 X-Rspam-User: X-Stat-Signature: r17azot87tru1nw9cfhs8mhfsan784y3 X-Rspamd-Server: rspam03 X-HE-Tag: 1695313256-432047 X-HE-Meta: U2FsdGVkX1+FT2HgpZWZgCV99T/JFnz2jAiMnkejCqE2Xf+cvmiJ/5+UDgzho/0XJSS5CeQsKpr2Ef6+0Dplv2Vp0ouu4DgykaVZ2+wMeNO+Tv13w101cpam/S5FKO30+jbVZGhwLgEvHV2jzWfGPzxWosSeqC0ey7KqqzsgobQ/T9Fmd8K0kuB5+sM8f4bKE2pYuxuHEhw8xKeY5kWprbaaHaUEgK24yaCJdN3WNbTsdbzZNYgUP0MXzB3TnS+7eB0S8n6cpneuIouKoXWGyPfdcCUynYlclWYFhV9HJPc8uPDkzDhGTOYDW+k83QcoTHh2tcrVM33Ssd+9tJ+GtsTIkLVLPDv5YEKKCkgRg2AI1gP3IlDfOLaTm8tuezJkf7jTc/xsHQcR0taCQh83366rSt0nIYcv2Pf54QGprOt7owHS7Z0bNtglpSRu10eixkcnWxAv20dyKQmvQbjctb0w2+4e7rZ7RcPhJTtkx6S7Gyd833qY30xyp8oP5mYjUkWejX1w/TMBMd44yCC48OUacSycjfdOLgXEFqR6Br2A/HnHSqf3w4lK2thZVYjG304/atUD2YDr5Hlmef2tauMS4ofTiSj1MWp25Ej4FhHqO6u7oAFg3NG/pkHMqKxVcMSRpgZKKg9thdKy5UcGQTvlcii+zqP5Earzma7EivmgszQZ5EFW881aqJRkNJKS3eQdOKn0wuqhUWqzVv3hZJmLvZFDJYr1x9DqbGaPSYX5C1QQmwREuK0xX4s2COC8dk9XwYL2h7lbAmPXuuFhNbvemLgoD4d/T86zTRSCDx3/GQ/g64OqwKJHuXxYPQu4D5WIZAwALtqWJKdyrzzdxXi0FD5K+vDqWzf56/1VS7Xkpbctcz4oBlWEdEu0qzbel4Tlz62IAY3c2Z1AmD8nLILIBJ5kBp5QsH4MDo6+48c+/r7G2tPvJ5mwK0qNjapoh9Z1+kVY1h1HYpgR5ho ybEo4+P6 dymrgFl10v4N/CXgM1cMtBqsXqp5gZv23w39d1jRfPrNnz1vZ7qAl6kdCXiW08sEnnDwKX2JndWC3h9Rr355sCB/e447z3oNu3kijfv9PGhp7CEutvYrfgn6SZyghMfPkTdPH8qUZIfXdUcfLXPYzAgQwdYB+XeRdbOIpAWyLkSx+7iYmsKluWUx4PQ00RdDa4BPLsQDZ8V1Acsc= 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 arm64 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/arm64/include/asm/hugetlb.h | 2 +- arch/arm64/mm/hugetlbpage.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h index f43a38ac1779..efc9025b9d27 100644 --- a/arch/arm64/include/asm/hugetlb.h +++ b/arch/arm64/include/asm/hugetlb.h @@ -27,7 +27,7 @@ static inline void arch_clear_hugepage_flags(struct page *page) pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags); #define arch_make_huge_pte arch_make_huge_pte #define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT -extern void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, +extern void set_huge_pte_at(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t pte); #define __HAVE_ARCH_HUGE_PTEP_SET_ACCESS_FLAGS extern int huge_ptep_set_access_flags(struct vm_area_struct *vma, diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 9c52718ea750..844832511c1e 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -248,9 +248,10 @@ static inline struct folio *hugetlb_swap_entry_to_folio(swp_entry_t entry) return page_folio(pfn_to_page(swp_offset_pfn(entry))); } -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) { + struct mm_struct *mm = vma->vm_mm; size_t pgsize; int i; int ncontig; @@ -571,5 +572,5 @@ pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma, unsigned long addr void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, pte_t old_pte, pte_t pte) { - set_huge_pte_at(vma->vm_mm, addr, ptep, pte); + set_huge_pte_at(vma, addr, ptep, pte); }