Skip to contentSkip to conversation

x86: Simplifying LAM

PATCH Superseded Maciej Wieczor-Retman 2 participants 9 messages Feb 24 – Feb 25

Subsystems (2)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover x86: Simplifying LAM

After ChkTag [1] announcement, 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 default lam to 4 bits as ChkTag will likely be the main user of the interface and such connection should simplify things in the future.

6-bit tags should still be available as a debug feature and possible to enable through debugfs. Tag width can be system wide whether it's the default 4 bits or debug 6 bits and when a process requests a specific tag width it should get the max amount enabled globally.

Series also cleans up some comments referencing LAM_U48 which was not implemented in the kernel and the comments shouldn't imply it can be enabled.

Patches are based on v7.01-rc1

Changelog v2:
- Extend a char buffer in debugfs read callback to fit the format string.

[1] https://community.intel.com/t5/Blogs/Tech-Innovation/open-intel/ChkTag-x86-Memory-Safety/post/1721490

Maciej Wieczor-Retman (4):
x86/process: Shorten the default LAM tag width x86/process: Add a debug interface to change LAM tag width x86/mm: Cleanup comments where LAM_U48 is mentioned selftests/lam: Add test cases for different LAM tag widths

 arch/x86/include/asm/mmu.h         |  2 +-
 arch/x86/include/asm/mmu_context.h |  3 ++
 arch/x86/include/asm/tlbflush.h    |  2 +-
 arch/x86/kernel/process_64.c       | 70 +++++++++++++++++++++---
 tools/testing/selftests/x86/lam.c  | 87 +++++++++++++++++++++++++-----
 5 files changed, 143 insertions(+), 21 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 1/4 x86/process: Shorten the default LAM tag width

From: Maciej Wieczor-Retman <[email protected]>

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 default lam to 4 bits as ChkTag will likely be the main user of the interface and such connection should simplify things in the future.

Set the default tag width to 4 bits and make it variable. While static keys were considered to implement it, the LAM tag width isn't used in any performance intensive code paths, and doesn't justify anything more than a simple global variable.

---
 arch/x86/include/asm/mmu_context.h |  3 +++
 arch/x86/kernel/process_64.c       | 15 +++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)
arch/x86/include/asm/mmu_context.h +3 -0
index 1acafb1c6a93..f8b2e8b855a1 100644
@@ -86,6 +86,9 @@ static inline void switch_ldt(struct mm_struct *prev, struct mm_struct *next)
 #endif
 
 #ifdef CONFIG_ADDRESS_MASKING
