Re: [tip: x86/asm] x86/asm: Make ASM_CALL_CONSTRAINT conditional on frame pointers

From: Josh Poimboeuf
Date: Tue Mar 04 2025 - 14:48:00 EST


On Tue, Mar 04, 2025 at 08:48:29AM -1000, Linus Torvalds wrote:
> In your own words from 8 years go in commit f5caf621ee35 ("x86/asm:
> Fix inline asm call constraints for Clang"), just having the register
> variable makes the problem go away:
>
> With GCC 7.2, however, GCC's behavior has changed. It now changes its
> behavior based on the conversion of the register variable to a global.
> That somehow convinces it to *always* set up the frame pointer before
> inserting *any* inline asm. (Therefore, listing the variable as an
> output constraint is a no-op and is no longer necessary.)
>
> and the whole ASM_CALL_CONSTRAINT thing is just unnecessary.

I don't know if that GCC 7.2 thing from eight years ago was a fluke or
what, but without ASM_CALL_CONSTRAINT, those "call without frame pointer
save/setup" warnings are still very much active with recent compilers.

Below is what I get with empty ASM_CALL_CONSTRAINT + GCC 14 + defconfig
+ CONFIG_UNWINDER_FRAME_POINTER.

vmlinux.o: warning: objtool: .altinstr_replacement+0x569: call without frame pointer save/setup
vmlinux.o: warning: objtool: cyc2ns_read_end+0x12: call without frame pointer save/setup
vmlinux.o: warning: objtool: native_sched_clock_from_tsc+0x66: call without frame pointer save/setup
vmlinux.o: warning: objtool: kernel_fpu_end+0x26: call without frame pointer save/setup
vmlinux.o: warning: objtool: set_tls_desc+0x170: call without frame pointer save/setup
vmlinux.o: warning: objtool: pfn_valid.isra.0+0x8c: call without frame pointer save/setup
vmlinux.o: warning: objtool: __ioremap_collect_map_flags+0xf4: call without frame pointer save/setup
vmlinux.o: warning: objtool: pfn_modify_allowed+0x13a: call without frame pointer save/setup
vmlinux.o: warning: objtool: __virt_addr_valid+0x112: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0xd22: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0xd58: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0xd62: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0xd71: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0xd7b: call without frame pointer save/setup
vmlinux.o: warning: objtool: migrate_disable+0x57: call without frame pointer save/setup
vmlinux.o: warning: objtool: down_read_trylock+0x55: call without frame pointer save/setup
vmlinux.o: warning: objtool: down_write_trylock+0x38: call without frame pointer save/setup
vmlinux.o: warning: objtool: pfn_valid+0xbb: call without frame pointer save/setup
vmlinux.o: warning: objtool: class_preempt_notrace_destructor.isra.0+0x13: call without frame pointer save/setup
vmlinux.o: warning: objtool: rcu_is_watching+0x2d: call without frame pointer save/setup
vmlinux.o: warning: objtool: __is_module_percpu_address+0xc4: call without frame pointer save/setup
vmlinux.o: warning: objtool: get_compat_sigevent+0x41: call without frame pointer save/setup
vmlinux.o: warning: objtool: kprobe_busy_end+0x1e: call without frame pointer save/setup
vmlinux.o: warning: objtool: ring_buffer_discard_commit+0x22a: call without frame pointer save/setup
vmlinux.o: warning: objtool: ring_buffer_nest_end+0x27: call without frame pointer save/setup
vmlinux.o: warning: objtool: saved_cmdlines_stop+0x19: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0x124c: call without frame pointer save/setup
vmlinux.o: warning: objtool: pfn_valid+0xbb: call without frame pointer save/setup
vmlinux.o: warning: objtool: pfn_valid+0xbb: call without frame pointer save/setup
vmlinux.o: warning: objtool: pfn_valid+0xbb: call without frame pointer save/setup
vmlinux.o: warning: objtool: __pageblock_pfn_to_page+0x1cb: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0x1722: call without frame pointer save/setup
vmlinux.o: warning: objtool: fput+0xe6: call without frame pointer save/setup
vmlinux.o: warning: objtool: __fput_sync+0x57: call without frame pointer save/setup
vmlinux.o: warning: objtool: __getname_maybe_null+0x7: call without frame pointer save/setup
vmlinux.o: warning: objtool: __d_rehash+0x7c: call without frame pointer save/setup
vmlinux.o: warning: objtool: ___d_drop+0x84: call without frame pointer save/setup
vmlinux.o: warning: objtool: __d_lookup_unhash+0xde: call without frame pointer save/setup
vmlinux.o: warning: objtool: get_next_ino+0x3f: call without frame pointer save/setup
vmlinux.o: warning: objtool: mnt_get_write_access+0x68: call without frame pointer save/setup
vmlinux.o: warning: objtool: mnt_put_write_access+0x21: call without frame pointer save/setup
vmlinux.o: warning: objtool: mnt_put_write_access_file+0x2b: call without frame pointer save/setup
vmlinux.o: warning: objtool: mb_cache_entry_get+0x9d: call without frame pointer save/setup
vmlinux.o: warning: objtool: pfn_valid+0xbb: call without frame pointer save/setup
vmlinux.o: warning: objtool: pfn_valid+0xbb: call without frame pointer save/setup
vmlinux.o: warning: objtool: jbd2_journal_grab_journal_head+0x5c: call without frame pointer save/setup
vmlinux.o: warning: objtool: class_preempt_notrace_destructor.isra.0+0x13: call without frame pointer save/setup
vmlinux.o: warning: objtool: autofs_expire_multi+0xf: call without frame pointer save/setup
vmlinux.o: warning: objtool: ksys_msgsnd+0xa: call without frame pointer save/setup
vmlinux.o: warning: objtool: __x64_sys_msgsnd+0x16: call without frame pointer save/setup
vmlinux.o: warning: objtool: __ia32_sys_msgsnd+0x15: call without frame pointer save/setup
vmlinux.o: warning: objtool: compat_ksys_msgsnd+0xf: call without frame pointer save/setup
vmlinux.o: warning: objtool: __ia32_compat_sys_msgsnd+0x16: call without frame pointer save/setup
vmlinux.o: warning: objtool: __x64_sys_lsm_list_modules+0x21: call without frame pointer save/setup
vmlinux.o: warning: objtool: __ia32_sys_lsm_list_modules+0x20: call without frame pointer save/setup
vmlinux.o: warning: objtool: blk_account_io_merge_bio.part.0+0x6c: call without frame pointer save/setup
vmlinux.o: warning: objtool: blk_account_io_completion.part.0+0x5a: call without frame pointer save/setup
vmlinux.o: warning: objtool: iocg_commit_bio+0x30: call without frame pointer save/setup
vmlinux.o: warning: objtool: class_preempt_notrace_destructor.isra.0+0x13: call without frame pointer save/setup
vmlinux.o: warning: objtool: sg_miter_stop+0x6d: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0x1c6b: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0x1c82: call without frame pointer save/setup
vmlinux.o: warning: objtool: write_port+0x6f: call without frame pointer save/setup
vmlinux.o: warning: objtool: drm_clflush_page+0x67: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0x1fae: call without frame pointer save/setup
vmlinux.o: warning: objtool: check_relocations+0x62: call without frame pointer save/setup
vmlinux.o: warning: objtool: scsi_kunmap_atomic_sg+0x21: call without frame pointer save/setup
vmlinux.o: warning: objtool: serport_ldisc_compat_ioctl+0xe: call without frame pointer save/setup
vmlinux.o: warning: objtool: serport_ldisc_ioctl+0xf: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0x2286: call without frame pointer save/setup
vmlinux.o: warning: objtool: cpuidle_use_deepest_state+0x2a: call without frame pointer save/setup
vmlinux.o: warning: objtool: cpuidle_get_driver+0x20: call without frame pointer save/setup
vmlinux.o: warning: objtool: skb_abort_seq_read+0x28: call without frame pointer save/setup
vmlinux.o: warning: objtool: skb_ts_finish+0x28: call without frame pointer save/setup
vmlinux.o: warning: objtool: skb_seq_read+0x24e: call without frame pointer save/setup
vmlinux.o: warning: objtool: xdr_terminate_string+0x55: call without frame pointer save/setup
vmlinux.o: warning: objtool: class_preempt_notrace_destructor.isra.0+0x13: call without frame pointer save/setup
vmlinux.o: warning: objtool: class_preempt_notrace_destructor.isra.0+0x13: call without frame pointer save/setup
vmlinux.o: warning: objtool: find_bug+0xad: call without frame pointer save/setup
vmlinux.o: warning: objtool: generic_bug_clear_once+0x96: call without frame pointer save/setup
vmlinux.o: warning: objtool: delay_tsc+0x87: call without frame pointer save/setup
vmlinux.o: warning: objtool: .altinstr_replacement+0x5f6: call without frame pointer save/setup
vmlinux.o: warning: objtool: pfn_valid+0x81: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_spin_trylock+0x36: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_write_unlock+0x15: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_write_unlock_irq+0x16: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_write_unlock_irqrestore+0x1e: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_read_trylock+0x45: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_write_trylock+0x36: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_read_unlock+0x1b: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_read_unlock_irq+0x1c: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_read_unlock_irqrestore+0x24: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_spin_unlock+0x15: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_spin_unlock_irq+0x16: call without frame pointer save/setup
vmlinux.o: warning: objtool: _raw_spin_unlock_irqrestore+0x1e: call without frame pointer save/setup

--
Josh