Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/amd64/exception.S
Show All 37 Lines | |||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#include "opt_atpic.h" | #include "opt_atpic.h" | ||||
#include "opt_hwpmc_hooks.h" | #include "opt_hwpmc_hooks.h" | ||||
#include "assym.inc" | #include "assym.inc" | ||||
#include <machine/asmacros.h> | |||||
#include <machine/psl.h> | #include <machine/psl.h> | ||||
#include <machine/asmacros.h> | |||||
#include <machine/trap.h> | #include <machine/trap.h> | ||||
#include <machine/specialreg.h> | #include <machine/specialreg.h> | ||||
#ifdef KDTRACE_HOOKS | #ifdef KDTRACE_HOOKS | ||||
.bss | .bss | ||||
.globl dtrace_invop_jump_addr | .globl dtrace_invop_jump_addr | ||||
.align 8 | .align 8 | ||||
.type dtrace_invop_jump_addr,@object | .type dtrace_invop_jump_addr,@object | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | alltraps_pushregs_no_rax: | ||||
movq %rbp,TF_RBP(%rsp) | movq %rbp,TF_RBP(%rsp) | ||||
movq %r10,TF_R10(%rsp) | movq %r10,TF_R10(%rsp) | ||||
movq %r11,TF_R11(%rsp) | movq %r11,TF_R11(%rsp) | ||||
movq %r12,TF_R12(%rsp) | movq %r12,TF_R12(%rsp) | ||||
movq %r13,TF_R13(%rsp) | movq %r13,TF_R13(%rsp) | ||||
movq %r14,TF_R14(%rsp) | movq %r14,TF_R14(%rsp) | ||||
movq %r15,TF_R15(%rsp) | movq %r15,TF_R15(%rsp) | ||||
movl $TF_HASSEGS,TF_FLAGS(%rsp) | movl $TF_HASSEGS,TF_FLAGS(%rsp) | ||||
cld | pushfq | ||||
andq $~(PSL_D | PSL_AC),(%rsp) | |||||
popfq | |||||
FAKE_MCOUNT(TF_RIP(%rsp)) | FAKE_MCOUNT(TF_RIP(%rsp)) | ||||
#ifdef KDTRACE_HOOKS | #ifdef KDTRACE_HOOKS | ||||
/* | /* | ||||
* DTrace Function Boundary Trace (fbt) probes are triggered | * DTrace Function Boundary Trace (fbt) probes are triggered | ||||
* by int3 (0xcc) which causes the #BP (T_BPTFLT) breakpoint | * by int3 (0xcc) which causes the #BP (T_BPTFLT) breakpoint | ||||
* interrupt. For all other trap types, just handle them in | * interrupt. For all other trap types, just handle them in | ||||
* the usual way. | * the usual way. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | IDTVEC(dblfault) | ||||
movq %r10,TF_R10(%rsp) | movq %r10,TF_R10(%rsp) | ||||
movq %r11,TF_R11(%rsp) | movq %r11,TF_R11(%rsp) | ||||
movq %r12,TF_R12(%rsp) | movq %r12,TF_R12(%rsp) | ||||
movq %r13,TF_R13(%rsp) | movq %r13,TF_R13(%rsp) | ||||
movq %r14,TF_R14(%rsp) | movq %r14,TF_R14(%rsp) | ||||
movq %r15,TF_R15(%rsp) | movq %r15,TF_R15(%rsp) | ||||
SAVE_SEGS | SAVE_SEGS | ||||
movl $TF_HASSEGS,TF_FLAGS(%rsp) | movl $TF_HASSEGS,TF_FLAGS(%rsp) | ||||
cld | pushfq | ||||
andq $~(PSL_D | PSL_AC),(%rsp) | |||||
popfq | |||||
testb $SEL_RPL_MASK,TF_CS(%rsp) /* Did we come from kernel? */ | testb $SEL_RPL_MASK,TF_CS(%rsp) /* Did we come from kernel? */ | ||||
jz 1f /* already running with kernel GS.base */ | jz 1f /* already running with kernel GS.base */ | ||||
swapgs | swapgs | ||||
1: | 1: | ||||
movq PCPU(KCR3),%rax | movq PCPU(KCR3),%rax | ||||
cmpq $~0,%rax | cmpq $~0,%rax | ||||
je 2f | je 2f | ||||
movq %rax,%cr3 | movq %rax,%cr3 | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | IDTVEC(dbg) | ||||
movq %r10,TF_R10(%rsp) | movq %r10,TF_R10(%rsp) | ||||
movq %r11,TF_R11(%rsp) | movq %r11,TF_R11(%rsp) | ||||
movq %r12,TF_R12(%rsp) | movq %r12,TF_R12(%rsp) | ||||
movq %r13,TF_R13(%rsp) | movq %r13,TF_R13(%rsp) | ||||
movq %r14,TF_R14(%rsp) | movq %r14,TF_R14(%rsp) | ||||
movq %r15,TF_R15(%rsp) | movq %r15,TF_R15(%rsp) | ||||
SAVE_SEGS | SAVE_SEGS | ||||
movl $TF_HASSEGS,TF_FLAGS(%rsp) | movl $TF_HASSEGS,TF_FLAGS(%rsp) | ||||
cld | pushfq | ||||
andq $~(PSL_D | PSL_AC),(%rsp) | |||||
popfq | |||||
testb $SEL_RPL_MASK,TF_CS(%rsp) | testb $SEL_RPL_MASK,TF_CS(%rsp) | ||||
jnz dbg_fromuserspace | jnz dbg_fromuserspace | ||||
/* | /* | ||||
* We've interrupted the kernel. Preserve GS.base in %r12, | * We've interrupted the kernel. Preserve GS.base in %r12, | ||||
* %cr3 in %r13, and possibly lower half of MSR_IA32_SPEC_CTL in %r14d. | * %cr3 in %r13, and possibly lower half of MSR_IA32_SPEC_CTL in %r14d. | ||||
*/ | */ | ||||
movl $MSR_GSBASE,%ecx | movl $MSR_GSBASE,%ecx | ||||
rdmsr | rdmsr | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | IDTVEC(nmi) | ||||
movq %r10,TF_R10(%rsp) | movq %r10,TF_R10(%rsp) | ||||
movq %r11,TF_R11(%rsp) | movq %r11,TF_R11(%rsp) | ||||
movq %r12,TF_R12(%rsp) | movq %r12,TF_R12(%rsp) | ||||
movq %r13,TF_R13(%rsp) | movq %r13,TF_R13(%rsp) | ||||
movq %r14,TF_R14(%rsp) | movq %r14,TF_R14(%rsp) | ||||
movq %r15,TF_R15(%rsp) | movq %r15,TF_R15(%rsp) | ||||
SAVE_SEGS | SAVE_SEGS | ||||
movl $TF_HASSEGS,TF_FLAGS(%rsp) | movl $TF_HASSEGS,TF_FLAGS(%rsp) | ||||
cld | pushfq | ||||
andq $~(PSL_D | PSL_AC),(%rsp) | |||||
popfq | |||||
xorl %ebx,%ebx | xorl %ebx,%ebx | ||||
testb $SEL_RPL_MASK,TF_CS(%rsp) | testb $SEL_RPL_MASK,TF_CS(%rsp) | ||||
jnz nmi_fromuserspace | jnz nmi_fromuserspace | ||||
/* | /* | ||||
* We've interrupted the kernel. Preserve GS.base in %r12, | * We've interrupted the kernel. Preserve GS.base in %r12, | ||||
* %cr3 in %r13, and possibly lower half of MSR_IA32_SPEC_CTL in %r14d. | * %cr3 in %r13, and possibly lower half of MSR_IA32_SPEC_CTL in %r14d. | ||||
*/ | */ | ||||
movl $MSR_GSBASE,%ecx | movl $MSR_GSBASE,%ecx | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | #ifdef HWPMC_HOOKS | ||||
* committed to return through doreti. | * committed to return through doreti. | ||||
*/ | */ | ||||
movq %rsp,%rsi /* source stack pointer */ | movq %rsp,%rsi /* source stack pointer */ | ||||
movq $TF_SIZE,%rcx | movq $TF_SIZE,%rcx | ||||
movq PCPU(RSP0),%rdx | movq PCPU(RSP0),%rdx | ||||
subq %rcx,%rdx | subq %rcx,%rdx | ||||
movq %rdx,%rdi /* destination stack pointer */ | movq %rdx,%rdi /* destination stack pointer */ | ||||
shrq $3,%rcx /* trap frame size in long words */ | shrq $3,%rcx /* trap frame size in long words */ | ||||
cld | pushfq | ||||
andq $~(PSL_D | PSL_AC),(%rsp) | |||||
popfq | |||||
rep | rep | ||||
movsq /* copy trapframe */ | movsq /* copy trapframe */ | ||||
movq %rdx,%rsp /* we are on the regular kstack */ | movq %rdx,%rsp /* we are on the regular kstack */ | ||||
testl $TDP_CALLCHAIN,TD_PFLAGS(%rax) /* flagged for capture? */ | testl $TDP_CALLCHAIN,TD_PFLAGS(%rax) /* flagged for capture? */ | ||||
jz nocallchain | jz nocallchain | ||||
/* | /* | ||||
* A user callchain is to be captured, so: | * A user callchain is to be captured, so: | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | IDTVEC(mchk) | ||||
movq %r10,TF_R10(%rsp) | movq %r10,TF_R10(%rsp) | ||||
movq %r11,TF_R11(%rsp) | movq %r11,TF_R11(%rsp) | ||||
movq %r12,TF_R12(%rsp) | movq %r12,TF_R12(%rsp) | ||||
movq %r13,TF_R13(%rsp) | movq %r13,TF_R13(%rsp) | ||||
movq %r14,TF_R14(%rsp) | movq %r14,TF_R14(%rsp) | ||||
movq %r15,TF_R15(%rsp) | movq %r15,TF_R15(%rsp) | ||||
SAVE_SEGS | SAVE_SEGS | ||||
movl $TF_HASSEGS,TF_FLAGS(%rsp) | movl $TF_HASSEGS,TF_FLAGS(%rsp) | ||||
cld | pushfq | ||||
andq $~(PSL_D | PSL_AC),(%rsp) | |||||
popfq | |||||
xorl %ebx,%ebx | xorl %ebx,%ebx | ||||
testb $SEL_RPL_MASK,TF_CS(%rsp) | testb $SEL_RPL_MASK,TF_CS(%rsp) | ||||
jnz mchk_fromuserspace | jnz mchk_fromuserspace | ||||
/* | /* | ||||
* We've interrupted the kernel. Preserve GS.base in %r12, | * We've interrupted the kernel. Preserve GS.base in %r12, | ||||
* %cr3 in %r13, and possibly lower half of MSR_IA32_SPEC_CTL in %r14d. | * %cr3 in %r13, and possibly lower half of MSR_IA32_SPEC_CTL in %r14d. | ||||
*/ | */ | ||||
movl $MSR_GSBASE,%ecx | movl $MSR_GSBASE,%ecx | ||||
▲ Show 20 Lines • Show All 394 Lines • Show Last 20 Lines |