+
+extern unsigned long lam_available_bits;
+
 static inline unsigned long mm_lam_cr3_mask(struct mm_struct *mm)
 {
 	/*
arch/x86/kernel/process_64.c +9 -6
index 08e72f429870..4a217f13ab90 100644
@@ -797,7 +797,10 @@ static long prctl_map_vdso(const struct vdso_image *image, unsigned long addr)
 
 #ifdef CONFIG_ADDRESS_MASKING
 
-#define LAM_U57_BITS 6
+#define LAM_MAX_BITS		6
+#define LAM_DEFAULT_BITS	4
+
+unsigned long lam_available_bits = LAM_DEFAULT_BITS;
 
 static void enable_lam_func(void *__mm)
 {
@@ -811,10 +814,10 @@ static void enable_lam_func(void *__mm)
 	}
 }
 
-static void mm_enable_lam(struct mm_struct *mm)
+static void mm_enable_lam(struct mm_struct *mm, unsigned long nr_bits)
 {
 	mm->context.lam_cr3_mask = X86_CR3_LAM_U57;
-	mm->context.untag_mask =  ~GENMASK(62, 57);
+	mm->context.untag_mask =  ~GENMASK(57 + lam_available_bits - 1, 57);
 
 	/*
 	 * Even though the process must still be single-threaded at this
@@ -850,12 +853,12 @@ static int prctl_enable_tagged_addr(struct mm_struct *mm, unsigned long nr_bits)
 		return -EBUSY;
 	}
 
-	if (!nr_bits || nr_bits > LAM_U57_BITS) {
+	if (!nr_bits || nr_bits > lam_available_bits) {
 		mmap_write_unlock(mm);
 		return -EINVAL;
 	}
 
-	mm_enable_lam(mm);
+	mm_enable_lam(mm, nr_bits);
 
 	mmap_write_unlock(mm);
 
@@ -965,7 +968,7 @@ long do_arch_prctl_64(struct task_struct *task, int option, unsigned long arg2)
 		if (!cpu_feature_enabled(X86_FEATURE_LAM))
 			return put_user(0, (unsigned long __user *)arg2);
 		else
-			return put_user(LAM_U57_BITS, (unsigned long __user *)arg2);
+			return put_user(lam_available_bits, (unsigned long __user *)arg2);
 #endif
 	case ARCH_SHSTK_ENABLE:
 	case ARCH_SHSTK_DISABLE:
Signature · 1 line
2.53.0
#2 lore raw

PATCH v2 2/4 x86/process: Add a debug interface to change LAM tag width

In reply to Maciej Wieczor-Retman

From: Maciej Wieczor-Retman <[email protected]>

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.

---
Changelog v2:
- Extend buf size from 2 to 3 and remove unused variable.

 arch/x86/kernel/process_64.c | 55 ++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
arch/x86/kernel/process_64.c +55 -0
index 4a217f13ab90..1d5b8c8851f1 100644
@@ -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,60 @@ 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[3];
+	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;
+	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;
Signature · 1 line
2.53.0
maintainer
#3 lore raw

Re: [PATCH v2 2/4] x86/process: Add a debug interface to change LAM tag width

Quoted 78 lines · Maciej Wieczor-Retman

From: Maciej Wieczor-Retman <[email protected]>

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.

---
Changelog v2:
- Extend buf size from 2 to 3 and remove unused variable.

arch/x86/kernel/process_64.c | 55 ++++++++++++++++++++++++++++++++++++

1 file changed, 55 insertions(+)
arch/x86/kernel/process_64.c +48 -0
index 4a217f13ab90..1d5b8c8851f1 100644
@@ -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,60 @@ 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[3];
+	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;
+	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)

arch/x86/kernel/process_64.c static long prctl_map_vdso(const struct vdso_image *image, unsigned long addr) · line 862

Quoted 10 lines
arch/x86/kernel/process_64.c +7 -0
+{
+	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;

The moment someone starts using this, it becomes an ABI no matter whether it is in debugfs or not.

So why do we *really* want it?

Signature · 1 line
Small device. Typos and formatting crap
#4 lore raw

Re: [PATCH v2 2/4] x86/process: Add a debug interface to change LAM tag width

Quoted 3 lines · Borislav Petkov
Quoted 2 lines · Maciej Wieczor-Retman

From: Maciej Wieczor-Retman <[email protected]> +

...

Quoted 8 lines
Quoted 8 lines
arch/x86/kernel/process_64.c +8 -0
+/*
+ * 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)

...

Quoted 6 lines

The moment someone starts using this, it becomes an ABI no matter whether it is in debugfs or not.

So why do we *really* want it?
--
Small device. Typos and formatting crap

The general intention as stated in the comment above is to move over to the 4-bits of LAM as the default value so that once things like ChkTag start using it they don't expect the wider value and any future ABIs don't break in case the 6-bit width is removed in favor of the 4-bit one.

Now the debugfs part of that was meant to allow access to the full functionality in case someone could find some temporary use for that. AFAIK so far only clang implemented a KASAN mode for x86 with the assumption of 6-bit LAM but from my tests with the KASAN series I'm working on it doesn't work properly and needs fixes anyway.

So if you think this is a problematic addition I'm not opposed to just dropping the debugfs part or documenting it that it shouldn't be relied on to stay here forever. Altough I thought that debugfs is documented as 'to not serve as a stable ABI to user space'?

Signature · 2 lines
Kind regards
Maciej Wieczór-Retman
maintainer
#5 lore raw

Re: [PATCH v2 2/4] x86/process: Add a debug interface to change LAM tag width

Quoted 32 lines · Maciej Wieczor-Retman
Quoted 3 lines · Borislav Petkov
Quoted 2 lines · Maciej Wieczor-Retman

From: Maciej Wieczor-Retman <[email protected]> +

...

Quoted 8 lines
Quoted 8 lines
arch/x86/kernel/process_64.c +8 -0
+/*
+ * 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)

...

Quoted 6 lines

The moment someone starts using this, it becomes an ABI no matter whether it is in debugfs or not.

So why do we *really* want it?
--
Small device. Typos and formatting crap

The general intention as stated in the comment above is to move over to the 4-bits of LAM as the default value so that once things like ChkTag start using it they don't expect the wider value and any future ABIs don't break in case the 6-bit width is removed in favor of the 4-bit one.

Now the debugfs part of that was meant to allow access to the full functionality in case someone could find some temporary use for that. AFAIK so far only clang implemented a KASAN mode for x86 with the assumption of 6-bit LAM but from my tests with the KASAN series I'm working on it doesn't work properly and needs fixes anyway.

Quoted 4 lines

So if you think this is a problematic addition I'm not opposed to just dropping the debugfs part or documenting it that it shouldn't be relied on to stay here forever. Altough I thought that debugfs is documented as 'to not serve as a stable ABI to user space'?

I'm on a plane right now but you can search "debugfs ABI" on lwn.net and read the article. "[I]n case someone could find some temporary use" is exactly the "interceptive" enablement we do NOT do. When someone does find a concrete use, we'll talk about proper design then.

Signature · 1 line
Small device. Typos and formatting crap
#6 lore raw

Re: [PATCH v2 2/4] x86/process: Add a debug interface to change LAM tag width

Quoted 38 lines · Borislav Petkov
Quoted 32 lines · Maciej Wieczor-Retman
Quoted 3 lines · Borislav Petkov
Quoted 2 lines · Maciej Wieczor-Retman

From: Maciej Wieczor-Retman <[email protected]> +

...

Quoted 8 lines
Quoted 8 lines
arch/x86/kernel/process_64.c +8 -0
+/*
+ * 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)

...

Quoted 6 lines

The moment someone starts using this, it becomes an ABI no matter whether it is in debugfs or not.

So why do we *really* want it?
--
Small device. Typos and formatting crap

The general intention as stated in the comment above is to move over to the 4-bits of LAM as the default value so that once things like ChkTag start using it they don't expect the wider value and any future ABIs don't break in case the 6-bit width is removed in favor of the 4-bit one.

Now the debugfs part of that was meant to allow access to the full functionality in case someone could find some temporary use for that. AFAIK so far only clang implemented a KASAN mode for x86 with the assumption of 6-bit LAM but from my tests with the KASAN series I'm working on it doesn't work properly and needs fixes anyway.

Quoted 4 lines

So if you think this is a problematic addition I'm not opposed to just dropping the debugfs part or documenting it that it shouldn't be relied on to stay here forever. Altough I thought that debugfs is documented as 'to not serve as a stable ABI to user space'?

Quoted 4 lines

I'm on a plane right now but you can search "debugfs ABI" on lwn.net and read the article. "[I]n case someone could find some temporary use" is exactly the "interceptive" enablement we do NOT do. When someone does find a concrete use, we'll talk about proper design then.

Okay, then I'll drop the debugfs part until that happens. Thanks!

Signature · 2 lines
Kind regards
Maciej Wieczór-Retman
#7 lore raw

PATCH v2 3/4 x86/mm: Cleanup comments where LAM_U48 is mentioned

In reply to Maciej Wieczor-Retman

From: Maciej Wieczor-Retman <[email protected]>

For simplicity only the LAM_U57 mode is implemented in the kernel. No matter whether the enabled paging mode is 5-level or 4-level the masked tag bits are the same as on a 5-level system.

Remove two mentions of LAM_U48 which implied that it could be enabled.

---
 arch/x86/include/asm/mmu.h      | 2 +-
 arch/x86/include/asm/tlbflush.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/mmu.h +1 -1
index 0fe9c569d171..9dcfce439c19 100644
@@ -49,7 +49,7 @@ typedef struct {
 	unsigned long flags;
 
 #ifdef CONFIG_ADDRESS_MASKING
-	/* Active LAM mode:  X86_CR3_LAM_U48 or X86_CR3_LAM_U57 or 0 (disabled) */
+	/* Active LAM mode: X86_CR3_LAM_U57 or 0 (disabled) */
 	unsigned long lam_cr3_mask;
 
 	/* Significant bits of the virtual address. Excludes tag bits. */
arch/x86/include/asm/tlbflush.h +1 -1
index 5a3cdc439e38..94c5ca1febaf 100644
@@ -110,7 +110,7 @@ struct tlb_state {
 	/*
 	 * Active LAM mode.
 	 *
-	 * X86_CR3_LAM_U57/U48 shifted right by X86_CR3_LAM_U57_BIT or 0 if LAM
+	 * X86_CR3_LAM_U57 shifted right by X86_CR3_LAM_U57_BIT or 0 if LAM
 	 * disabled.
 	 */
 	u8 lam;
Signature · 1 line
2.53.0
#8 lore raw

PATCH v2 4/4 selftests/lam: Add test cases for different LAM tag widths

In reply to Maciej Wieczor-Retman

From: Maciej Wieczor-Retman <[email protected]>

After the default tag width in LAM (Linear Address Masking) is set to 4 bits, it's still possible to enable 6 bit wide tags for debug purposes through debugfs.

When a program enables LAM, it should be able to, through a syscall, request a number of tag bits equal or smaller to the one used system wide. If it requests a smaller one it should receive the system wide setting anyway.

Change the default tag width. Add four tests to check all combinations of tag width requests. Modify the existing test infrastructure to check with a syscall what the needed tag width actually is.

---
 tools/testing/selftests/x86/lam.c | 87 ++++++++++++++++++++++++++-----
 1 file changed, 74 insertions(+), 13 deletions(-)
tools/testing/selftests/x86/lam.c +74 -13
index 1919fa6daec0..9ed2964082eb 100644
@@ -26,9 +26,11 @@
 
 /* LAM modes, these definitions were copied from kernel code */
 #define LAM_NONE                0
-#define LAM_U57_BITS            6
+#define LAM_U57_BITS            4
+#define LAM_MAX_BITS            6
 
-#define LAM_U57_MASK            (0x3fULL << 57)
+#define LAM_U57_MASK            (0xfULL << 57)
+#define LAM_MAX_MASK            (0x3fULL << 57)
 /* arch prctl for LAM */
 #define ARCH_GET_UNTAG_MASK     0x4001
 #define ARCH_ENABLE_TAGGED_ADDR 0x4002
@@ -175,7 +177,7 @@ static int set_lam(unsigned long lam)
 	int ret = 0;
 	uint64_t ptr = 0;
 
-	if (lam != LAM_U57_BITS && lam != LAM_NONE)
+	if (lam != LAM_U57_BITS && lam != LAM_MAX_BITS && lam != LAM_NONE)
 		return -1;
 
 	/* Skip check return */
@@ -184,16 +186,21 @@ static int set_lam(unsigned long lam)
 	/* Get untagged mask */
 	syscall(SYS_arch_prctl, ARCH_GET_UNTAG_MASK, &ptr);
 
+	/* Update lam in case lam6 is enabled */
+	syscall(SYS_arch_prctl, ARCH_GET_MAX_TAG_BITS, &lam);
+
 	/* Check mask returned is expected */
 	if (lam == LAM_U57_BITS)
 		ret = (ptr != ~(LAM_U57_MASK));
+	else if (lam == LAM_MAX_BITS)
+		ret = (ptr != ~(LAM_MAX_MASK));
 	else if (lam == LAM_NONE)
 		ret = (ptr != -1ULL);
 
 	return ret;
 }
 
-static unsigned long get_default_tag_bits(void)
+static unsigned long get_default_tag_bits(int bits)
 {
 	pid_t pid;
 	int lam = LAM_NONE;
@@ -204,8 +211,8 @@ static unsigned long get_default_tag_bits(void)
 		perror("Fork failed.");
 	} else if (pid == 0) {
 		/* Set LAM mode in child process */
-		if (set_lam(LAM_U57_BITS) == 0)
-			lam = LAM_U57_BITS;
+		if (set_lam(bits) == 0)
+			syscall(SYS_arch_prctl, ARCH_GET_MAX_TAG_BITS, &lam);
 		else
 			lam = LAM_NONE;
 		exit(lam);
@@ -217,6 +224,27 @@ static unsigned long get_default_tag_bits(void)
 	return lam;
 }
 
+static int change_lam_width(unsigned char width)
+{
+	char buf[2];
+	int ret, fd;
+
+	snprintf(buf, sizeof(buf), "%u", width);
+	fd = open("/sys/kernel/debug/x86/lam_available_bits", O_WRONLY);
+	if (fd < 0) {
+		ksft_print_msg("lam_available_bits debug file not found!\n");
+		return fd;
+	}
+
+	ret = write(fd, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
+
+	close(fd);
+
+	return 0;
+}
+
 /*
  * Set tagged address and read back untag mask.
  * check if the untag mask is expected.
@@ -284,20 +312,32 @@ static int handle_lam_test(void *src, unsigned int lam)
 	return (!!strcmp((char *)src, (char *)ptr));
 }
 
-
 int handle_max_bits(struct testcases *test)
 {
-	unsigned long exp_bits = get_default_tag_bits();
-	unsigned long bits = 0;
+	unsigned long exp_bits, bits = 0;
+	int ret = 1;
 
-	if (exp_bits != LAM_NONE)
-		exp_bits = LAM_U57_BITS;
+	if (test->later) {
+		ret = change_lam_width(LAM_MAX_BITS);
+		if (ret)
+			return ret;
+	}
+
+	exp_bits = get_default_tag_bits(test->lam);
 
 	/* Get LAM max tag bits */
 	if (syscall(SYS_arch_prctl, ARCH_GET_MAX_TAG_BITS, &bits) == -1)
-		return 1;
+		goto out;
 
-	return (exp_bits != bits);
+	ret = exp_bits != bits;
+out:
+	if (test->later) {
+		ret = change_lam_width(LAM_U57_BITS);
+		if (ret)
+			return ret;
+	}
+
+	return ret;
 }
 
 /*
@@ -968,9 +1008,30 @@ static struct testcases malloc_cases[] = {
 
 static struct testcases bits_cases[] = {
 	{
+		.later = 0,
+		.lam = LAM_U57_BITS,
 		.test_func = handle_max_bits,
 		.msg = "BITS: Check default tag bits\n",
 	},
+	{
+		.later = 1,
+		.lam = LAM_U57_BITS,
+		.test_func = handle_max_bits,
+		.msg = "BITS: Check if 4 bits can be requested in 6 bit mode.\n",
+	},
+	{
+		.later = 0,
+		.expected = 1,
+		.lam = LAM_MAX_BITS,
+		.test_func = handle_max_bits,
+		.msg = "BITS:[Negative] Check if 6 bits can be requested in 4 bit mode.\n",
+	},
+	{
+		.later = 1,
+		.lam = LAM_MAX_BITS,
+		.test_func = handle_max_bits,
+		.msg = "BITS: Check if 6 bits can be requested in 6 bit mode.\n",
+	},
 };
 
 static struct testcases syscall_cases[] = {
Signature · 1 line
2.53.0