[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <9feb4672b89ba928fe16cb43eb9602dd9392040f.1768900340.git.houwenlong.hwl@antgroup.com>
Date: Tue, 20 Jan 2026 21:44:29 +0800
From: Hou Wenlong <houwenlong.hwl@...group.com>
To: linux-kernel@...r.kernel.org
Cc: Hou Wenlong <houwenlong.hwl@...group.com>,
Rik van Riel <riel@...riel.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...nel.org>,
Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>
Subject: [PATCH v2 3/4] x86/mm: Correct the actual size of ASID range
As noted in the comment, 'MAX_ASID_AVAILABLE' represents the maximum
valid ASID, i.e., the valid ASID range is '[0, MAX_ASID_AVAILABLE]'.
Therefore, the actual size of the ASID range should be
'MAX_ASID_AVAILABLE + 1', as it is zero-based. However, global ASID
allocation uses this value as the size of the bitmap, which results in
the maximum ASID being excluded from global ASID allocation. To address
this issue, redefine the 'MAX_ASID_AVAILABLE' as the size of ASID range.
Reviewed-by: Rik van Riel <riel@...riel.com>
Signed-off-by: Hou Wenlong <houwenlong.hwl@...group.com>
---
arch/x86/mm/tlb.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index a1e217a382d1..a7dbf784efd9 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -104,18 +104,17 @@
#define CR3_AVAIL_PCID_BITS (X86_CR3_PCID_BITS - PTI_CONSUMED_PCID_BITS)
/*
- * ASIDs are zero-based: 0->MAX_AVAIL_ASID are valid. -1 below to account
- * for them being zero-based. Another -1 is because PCID 0 is reserved for
- * use by non-PCID-aware users.
+ * ASIDs are zero-based: 0->MAX_ASID_AVAILABLE-1 are valid. -1 is because
+ * PCID 0 is reserved for use by non-PCID-aware users.
*/
-#define MAX_ASID_AVAILABLE ((1 << CR3_AVAIL_PCID_BITS) - 2)
+#define MAX_ASID_AVAILABLE ((1 << CR3_AVAIL_PCID_BITS) - 1)
/*
* Given @asid, compute kPCID
*/
static inline u16 kern_pcid(u16 asid)
{
- VM_WARN_ON_ONCE(asid > MAX_ASID_AVAILABLE);
+ VM_WARN_ON_ONCE(asid >= MAX_ASID_AVAILABLE);
#ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
/*
--
2.31.1
Powered by blists - more mailing lists