Commit 3c469798 authored by Guo Ren's avatar Guo Ren Committed by Palmer Dabbelt

riscv: Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT

Lockdep is needed by proving the spinlocks and rwlocks. To suupport
it, we need fixup TRACE_IRQFLAGS_SUPPORT in kernel/entry.S. This
patch follow Documentation/irqflags-tracing.txt.
Signed-off-by: default avatarGuo Ren <guoren@linux.alibaba.com>
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
parent c1595992
...@@ -179,6 +179,9 @@ config PGTABLE_LEVELS ...@@ -179,6 +179,9 @@ config PGTABLE_LEVELS
default 3 if 64BIT default 3 if 64BIT
default 2 default 2
config LOCKDEP_SUPPORT
def_bool y
source "arch/riscv/Kconfig.socs" source "arch/riscv/Kconfig.socs"
menu "Platform type" menu "Platform type"
......
...@@ -97,19 +97,26 @@ _save_context: ...@@ -97,19 +97,26 @@ _save_context:
la gp, __global_pointer$ la gp, __global_pointer$
.option pop .option pop
la ra, ret_from_exception #ifdef CONFIG_TRACE_IRQFLAGS
call trace_hardirqs_off
#endif
/* /*
* MSB of cause differentiates between * MSB of cause differentiates between
* interrupts and exceptions * interrupts and exceptions
*/ */
bge s4, zero, 1f bge s4, zero, 1f
la ra, ret_from_exception
/* Handle interrupts */ /* Handle interrupts */
move a0, sp /* pt_regs */ move a0, sp /* pt_regs */
la a1, handle_arch_irq la a1, handle_arch_irq
REG_L a1, (a1) REG_L a1, (a1)
jr a1 jr a1
1: 1:
#ifdef CONFIG_TRACE_IRQFLAGS
call trace_hardirqs_on
#endif
/* /*
* Exceptions run with interrupts enabled or disabled depending on the * Exceptions run with interrupts enabled or disabled depending on the
* state of SR_PIE in m/sstatus. * state of SR_PIE in m/sstatus.
...@@ -119,6 +126,7 @@ _save_context: ...@@ -119,6 +126,7 @@ _save_context:
csrs CSR_STATUS, SR_IE csrs CSR_STATUS, SR_IE
1: 1:
la ra, ret_from_exception
/* Handle syscalls */ /* Handle syscalls */
li t0, EXC_SYSCALL li t0, EXC_SYSCALL
beq s4, t0, handle_syscall beq s4, t0, handle_syscall
...@@ -137,6 +145,17 @@ _save_context: ...@@ -137,6 +145,17 @@ _save_context:
tail do_trap_unknown tail do_trap_unknown
handle_syscall: handle_syscall:
#ifdef CONFIG_TRACE_IRQFLAGS
/* Recover a0 - a7 for system calls */
REG_L a0, PT_A0(sp)
REG_L a1, PT_A1(sp)
REG_L a2, PT_A2(sp)
REG_L a3, PT_A3(sp)
REG_L a4, PT_A4(sp)
REG_L a5, PT_A5(sp)
REG_L a6, PT_A6(sp)
REG_L a7, PT_A7(sp)
#endif
/* save the initial A0 value (needed in signal handlers) */ /* save the initial A0 value (needed in signal handlers) */
REG_S a0, PT_ORIG_A0(sp) REG_S a0, PT_ORIG_A0(sp)
/* /*
...@@ -190,6 +209,9 @@ ret_from_syscall_rejected: ...@@ -190,6 +209,9 @@ ret_from_syscall_rejected:
ret_from_exception: ret_from_exception:
REG_L s0, PT_STATUS(sp) REG_L s0, PT_STATUS(sp)
csrc CSR_STATUS, SR_IE csrc CSR_STATUS, SR_IE
#ifdef CONFIG_TRACE_IRQFLAGS
call trace_hardirqs_off
#endif
#ifdef CONFIG_RISCV_M_MODE #ifdef CONFIG_RISCV_M_MODE
/* the MPP value is too large to be used as an immediate arg for addi */ /* the MPP value is too large to be used as an immediate arg for addi */
li t0, SR_MPP li t0, SR_MPP
...@@ -216,6 +238,16 @@ resume_userspace: ...@@ -216,6 +238,16 @@ resume_userspace:
csrw CSR_SCRATCH, tp csrw CSR_SCRATCH, tp
restore_all: restore_all:
#ifdef CONFIG_TRACE_IRQFLAGS
REG_L s1, PT_STATUS(sp)
andi t0, s1, SR_PIE
beqz t0, 1f
call trace_hardirqs_on
j 2f
1:
call trace_hardirqs_off
2:
#endif
REG_L a0, PT_STATUS(sp) REG_L a0, PT_STATUS(sp)
/* /*
* The current load reservation is effectively part of the processor's * The current load reservation is effectively part of the processor's
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment