From: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
While shortening the tag bits to converge the specifications of LAM and
ChkTag, the 6 bit wide LAM (Linear Address Masking) tags should still be
available to use. Since using this tag width is likely going to be for
debug purposes only, using debugfs is the best choice.
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
---
arch/x86/kernel/process_64.c | 56 ++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 04968b303e66..2f9f74cddd2a 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -41,6 +41,7 @@
#include <linux/ftrace.h>
#include <linux/syscalls.h>
#include <linux/iommu.h>
+#include <linux/debugfs.h>
#include <asm/processor.h>
#include <asm/pkru.h>
@@ -802,6 +803,61 @@ static long prctl_map_vdso(const struct vdso_image *image, unsigned long addr)
unsigned long lam_available_bits = LAM_DEFAULT_BITS;
+static ssize_t lam_bits_read_file(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ char buf[2];
+ unsigned int len;
+
+ len = sprintf(buf, "%ld\n", lam_available_bits);
+ return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+/*
+ * Writing a number to this file changes the used lam tag width. Valid values
+ * are 4 bit tag width and 6 bit tag width - the second, non-default one is
+ * meant mostly for debug and shall be deprecated in the future.
+ */
+static ssize_t lam_bits_write_file(struct file *file,
+ const char __user *user_buf, size_t count,
+ loff_t *ppos)
+{
+ char buf[32];
+ ssize_t len;
+ int ceiling;
+ u8 bits;
+
+ len = min(count, sizeof(buf) - 1);
+ if (copy_from_user(buf, user_buf, len))
+ return -EFAULT;
+
+ buf[len] = '\0';
+ if (kstrtou8(buf, 0, &bits))
+ return -EINVAL;
+
+ switch (bits) {
+ case LAM_DEFAULT_BITS:
+ case LAM_MAX_BITS:
+ lam_available_bits = bits;
+ return count;
+ default:
+ return -EINVAL;
+ }
+}
+
+static const struct file_operations fops_lam_bits = {
+ .read = lam_bits_read_file,
+ .write = lam_bits_write_file,
+};
+
+static int __init create_lam_available_bits(void)
+{
+ debugfs_create_file("lam_available_bits", 0600,
+ arch_debugfs_dir, NULL, &fops_lam_bits);
+ return 0;
+}
+late_initcall(create_lam_available_bits);
+
static void enable_lam_func(void *__mm)
{
struct mm_struct *mm = __mm;
--
2.53.0
Hi Maciej,
kernel test robot noticed the following build warnings:
[auto build test WARNING on tip/x86/core]
[also build test WARNING on peterz-queue/sched/core akpm-mm/mm-everything linus/master v6.19 next-20260220]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Maciej-Wieczor-Retman/x86-process-Shorten-the-default-LAM-tag-width/20260220-205155
base: tip/x86/core
patch link: https://lore.kernel.org/r/5ed38af72848015f3417c462e624e52891dc14ed.1771589807.git.m.wieczorretman%40pm.me
patch subject: [PATCH v1 2/4] x86/process: Add a debug interface to change LAM tag width
config: x86_64-buildonly-randconfig-001-20260220 (https://download.01.org/0day-ci/archive/20260221/202602210040.C4PVoS0u-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260221/202602210040.C4PVoS0u-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602210040.C4PVoS0u-lkp@intel.com/
All warnings (new ones prefixed by >>):
arch/x86/kernel/process_64.c:812:8: warning: 'sprintf' will always overflow; destination buffer has size 2, but format string expands to at least 3 [-Wformat-overflow]
812 | len = sprintf(buf, "%ld\n", lam_available_bits);
| ^
>> arch/x86/kernel/process_64.c:827:6: warning: unused variable 'ceiling' [-Wunused-variable]
827 | int ceiling;
| ^~~~~~~
2 warnings generated.
vim +/ceiling +827 arch/x86/kernel/process_64.c
815
816 /*
817 * Writing a number to this file changes the used lam tag width. Valid values
818 * are 4 bit tag width and 6 bit tag width - the second, non-default one is
819 * meant mostly for debug and shall be deprecated in the future.
820 */
821 static ssize_t lam_bits_write_file(struct file *file,
822 const char __user *user_buf, size_t count,
823 loff_t *ppos)
824 {
825 char buf[32];
826 ssize_t len;
> 827 int ceiling;
828 u8 bits;
829
830 len = min(count, sizeof(buf) - 1);
831 if (copy_from_user(buf, user_buf, len))
832 return -EFAULT;
833
834 buf[len] = '\0';
835 if (kstrtou8(buf, 0, &bits))
836 return -EINVAL;
837
838 switch (bits) {
839 case LAM_DEFAULT_BITS:
840 case LAM_MAX_BITS:
841 lam_available_bits = bits;
842 return count;
843 default:
844 return -EINVAL;
845 }
846 }
847
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
I'll correct these in the next version.
On 2026-02-21 at 00:41:41 +0800, kernel test robot wrote:
>Hi Maciej,
>
>kernel test robot noticed the following build warnings:
>
>[auto build test WARNING on tip/x86/core]
>[also build test WARNING on peterz-queue/sched/core akpm-mm/mm-everything linus/master v6.19 next-20260220]
>[If your patch is applied to the wrong git tree, kindly drop us a note.
>And when submitting patch, we suggest to use '--base' as documented in
>https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
>url: https://github.com/intel-lab-lkp/linux/commits/Maciej-Wieczor-Retman/x86-process-Shorten-the-default-LAM-tag-width/20260220-205155
>base: tip/x86/core
>patch link: https://lore.kernel.org/r/5ed38af72848015f3417c462e624e52891dc14ed.1771589807.git.m.wieczorretman%40pm.me
>patch subject: [PATCH v1 2/4] x86/process: Add a debug interface to change LAM tag width
>config: x86_64-buildonly-randconfig-001-20260220 (https://download.01.org/0day-ci/archive/20260221/202602210040.C4PVoS0u-lkp@intel.com/config)
>compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
>rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
>reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260221/202602210040.C4PVoS0u-lkp@intel.com/reproduce)
>
>If you fix the issue in a separate patch/commit (i.e. not just a new version of
>the same patch/commit), kindly add following tags
>| Reported-by: kernel test robot <lkp@intel.com>
>| Closes: https://lore.kernel.org/oe-kbuild-all/202602210040.C4PVoS0u-lkp@intel.com/
>
>All warnings (new ones prefixed by >>):
>
> arch/x86/kernel/process_64.c:812:8: warning: 'sprintf' will always overflow; destination buffer has size 2, but format string expands to at least 3 [-Wformat-overflow]
> 812 | len = sprintf(buf, "%ld\n", lam_available_bits);
> | ^
>>> arch/x86/kernel/process_64.c:827:6: warning: unused variable 'ceiling' [-Wunused-variable]
> 827 | int ceiling;
> | ^~~~~~~
> 2 warnings generated.
>
>
>vim +/ceiling +827 arch/x86/kernel/process_64.c
>
> 815
> 816 /*
> 817 * Writing a number to this file changes the used lam tag width. Valid values
> 818 * are 4 bit tag width and 6 bit tag width - the second, non-default one is
> 819 * meant mostly for debug and shall be deprecated in the future.
> 820 */
> 821 static ssize_t lam_bits_write_file(struct file *file,
> 822 const char __user *user_buf, size_t count,
> 823 loff_t *ppos)
> 824 {
> 825 char buf[32];
> 826 ssize_t len;
> > 827 int ceiling;
> 828 u8 bits;
> 829
> 830 len = min(count, sizeof(buf) - 1);
> 831 if (copy_from_user(buf, user_buf, len))
> 832 return -EFAULT;
> 833
> 834 buf[len] = '\0';
> 835 if (kstrtou8(buf, 0, &bits))
> 836 return -EINVAL;
> 837
> 838 switch (bits) {
> 839 case LAM_DEFAULT_BITS:
> 840 case LAM_MAX_BITS:
> 841 lam_available_bits = bits;
> 842 return count;
> 843 default:
> 844 return -EINVAL;
> 845 }
> 846 }
> 847
>
>--
>0-DAY CI Kernel Test Service
>https://github.com/intel/lkp-tests/wiki
--
Kind regards
Maciej Wieczór-Retman
© 2016 - 2026 Red Hat, Inc.