On Wed, May 06, 2026 at 03:03:27PM +0200, Marco Elver wrote:
> Bah, this is why it doesn't work:
>
> >> drivers/gpu/drm/msm/msm_gpu.c:272:4: error: cannot jump from this indirect
> >> goto statement to one of its possible targets
> 272 | drm_exec_retry_on_contention(&exec);
> | ^
> include/drm/drm_exec.h:123:4: note: expanded from macro
> 'drm_exec_retry_on_contention'
> 123 | goto *__drm_exec_retry_ptr; \
> | ^
> drivers/gpu/drm/msm/msm_gpu.c:304:16: note: possible target of
> indirect goto statement
> 304 | state->bos = kcalloc(submit->nr_bos,
> | ^
> include/linux/slab.h:1173:34: note: expanded from macro 'kcalloc'
> 1173 | #define kcalloc(n, size, flags) kmalloc_array(n,
> size, (flags) | __GFP_ZERO)
> | ^
> include/linux/slab.h:1133:42: note: expanded from macro 'kmalloc_array'
> 1133 | #define kmalloc_array(...)
> alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))
> | ^
> include/linux/slab.h:1132:71: note: expanded from macro
> 'kmalloc_array_noprof'
> 1132 | #define kmalloc_array_noprof(...)
> _kmalloc_array_noprof(__VA_ARGS__, __kmalloc_token(__VA_ARGS__))
> |
> ^
> include/linux/slab.h:506:55: note: expanded from macro '__kmalloc_token'
> 506 | #define __kmalloc_token(...) ((kmalloc_token_t){ .v = _THIS_IP_ })
> | ^
> include/linux/instruction_pointer.h:10:41: note: expanded from
> macro '_THIS_IP_'
> 10 | #define _THIS_IP_ ({ __label__ __here; __here: (unsigned
> long)&&__here; })
> | ^
> drivers/gpu/drm/msm/msm_gpu.c:304:16: note: jump enters a statement
> expression
>
>
> Apparently using _THIS_IP_ creates a possible indirect jump target,
> but because it's in a statement expression, it's invalid, so the
> compiler complains. This is obviously nonsense, because the actual
> indirect jump in this gpu driver code would never jump to the
> _THIS_IP_ __here label, but that's what it is.
>
> Given this pre-existing issue, we probably need to continue using
> _RET_IP_, as before. I tried to fix _THIS_IP_, but it's incredibly
> brittle (e.g. __always_inline function returning address of label
> doesn't work on Clang, but would on GCC).
For what it's worth, both LLVM and GCC consider the generic version of
_THIS_IP_ to be broken (even if it works currently), as the address of a
label is only expected to be used with a computed goto (hence the clang
error above, it just looks for possible computed goto targets):
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44298
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120071
https://github.com/llvm/llvm-project/issues/138272
--
Cheers,
Nathan