Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/support.S
Show First 20 Lines • Show All 805 Lines • ▼ Show 20 Lines | ENTRY(casueword32_nosmap) | ||||
cmpq %rax,%rdi /* verify address is valid */ | cmpq %rax,%rdi /* verify address is valid */ | ||||
ja fusufault | ja fusufault | ||||
movl %esi,%eax /* old */ | movl %esi,%eax /* old */ | ||||
#ifdef SMP | #ifdef SMP | ||||
lock | lock | ||||
#endif | #endif | ||||
cmpxchgl %ecx,(%rdi) /* new = %ecx */ | cmpxchgl %ecx,(%rdi) /* new = %ecx */ | ||||
setne %cl | |||||
/* | /* | ||||
* The old value is in %eax. If the store succeeded it will be the | * The old value is in %eax. If the store succeeded it will be the | ||||
* value we expected (old) from before the store, otherwise it will | * value we expected (old) from before the store, otherwise it will | ||||
* be the current value. Save %eax into %esi to prepare the return | * be the current value. Save %eax into %esi to prepare the return | ||||
* value. | * value. | ||||
*/ | */ | ||||
movl %eax,%esi | movl %eax,%esi | ||||
xorl %eax,%eax | xorl %eax,%eax | ||||
movq %rax,PCB_ONFAULT(%r8) | movq %rax,PCB_ONFAULT(%r8) | ||||
/* | /* | ||||
* Access the oldp after the pcb_onfault is cleared, to correctly | * Access the oldp after the pcb_onfault is cleared, to correctly | ||||
* catch corrupted pointer. | * catch corrupted pointer. | ||||
*/ | */ | ||||
movl %esi,(%rdx) /* oldp = %rdx */ | movl %esi,(%rdx) /* oldp = %rdx */ | ||||
POP_FRAME_POINTER | POP_FRAME_POINTER | ||||
movzbl %cl, %eax | |||||
ret | ret | ||||
END(casueword32_nosmap) | END(casueword32_nosmap) | ||||
ENTRY(casueword32_smap) | ENTRY(casueword32_smap) | ||||
PUSH_FRAME_POINTER | PUSH_FRAME_POINTER | ||||
movq PCPU(CURPCB),%r8 | movq PCPU(CURPCB),%r8 | ||||
movq $fusufault,PCB_ONFAULT(%r8) | movq $fusufault,PCB_ONFAULT(%r8) | ||||
movq $VM_MAXUSER_ADDRESS-4,%rax | movq $VM_MAXUSER_ADDRESS-4,%rax | ||||
cmpq %rax,%rdi /* verify address is valid */ | cmpq %rax,%rdi /* verify address is valid */ | ||||
ja fusufault | ja fusufault | ||||
movl %esi,%eax /* old */ | movl %esi,%eax /* old */ | ||||
stac | stac | ||||
#ifdef SMP | #ifdef SMP | ||||
lock | lock | ||||
#endif | #endif | ||||
cmpxchgl %ecx,(%rdi) /* new = %ecx */ | cmpxchgl %ecx,(%rdi) /* new = %ecx */ | ||||
clac | clac | ||||
setne %cl | |||||
/* | /* | ||||
* The old value is in %eax. If the store succeeded it will be the | * The old value is in %eax. If the store succeeded it will be the | ||||
* value we expected (old) from before the store, otherwise it will | * value we expected (old) from before the store, otherwise it will | ||||
* be the current value. Save %eax into %esi to prepare the return | * be the current value. Save %eax into %esi to prepare the return | ||||
* value. | * value. | ||||
*/ | */ | ||||
movl %eax,%esi | movl %eax,%esi | ||||
xorl %eax,%eax | xorl %eax,%eax | ||||
movq %rax,PCB_ONFAULT(%r8) | movq %rax,PCB_ONFAULT(%r8) | ||||
/* | /* | ||||
* Access the oldp after the pcb_onfault is cleared, to correctly | * Access the oldp after the pcb_onfault is cleared, to correctly | ||||
* catch corrupted pointer. | * catch corrupted pointer. | ||||
*/ | */ | ||||
movl %esi,(%rdx) /* oldp = %rdx */ | movl %esi,(%rdx) /* oldp = %rdx */ | ||||
POP_FRAME_POINTER | POP_FRAME_POINTER | ||||
movzbl %cl, %eax | |||||
ret | ret | ||||
END(casueword32_smap) | END(casueword32_smap) | ||||
/* | /* | ||||
* casueword. Compare and set user long. Returns -1 on fault, | * casueword. Compare and set user long. Returns -1 on fault, | ||||
* 0 if access was successful. Old value is written to *oldp. | * 0 if access was successful. Old value is written to *oldp. | ||||
* dst = %rdi, old = %rsi, oldp = %rdx, new = %rcx | * dst = %rdi, old = %rsi, oldp = %rdx, new = %rcx | ||||
*/ | */ | ||||
ENTRY(casueword_nosmap) | ENTRY(casueword_nosmap) | ||||
PUSH_FRAME_POINTER | PUSH_FRAME_POINTER | ||||
movq PCPU(CURPCB),%r8 | movq PCPU(CURPCB),%r8 | ||||
movq $fusufault,PCB_ONFAULT(%r8) | movq $fusufault,PCB_ONFAULT(%r8) | ||||
movq $VM_MAXUSER_ADDRESS-4,%rax | movq $VM_MAXUSER_ADDRESS-4,%rax | ||||
cmpq %rax,%rdi /* verify address is valid */ | cmpq %rax,%rdi /* verify address is valid */ | ||||
ja fusufault | ja fusufault | ||||
movq %rsi,%rax /* old */ | movq %rsi,%rax /* old */ | ||||
#ifdef SMP | #ifdef SMP | ||||
lock | lock | ||||
#endif | #endif | ||||
cmpxchgq %rcx,(%rdi) /* new = %rcx */ | cmpxchgq %rcx,(%rdi) /* new = %rcx */ | ||||
setne %cl | |||||
/* | /* | ||||
* The old value is in %rax. If the store succeeded it will be the | * The old value is in %rax. If the store succeeded it will be the | ||||
* value we expected (old) from before the store, otherwise it will | * value we expected (old) from before the store, otherwise it will | ||||
* be the current value. | * be the current value. | ||||
*/ | */ | ||||
movq %rax,%rsi | movq %rax,%rsi | ||||
xorl %eax,%eax | xorl %eax,%eax | ||||
movq %rax,PCB_ONFAULT(%r8) | movq %rax,PCB_ONFAULT(%r8) | ||||
movq %rsi,(%rdx) | movq %rsi,(%rdx) | ||||
POP_FRAME_POINTER | POP_FRAME_POINTER | ||||
movzbl %cl, %eax | |||||
ret | ret | ||||
END(casueword_nosmap) | END(casueword_nosmap) | ||||
ENTRY(casueword_smap) | ENTRY(casueword_smap) | ||||
PUSH_FRAME_POINTER | PUSH_FRAME_POINTER | ||||
movq PCPU(CURPCB),%r8 | movq PCPU(CURPCB),%r8 | ||||
movq $fusufault,PCB_ONFAULT(%r8) | movq $fusufault,PCB_ONFAULT(%r8) | ||||
movq $VM_MAXUSER_ADDRESS-4,%rax | movq $VM_MAXUSER_ADDRESS-4,%rax | ||||
cmpq %rax,%rdi /* verify address is valid */ | cmpq %rax,%rdi /* verify address is valid */ | ||||
ja fusufault | ja fusufault | ||||
movq %rsi,%rax /* old */ | movq %rsi,%rax /* old */ | ||||
stac | stac | ||||
#ifdef SMP | #ifdef SMP | ||||
lock | lock | ||||
#endif | #endif | ||||
cmpxchgq %rcx,(%rdi) /* new = %rcx */ | cmpxchgq %rcx,(%rdi) /* new = %rcx */ | ||||
clac | clac | ||||
setne %cl | |||||
/* | /* | ||||
* The old value is in %rax. If the store succeeded it will be the | * The old value is in %rax. If the store succeeded it will be the | ||||
* value we expected (old) from before the store, otherwise it will | * value we expected (old) from before the store, otherwise it will | ||||
* be the current value. | * be the current value. | ||||
*/ | */ | ||||
movq %rax,%rsi | movq %rax,%rsi | ||||
xorl %eax,%eax | xorl %eax,%eax | ||||
movq %rax,PCB_ONFAULT(%r8) | movq %rax,PCB_ONFAULT(%r8) | ||||
movq %rsi,(%rdx) | movq %rsi,(%rdx) | ||||
POP_FRAME_POINTER | POP_FRAME_POINTER | ||||
movzbl %cl, %eax | |||||
ret | ret | ||||
END(casueword_smap) | END(casueword_smap) | ||||
/* | /* | ||||
* Fetch (load) a 64-bit word, a 32-bit word, a 16-bit word, or an 8-bit | * Fetch (load) a 64-bit word, a 32-bit word, a 16-bit word, or an 8-bit | ||||
* byte from user memory. | * byte from user memory. | ||||
* addr = %rdi, valp = %rsi | * addr = %rdi, valp = %rsi | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 928 Lines • Show Last 20 Lines |