version 1.34.2.3, 2020/04/13 08:03:30 |
version 1.35, 2018/07/14 14:29:40 |
|
|
*/ |
*/ |
|
|
#include "opt_ddb.h" |
#include "opt_ddb.h" |
#include "opt_kasan.h" |
|
#include "opt_kmsan.h" |
|
|
|
#define ALIGN_TEXT .align 16,0x90 |
#define ALIGN_TEXT .align 16,0x90 |
|
|
|
|
|
|
.text |
.text |
|
|
/* |
|
* int splraise(int s); |
|
*/ |
|
ENTRY(splraise) |
|
movl CPUVAR(ILEVEL),%eax |
|
cmpl %edi,%eax |
|
cmoval %eax,%edi |
|
movl %edi,CPUVAR(ILEVEL) |
|
KMSAN_INIT_RET(4) |
|
ret |
|
END(splraise) |
|
|
|
#ifndef XEN |
#ifndef XEN |
/* |
/* |
* Xsoftintr() |
* Xsoftintr() |
Line 119 IDTVEC(softintr) |
|
Line 105 IDTVEC(softintr) |
|
movq L_PCB(%r15),%rcx |
movq L_PCB(%r15),%rcx |
movq %rdi,CPUVAR(CURLWP) |
movq %rdi,CPUVAR(CURLWP) |
|
|
#ifdef KASAN |
|
/* clear the new stack */ |
|
pushq %rax |
|
pushq %rdx |
|
pushq %rcx |
|
callq _C_LABEL(kasan_softint) |
|
popq %rcx |
|
popq %rdx |
|
popq %rax |
|
#endif |
|
|
|
#ifdef KMSAN |
|
pushq %rax |
|
pushq %rdx |
|
pushq %rcx |
|
callq _C_LABEL(kmsan_softint) |
|
popq %rcx |
|
popq %rdx |
|
popq %rax |
|
#endif |
|
|
|
/* save old context */ |
/* save old context */ |
movq %rsp,PCB_RSP(%rcx) |
movq %rsp,PCB_RSP(%rcx) |
movq %rbp,PCB_RBP(%rcx) |
movq %rbp,PCB_RBP(%rcx) |
Line 174 IDTVEC_END(softintr) |
|
Line 139 IDTVEC_END(softintr) |
|
*/ |
*/ |
ENTRY(softintr_ret) |
ENTRY(softintr_ret) |
incl CPUVAR(MTX_COUNT) /* re-adjust after mi_switch */ |
incl CPUVAR(MTX_COUNT) /* re-adjust after mi_switch */ |
|
movl $0,L_CTXSWTCH(%rax) /* %rax from cpu_switchto */ |
cli |
cli |
jmp *%r13 /* back to Xspllower/Xdoreti */ |
jmp *%r13 /* back to Xspllower/Xdoreti */ |
END(softintr_ret) |
END(softintr_ret) |
Line 198 IDTVEC(recurse_preempt) |
|
Line 164 IDTVEC(recurse_preempt) |
|
movl $IPL_PREEMPT,CPUVAR(ILEVEL) |
movl $IPL_PREEMPT,CPUVAR(ILEVEL) |
sti |
sti |
xorq %rdi,%rdi |
xorq %rdi,%rdi |
KMSAN_INIT_ARG(8) |
|
call _C_LABEL(kpreempt) |
call _C_LABEL(kpreempt) |
cli |
cli |
jmp *%r13 /* back to Xspllower */ |
jmp *%r13 /* back to Xspllower */ |
Line 215 IDTVEC(resume_preempt) |
|
Line 180 IDTVEC(resume_preempt) |
|
testq $SEL_RPL,TF_CS(%rsp) |
testq $SEL_RPL,TF_CS(%rsp) |
jnz 1f |
jnz 1f |
movq TF_RIP(%rsp),%rdi |
movq TF_RIP(%rsp),%rdi |
KMSAN_INIT_ARG(8) |
|
call _C_LABEL(kpreempt) /* from kernel */ |
call _C_LABEL(kpreempt) /* from kernel */ |
cli |
cli |
jmp *%r13 /* back to Xdoreti */ |
jmp *%r13 /* back to Xdoreti */ |
Line 224 IDTVEC(resume_preempt) |
|
Line 188 IDTVEC(resume_preempt) |
|
cli |
cli |
jmp *%r13 /* back to Xdoreti */ |
jmp *%r13 /* back to Xdoreti */ |
IDTVEC_END(resume_preempt) |
IDTVEC_END(resume_preempt) |
#endif /* XEN */ |
|
|
|
#ifndef XENPV |
/* |
|
* int splraise(int s); |
|
*/ |
|
ENTRY(splraise) |
|
movl CPUVAR(ILEVEL),%eax |
|
cmpl %edi,%eax |
|
cmoval %eax,%edi |
|
movl %edi,CPUVAR(ILEVEL) |
|
ret |
|
END(splraise) |
|
|
/* |
/* |
* void spllower(int s); |
* void spllower(int s); |
* |
* |
|
|
.align 16 |
.align 16 |
END(spllower) |
END(spllower) |
LABEL(spllower_end) |
LABEL(spllower_end) |
|
#endif /* !XEN */ |
|
|
/* |
/* |
* void cx8_spllower(int s); |
* void cx8_spllower(int s); |
Line 294 LABEL(cx8_spllower_patch) |
|
Line 268 LABEL(cx8_spllower_patch) |
|
END(cx8_spllower_patch) |
END(cx8_spllower_patch) |
END(cx8_spllower) |
END(cx8_spllower) |
LABEL(cx8_spllower_end) |
LABEL(cx8_spllower_end) |
#endif /* !XENPV */ |
|
|
|
/* |
/* |
* void Xspllower(int s); |
* void Xspllower(int s); |
Line 323 IDTVEC(spllower) |
|
Line 296 IDTVEC(spllower) |
|
movl %edi,%ebx |
movl %edi,%ebx |
leaq 1f(%rip),%r13 /* address to resume loop at */ |
leaq 1f(%rip),%r13 /* address to resume loop at */ |
1: movl %ebx,%eax /* get cpl */ |
1: movl %ebx,%eax /* get cpl */ |
#if !defined(XENPV) |
|
movl CPUVAR(IUNMASK)(,%rax,4),%eax |
movl CPUVAR(IUNMASK)(,%rax,4),%eax |
CLI(si) |
CLI(si) |
andl CPUVAR(IPENDING),%eax /* any non-masked bits left? */ |
andl CPUVAR(IPENDING),%eax /* any non-masked bits left? */ |
Line 332 IDTVEC(spllower) |
|
Line 304 IDTVEC(spllower) |
|
btrl %eax,CPUVAR(IPENDING) |
btrl %eax,CPUVAR(IPENDING) |
movq CPUVAR(ISOURCES)(,%rax,8),%rax |
movq CPUVAR(ISOURCES)(,%rax,8),%rax |
jmp *IS_RECURSE(%rax) |
jmp *IS_RECURSE(%rax) |
#endif |
|
2: |
2: |
#if defined(XEN) |
|
movl CPUVAR(XUNMASK)(,%rax,4),%eax |
|
CLI(si) |
|
andl CPUVAR(XPENDING),%eax /* any non-masked bits left? */ |
|
jz 3f |
|
bsrl %eax,%eax |
|
btrl %eax,CPUVAR(XPENDING) |
|
movq CPUVAR(XSOURCES)(,%rax,8),%rax |
|
jmp *IS_RECURSE(%rax) |
|
#endif |
|
3: |
|
movl %ebx,CPUVAR(ILEVEL) |
movl %ebx,CPUVAR(ILEVEL) |
STI(si) |
STI(si) |
popq %r12 |
popq %r12 |
|
|
decl CPUVAR(IDEPTH) |
decl CPUVAR(IDEPTH) |
leaq 1f(%rip),%r13 |
leaq 1f(%rip),%r13 |
1: movl %ebx,%eax |
1: movl %ebx,%eax |
#if !defined(XENPV) |
|
movl CPUVAR(IUNMASK)(,%rax,4),%eax |
movl CPUVAR(IUNMASK)(,%rax,4),%eax |
CLI(si) |
CLI(si) |
andl CPUVAR(IPENDING),%eax |
andl CPUVAR(IPENDING),%eax |
|
|
btrl %eax,CPUVAR(IPENDING) |
btrl %eax,CPUVAR(IPENDING) |
movq CPUVAR(ISOURCES)(,%rax,8),%rax |
movq CPUVAR(ISOURCES)(,%rax,8),%rax |
jmp *IS_RESUME(%rax) |
jmp *IS_RESUME(%rax) |
#endif |
2: /* Check for ASTs on exit to user mode. */ |
2: |
|
#if defined(XEN) |
|
movl CPUVAR(XUNMASK)(,%rax,4),%eax |
|
CLI(si) |
|
andl CPUVAR(XPENDING),%eax |
|
jz 3f |
|
bsrl %eax,%eax /* slow, but not worth optimizing */ |
|
btrl %eax,CPUVAR(XPENDING) |
|
movq CPUVAR(XSOURCES)(,%rax,8),%rax |
|
jmp *IS_RESUME(%rax) |
|
#endif |
|
3: /* Check for ASTs on exit to user mode. */ |
|
movl %ebx,CPUVAR(ILEVEL) |
movl %ebx,CPUVAR(ILEVEL) |
5: |
5: |
testb $SEL_RPL,TF_CS(%rsp) |
testb $SEL_RPL,TF_CS(%rsp) |
Line 404 LABEL(doreti_checkast) |
|
Line 351 LABEL(doreti_checkast) |
|
movl $T_ASTFLT,TF_TRAPNO(%rsp) /* XXX undo later.. */ |
movl $T_ASTFLT,TF_TRAPNO(%rsp) /* XXX undo later.. */ |
/* Pushed T_ASTFLT into tf_trapno on entry. */ |
/* Pushed T_ASTFLT into tf_trapno on entry. */ |
movq %rsp,%rdi |
movq %rsp,%rdi |
KMSAN_INIT_ARG(8) |
|
call _C_LABEL(trap) |
call _C_LABEL(trap) |
CLI(si) |
CLI(si) |
jmp doreti_checkast |
jmp doreti_checkast |
3: |
3: |
CHECK_DEFERRED_SWITCH |
CHECK_DEFERRED_SWITCH |
jnz 9f |
jnz 9f |
HANDLE_DEFERRED_FPU |
|
6: |
6: |
INTRFASTEXIT |
INTRFASTEXIT |
9: |
9: |