public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Maciej Wieczor-Retman <m.wieczorretman@pm.me>
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
Date: Wed, 8 Apr 2026 09:51:44 +0100	[thread overview]
Message-ID: <20260408095144.41ee4cbc@pumpkin> (raw)
In-Reply-To: <adV6bnZC_2BEZxjk@wieczorr-mobl1.localdomain>

On Tue, 07 Apr 2026 21:53:32 +0000
Maciej Wieczor-Retman <m.wieczorretman@pm.me> wrote:

> On 2026-04-07 at 22:36:53 +0100, David Laight wrote:
> >On Tue, 07 Apr 2026 17:45:20 +0000
> >Maciej Wieczor-Retman <m.wieczorretman@pm.me> wrote:
> >  
> >> From: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
> >>
> >> 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 <maciej.wieczor-retman@intel.com>
> >> ---
> >> 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 recall people were annoyed when I previously open coded something that could
> have been a GENMASK() instead. Is there a downside to using GENMASK() here?

Some people do like GENMASK(), personally I don't think it helps in many cases.
Fine if you are describing a hardware register that has some single bit
fields and some multi-bit fields - especially if the documentation uses
bit numbers (which is often true).
But here you want something that has a base bit number (57) and a width
(LAM_BITS) and that isn't GENMASK().

> 
> >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.  
> 
> I'd imagine if someone was writing a userspace program that'd interface with LAM
> they'd have to know which bits are okay to use.
> 
> But maybe I'm misunderstanding what you meant.

That is exactly what I meant, how do they find out which bits to use.
The API seems so let them say how many they want, but not which ones.

	David

> 
> >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
> >  
> 


  reply	other threads:[~2026-04-08  8:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07 17:45 [PATCH v5 0/3] x86: Simplifying LAM Maciej Wieczor-Retman
2026-04-07 17:45 ` [PATCH v5 1/3] x86/process: Shorten the default LAM tag width Maciej Wieczor-Retman
2026-04-07 19:52   ` Sohil Mehta
2026-04-07 20:31     ` Maciej Wieczor-Retman
2026-04-07 21:30       ` Sohil Mehta
2026-04-07 21:36         ` Maciej Wieczor-Retman
2026-04-07 21:36   ` David Laight
2026-04-07 21:53     ` Maciej Wieczor-Retman
2026-04-08  8:51       ` David Laight [this message]
2026-04-08 10:19         ` Maciej Wieczor-Retman
2026-04-07 17:45 ` [PATCH v5 2/3] x86/mm: Cleanup comments where LAM_U48 is mentioned Maciej Wieczor-Retman
2026-04-07 19:58   ` Sohil Mehta
2026-04-07 17:45 ` [PATCH v5 3/3] selftests/lam: Add test cases for different LAM tag widths Maciej Wieczor-Retman
2026-04-07 20:06   ` Sohil Mehta
2026-04-07 20:34     ` Maciej Wieczor-Retman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260408095144.41ee4cbc@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@kernel.org \
    --cc=houwenlong.hwl@antgroup.com \
    --cc=hpa@zytor.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=james.morse@arm.com \
    --cc=jgross@suse.com \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=m.wieczorretman@pm.me \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=oleg@redhat.com \
    --cc=perry.yuan@amd.com \
    --cc=peterz@infradead.org \
    --cc=ryan.roberts@arm.com \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    --cc=tglx@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=xin@zytor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox