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: 142899 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5130439vqi; Thu, 21 Sep 2023 13:50:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8UqCzpA60Oxkv/xKgQcr4J9HvbYzkBXjXrbFw9IwcYdZ8OCgUbPZl93yxFz3ALlxrmU9c X-Received: by 2002:a17:902:c3c6:b0:1bb:9b29:20d9 with SMTP id j6-20020a170902c3c600b001bb9b2920d9mr6213193plj.20.1695329447434; Thu, 21 Sep 2023 13:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695329447; cv=none; d=google.com; s=arc-20160816; b=YA4341lruHeEhe/7BtF6cV9Y9hcDZ4UwpVmBBsuijVNkZjXYyBn/D7qXD3HpEyCTD+ QCoz/TAuF7dck6P/VKUi1Osv1FFmZ+9bPgygditIZKz9/3zAGoIMwUsqvTZ4wM42MNJ4 a/EtMQw5+6xM/vYzE7rzXykSriqdHvb+OEl65eLP+6gbB7AtFqX+nF4V06sqKcnXuxob CYrUFsgOGuBWzOl48oRaINkEWRbWhpTjCQJhNTQ77gecB0SfQkvq9ld261NiR5xRPvQZ w7iyEmcfqMnIETsx3nGSNVM0UOF3ZdUQgq606/paZ+5SupaGVwZDKVJgITTwiMkhIN5t gJgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uDoY3OFCzCUrgBPULkVVbTB1+G/+iNF7LD/wFw9wqJU=; fh=q/eoddAVbbeWDzUVs4Vwk85GEJr6Ex1kH1y0q+v38Hg=; b=UCOk5m+HXODZCDptdyVU6wnElmsHNYYMBI9pcL7S+aYrTuqeDEZqBvXh6NlRVKbBZh gZ+B6HrbhAcUQEHzEquCYi3jC9W+AaFa3JVppOISZIxTejTo73pxg0S12C9bHLhYhqhC eHt2AH8C6XIOpWH47IEUtipku1G+Qp2/tQfnNK1RtggggSM+wDyZbfjBCr4lXKekTppp 3gDatsNwjUaRyqvotiKf8OIb/QMoKlinzreqDSO7gTxAh4VUdg6yKKRVtxgQ3AxB/j8B A579tufI3c/mDODEHAOzNGHOjhBeNNl8FiLoWekuXmqVvBBRC4QP5/2jI5hcUIaOge89 KKAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id q3-20020a170902dac300b001b82a4d3ea7si2461971plx.249.2023.09.21.13.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 13:50:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A0A0F801B3C4; Thu, 21 Sep 2023 13:36:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231825AbjIUUf5 (ORCPT + 29 others); Thu, 21 Sep 2023 16:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232135AbjIUUel (ORCPT ); Thu, 21 Sep 2023 16:34:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4299685D06; Thu, 21 Sep 2023 10:37:47 -0700 (PDT) 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:36:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777681770242388062 X-GMAIL-MSGID: 1777681770242388062 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); }