2019-05-19 20:07:45 +08:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2017-07-11 09:08:08 +08:00
|
|
|
#
|
|
|
|
# Makefile for the RISC-V Linux kernel
|
|
|
|
#
|
|
|
|
|
2017-12-18 17:52:48 +08:00
|
|
|
ifdef CONFIG_FTRACE
|
2020-12-18 00:01:39 +08:00
|
|
|
CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
|
|
|
|
CFLAGS_REMOVE_patch.o = $(CC_FLAGS_FTRACE)
|
riscv: Fixup patch_text panic in ftrace
Just like arm64, we can't trace the function in the patch_text path.
Here is the bug log:
[ 45.234334] Unable to handle kernel paging request at virtual address ffffffd38ae80900
[ 45.242313] Oops [#1]
[ 45.244600] Modules linked in:
[ 45.247678] CPU: 0 PID: 11 Comm: migration/0 Not tainted 5.9.0-00025-g9b7db83-dirty #215
[ 45.255797] epc: ffffffe00021689a ra : ffffffe00021718e sp : ffffffe01afabb58
[ 45.262955] gp : ffffffe00136afa0 tp : ffffffe01af94d00 t0 : 0000000000000002
[ 45.270200] t1 : 0000000000000000 t2 : 0000000000000001 s0 : ffffffe01afabc08
[ 45.277443] s1 : ffffffe0013718a8 a0 : 0000000000000000 a1 : ffffffe01afabba8
[ 45.284686] a2 : 0000000000000000 a3 : 0000000000000000 a4 : c4c16ad38ae80900
[ 45.291929] a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000052464e43
[ 45.299173] s2 : 0000000000000001 s3 : ffffffe000206a60 s4 : ffffffe000206a60
[ 45.306415] s5 : 00000000000009ec s6 : ffffffe0013718a8 s7 : c4c16ad38ae80900
[ 45.313658] s8 : 0000000000000004 s9 : 0000000000000001 s10: 0000000000000001
[ 45.320902] s11: 0000000000000003 t3 : 0000000000000001 t4 : ffffffffd192fe79
[ 45.328144] t5 : ffffffffb8f80000 t6 : 0000000000040000
[ 45.333472] status: 0000000200000100 badaddr: ffffffd38ae80900 cause: 000000000000000f
[ 45.341514] ---[ end trace d95102172248fdcf ]---
[ 45.346176] note: migration/0[11] exited with preempt_count 1
(gdb) x /2i $pc
=> 0xffffffe00021689a <__do_proc_dointvec+196>: sd zero,0(s7)
0xffffffe00021689e <__do_proc_dointvec+200>: li s11,0
(gdb) bt
0 __do_proc_dointvec (tbl_data=0x0, table=0xffffffe01afabba8,
write=0, buffer=0x0, lenp=0x7bf897061f9a0800, ppos=0x4, conv=0x0,
data=0x52464e43) at kernel/sysctl.c:581
1 0xffffffe00021718e in do_proc_dointvec (data=<optimized out>,
conv=<optimized out>, ppos=<optimized out>, lenp=<optimized out>,
buffer=<optimized out>, write=<optimized out>, table=<optimized out>)
at kernel/sysctl.c:964
2 proc_dointvec_minmax (ppos=<optimized out>, lenp=<optimized out>,
buffer=<optimized out>, write=<optimized out>, table=<optimized out>)
at kernel/sysctl.c:964
3 proc_do_static_key (table=<optimized out>, write=1, buffer=0x0,
lenp=0x0, ppos=0x7bf897061f9a0800) at kernel/sysctl.c:1643
4 0xffffffe000206792 in ftrace_make_call (rec=<optimized out>,
addr=<optimized out>) at arch/riscv/kernel/ftrace.c:109
5 0xffffffe0002c9c04 in __ftrace_replace_code
(rec=0xffffffe01ae40c30, enable=3) at kernel/trace/ftrace.c:2503
6 0xffffffe0002ca0b2 in ftrace_replace_code (mod_flags=<optimized
out>) at kernel/trace/ftrace.c:2530
7 0xffffffe0002ca26a in ftrace_modify_all_code (command=5) at
kernel/trace/ftrace.c:2677
8 0xffffffe0002ca30e in __ftrace_modify_code (data=<optimized out>)
at kernel/trace/ftrace.c:2703
9 0xffffffe0002c13b0 in multi_cpu_stop (data=0x0) at kernel/stop_machine.c:224
10 0xffffffe0002c0fde in cpu_stopper_thread (cpu=<optimized out>) at
kernel/stop_machine.c:491
11 0xffffffe0002343de in smpboot_thread_fn (data=0x0) at kernel/smpboot.c:165
12 0xffffffe00022f8b4 in kthread (_create=0xffffffe01af0c040) at
kernel/kthread.c:292
13 0xffffffe000201fac in handle_exception () at arch/riscv/kernel/entry.S:236
0xffffffe00020678a <+114>: auipc ra,0xffffe
0xffffffe00020678e <+118>: jalr -118(ra) # 0xffffffe000204714 <patch_text_nosync>
0xffffffe000206792 <+122>: snez a0,a0
(gdb) disassemble patch_text_nosync
Dump of assembler code for function patch_text_nosync:
0xffffffe000204714 <+0>: addi sp,sp,-32
0xffffffe000204716 <+2>: sd s0,16(sp)
0xffffffe000204718 <+4>: sd ra,24(sp)
0xffffffe00020471a <+6>: addi s0,sp,32
0xffffffe00020471c <+8>: auipc ra,0x0
0xffffffe000204720 <+12>: jalr -384(ra) # 0xffffffe00020459c <patch_insn_write>
0xffffffe000204724 <+16>: beqz a0,0xffffffe00020472e <patch_text_nosync+26>
0xffffffe000204726 <+18>: ld ra,24(sp)
0xffffffe000204728 <+20>: ld s0,16(sp)
0xffffffe00020472a <+22>: addi sp,sp,32
0xffffffe00020472c <+24>: ret
0xffffffe00020472e <+26>: sd a0,-24(s0)
0xffffffe000204732 <+30>: auipc ra,0x4
0xffffffe000204736 <+34>: jalr -1464(ra) # 0xffffffe00020817a <flush_icache_all>
0xffffffe00020473a <+38>: ld a0,-24(s0)
0xffffffe00020473e <+42>: ld ra,24(sp)
0xffffffe000204740 <+44>: ld s0,16(sp)
0xffffffe000204742 <+46>: addi sp,sp,32
0xffffffe000204744 <+48>: ret
(gdb) disassemble flush_icache_all-4
Dump of assembler code for function flush_icache_all:
0xffffffe00020817a <+0>: addi sp,sp,-8
0xffffffe00020817c <+2>: sd ra,0(sp)
0xffffffe00020817e <+4>: auipc ra,0xfffff
0xffffffe000208182 <+8>: jalr -1822(ra) # 0xffffffe000206a60 <ftrace_caller>
0xffffffe000208186 <+12>: ld ra,0(sp)
0xffffffe000208188 <+14>: addi sp,sp,8
0xffffffe00020818a <+0>: addi sp,sp,-16
0xffffffe00020818c <+2>: sd s0,0(sp)
0xffffffe00020818e <+4>: sd ra,8(sp)
0xffffffe000208190 <+6>: addi s0,sp,16
0xffffffe000208192 <+8>: li a0,0
0xffffffe000208194 <+10>: auipc ra,0xfffff
0xffffffe000208198 <+14>: jalr -410(ra) # 0xffffffe000206ffa <sbi_remote_fence_i>
0xffffffe00020819c <+18>: ld s0,0(sp)
0xffffffe00020819e <+20>: ld ra,8(sp)
0xffffffe0002081a0 <+22>: addi sp,sp,16
0xffffffe0002081a2 <+24>: ret
(gdb) frame 5
(rec=0xffffffe01ae40c30, enable=3) at kernel/trace/ftrace.c:2503
2503 return ftrace_make_call(rec, ftrace_addr);
(gdb) p /x rec->ip
$2 = 0xffffffe00020817a -> flush_icache_all !
When we modified flush_icache_all's patchable-entry with ftrace_caller:
- Insert ftrace_caller at flush_icache_all prologue.
- Call flush_icache_all to sync I/Dcache, but flush_icache_all is
just we modified by half.
Link: https://lore.kernel.org/linux-riscv/CAJF2gTT=oDWesWe0JVWvTpGi60-gpbNhYLdFWN_5EbyeqoEDdw@mail.gmail.com/T/#t
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
2020-12-18 00:01:40 +08:00
|
|
|
CFLAGS_REMOVE_sbi.o = $(CC_FLAGS_FTRACE)
|
2024-02-02 09:51:02 +08:00
|
|
|
CFLAGS_REMOVE_return_address.o = $(CC_FLAGS_FTRACE)
|
2017-12-18 17:52:48 +08:00
|
|
|
endif
|
riscv: syscall_table: Reduce W=1 compilation warnings noise
Building riscv syscall table with W=1 throws the warning as
following pattern:
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
./include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro ‘__SYSCALL’
29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
| ^~~~~~~~~
./include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro ‘__SC_COMP’
34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for ‘sys_call_table[0]’)
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
./include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro ‘__SYSCALL’
29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
| ^~~~~~~~~
./include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro ‘__SC_COMP’
34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
...
Since we intentionally build the syscall tables this way,ignore the warning.
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
2021-03-05 19:33:29 +08:00
|
|
|
CFLAGS_syscall_table.o += $(call cc-option,-Wno-override-init,)
|
2023-05-02 06:33:54 +08:00
|
|
|
CFLAGS_compat_syscall_table.o += $(call cc-option,-Wno-override-init,)
|
2017-12-18 17:52:48 +08:00
|
|
|
|
2023-12-01 14:25:38 +08:00
|
|
|
ifdef CONFIG_KEXEC_CORE
|
2021-07-22 10:17:15 +08:00
|
|
|
AFLAGS_kexec_relocate.o := -mcmodel=medany $(call cc-option,-mno-relax)
|
2021-04-19 08:55:36 +08:00
|
|
|
endif
|
|
|
|
|
2022-05-12 03:29:21 +08:00
|
|
|
# cmodel=medany and notrace when patching early
|
|
|
|
ifdef CONFIG_RISCV_ALTERNATIVE_EARLY
|
|
|
|
CFLAGS_alternative.o := -mcmodel=medany
|
|
|
|
CFLAGS_cpufeature.o := -mcmodel=medany
|
|
|
|
ifdef CONFIG_FTRACE
|
|
|
|
CFLAGS_REMOVE_alternative.o = $(CC_FLAGS_FTRACE)
|
|
|
|
CFLAGS_REMOVE_cpufeature.o = $(CC_FLAGS_FTRACE)
|
|
|
|
endif
|
2023-05-26 23:46:30 +08:00
|
|
|
ifdef CONFIG_RELOCATABLE
|
|
|
|
CFLAGS_alternative.o += -fno-pie
|
|
|
|
CFLAGS_cpufeature.o += -fno-pie
|
|
|
|
endif
|
2022-05-12 03:29:21 +08:00
|
|
|
ifdef CONFIG_KASAN
|
|
|
|
KASAN_SANITIZE_alternative.o := n
|
|
|
|
KASAN_SANITIZE_cpufeature.o := n
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2017-07-11 09:08:08 +08:00
|
|
|
extra-y += vmlinux.lds
|
|
|
|
|
2022-09-25 02:19:14 +08:00
|
|
|
obj-y += head.o
|
2020-03-16 08:47:38 +08:00
|
|
|
obj-y += soc.o
|
2022-05-12 03:29:10 +08:00
|
|
|
obj-$(CONFIG_RISCV_ALTERNATIVE) += alternative.o
|
2017-07-11 09:08:08 +08:00
|
|
|
obj-y += cpu.o
|
|
|
|
obj-y += cpufeature.o
|
|
|
|
obj-y += entry.o
|
|
|
|
obj-y += irq.o
|
|
|
|
obj-y += process.o
|
|
|
|
obj-y += ptrace.o
|
|
|
|
obj-y += reset.o
|
2024-02-02 09:51:02 +08:00
|
|
|
obj-y += return_address.o
|
2017-07-11 09:08:08 +08:00
|
|
|
obj-y += setup.o
|
|
|
|
obj-y += signal.o
|
|
|
|
obj-y += syscall_table.o
|
|
|
|
obj-y += sys_riscv.o
|
2023-11-23 00:47:03 +08:00
|
|
|
obj-y += sys_hwprobe.o
|
2017-07-11 09:08:08 +08:00
|
|
|
obj-y += time.o
|
|
|
|
obj-y += traps.o
|
|
|
|
obj-y += riscv_ksyms.o
|
|
|
|
obj-y += stacktrace.o
|
|
|
|
obj-y += cacheinfo.o
|
2020-03-10 00:55:43 +08:00
|
|
|
obj-y += patch.o
|
2020-12-18 00:01:42 +08:00
|
|
|
obj-y += probes/
|
2023-11-02 02:33:01 +08:00
|
|
|
obj-y += tests/
|
2019-10-28 20:10:41 +08:00
|
|
|
obj-$(CONFIG_MMU) += vdso.o vdso/
|
2017-07-11 09:08:08 +08:00
|
|
|
|
2023-10-04 23:13:59 +08:00
|
|
|
obj-$(CONFIG_RISCV_MISALIGNED) += traps_misaligned.o
|
2024-03-09 02:25:58 +08:00
|
|
|
obj-$(CONFIG_RISCV_MISALIGNED) += unaligned_access_speed.o
|
|
|
|
obj-$(CONFIG_RISCV_PROBE_UNALIGNED_ACCESS) += copy-unaligned.o
|
|
|
|
|
2018-10-09 10:18:33 +08:00
|
|
|
obj-$(CONFIG_FPU) += fpu.o
|
2024-03-29 15:18:26 +08:00
|
|
|
obj-$(CONFIG_FPU) += kernel_mode_fpu.o
|
2023-06-05 19:07:05 +08:00
|
|
|
obj-$(CONFIG_RISCV_ISA_V) += vector.o
|
2024-01-15 13:59:20 +08:00
|
|
|
obj-$(CONFIG_RISCV_ISA_V) += kernel_mode_vector.o
|
2017-07-11 09:08:08 +08:00
|
|
|
obj-$(CONFIG_SMP) += smpboot.o
|
|
|
|
obj-$(CONFIG_SMP) += smp.o
|
2020-03-18 09:11:40 +08:00
|
|
|
obj-$(CONFIG_SMP) += cpu_ops.o
|
2022-01-20 17:09:17 +08:00
|
|
|
|
|
|
|
obj-$(CONFIG_RISCV_BOOT_SPINWAIT) += cpu_ops_spinwait.o
|
2017-07-11 09:08:08 +08:00
|
|
|
obj-$(CONFIG_MODULES) += module.o
|
2018-03-15 16:50:41 +08:00
|
|
|
obj-$(CONFIG_MODULE_SECTIONS) += module-sections.o
|
2018-02-13 13:13:17 +08:00
|
|
|
|
2022-02-10 13:49:42 +08:00
|
|
|
obj-$(CONFIG_CPU_PM) += suspend_entry.o suspend.o
|
2023-03-30 14:43:21 +08:00
|
|
|
obj-$(CONFIG_HIBERNATION) += hibernate.o hibernate-asm.o
|
2022-02-10 13:49:42 +08:00
|
|
|
|
2018-02-13 13:13:17 +08:00
|
|
|
obj-$(CONFIG_FUNCTION_TRACER) += mcount.o ftrace.o
|
|
|
|
obj-$(CONFIG_DYNAMIC_FTRACE) += mcount-dyn.o
|
2017-07-11 09:08:08 +08:00
|
|
|
|
2019-08-29 14:57:00 +08:00
|
|
|
obj-$(CONFIG_PERF_EVENTS) += perf_callchain.o
|
2019-09-05 11:46:35 +08:00
|
|
|
obj-$(CONFIG_HAVE_PERF_REGS) += perf_regs.o
|
2019-10-28 20:10:35 +08:00
|
|
|
obj-$(CONFIG_RISCV_SBI) += sbi.o
|
2020-03-18 09:11:43 +08:00
|
|
|
ifeq ($(CONFIG_RISCV_SBI), y)
|
2023-03-28 11:52:19 +08:00
|
|
|
obj-$(CONFIG_SMP) += sbi-ipi.o
|
2020-03-18 09:11:43 +08:00
|
|
|
obj-$(CONFIG_SMP) += cpu_ops_sbi.o
|
|
|
|
endif
|
2020-03-18 09:11:44 +08:00
|
|
|
obj-$(CONFIG_HOTPLUG_CPU) += cpu-hotplug.o
|
2023-12-21 00:00:14 +08:00
|
|
|
obj-$(CONFIG_PARAVIRT) += paravirt.o
|
2020-04-16 10:38:05 +08:00
|
|
|
obj-$(CONFIG_KGDB) += kgdb.o
|
2022-06-01 15:02:04 +08:00
|
|
|
obj-$(CONFIG_KEXEC_CORE) += kexec_relocate.o crash_save_regs.o machine_kexec.o
|
2022-04-08 18:09:11 +08:00
|
|
|
obj-$(CONFIG_KEXEC_FILE) += elf_kexec.o machine_kexec_file.o
|
2021-04-19 08:55:39 +08:00
|
|
|
obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
|
2024-01-24 13:12:42 +08:00
|
|
|
obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o
|
2018-04-20 07:27:49 +08:00
|
|
|
|
2020-07-14 15:40:44 +08:00
|
|
|
obj-$(CONFIG_JUMP_LABEL) += jump_label.o
|
|
|
|
|
2023-07-11 02:35:49 +08:00
|
|
|
obj-$(CONFIG_CFI_CLANG) += cfi.o
|
|
|
|
|
2020-09-18 06:37:15 +08:00
|
|
|
obj-$(CONFIG_EFI) += efi.o
|
2022-04-05 15:13:05 +08:00
|
|
|
obj-$(CONFIG_COMPAT) += compat_syscall_table.o
|
2022-04-05 15:13:12 +08:00
|
|
|
obj-$(CONFIG_COMPAT) += compat_signal.o
|
2022-04-05 15:13:10 +08:00
|
|
|
obj-$(CONFIG_COMPAT) += compat_vdso/
|
2023-04-24 17:23:13 +08:00
|
|
|
|
|
|
|
obj-$(CONFIG_64BIT) += pi/
|
2023-05-15 13:49:13 +08:00
|
|
|
obj-$(CONFIG_ACPI) += acpi.o
|