Skip to contentSkip to conversation

drivers/gpu/drm/xe/xe_migrate.c:422:3: error: cannot jump from this indirect goto statement to one of its possible targets

PATCH kernel test robot 3 participants 4 messages Sep 10, 2025 – Sep 11, 2025

Subsystems (2)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next
head:   844150c255c94230aec41f88db8e2875cb97439e
commit: 59eabff2a3524d7f3bf6c24890cd197c4c116fcb [11/13] drm/xe: Convert xe_bo_create_pin_map() for exhaustive eviction
config: loongarch-randconfig-001-20250910 (https://download.01.org/0day-ci/archive/20250910/[email protected]/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250910/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/xe/xe_migrate.c:422:3: error: cannot jump from this indirect goto statement to one of its possible targets
     422 |                 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/xe/xe_migrate.c:465:2: note: possible target of indirect goto statement
     465 |         might_lock(&m->job_mutex);
         |         ^
   include/linux/lockdep.h:552:51: note: expanded from macro 'might_lock'
     552 |         lock_acquire(&(lock)->dep_map, 0, 0, 0, 1, NULL, _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/xe/xe_migrate.c:420:2: note: jump exits scope of variable with __attribute__((cleanup))
     420 |         xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
         |         ^
   drivers/gpu/drm/xe/xe_validation.h:189:2: note: expanded from macro 'xe_validation_guard'
     189 |         scoped_guard(xe_validation, _ctx, _val, _exec, _flags, _ret) \
         |         ^
   include/linux/cleanup.h:429:2: note: expanded from macro 'scoped_guard'
     429 |         __scoped_guard(_name, __UNIQUE_ID(label), args)
         |         ^
   include/linux/cleanup.h:420:20: note: expanded from macro '__scoped_guard'
     420 |         for (CLASS(_name, scope)(args);                                 \
         |                           ^
   drivers/gpu/drm/xe/xe_migrate.c:465:2: note: jump enters a statement expression
     465 |         might_lock(&m->job_mutex);
         |         ^
   include/linux/lockdep.h:552:51: note: expanded from macro 'might_lock'
     552 |         lock_acquire(&(lock)->dep_map, 0, 0, 0, 1, NULL, _THIS_IP_);    \
         |                                                          ^
   include/linux/instruction_pointer.h:10:20: note: expanded from macro '_THIS_IP_'
      10 | #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
         |                    ^
>> drivers/gpu/drm/xe/xe_migrate.c:422:3: error: cannot jump from this indirect goto statement to one of its possible targets
     422 |                 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/xe/xe_migrate.c:465:2: note: possible target of indirect goto statement
     465 |         might_lock(&m->job_mutex);
         |         ^
   include/linux/lockdep.h:553:33: note: expanded from macro 'might_lock'
     553 |         lock_release(&(lock)->dep_map, _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/xe/xe_migrate.c:420:2: note: jump exits scope of variable with __attribute__((cleanup))
     420 |         xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
         |         ^
   drivers/gpu/drm/xe/xe_validation.h:189:2: note: expanded from macro 'xe_validation_guard'
     189 |         scoped_guard(xe_validation, _ctx, _val, _exec, _flags, _ret) \
         |         ^
   include/linux/cleanup.h:429:2: note: expanded from macro 'scoped_guard'
     429 |         __scoped_guard(_name, __UNIQUE_ID(label), args)
         |         ^
   include/linux/cleanup.h:420:20: note: expanded from macro '__scoped_guard'
     420 |         for (CLASS(_name, scope)(args);                                 \
         |                           ^
   drivers/gpu/drm/xe/xe_migrate.c:465:2: note: jump enters a statement expression
     465 |         might_lock(&m->job_mutex);
         |         ^
   include/linux/lockdep.h:553:33: note: expanded from macro 'might_lock'
     553 |         lock_release(&(lock)->dep_map, _THIS_IP_);                      \
         |                                        ^
   include/linux/instruction_pointer.h:10:20: note: expanded from macro '_THIS_IP_'
      10 | #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
         |                    ^

2 errors generated.

vim +422 drivers/gpu/drm/xe/xe_migrate.c

396
397 /**
398 * xe_migrate_init() - Initialize a migrate context
399 * @m: The migration context
400 *
401 * Return: 0 if successful, negative error code on failure
402 */
403 int xe_migrate_init(struct xe_migrate *m)
404 {
405 struct xe_tile *tile = m->tile;
406 struct xe_gt *primary_gt = tile->primary_gt;
407 struct xe_device *xe = tile_to_xe(tile);
408 struct xe_validation_ctx ctx;
409 struct drm_exec exec;
410 struct xe_vm *vm;
411 int err;
412
413 /* Special layout, prepared below.. */
414 vm = xe_vm_create(xe, XE_VM_FLAG_MIGRATION |
415 XE_VM_FLAG_SET_TILE_ID(tile), NULL);
416 if (IS_ERR(vm))
417 return PTR_ERR(vm);
418
419 err = 0;
420 xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
421 err = xe_vm_drm_exec_lock(vm, &exec);

 > 422			drm_exec_retry_on_contention(&exec);
   423			err = xe_migrate_prepare_vm(tile, m, vm, &exec);
   424			drm_exec_retry_on_contention(&exec);
   425			xe_validation_retry_on_oom(&ctx, &err);
   426		}
   427		if (err)
   428			return err;
   429	
   430		if (xe->info.has_usm) {
   431			struct xe_hw_engine *hwe = xe_gt_hw_engine(primary_gt,
   432								   XE_ENGINE_CLASS_COPY,
   433								   primary_gt->usm.reserved_bcs_instance,
   434								   false);
   435			u32 logical_mask = xe_migrate_usm_logical_mask(primary_gt);
   436	
   437			if (!hwe || !logical_mask) {
   438				err = -EINVAL;
   439				goto err_out;
   440			}
   441	
   442			/*
   443			 * XXX: Currently only reserving 1 (likely slow) BCS instance on
   444			 * PVC, may want to revisit if performance is needed.
   445			 */
   446			m->q = xe_exec_queue_create(xe, vm, logical_mask, 1, hwe,
   447						    EXEC_QUEUE_FLAG_KERNEL |
   448						    EXEC_QUEUE_FLAG_PERMANENT |
   449						    EXEC_QUEUE_FLAG_HIGH_PRIORITY |
   450						    EXEC_QUEUE_FLAG_MIGRATE, 0);
   451		} else {
   452			m->q = xe_exec_queue_create_class(xe, primary_gt, vm,
   453							  XE_ENGINE_CLASS_COPY,
   454							  EXEC_QUEUE_FLAG_KERNEL |
   455							  EXEC_QUEUE_FLAG_PERMANENT |
   456							  EXEC_QUEUE_FLAG_MIGRATE, 0);

457 }
458 if (IS_ERR(m->q)) {
459 err = PTR_ERR(m->q);
460 goto err_out;
461 }
462
463 mutex_init(&m->job_mutex);
464 fs_reclaim_acquire(GFP_KERNEL);
465 might_lock(&m->job_mutex);
466 fs_reclaim_release(GFP_KERNEL);
467
468 err = devm_add_action_or_reset(xe->drm.dev, xe_migrate_fini, m);
469 if (err)
470 return err;
471
472 if (IS_DGFX(xe)) {
473 if (xe_migrate_needs_ccs_emit(xe))
474 /* min chunk size corresponds to 4K of CCS Metadata */
475 m->min_chunk_size = SZ_4K * SZ_64K /
476 xe_device_ccs_bytes(xe, SZ_64K);
477 else
478 /* Somewhat arbitrary to avoid a huge amount of blits */
479 m->min_chunk_size = SZ_64K;
480 m->min_chunk_size = roundup_pow_of_two(m->min_chunk_size);
481 drm_dbg(&xe->drm, "Migrate min chunk size is 0x%08llx\n",
482 (unsigned long long)m->min_chunk_size);
483 }
484
485 return err;
486
487 err_out:
488 xe_vm_close_and_put(vm);
489 return err;
490

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 14 lines · kernel test robot

tree:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next head:   844150c255c94230aec41f88db8e2875cb97439e
commit: 59eabff2a3524d7f3bf6c24890cd197c4c116fcb [11/13] drm/xe:
Convert xe_bo_create_pin_map() for exhaustive eviction
config: loongarch-randconfig-001-20250910
(https://download.01.org/0day-ci/archive/20250910/202509101853.nDmyxT
[email protected]/config)
compiler: clang version 18.1.8
(https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7a
b81f3d7ff)
reproduce (this is a W=1 build):
(https://download.01.org/0day-ci/archive/20250910/202509101853.nDmyxT
[email protected]/reproduce)

Quoted 10 lines

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

Quoted 3 lines

Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/xe/xe_migrate.c:422:3: error: cannot jump from

This one looks like a clang loongarch bug. It doesn't happen on clang x86 and looks implausible.

Thanks,
Thomas

Quoted 239 lines
Quoted 1 line
Quoted 1 line

this indirect goto statement to one of its possible targets

     422 |                 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/xe/xe_migrate.c:465:2: note: possible target of indirect goto statement
     465 |         might_lock(&m->job_mutex);
         |         ^
   include/linux/lockdep.h:552:51: note: expanded from macro 'might_lock'
     552 |         lock_acquire(&(lock)->dep_map, 0, 0, 0, 1, NULL, _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/xe/xe_migrate.c:420:2: note: jump exits scope of variable with __attribute__((cleanup))
     420 |         xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
         |         ^ drivers/gpu/drm/xe/xe_validation.h:189:2: note: expanded from macro 'xe_validation_guard'
     189 |         scoped_guard(xe_validation, _ctx, _val, _exec, _flags, _ret) \
         |         ^
   include/linux/cleanup.h:429:2: note: expanded from macro 'scoped_guard'
     429 |         __scoped_guard(_name, __UNIQUE_ID(label), args) |         ^
   include/linux/cleanup.h:420:20: note: expanded from macro '__scoped_guard'
     420 |         for (CLASS(_name,
scope)(args);                                 \
         |                           ^ drivers/gpu/drm/xe/xe_migrate.c:465:2: note: jump enters a statement expression
     465 |         might_lock(&m->job_mutex);
         |         ^
   include/linux/lockdep.h:552:51: note: expanded from macro 'might_lock'
     552 |         lock_acquire(&(lock)->dep_map, 0, 0, 0, 1, NULL, _THIS_IP_);    \
         |                                                          ^ include/linux/instruction_pointer.h:10:20: note: expanded from macro '_THIS_IP_'
      10 | #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
         |                    ^

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/xe/xe_migrate.c:422:3: error: cannot jump from this indirect goto statement to one of its possible targets

     422 |                 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/xe/xe_migrate.c:465:2: note: possible target of indirect goto statement
     465 |         might_lock(&m->job_mutex);
         |         ^
   include/linux/lockdep.h:553:33: note: expanded from macro 'might_lock'
     553 |         lock_release(&(lock)->dep_map, _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/xe/xe_migrate.c:420:2: note: jump exits scope of variable with __attribute__((cleanup))
     420 |         xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
         |         ^ drivers/gpu/drm/xe/xe_validation.h:189:2: note: expanded from macro 'xe_validation_guard'
     189 |         scoped_guard(xe_validation, _ctx, _val, _exec, _flags, _ret) \
         |         ^
   include/linux/cleanup.h:429:2: note: expanded from macro 'scoped_guard'
     429 |         __scoped_guard(_name, __UNIQUE_ID(label), args) |         ^
   include/linux/cleanup.h:420:20: note: expanded from macro '__scoped_guard'
     420 |         for (CLASS(_name,
scope)(args);                                 \
         |                           ^ drivers/gpu/drm/xe/xe_migrate.c:465:2: note: jump enters a statement expression
     465 |         might_lock(&m->job_mutex);
         |         ^
   include/linux/lockdep.h:553:33: note: expanded from macro 'might_lock'
     553 |         lock_release(&(lock)->dep_map, _THIS_IP_);                      \
         |                                        ^ include/linux/instruction_pointer.h:10:20: note: expanded from macro '_THIS_IP_'
      10 | #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
         |                    ^
   2 errors generated.

vim +422 drivers/gpu/drm/xe/xe_migrate.c

   396
   397 /**
   398 * xe_migrate_init() - Initialize a migrate context
   399 * @m: The migration context
   400 *
   401 * Return: 0 if successful, negative error code on failure
   402 */
   403 int xe_migrate_init(struct xe_migrate *m)
   404 {
   405 struct xe_tile *tile = m->tile;
   406 struct xe_gt *primary_gt = tile->primary_gt;
   407 struct xe_device *xe = tile_to_xe(tile);
   408 struct xe_validation_ctx ctx;
   409 struct drm_exec exec;
   410 struct xe_vm *vm;
   411 int err;
   412
   413 /* Special layout, prepared below.. */
   414 vm = xe_vm_create(xe, XE_VM_FLAG_MIGRATION |
   415   XE_VM_FLAG_SET_TILE_ID(tile),
NULL);
   416 if (IS_ERR(vm))
   417 return PTR_ERR(vm);
   418
   419 err = 0;
   420 xe_validation_guard(&ctx, &xe->val, &exec, (struct
xe_val_flags) {}, err) {
   421 err = xe_vm_drm_exec_lock(vm, &exec);
 > 422 drm_exec_retry_on_contention(&exec);
   423 err = xe_migrate_prepare_vm(tile, m, vm,
&exec);
   424 drm_exec_retry_on_contention(&exec);
   425 xe_validation_retry_on_oom(&ctx, &err);
   426 }
   427 if (err)
   428 return err;
   429
   430 if (xe->info.has_usm) {
   431 struct xe_hw_engine *hwe =
xe_gt_hw_engine(primary_gt,
   432
XE_ENGINE_CLASS_COPY,
   433
primary_gt->usm.reserved_bcs_instance,
   434
false);
   435 u32 logical_mask =
xe_migrate_usm_logical_mask(primary_gt);
   436
   437 if (!hwe || !logical_mask) {
   438 err = -EINVAL;
   439 goto err_out;
   440 }
   441
   442 /*
   443 * XXX: Currently only reserving 1 (likely
slow) BCS instance on
   444 * PVC, may want to revisit if performance
is needed.
   445 */
   446 m->q = xe_exec_queue_create(xe, vm,
logical_mask, 1, hwe,
   447
EXEC_QUEUE_FLAG_KERNEL |
   448
EXEC_QUEUE_FLAG_PERMANENT |
   449
EXEC_QUEUE_FLAG_HIGH_PRIORITY |
   450
EXEC_QUEUE_FLAG_MIGRATE, 0);
   451 } else {
   452 m->q = xe_exec_queue_create_class(xe,
primary_gt, vm,
   453
XE_ENGINE_CLASS_COPY,
   454
EXEC_QUEUE_FLAG_KERNEL |
   455
EXEC_QUEUE_FLAG_PERMANENT |
   456
EXEC_QUEUE_FLAG_MIGRATE, 0);
   457 }
   458 if (IS_ERR(m->q)) {
   459 err = PTR_ERR(m->q);
   460 goto err_out;
   461 }
   462
   463 mutex_init(&m->job_mutex);
   464 fs_reclaim_acquire(GFP_KERNEL);
   465 might_lock(&m->job_mutex);
   466 fs_reclaim_release(GFP_KERNEL);
   467
   468 err = devm_add_action_or_reset(xe->drm.dev,
xe_migrate_fini, m);
   469 if (err)
   470 return err;
   471
   472 if (IS_DGFX(xe)) {
   473 if (xe_migrate_needs_ccs_emit(xe))
   474 /* min chunk size corresponds to 4K
of CCS Metadata */
   475 m->min_chunk_size = SZ_4K * SZ_64K /
   476 xe_device_ccs_bytes(xe,
SZ_64K);
   477 else
   478 /* Somewhat arbitrary to avoid a
huge amount of blits */
   479 m->min_chunk_size = SZ_64K;
   480 m->min_chunk_size = roundup_pow_of_two(m-

Quoted 1 line

min_chunk_size);

   481 drm_dbg(&xe->drm, "Migrate min chunk size is
0x%08llx\n",
   482 (unsigned long long)m-

Quoted 1 line

min_chunk_size);

   483 }
   484
   485 return err;
   486
   487 err_out:
   488 xe_vm_close_and_put(vm);
   489 return err;
   490

#2 lore raw
Quoted 22 lines · Thomas Hellström
Quoted 21 lines · kernel test robot

tree:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next head:   844150c255c94230aec41f88db8e2875cb97439e
commit: 59eabff2a3524d7f3bf6c24890cd197c4c116fcb [11/13] drm/xe:
Convert xe_bo_create_pin_map() for exhaustive eviction
config: loongarch-randconfig-001-20250910
(https://download.01.org/0day-ci/archive/20250910/202509101853.nDmyxT
[email protected]/config)
compiler: clang version 18.1.8
(https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7a
b81f3d7ff)
reproduce (this is a W=1 build):
(https://download.01.org/0day-ci/archive/20250910/202509101853.nDmyxT
[email protected]/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

Quoted 3 lines

Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 6 lines
Quoted 3 lines

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/xe/xe_migrate.c:422:3: error: cannot jump from

This one looks like a clang loongarch bug. It doesn't happen on clang x86 and looks implausible.

This does not appear for x86_64 because its defintion of _THIS_IP_ in arch/x86/include/asm/linkage.h does not use the address of a label

  #ifdef CONFIG_64BIT
  /*
   * The generic version tends to create spurious ENDBR instructions under
   * certain conditions.
   */
  #define _THIS_IP_ ({ unsigned long __here; asm ("lea 0(%%rip), %0" : "=r" (__here)); __here; })
  #endif

compared to

  #ifndef _THIS_IP_
  #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
  #endif

for all other architectures. I can reproduce this with both arm64 and i386:

  $ make -skj"$(nproc)" ARCH=i386 LLVM=1 clean defconfig
  $ scripts/config -e DRM_XE -e PROVE_LOCKING
  $ make -skj"$(nproc)" ARCH=i386 LLVM=1 olddefconfig drivers/gpu/drm/xe/xe_migrate.o
  drivers/gpu/drm/xe/xe_migrate.c:422:3: error: cannot jump from this indirect goto statement to one of its possible targets
    422 |                 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/xe/xe_migrate.c:465:2: note: possible target of indirect goto statement
    465 |         might_lock(&m->job_mutex);
        |         ^
  include/linux/lockdep.h:553:33: note: expanded from macro 'might_lock'
    553 |         lock_release(&(lock)->dep_map, _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/xe/xe_migrate.c:420:2: note: jump exits scope of variable with __attribute__((cleanup))
    420 |         xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
        |         ^
  drivers/gpu/drm/xe/xe_validation.h:189:2: note: expanded from macro 'xe_validation_guard'
    189 |         scoped_guard(xe_validation, _ctx, _val, _exec, _flags, _ret) \
        |         ^
  include/linux/cleanup.h:429:2: note: expanded from macro 'scoped_guard'
    429 |         __scoped_guard(_name, __UNIQUE_ID(label), args)
        |         ^
  include/linux/cleanup.h:420:20: note: expanded from macro '__scoped_guard'
    420 |         for (CLASS(_name, scope)(args);                                 \
        |                           ^
  drivers/gpu/drm/xe/xe_migrate.c:465:2: note: jump enters a statement expression
    465 |         might_lock(&m->job_mutex);
        |         ^
  include/linux/lockdep.h:553:33: note: expanded from macro 'might_lock'
    553 |         lock_release(&(lock)->dep_map, _THIS_IP_);                      \
        |                                        ^
  include/linux/instruction_pointer.h:10:20: note: expanded from macro '_THIS_IP_'
     10 | #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
        |                    ^
  ...

While I agree that this is clearly a false positive because __drm_exec_retry_ptr is only assigned the label in drm_exec_until_all_locked() so we know __here will never be jumped to via 'goto *__drm_exec_retry_ptr;', I am not sure that this is a clang bug. Both compilers agree that the kernel's use of the address of a label in _THIS_IP_ is problematic because it does not conform to the only supported use case for taking the address of a label, which is for computed gotos:

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
https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html

Given that is the only supported use case, I don't think it is unreasonable for clang to make sure all address-taken labels in a function are valid jump targets for a computed goto since that is the only reason they should be exist in a function.

This could be worked around fairly simply with something like the following diff.

Cheers,
Nathan

drivers/gpu/drm/xe/xe_migrate.c +6 -0
index 6fad5d469629..b80eddf1a36e 100644
@@ -462,7 +462,13 @@ int xe_migrate_init(struct xe_migrate *m)
 
 	mutex_init(&m->job_mutex);
 	fs_reclaim_acquire(GFP_KERNEL);
+#ifndef CONFIG_CC_IS_CLANG
+	/*
+	 * _THIS_IP_ runs afoul of clang's scope checking and the computed goto
+	 * in drm_exec_retry_on_contention().
+	 */
 	might_lock(&m->job_mutex);
+#endif
 	fs_reclaim_release(GFP_KERNEL);
 
 	err = devm_add_action_or_reset(xe->drm.dev, xe_migrate_fini, m);
#3 lore raw

Hi,

Quoted 147 lines · Nathan Chancellor
Quoted 30 lines · Thomas Hellström
Quoted 29 lines · kernel test robot

tree:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe- next
head:   844150c255c94230aec41f88db8e2875cb97439e
commit: 59eabff2a3524d7f3bf6c24890cd197c4c116fcb [11/13] drm/xe:
Convert xe_bo_create_pin_map() for exhaustive eviction
config: loongarch-randconfig-001-20250910
(
https://download.01.org/0day-ci/archive/20250910/202509101853.nDmy
xT
[email protected]/config)
compiler: clang version 18.1.8
(
https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d
7a
b81f3d7ff)
reproduce (this is a W=1 build):
(
https://download.01.org/0day-ci/archive/20250910/202509101853.nDmy
xT
[email protected]/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

Quoted 3 lines

Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 8 lines
Quoted 4 lines

All errors (new ones prefixed by >>):

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/xe/xe_migrate.c:422:3: error: cannot jump from

This one looks like a clang loongarch bug. It doesn't happen on clang
x86 and looks implausible.

This does not appear for x86_64 because its defintion of _THIS_IP_ in arch/x86/include/asm/linkage.h does not use the address of a label

  #ifdef CONFIG_64BIT
  /*
   * The generic version tends to create spurious ENDBR instructions under
   * certain conditions.
   */
  #define _THIS_IP_ ({ unsigned long __here; asm ("lea 0(%%rip), %0" : "=r" (__here)); __here; })
  #endif

compared to

  #ifndef _THIS_IP_
  #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
  #endif

for all other architectures. I can reproduce this with both arm64 and i386:

  $ make -skj"$(nproc)" ARCH=i386 LLVM=1 clean defconfig
  $ scripts/config -e DRM_XE -e PROVE_LOCKING
  $ make -skj"$(nproc)" ARCH=i386 LLVM=1 olddefconfig
drivers/gpu/drm/xe/xe_migrate.o
  drivers/gpu/drm/xe/xe_migrate.c:422:3: error: cannot jump from this
indirect goto statement to one of its possible targets
    422 |                 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/xe/xe_migrate.c:465:2: note: possible target of
indirect goto statement
    465 |         might_lock(&m->job_mutex);
        |         ^
  include/linux/lockdep.h:553:33: note: expanded from macro
'might_lock'
    553 |         lock_release(&(lock)->dep_map,
_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/xe/xe_migrate.c:420:2: note: jump exits scope of
variable with __attribute__((cleanup))
    420 |         xe_validation_guard(&ctx, &xe->val, &exec, (struct
xe_val_flags) {}, err) {
        |         ^
  drivers/gpu/drm/xe/xe_validation.h:189:2: note: expanded from macro
'xe_validation_guard'
    189 |         scoped_guard(xe_validation, _ctx, _val, _exec,
_flags, _ret) \
        |         ^
  include/linux/cleanup.h:429:2: note: expanded from macro
'scoped_guard'
    429 |         __scoped_guard(_name, __UNIQUE_ID(label), args)
        |         ^
  include/linux/cleanup.h:420:20: note: expanded from macro
'__scoped_guard'
    420 |         for (CLASS(_name,
scope)(args);                                 \
        |                           ^
  drivers/gpu/drm/xe/xe_migrate.c:465:2: note: jump enters a
statement expression
    465 |         might_lock(&m->job_mutex);
        |         ^
  include/linux/lockdep.h:553:33: note: expanded from macro
'might_lock'
    553 |         lock_release(&(lock)->dep_map,
_THIS_IP_);                      \
        |                                        ^
  include/linux/instruction_pointer.h:10:20: note: expanded from
macro '_THIS_IP_'
     10 | #define _THIS_IP_  ({ __label__ __here; __here: (unsigned
long)&&__here; })
        |                    ^
  ...

While I agree that this is clearly a false positive because __drm_exec_retry_ptr is only assigned the label in drm_exec_until_all_locked() so we know __here will never be jumped to via 'goto *__drm_exec_retry_ptr;', I am not sure that this is a clang bug. Both compilers agree that the kernel's use of the address of a label in _THIS_IP_ is problematic because it does not conform to the only supported use case for taking the address of a label, which is for
computed gotos:

  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
  https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html

Given that is the only supported use case, I don't think it is unreasonable for clang to make sure all address-taken labels in a function are valid jump targets for a computed goto since that is the only reason they should be exist in a function.

Quoted 5 lines

This could be worked around fairly simply with something like the following diff.

Cheers,
Nathan

Yeah, I already have a patch in our CI that moves the goto and the corresponding label to a separate static function so we can keep the lockdep check.

Given your explanation, I need to change the commit message, though.

Thanks,
Thomas

Quoted 22 lines
drivers/gpu/drm/xe/xe_migrate.c +0 -0
index 6fad5d469629..b80eddf1a36e 100644
@@ -462,7 +462,13 @@ int xe_migrate_init(struct xe_migrate *m)


  mutex_init(&m->job_mutex);
  fs_reclaim_acquire(GFP_KERNEL);

drivers/gpu/drm/xe/xe_migrate.c +3 -0
+#ifndef CONFIG_CC_IS_CLANG
+	/*
+	 * _THIS_IP_ runs afoul of clang's scope checking and the

computed goto

drivers/gpu/drm/xe/xe_migrate.c +2 -0
+	 * in drm_exec_retry_on_contention().
+	 */

  might_lock(&m->job_mutex);
+#endif
  fs_reclaim_release(GFP_KERNEL);

  err = devm_add_action_or_reset(xe->drm.dev, xe_migrate_fini, m);