2019-05-19 12:07:45 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2017-07-11 01:08:08 +00:00
|
|
|
#
|
|
|
|
# Makefile for the RISC-V Linux kernel
|
|
|
|
#
|
|
|
|
|
2017-12-18 09:52:48 +00:00
|
|
|
ifdef CONFIG_FTRACE
|
2020-12-17 16:01:39 +00: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-17 16:01:40 +00:00
|
|
|
CFLAGS_REMOVE_sbi.o = $(CC_FLAGS_FTRACE)
|
2017-12-18 09:52:48 +00: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 11:33:29 +00:00
|
|
|
CFLAGS_syscall_table.o += $(call cc-option,-Wno-override-init,)
|
2023-05-01 22:33:54 +00:00
|
|
|
CFLAGS_compat_syscall_table.o += $(call cc-option,-Wno-override-init,)
|
2017-12-18 09:52:48 +00:00
|
|
|
|
2021-04-19 00:55:36 +00:00
|
|
|
ifdef CONFIG_KEXEC
|
2021-07-22 02:17:15 +00:00
|
|
|
AFLAGS_kexec_relocate.o := -mcmodel=medany $(call cc-option,-mno-relax)
|
2021-04-19 00:55:36 +00:00
|
|
|
endif
|
|
|
|
|
2022-05-11 19:29:21 +00: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
|
|
|
|
ifdef CONFIG_KASAN
|
|
|
|
KASAN_SANITIZE_alternative.o := n
|
|
|
|
KASAN_SANITIZE_cpufeature.o := n
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2017-07-11 01:08:08 +00:00
|
|
|
extra-y += vmlinux.lds
|
|
|
|
|
2022-09-24 18:19:14 +00:00
|
|
|
obj-y += head.o
|
2020-03-16 00:47:38 +00:00
|
|
|
obj-y += soc.o
|
2022-05-11 19:29:10 +00:00
|
|
|
obj-$(CONFIG_RISCV_ALTERNATIVE) += alternative.o
|
2017-07-11 01:08:08 +00: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
|
|
|
|
obj-y += setup.o
|
|
|
|
obj-y += signal.o
|
|
|
|
obj-y += syscall_table.o
|
|
|
|
obj-y += sys_riscv.o
|
|
|
|
obj-y += time.o
|
|
|
|
obj-y += traps.o
|
|
|
|
obj-y += riscv_ksyms.o
|
|
|
|
obj-y += stacktrace.o
|
|
|
|
obj-y += cacheinfo.o
|
2020-03-09 16:55:43 +00:00
|
|
|
obj-y += patch.o
|
2020-12-17 16:01:42 +00:00
|
|
|
obj-y += probes/
|
2019-10-28 12:10:41 +00:00
|
|
|
obj-$(CONFIG_MMU) += vdso.o vdso/
|
2017-07-11 01:08:08 +00:00
|
|
|
|
2020-08-17 12:42:50 +00:00
|
|
|
obj-$(CONFIG_RISCV_M_MODE) += traps_misaligned.o
|
2018-10-09 02:18:33 +00:00
|
|
|
obj-$(CONFIG_FPU) += fpu.o
|
2017-07-11 01:08:08 +00:00
|
|
|
obj-$(CONFIG_SMP) += smpboot.o
|
|
|
|
obj-$(CONFIG_SMP) += smp.o
|
2020-03-18 01:11:40 +00:00
|
|
|
obj-$(CONFIG_SMP) += cpu_ops.o
|
2022-01-20 09:09:17 +00:00
|
|
|
|
|
|
|
obj-$(CONFIG_RISCV_BOOT_SPINWAIT) += cpu_ops_spinwait.o
|
2017-07-11 01:08:08 +00:00
|
|
|
obj-$(CONFIG_MODULES) += module.o
|
2018-03-15 08:50:41 +00:00
|
|
|
obj-$(CONFIG_MODULE_SECTIONS) += module-sections.o
|
2018-02-13 05:13:17 +00:00
|
|
|
|
2022-02-10 05:49:42 +00:00
|
|
|
obj-$(CONFIG_CPU_PM) += suspend_entry.o suspend.o
|
2023-03-30 06:43:21 +00:00
|
|
|
obj-$(CONFIG_HIBERNATION) += hibernate.o hibernate-asm.o
|
2022-02-10 05:49:42 +00:00
|
|
|
|
2018-02-13 05:13:17 +00:00
|
|
|
obj-$(CONFIG_FUNCTION_TRACER) += mcount.o ftrace.o
|
|
|
|
obj-$(CONFIG_DYNAMIC_FTRACE) += mcount-dyn.o
|
2017-07-11 01:08:08 +00:00
|
|
|
|
2019-08-29 06:57:00 +00:00
|
|
|
obj-$(CONFIG_PERF_EVENTS) += perf_callchain.o
|
2019-09-05 03:46:35 +00:00
|
|
|
obj-$(CONFIG_HAVE_PERF_REGS) += perf_regs.o
|
2019-10-28 12:10:35 +00:00
|
|
|
obj-$(CONFIG_RISCV_SBI) += sbi.o
|
2020-03-18 01:11:43 +00:00
|
|
|
ifeq ($(CONFIG_RISCV_SBI), y)
|
2023-03-28 03:52:19 +00:00
|
|
|
obj-$(CONFIG_SMP) += sbi-ipi.o
|
2020-03-18 01:11:43 +00:00
|
|
|
obj-$(CONFIG_SMP) += cpu_ops_sbi.o
|
|
|
|
endif
|
2020-03-18 01:11:44 +00:00
|
|
|
obj-$(CONFIG_HOTPLUG_CPU) += cpu-hotplug.o
|
2020-04-16 02:38:05 +00:00
|
|
|
obj-$(CONFIG_KGDB) += kgdb.o
|
2022-06-01 07:02:04 +00:00
|
|
|
obj-$(CONFIG_KEXEC_CORE) += kexec_relocate.o crash_save_regs.o machine_kexec.o
|
2022-04-08 10:09:11 +00:00
|
|
|
obj-$(CONFIG_KEXEC_FILE) += elf_kexec.o machine_kexec_file.o
|
2021-04-19 00:55:39 +00:00
|
|
|
obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
|
RISC-V: Add arch_crash_save_vmcoreinfo support
Add arch_crash_save_vmcoreinfo(), which exports VM layout(MODULES,
VMALLOC, VMEMMAP ranges and KERNEL_LINK_ADDR), va bits and ram base for
vmcore.
Default pagetable levels and PAGE_OFFSET aren't same for different
kernel version as below. For pagetable levels, it sets sv57 by default
and falls back to setting sv48 at boot time if sv57 is not supported by
the hardware.
For ram base, the default value is 0x80200000 for qemu riscv64 env and,
for example, is 0x200000 on the XuanTie 910 CPU.
* Linux Kernel 5.18 ~
* PGTABLE_LEVELS = 5
* PAGE_OFFSET = 0xff60000000000000
* Linux Kernel 5.17 ~
* PGTABLE_LEVELS = 4
* PAGE_OFFSET = 0xffffaf8000000000
* Linux Kernel 4.19 ~
* PGTABLE_LEVELS = 3
* PAGE_OFFSET = 0xffffffe000000000
Since these configurations change from time to time and version to
version, it is preferable to export them via vmcoreinfo than to change
the crash's code frequently, it can simplify the development of crash
tool.
Signed-off-by: Xianting Tian <xianting.tian@linux.alibaba.com>
Tested-by: Deepak Gupta <debug@rivosinc.com>
Tested-by: Guo Ren <guoren@kernel.org>
Acked-by: Baoquan He <bhe@redhat.com>
Link: https://lore.kernel.org/r/20221026144208.373504-2-xianting.tian@linux.alibaba.com
[Palmer: wrap commit text]
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2022-10-26 14:42:07 +00:00
|
|
|
obj-$(CONFIG_CRASH_CORE) += crash_core.o
|
2018-04-19 23:27:49 +00:00
|
|
|
|
2020-07-14 07:40:44 +00:00
|
|
|
obj-$(CONFIG_JUMP_LABEL) += jump_label.o
|
|
|
|
|
2020-09-17 22:37:15 +00:00
|
|
|
obj-$(CONFIG_EFI) += efi.o
|
2022-04-05 07:13:05 +00:00
|
|
|
obj-$(CONFIG_COMPAT) += compat_syscall_table.o
|
2022-04-05 07:13:12 +00:00
|
|
|
obj-$(CONFIG_COMPAT) += compat_signal.o
|
2022-04-05 07:13:10 +00:00
|
|
|
obj-$(CONFIG_COMPAT) += compat_vdso/
|
2023-04-24 09:23:13 +00:00
|
|
|
|
|
|
|
obj-$(CONFIG_64BIT) += pi/
|