Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2530107rdb; Fri, 22 Sep 2023 00:56:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiGicthKjpiSUI7yaSLfQtTpo3nqKc1EAOnhSw82IWaVqZv9+wUfj39TBDljNXgNNFW3Lm X-Received: by 2002:a05:6830:1d9c:b0:6c4:c026:a658 with SMTP id y28-20020a0568301d9c00b006c4c026a658mr921707oti.26.1695369375536; Fri, 22 Sep 2023 00:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695369375; cv=none; d=google.com; s=arc-20160816; b=V/6FbqxJ2rRmujOlmrxOqnymZD6RwRRfF46YkE8r72Gwhp57KtZYiLAQSOjyEHTE8g ZPqrqCpjEMutEmlvxrxQ1dus3leS83LILJBr9ll9NI4aMb8DmXCwqemtEOpGvKMKxhQK NNLMiCzvEgo1atCnjS5eZAsNQw8WowuSqQ6i/Q+EUljWSOQT/zGtK1NP+9dZMW7odPPt oXh212Xq7ZLhIX3Q4m6AyuCbsOSGGK28i2UA8z+ptCyvGJ/HLdu7Ef+b0vq9dTTF1A/W jXrW5Yb4+jhOaQPFYoLbf7qRT3DYHjolNLEM2TP6Wu3TLvHsficIq7lKg+lBixUheMLh 88Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=HEWvIjT6QxyzfvXgnU+6v1MV9X1aL95EzEib/UoJPqk=; fh=zFZxy1id+WynbhYLkrhMf/kFHKyVYmGrzwwgX587BeI=; b=UZC/y7+8jpTc2TlJw476Rl5bRmfmyRwSqDAI+wEvKu3ybgq3FMDwSWDhfCmRIk3BJX QdGv+gRaaaZOtiogJfeRHJ/ylsqWz7NgfK1VpEYAo1WzjiCvQjoDhTtVE4AkO7mE84cD xe0kB9fGxvnmpJwpiS+Y1zojdIQ8brxrNc7L5Vc0553N8YgKaTc2llvi7Yx/TNft5qwo iQnrUPKxw3KDBE0a0Ng/H6sgLfvkvs1uuplBVswc+RFlvNNElcagZ+U1UGMwGc5Z0O1i S2/MoJLYH3Br3Buwe7y3f1cL8mNocjEZeUvWX7OSDEOrEhuVztAGvduXHhDGpVxmMaYc 6ciQ== 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:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id o8-20020a056a001bc800b0068a3c575900si3175737pfw.84.2023.09.22.00.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 00:56:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 77C0A835DBD9; Fri, 22 Sep 2023 00:54:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230435AbjIVHyr (ORCPT + 99 others); Fri, 22 Sep 2023 03:54:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbjIVHym (ORCPT ); Fri, 22 Sep 2023 03:54:42 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4561CA; Fri, 22 Sep 2023 00:54:35 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 51B81FF809; Fri, 22 Sep 2023 07:54:21 +0000 (UTC) Message-ID: <7bbceed4-c5f6-42d4-5d94-060032b73385@ghiti.fr> Date: Fri, 22 Sep 2023 09:54:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v1 3/8] riscv: hugetlb: Convert set_huge_pte_at() to take vma Content-Language: en-US To: Ryan Roberts , 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: 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 References: <20230921162007.1630149-1-ryan.roberts@arm.com> <20230921162007.1630149-4-ryan.roberts@arm.com> From: Alexandre Ghiti In-Reply-To: <20230921162007.1630149-4-ryan.roberts@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 pete.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 (pete.vger.email [0.0.0.0]); Fri, 22 Sep 2023 00:54:52 -0700 (PDT) Hi Ryan, On 21/09/2023 18:20, Ryan Roberts wrote: > 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 riscv 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/riscv/include/asm/hugetlb.h | 2 +- > arch/riscv/mm/hugetlbpage.c | 3 ++- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/include/asm/hugetlb.h b/arch/riscv/include/asm/hugetlb.h > index 34e24f078cc1..be1ac8582bc2 100644 > --- a/arch/riscv/include/asm/hugetlb.h > +++ b/arch/riscv/include/asm/hugetlb.h > @@ -17,7 +17,7 @@ void huge_pte_clear(struct mm_struct *mm, unsigned long addr, > pte_t *ptep, unsigned long sz); > > #define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT > -void set_huge_pte_at(struct mm_struct *mm, > +void set_huge_pte_at(struct vm_area_struct *vma, > unsigned long addr, pte_t *ptep, pte_t pte); > > #define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEAR > diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c > index 96225a8533ad..7cdbf0960772 100644 > --- a/arch/riscv/mm/hugetlbpage.c > +++ b/arch/riscv/mm/hugetlbpage.c > @@ -177,11 +177,12 @@ pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags) > return entry; > } > > -void set_huge_pte_at(struct mm_struct *mm, > +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; > int i, pte_num; > > if (!pte_napot(pte)) { You can add: Reviewed-by: Alexandre Ghiti I realize that we may have the same issue with our contig pte implementation (called napot in riscv) as we don't handle swap/migration entries at all. So I guess we need something similar, and I'll implement it (unless you want to do it of course, but I guess it's easier for me to test). One (maybe stupid) question though: wouldn't it be possible to extract the contig pte size from the value of ptep instead of using a vma? Thanks, Alex