From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793086554; b=Tnyrnn62yGGVOrKxhWkp+vLmwfJyFvFpt28W+mLt7lTabjZN3CgcmoECvW6WFF1l3vgz OudJyedL6KAwmG+7MK8Xqi1acPwZqMszPPnY3dIgbYf/7jNvPYybM3IOqwmdUfXz2B1Hn Jec/HnFDkY5bg/rYh+g0KX6NWi4aFNImydgj2UoZ5YOmJmxY8Kgpogw9vKD0xjKgzfgxl zGAUrnZO43BAftfBTu6dAeK5yy9CWIQ0NfkL6ZNaL1215DoGB0neb6RPPaiznXW2xSKEh RCZoDG+weJAGIlJnaD+JHHjiKkzwuYesiI9yLoVeVrGluSBebu0klpl9+ott0RuxwGQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793086554; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=5jc2ZtnsslhTBje2qQpVD7MrTZfTUlL74O4i/llDB/M=; b=HK7b0hFK9ekbCd1jwKEOIVbpTiErYlHdr3sPZp6IofAcTTj5rHqNZ3g4Mw/en6mvR+Mo kLJm1xgCa2S1f3fdXVLkFECSjjGqG9weOnyF1K9vnYlsZ0Ke4mzPHe7Q+qw9Cy/4JjfS3 ZvvA4SQIFwq+gXdC1ZWDJQ7hFCAP6eYHX9Sbu9SIbDNifjPQ/O8Rv5q4c2Zm+Ua3A0k7r /qc2zcWxr9g76ZKiB1nUJUDcmliI/qqIFkBvs0IvH7Fs6Cp6JmKwUrN6UmDRGhlekZkZF C+HaiLXyk49ofZl7KIPfF16v0DTyV019fnIAjpzxRBT8FGvy7wlJj3/rOGv8ivw+/1w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b="ShPz/LB/"; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F324606A323; Tue, 27 Oct 2026 07:35:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9F324606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=ShPz/LB/ 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 C08721655; Tue, 27 Oct 2026 00:35:48 -0700 (PDT) Received: from [10.163.152.160] (unknown [10.163.152.160]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 316693F673; Tue, 27 Oct 2026 00:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1793086551; bh=n2WrtA8FsjLacOwP70K0qkcnkliELHh0b55ywQMgrm4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ShPz/LB/JTXMSaXWoN89wpg1R0MFhTQ3+OYAWgQenVr07qFiwcr+BtH2v6xKKQfRM QrYTx4Q3mPU1qcZAPdg41yN63hG8hPH4qkEAk45cxkJ8LLmOSK716gyfQv1IvIJqjZ R/89T7N51QEEo+TuFrpiXNQLA0t0iBWtwxXvK0jA= Message-ID: <21091d4e-0afb-4b5b-84ac-b36bac58e40f@arm.com> Date: Tue, 27 Oct 2026 13:05:27 +0530 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 26/46] mm/mmu_gather: fix flushing ranges with 4 GiB or larger To: "David Hildenbrand (Arm)" , Andrew Morton , Johannes Weiner , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Kees Cook , Peter Zijlstra , Jann Horn , Pedro Falcato , Hugh Dickins , Pasha Tatashin , Pratyush Yadav , "Matthew Wilcox (Oracle)" , Jan Kara , Zi Yan , Lance Yang , Rik van Riel , Harry Yoo , Alistair Popple , Nico Pache , Ryan Roberts , Usama Arif , Kiryl Shutsemau , Matthew Brost , John Hubbard , Peter Xu , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Oscar Salvador , Minchan Kim , Muchun Song , Xu Xin , Chengming Zhou , Chris Li , Kemeng Shi , Nhat Pham , Youngjun Park , Gregory Price , Joshua Hahn , Rakie Kim , Ying Huang , Jason Gunthorpe Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, Josef Bacik , stable@vger.kernel.org References: <20261027-fixes_core-v1-0-6f74bec9a5bb@kernel.org> <20261027-fixes_core-v1-26-6f74bec9a5bb@kernel.org> Content-Language: en-US From: Dev Jain In-Reply-To: <20261027-fixes_core-v1-26-6f74bec9a5bb@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 27/10/26 4:47 am, David Hildenbrand (Arm) wrote: > From: Josef Bacik > > __tlb_adjust_range() takes the size of the range which has to be flushed > as an unsigned int. Its callers, tlb_flush_{pte,pmd,pud,p4d}_range(), get > and pass an unsigned long. Consequently, a range that is 4 GiB or larger > gets truncated, possibly to 0. > > On arm64 with hugetlb, a 64k kernel can flush 16 GiB hugetlb PMDs, and a Nit: this wasn't obvious to me. Better expressed as: "a 64K kernel can have 16 GiB hugepage mapped contiguously at the PMD level" > 16k kernel can flush 64 GiB PUDs through tlb_unshare_pmd_ptdesc(). So > at least these two scenarios are affected. > > Fix it by flushing the proper range instead of the truncated one. Nit: after reading this I thought you are passing some other parameter now. But that is just a type change. > > Fix generated by an LLM and sent by Josef Bacik in private. > > Fixes: b528e4b6405b ("mm/hugetlb: add tlb_remove_hugetlb_entry for handling hugetlb pages") > Fixes: 8ce720d5bd91 ("mm/hugetlb: fix excessive IPI broadcasts when unsharing PMD tables using mmu_gather") > Cc: stable@vger.kernel.org > Signed-off-by: Josef Bacik > Acked-by: Lorenzo Stoakes (ARM) > [ david: use two-tab indent, simplify description ] > Signed-off-by: David Hildenbrand (Arm) > --- Reviewed-by: Dev Jain > include/asm-generic/tlb.h | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h > index fbe1114e9a443..3f4a180b48f3c 100644 > --- a/include/asm-generic/tlb.h > +++ b/include/asm-generic/tlb.h > @@ -350,8 +350,7 @@ struct mmu_gather { > void tlb_flush_mmu(struct mmu_gather *tlb); > > static inline void __tlb_adjust_range(struct mmu_gather *tlb, > - unsigned long address, > - unsigned int range_size) > + unsigned long address, unsigned long range_size) > { > tlb->start = min(tlb->start, address); > tlb->end = max(tlb->end, address + range_size); >