/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1994, 95, 96, 99, 2001 Ralf Baechle * Copyright (C) 1994, 1995, 1996 Paul M. Antoine. * Copyright (C) 1999 Silicon Graphics, Inc. * Copyright (C) 2007 Maciej W. Rozycki
*/ #ifndef _ASM_STACKFRAME_H #define _ASM_STACKFRAME_H
/* * get_saved_sp returns the SP for the current CPU by looking in the * kernelsp array for it. If tosp is set, it stores the current sp in * k0 and loads the new value in sp. If not, it clobbers k0 and * stores the new value in k1, leaving sp unaffected.
*/ #ifdef CONFIG_SMP
.macro SAVE_SOME docfi=0
.set push
.set noat
.set reorder
mfc0 k0, CP0_STATUS
sll k0, 3 /* extract cu0 bit */
.set noreorder
bltz k0, 8f
move k0, sp
.if \docfi
.cfi_register sp, k0
.endif #ifdef CONFIG_EVA /* * Flush interAptiv's Return Prediction Stack (RPS) by writing * EntryHi. Toggling Config7.RPS is slower and less portable. * * The RPS isn't automatically flushed when exceptions are * taken, which can result in kernel mode speculative accesses * to user addresses if the RPS mispredicts. That's harmless * when user and kernel share the same address space, but with * EVA the same user segments may be unmapped to kernel mode, * even containing sensitive MMIO regions or invalid memory. * * This can happen when the kernel sets the return address to * ret_from_* and jr's to the exception handler, which looks * more like a tail call than a function call. If nested calls * don't evict the last user address in the RPS, it will * mispredict the return and fetch from a user controlled * address into the icache. * * More recent EVA-capable cores with MAAR to restrict * speculative accesses aren't affected.
*/
MFC0 k0, CP0_ENTRYHI
MTC0 k0, CP0_ENTRYHI #endif
.set reorder /* Called from user mode, new stack. */
get_saved_sp docfi=\docfi tosp=1
8: #ifdef CONFIG_CPU_DADDI_WORKAROUNDS
.set at=k1 #endif
PTR_SUBU sp, PT_SIZE #ifdef CONFIG_CPU_DADDI_WORKAROUNDS
.set noat #endif
.if \docfi
.cfi_def_cfa sp,0
.endif
cfi_st k0, PT_R29, \docfi
cfi_rel_offset sp, PT_R29, \docfi
cfi_st v1, PT_R3, \docfi /* * You might think that you don't need to save $0, * but the FPU emulator and gdb remote debug stub * need it to operate correctly
*/
LONG_S $0, PT_R0(sp)
mfc0 v1, CP0_STATUS
cfi_st v0, PT_R2, \docfi
LONG_S v1, PT_STATUS(sp)
cfi_st $4, PT_R4, \docfi
mfc0 v1, CP0_CAUSE
cfi_st $5, PT_R5, \docfi
LONG_S v1, PT_CAUSE(sp)
cfi_st $6, PT_R6, \docfi
cfi_st ra, PT_R31, \docfi
MFC0 ra, CP0_EPC
cfi_st $7, PT_R7, \docfi #ifdef CONFIG_64BIT
cfi_st $8, PT_R8, \docfi
cfi_st $9, PT_R9, \docfi #endif
LONG_S ra, PT_EPC(sp)
.if \docfi
.cfi_rel_offset ra, PT_EPC
.endif
cfi_st $25, PT_R25, \docfi
cfi_st $28, PT_R28, \docfi
/* Set thread_info if we're coming from user mode */
mfc0 k0, CP0_STATUS
sll k0, 3 /* extract cu0 bit */
bltz k0, 9f
ori $28, sp, _THREAD_MASK
xori $28, _THREAD_MASK #ifdef CONFIG_CPU_CAVIUM_OCTEON
.set mips64
pref 0, 0($28) /* Prefetch the current pointer */ #endif
9:
.set pop
.endm
/* * Move to kernel mode and disable interrupts. * Set cp0 enable bit as sign that we're running on the kernel stack
*/
.macro CLI
mfc0 t0, CP0_STATUS
li t1, ST0_KERNEL_CUMASK | STATMASK or t0, t1
xori t0, STATMASK
mtc0 t0, CP0_STATUS
irq_disable_hazard
.endm
/* * Move to kernel mode and enable interrupts. * Set cp0 enable bit as sign that we're running on the kernel stack
*/
.macro STI
mfc0 t0, CP0_STATUS
li t1, ST0_KERNEL_CUMASK | STATMASK or t0, t1
xori t0, STATMASK & ~1
mtc0 t0, CP0_STATUS
irq_enable_hazard
.endm
/* * Just move to kernel mode and leave interrupts as they are. Note * for the R3000 this means copying the previous enable from IEp. * Set cp0 enable bit as sign that we're running on the kernel stack
*/
.macro KMODE
mfc0 t0, CP0_STATUS
li t1, ST0_KERNEL_CUMASK | (STATMASK & ~1) #ifdefined(CONFIG_CPU_R3000)
andi t2, t0, ST0_IEP
srl t2, 2 or t0, t2 #endif or t0, t1
xori t0, STATMASK & ~1
mtc0 t0, CP0_STATUS
irq_disable_hazard
.endm
#endif/* _ASM_STACKFRAME_H */
Messung V0.5
¤ Dauer der Verarbeitung: 0.25 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.