[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#935536: Compiling Linux with "bdver2" gcc optimization option



Package: linux-kbuild-4.19
Version: 4.19.37-5+deb10u2

In order to achieve Linux kernel optimized for my CPU AMD FX-8350
Bulldozer2 I changed the "Processor family" to
"Opteron/Athlon64/Hammer/K8" under "Processor type and features" menu of
the configuration program of the kernel (make menuconfig). Then I
changed line 121 of linux-source-4.19/arch/x86/Makefile
from:

cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)

to:

cflags-$(CONFIG_MK8) += $(call cc-option,-march=bdver2) \
<Tab>	<Tab>	$(call cc-option,-mtune=bdver2,$(call
cc-option,-mtune=generic))

compiling the kernel up to Debian 9.x Stretch all worked fine but with
Debian 10 Buster I get a lot of warning messages:

~/linux-source-4.19$ time make -s -j9 ; make -s -j9 modules
<snip>
mm/memory.o: warning: objtool: remap_pfn_range()+0xd5: unsupported
intra-function call
mm/memory.o: warning: objtool: If this is a retpoline, please patch it
in with alternatives and annotate it with ANNOTATE_NOSPEC_ALTERNATIVE.
mm/mlock.o: warning: objtool: __munlock_isolate_lru_page()+0xd6: stack
state mismatch: cfa1=7+64 cfa2=7+56
mm/mlock.o: warning: objtool: clear_page_mlock()+0x39: unsupported
instruction in callable function
mm/mlock.o: warning: objtool: mlock_vma_page()+0x8e: sibling call from
callable instruction with modified stack frame
mm/mlock.o: warning: objtool: munlock_vma_page()+0x163: return with
modified stack frame
kernel/bpf/stackmap.o: warning: objtool: bpf_get_stack()+0x68: return
with modified stack frame
kernel/bpf/sockmap.o: warning: objtool: bpf_exec_tx_verdict()+0x436:
stack state mismatch: cfa1=7+168 cfa2=7+160
kernel/power/qos.o: warning: objtool: pm_qos_remove_request()+0x6d:
return with modified stack frame
arch/x86/kernel/dumpstack.o: warning: objtool: __die()+0xc2: return with
modified stack frame
arch/x86/kernel/cpu/amd.o: warning: objtool: bsp_init_amd()+0xb1: can't
find jump dest instruction at .text+0x193
arch/x86/kvm/x86.o: warning: objtool: kvm_set_cr3()+0x18: can't find
jump dest instruction at .text+0x5cc0
arch/x86/kernel/ldt.o: warning: objtool: write_ldt()+0x110: can't find
jump dest instruction at .text+0x56a
mm/mmap.o: warning: objtool: init_user_reserve()+0x34: return with
modified stack frame
mm/mmap.o: warning: objtool: init_admin_reserve()+0x34: return with
modified stack frame
mm/mmap.o: warning: objtool: vm_brk_flags()+0x55: stack state mismatch:
cfa1=7+80 cfa2=7+72
mm/mmap.o: warning: objtool: do_mmap()+0x1bf: stack state mismatch:
cfa1=7+80 cfa2=7+72
mm/mprotect.o: warning: objtool: change_protection()+0x4f5: can't find
jump dest instruction at .text+0x5a3
mm/mremap.o: warning: objtool: move_page_tables()+0x60: stack state
mismatch: cfa1=7+144 cfa2=7+136
mm/mremap.o: warning: objtool: __se_sys_mremap()+0x12d: stack state
mismatch: cfa1=7+160 cfa2=7+152
arch/x86/kernel/sys_x86_64.o: warning: objtool: get_align_mask()+0x1d:
can't find jump dest instruction at .text+0x2f
mm/page_vma_mapped.o: warning: objtool: check_pte()+0x108: return with
modified stack frame
mm/page_vma_mapped.o: warning: objtool: page_vma_mapped_walk()+0x15e:
stack state mismatch: cfa1=7+56 cfa2=7+40
mm/pagewalk.o: warning: objtool: __walk_page_range()+0x1be: return with
modified stack frame
kernel/printk/printk.o: warning: objtool: devkmsg_write.cold.15()+0x30:
can't find jump dest instruction at .text.unlikely+0x2a1
arch/x86/kvm/emulate.o: warning: objtool: rsm_load_state_32()+0x2e2:
can't find jump dest instruction at .text+0xfa4
arch/x86/kvm/i8254.o: warning: objtool: pit_ioport_read()+0x141: can't
find jump dest instruction at .text+0x7cb
arch/x86/kvm/mmu.o: warning: objtool:
kvm_calc_tdp_mmu_root_page_role()+0xb: can't find jump dest instruction
at .text+0x3fd
arch/x86/kvm/lapic.o: warning: objtool: recalculate_apic_map()+0x2f6:
can't find jump dest instruction at .text+0x968
mm/rmap.o: warning: objtool: try_to_unmap_one()+0x4d1: can't find jump
dest instruction at .text+0x185b
arch/x86/kvm/ioapic.o: warning: objtool:
rtc_irq_eoi_tracking_reset()+0x45: return with modified stack frame
arch/x86/kvm/ioapic.o: warning: objtool: ioapic_mmio_write()+0x62: stack
state mismatch: cfa1=7+48 cfa2=7+40
arch/x86/kvm/ioapic.o: warning: objtool: ioapic_mmio_read()+0xe5: stack
state mismatch: cfa1=7+64 cfa2=7+56
arch/x86/kvm/ioapic.o: warning: objtool: kvm_get_ioapic()+0x72: return
with modified stack frame
arch/x86/kvm/ioapic.o: warning: objtool: kvm_set_ioapic()+0x105: return
with modified stack frame
arch/x86/kvm/irq_comm.o: warning: objtool: kvm_set_msi_irq()+0x60:
return with modified stack frame
kernel/rcu/sync.o: warning: objtool: rcu_sync_init()+0x52: return with
modified stack frame
mm/vmalloc.o: warning: objtool: vmalloc_to_page()+0x150: return with
modified stack frame
mm/vmalloc.o: warning: objtool: vunmap_page_range()+0x2fc: return with
modified stack frame
mm/vmalloc.o: warning: objtool: vm_unmap_ram()+0x11f: sibling call from
callable instruction with modified stack frame
mm/vmalloc.o: warning: objtool: vmap_page_range_noflush()+0x2ec: return
with modified stack frame
mm/vmalloc.o: warning: objtool: vread()+0x1cf: stack state mismatch:
cfa1=7+96 cfa2=7+88
mm/vmalloc.o: warning: objtool: vwrite()+0x176: stack state mismatch:
cfa1=7+96 cfa2=7+88
arch/x86/kvm/cpuid.o: warning: objtool: do_cpuid_ent()+0x6b4: can't find
jump dest instruction at .text+0xba6
arch/x86/kvm/pmu.o: warning: objtool: reprogram_fixed_counter()+0xbb:
can't find jump dest instruction at .text+0x37d
kernel/rcu/srcutree.o: warning: objtool: process_srcu()+0x50: stack
state mismatch: cfa1=7+128 cfa2=7+120
kernel/rcu/srcutree.o: warning: objtool: __call_srcu()+0xba: sibling
call from callable instruction with modified stack frame
arch/x86/kernel/alternative.o: warning: objtool:
apply_alternatives()+0x10f: stack state mismatch: cfa1=7+336 cfa2=7+328
arch/x86/kernel/alternative.o: warning: objtool: apply_paravirt()+0x118:
stack state mismatch: cfa1=7+296 cfa2=7+288
arch/x86/kvm/hyperv.o: warning: objtool:
kvm_hv_notify_acked_sint()+0x4a: can't find jump dest instruction at
.text+0x20c
mm/madvise.o: warning: objtool: swapin_walk_pmd_entry()+0x1ec: stack
state mismatch: cfa1=7+88 cfa2=7+80
mm/madvise.o: warning: objtool: madvise_free_pte_range()+0x39e: stack
state mismatch: cfa1=7+136 cfa2=7+128
arch/x86/kernel/tsc_msr.o: warning: objtool: cpu_khz_from_msr()+0x99:
can't find jump dest instruction at .text+0x36
kernel/rcu/tree.o: warning: objtool: rcu_exp_wait_wake()+0x224: return
with modified stack frame
kernel/rcu/tree.o: warning: objtool:
_synchronize_rcu_expedited.constprop.55()+0x1c7: stack state mismatch:
cfa1=7+192 cfa2=7+184
arch/x86/kernel/tsc.o: warning: objtool:
pit_hpet_ptimer_calibrate_cpu()+0x1c4: stack state mismatch: cfa1=7+112
cfa2=7+104
arch/x86/kernel/tsc.o: warning: objtool:
tsc_refine_calibration_work()+0xd8: stack state mismatch: cfa1=7+48
cfa2=7+40
</snip>

I guess that objtool has stopped recognize CPU instructions for
-march=bdver2 gcc optimization flag. The only workaround I know it is to
use -march=bdver1 instead this compiles without warnings.
Is there a way to get the kernel optimized for my CPU as it happened in
all the previous Debian versions?

Kind regards
-- 
Franco Martelli


Reply to: