Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp232566rdb; Sat, 30 Sep 2023 02:15:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQy0QPsa3Q8EjwH1sxtMcHyCf534uNe4IgrtUUcmAUy0w6zpTW9o6N7BoSYdiOcakyQl1+ X-Received: by 2002:a05:6a20:3cac:b0:15d:9ee7:1816 with SMTP id b44-20020a056a203cac00b0015d9ee71816mr7245339pzj.10.1696065300856; Sat, 30 Sep 2023 02:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696065300; cv=none; d=google.com; s=arc-20160816; b=BhanSLm3NpZCG0aOZivauwz+Qm/ozHkqgSI4jfrWXGeQL5eHrnH0Fd9EbygETNjmw0 Ka4c4sbDC6qEtTFP3GdA3tiA+vSdhDzi6dBUqX6mEXA6idtXJZ0f8vmqnoKqoMmLsb+/ agBII++kX9iUS0GnQPp4hRURqgC7YI4FFvxRMXSg/IBNhPZ7q1ptfFY4L4ehRtnL0wD0 0HSUDmf1Squw+zYUOSJVxYOxL05zsrV3qSxbZxHfP7LqetWBIuR+EFrUaEm8qd5cA4HP 43y4tRakDS3SxTdY8ujm6ly3eWtWY+059a8imozjPiPkJd0JkLuE8QqZw7orZkvw6309 opBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=X9udQfbQI1++HGzLkAE50ROjE+3ZPkYSmPslA4IGkxg=; fh=OYB2LDTkoJri1eon/NtkIrIY+Y4rvJKrcPTpLCUFSv4=; b=PHW+AHJO+EaLZY3JhEuM20DqUZxoWGJle4Xet4HSb/TuPb2HVjoPc7Ln9dsSGRjtam tPQNJuN74tctd+nGq5hBGkKE4ngO3a82EL0BKbCiN7GconwyzmzN2YUUECz7NEeHxpLk C8gyaCYJM1uFuXMFiA0Pc53dVsIJ7S9nS3iL/Rfx1jgh2Qoh/Zq/v4cKIoZYVs+PNGyj Muv3813DNptix4+Ln9JfDFN+n99gH5Bg4TJScWrxRZHQTbOIHCCqsVWQoXD47yKxYnO/ he1N4EkTfLD9/4txqd/A1Eg9iUyEmerTMl2GDjvCIgHYxhcYkqwfjdjXeAltJ6bckdd/ j12A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aMA4lonE; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id mh6-20020a17090b4ac600b002736ff3cc79si3675839pjb.23.2023.09.30.02.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 02:15:00 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aMA4lonE; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1D156828E09D; Sat, 30 Sep 2023 02:14:56 -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 S231401AbjI3JOn (ORCPT + 99 others); Sat, 30 Sep 2023 05:14:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjI3JOn (ORCPT ); Sat, 30 Sep 2023 05:14:43 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6995FBF for ; Sat, 30 Sep 2023 02:14:39 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1ABD2C433C8; Sat, 30 Sep 2023 09:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696065279; bh=26DZrEFmmX7RPrQtrMeeSVZD6kM5LM3HQlhgRqueXPE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aMA4lonEOQcec+Y8U5X5uNPY9wy9SAqm8cvrp3N/D9OQuPojEY5CMrfbFvlHeVuIC kDJXYuyKlcCJ09Q6e+/O4OtuyfcTo3Sdchh8MdtED0rM3RfnGVy1IgVcio5HfJ8pRQ EEbw7emfAhc93brMUsc/bz40LDdaLvuafpZpjP7FHA6d7lAzfGBCLvpgUUjgwTsk+u Ju35FdtKswl6b5xzXTQmORx5HMH2sR3mIPpCxm4NCR+LFC2jLXEFVkXC6tKoVe1LPE A2MGxiwjheZxsMF6x/TIR9bzxlK+Jx6iRe/Fctnsi4P+OrFZuAm5lzLHxG/o9vZijG 0OIkeo9dbixxw== Date: Sat, 30 Sep 2023 10:14:34 +0100 From: Conor Dooley To: Alexandre Ghiti Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones , Qinglin Pan , Ryan Roberts , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -fixes 2/2] riscv: Fix set_huge_pte_at() for NAPOT mappings when a swap entry is set Message-ID: <20230930-unnoticed-slacked-0bf5696cc265@spud> References: <20230928151846.8229-1-alexghiti@rivosinc.com> <20230928151846.8229-3-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5QYzZhHNu7GI5bSx" Content-Disposition: inline In-Reply-To: <20230928151846.8229-3-alexghiti@rivosinc.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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]); Sat, 30 Sep 2023 02:14:56 -0700 (PDT) --5QYzZhHNu7GI5bSx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 28, 2023 at 05:18:46PM +0200, Alexandre Ghiti wrote: > We used to determine the number of page table entries to set for a NAPOT > hugepage by using the pte value which actually fails when the pte to set = is > a swap entry. >=20 > So take advantage of a recent fix for arm64 reported in [1] which > introduces the size of the mapping as an argument of set_huge_pte_at(): we > can then use this size to compute the number of page table entries to set > for a NAPOT region. >=20 > Fixes: 82a1a1f3bfb6 ("riscv: mm: support Svnapot in hugetlb page") > Reported-by: Ryan Roberts > Closes: https://lore.kernel.org/linux-arm-kernel/20230922115804.2043771-1= -ryan.roberts@arm.com/ [1] > Signed-off-by: Alexandre Ghiti Breaks the build. Your $subject marks this for -fixes, but this will not build there, as it relies on content that's not yet in that branch. AFAICT, you're going to have to resend this with akpm on CC, as the dependency is in his tree... Thanks, Conor. > --- > arch/riscv/mm/hugetlbpage.c | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) >=20 > diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c > index e4a2ace92dbe..b52f0210481f 100644 > --- a/arch/riscv/mm/hugetlbpage.c > +++ b/arch/riscv/mm/hugetlbpage.c > @@ -183,15 +183,22 @@ void set_huge_pte_at(struct mm_struct *mm, > pte_t pte, > unsigned long sz) > { > + unsigned long hugepage_shift; > int i, pte_num; > =20 > - if (!pte_napot(pte)) { > - set_pte_at(mm, addr, ptep, pte); > - return; > - } > + if (sz >=3D PGDIR_SIZE) > + hugepage_shift =3D PGDIR_SHIFT; > + else if (sz >=3D P4D_SIZE) > + hugepage_shift =3D P4D_SHIFT; > + else if (sz >=3D PUD_SIZE) > + hugepage_shift =3D PUD_SHIFT; > + else if (sz >=3D PMD_SIZE) > + hugepage_shift =3D PMD_SHIFT; > + else > + hugepage_shift =3D PAGE_SHIFT; > =20 > - pte_num =3D napot_pte_num(napot_cont_order(pte)); > - for (i =3D 0; i < pte_num; i++, ptep++, addr +=3D PAGE_SIZE) > + pte_num =3D sz >> hugepage_shift; > + for (i =3D 0; i < pte_num; i++, ptep++, addr +=3D (1 << hugepage_shift)) > set_pte_at(mm, addr, ptep, pte); > } > =20 > --=20 > 2.39.2 >=20 >=20 > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv --5QYzZhHNu7GI5bSx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZRfm+gAKCRB4tDGHoIJi 0m0zAP91gvh8xVeSCkLcZbXEq+3qnMduthZnz3KibSQU6EOWGQD/ZuPEswXNV4uy bVcB6Egf+5E3mB3MeG1hbuQ6lvtluQ0= =1QHA -----END PGP SIGNATURE----- --5QYzZhHNu7GI5bSx--