[PATCH v2 1/4] x86/mm: Correct the actual size of available global ASID range

Hou Wenlong posted 4 patches 2 weeks, 5 days ago
[PATCH v2 1/4] x86/mm: Correct the actual size of available global ASID range
Posted by Hou Wenlong 2 weeks, 5 days ago
As noted in the comment, the available ASID range for global ASID
allocation is '[TLB_NR_DYN_ASIDS, MAX_ASID_AVAILABLE-1]', which is a
close interval. The size of bitmap is defined as 'MAX_ASID_AVAILABLE',
so the actual available size should be
'(MAX_ASID_AVAILABLE-1) - TLB_NR_DYN_ASIDS + 1'; otherwise, one ASID will
leak.

Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
---
 arch/x86/mm/tlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 621e09d049cb..42b025e2f825 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -286,7 +286,7 @@ static DEFINE_RAW_SPINLOCK(global_asid_lock);
 static u16 last_global_asid = MAX_ASID_AVAILABLE;
 static DECLARE_BITMAP(global_asid_used, MAX_ASID_AVAILABLE);
 static DECLARE_BITMAP(global_asid_freed, MAX_ASID_AVAILABLE);
-static int global_asid_available = MAX_ASID_AVAILABLE - TLB_NR_DYN_ASIDS - 1;
+static int global_asid_available = MAX_ASID_AVAILABLE - TLB_NR_DYN_ASIDS;
 
 /*
  * When the search for a free ASID in the global ASID space reaches
-- 
2.31.1
Re: [PATCH v2 1/4] x86/mm: Correct the actual size of available global ASID range
Posted by Rik van Riel 2 weeks, 5 days ago
On Tue, 2026-01-20 at 21:44 +0800, Hou Wenlong wrote:
> As noted in the comment, the available ASID range for global ASID
> allocation is '[TLB_NR_DYN_ASIDS, MAX_ASID_AVAILABLE-1]', which is a
> close interval. The size of bitmap is defined as
> 'MAX_ASID_AVAILABLE',
> so the actual available size should be
> '(MAX_ASID_AVAILABLE-1) - TLB_NR_DYN_ASIDS + 1'; otherwise, one ASID
> will
> leak.
> 
> Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>

Reviewed-by: Rik van Riel <riel@surriel.com>

-- 
All Rights Reversed.