[PATCH v2 2/4] x86/mm: Fix wrong judgement in allocate_global_asid()

Hou Wenlong posted 4 patches 2 weeks, 6 days ago
[PATCH v2 2/4] x86/mm: Fix wrong judgement in allocate_global_asid()
Posted by Hou Wenlong 2 weeks, 6 days ago
In allocate_global_asid(), 'global_asid_available' cannot be zero, as it
has already been checked in use_global_asid(). The wrong judgment could
result in the invalid ASID 'MAX_ASID_AVAILABLE' being allocated,
triggering the warning in kern_pcid(). Therefore, remove the check for
'global_asid_available', since when the allocation reaches
'MAX_ASID_AVAILABLE', it must return regardless of the value of
'global_asid_available'.

Fixes: d504d1247e36 ("x86/mm: Add global ASID allocation helper functions")
Reviewed-by: Rik van Riel <riel@surriel.com>
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 42b025e2f825..a1e217a382d1 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -326,7 +326,7 @@ static u16 allocate_global_asid(void)
 
 	asid = find_next_zero_bit(global_asid_used, MAX_ASID_AVAILABLE, last_global_asid);
 
-	if (asid >= MAX_ASID_AVAILABLE && !global_asid_available) {
+	if (asid >= MAX_ASID_AVAILABLE) {
 		/* This should never happen. */
 		VM_WARN_ONCE(1, "Unable to allocate global ASID despite %d available\n",
 				global_asid_available);
-- 
2.31.1