[PATCH bpf-next v1 1/3] compiler_types: Emit a BTF type tag for __iomem

From: Kumar Kartikeya Dwivedi

Date: Fri Nov 27 2026 - 21:53:29 EST


__user, __percpu and __rcu pointers carry a BTF type tag, which tells the
BPF verifier what they point to. __iomem pointers do not: outside of sparse
the annotation expands to nothing, and in BTF such a pointer looks like any
other.

Define __iomem as BTF_TYPE_TAG(iomem), so that BTF records which pointers
hold the address of a device register. The next patch uses it.

As for the other three, the tag is only emitted with CONFIG_DEBUG_INFO_BTF,
a pahole that supports type tags and a compiler that has the btf_type_tag
attribute. The attribute does not take part in type checking. With the
config of the BPF selftests, vmlinux BTF grows by 892 bytes for 27 tagged
types.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
---
include/linux/compiler_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index c5921f139007..8cfa555664e9 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -67,7 +67,7 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
# else
# define __user BTF_TYPE_TAG(user)
# endif
-# define __iomem
+# define __iomem BTF_TYPE_TAG(iomem)
# define __percpu __percpu_qual BTF_TYPE_TAG(percpu)
# define __rcu BTF_TYPE_TAG(rcu)

--
2.53.1-Meta