From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 210AF33BBCF for ; Tue, 7 Apr 2026 21:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775597820; cv=none; b=n40Z42Ymor/BZBarTESe/IGO3XNth2f7DEvfCqBimD+CULEIiI/e/mRMCe9nVUwVKMfX8yx7xUi31UttrgVdZpR6C2Pt1dW89JkWOr5ghM9SpzK/S4At1D+L+Nra7FXtrIrBX6AGBfhUn3Bx7pSH5qpRXwEApNJ1Mv8b9vDoFVo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775597820; c=relaxed/simple; bh=EpKTL3G7H2XFaseYYG+2w0nRlWysJEnHpsD48AKJrRs=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pR45xaQhAX3nBikVkxOmnXLNt5x/fS0o5H9YaSs/g/Lk+3bn7tG3vqHrKnnOzFAnZ5D/BC9CunrzzpIqBL/+EVPlxNjKf2jDR5X+fgpuBrd/UNnnsCK8w/ChNfGPUFPTVHLmd8PBLVQjVbnavkxddEppNat+ssyaZptqaDso15w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=P/inMpMo; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P/inMpMo" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4852b81c73aso46453395e9.3 for ; Tue, 07 Apr 2026 14:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775597817; x=1776202617; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=hKcy50S1bW/vY4PpqHDf6kRxjpQRD4gf10Ur4mE7VLM=; b=P/inMpMoKeSaO30YmvEjixJ+lZypQ8cU6k5RKFvDH+F7aTdbh36orDnjTKBV3+Ji6O rrj/dTIlh/SNjRBUv2V6J82UD5X/kUKUfj9EwW3sH/quD1IJcms64tKKx5dhhM44KjRm iEzB6uNfWpMEsxr88hX1DK7PVywxqxEEhwnsd02MttlQMQfvQ1qoQIvfvpPgO3p95ICm LAfrCAHuvFTmaQbfpPIhxGCHjdCdWewWbOQtNjjwNOb/kLxOL9zT43BRtdq7x4R24xzt 3ww7x5YQvZAyTTv5Jed9mC3MyWU0yriyZjJyWPAF8UQbg9HmXVEFAWxbgnpt48fTLM0h 5RLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775597817; x=1776202617; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hKcy50S1bW/vY4PpqHDf6kRxjpQRD4gf10Ur4mE7VLM=; b=UOx/YIMMocEsazpH3ZH7dMz+Cg3plmUTj7/geu2ewQbrXIG5exPGZYw8Hjw8kbsP6k r4invlchZNNyxwGwql5qXX0iE4LICUO/eOB4ZVDawBAAPKpfpfI3UD0SwbsaWuj2muQw 4tDAfyKX/8ozsjfwuaHivyEsnYPf7dl20rBH5EY0Tk5OnKz2yC96/V1y6fltEdJ2DGAb 2rEE20pjl1pcMb3FBjRkbugFEhCSV58yMSCP7CptMoq7TiqtC9LaaiRPrPJ7ZUayxx1d +3qkIrC1vG5ZdOYuSVZ0CdWsQBakexqxooi5ZiMU6GXmvxmDWkX/9p8aYJWLT7P6WLiI XWLA== X-Forwarded-Encrypted: i=1; AJvYcCXfUSPcVJXR/IyTyp7dksWkrsULzwrXInjfIf3LtbOaYyho7voA7M3ltd9Zv72nAqLiAd+15LjrTzcJoJU=@vger.kernel.org X-Gm-Message-State: AOJu0YwBVXJAXw3ZL2dl5PFmQlFGA7gq0SyogZRru69uhUCjsqnLRmTK onAAnCuL0frgHZW8YtWt5v5uPV576+b4tgXVtdVBkNPOnTeKy1QcMptM X-Gm-Gg: AeBDievN8JOWH6ol/jU9RngaBvLHzMUM/3hGBX/KtPMKocQKy0jG1HXkiuEndRP4R81 mXqsfDS4zCSSsS/Q2/vhXabrvwVS8jqgnPwpbAqdUhEkE3FHbFBWLD/Cjq5yYFeqY2WhXnETxyC rNQ43mrWsTd02ovVWhUpkVcTniAMisIHc6999kOWVPQRGeUIyCOZ6CmN+QTowdL+IWXqE8BHJa0 uVwwoFS36A/IuIIBkJ4aPA0xTO/ZV7GVdFRDLVTPoGmeFeyB9edtJeZnXWyRvxL0SACVkPqa7Sj 9h8eEBvmYvKo56eVnIq82VwZVJ3mmV/G3eKZEl1NGfapthyXDG4ft+Nb/6IviDCwp7BTxlWiimm f8cVx4YlMDYPzJuQGxjTU0rMwnVTTUqMNWEU5E3a8mjBjjSQ/obVQctjiCkQT2BnAPvHz/pET3n 7j1b053xJJqVMZehP9sLUthCNGnk/Zgvo59QjR24T+r/602UOks6kk2oOX2YLUxPNI X-Received: by 2002:a05:600c:3acb:b0:485:557d:9fe with SMTP id 5b1f17b1804b1-4889972b8c2mr222088045e9.12.1775597817192; Tue, 07 Apr 2026 14:36:57 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887e83682fsm611304445e9.7.2026.04.07.14.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 14:36:56 -0700 (PDT) Date: Tue, 7 Apr 2026 22:36:53 +0100 From: David Laight To: Maciej Wieczor-Retman Cc: houwenlong.hwl@antgroup.com, dave.hansen@linux.intel.com, ryan.roberts@arm.com, nick.desaulniers+lkml@gmail.com, bp@alien8.de, will@kernel.org, maciej.wieczor-retman@intel.com, david@kernel.org, nathan@kernel.org, justinstitt@google.com, seanjc@google.com, perry.yuan@amd.com, oleg@redhat.com, tglx@kernel.org, hpa@zytor.com, james.morse@arm.com, mingo@redhat.com, akpm@linux-foundation.org, jgross@suse.com, peterz@infradead.org, morbo@google.com, ilpo.jarvinen@linux.intel.com, xin@zytor.com, shuah@kernel.org, x86@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH v5 1/3] x86/process: Shorten the default LAM tag width Message-ID: <20260407223653.2d3d3c60@pumpkin> In-Reply-To: References: X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 07 Apr 2026 17:45:20 +0000 Maciej Wieczor-Retman wrote: > From: Maciej Wieczor-Retman > > With the announcement of ChkTag, it's worth preparing a stable x86 > linear address masking (lam) user interface. One important aspect of lam > is the tag width, and aligning it with other industry solutions can > provide a more popular, generalized interface that other technologies > could utilize. > > ChkTag will use 4-bit tags and since that's the direction other memory > tagging implementations seem to be taking too (for example Arm's MTE) > it's reasonable to converge lam in linux to the same specification. Even > though x86's LAM supports 6-bit tags it is beneficial to shorten lam to > 4 bits as ChkTag will likely be the main user of the interface and such > connection should simplify things in the future. > > Shrink the maximum acceptable tag width from 6 to 4. > > Signed-off-by: Maciej Wieczor-Retman > --- > Changelog v4: > - Ditch the default wording in the patch message. > - Add the imperative last line as Dave suggested. > > Changelog v3: > - Remove the variability of the lam width after the debugfs part was > removed from the patchset. > > arch/x86/kernel/process_64.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c > index 08e72f429870..1a0e96835bbc 100644 > --- a/arch/x86/kernel/process_64.c > +++ b/arch/x86/kernel/process_64.c > @@ -797,7 +797,7 @@ static long prctl_map_vdso(const struct vdso_image *image, unsigned long addr) > > #ifdef CONFIG_ADDRESS_MASKING > > -#define LAM_U57_BITS 6 > +#define LAM_DEFAULT_BITS 4 > > static void enable_lam_func(void *__mm) > { > @@ -814,7 +814,7 @@ static void enable_lam_func(void *__mm) > static void mm_enable_lam(struct mm_struct *mm) > { > mm->context.lam_cr3_mask = X86_CR3_LAM_U57; > - mm->context.untag_mask = ~GENMASK(62, 57); > + mm->context.untag_mask = ~GENMASK(57 + LAM_DEFAULT_BITS - 1, 57); I'm not sure that GENMASK() is really the best way to describe that value. It really is ((1ul << LAM_BITS) - 1) << 57 and even the 57 shouldn't be a magic constant. I also wonder how userspace knows which bits to use. The other patches just seem to handle a count from userspace, but you aren't giving out the highest available bits. If this had been done for 48bit vaddr, you would really have wished that that bits 62-59 had been used not 51-48. David