Spectral/src/stubs.s

101 lines
No EOL
1.3 KiB
ArmAsm

# Ring-0 stubs AMD64 System V ABI.
# Args: rdi, rsi, rdx, rcx, r8, r9. Return: rax (rdx:rax for 128-bit).
# All of these fault at CPL > 0 (#GP or #UD).
.text
# read_cr3() -> u64
# returns the physical address of the host PML4.
.globl read_cr3
read_cr3:
movq %cr3, %rax
ret
# write_cr3(cr3: u64)
# flushes all non-global TLB entries
.globl write_cr3
write_cr3:
movq %rdi, %cr3
ret
# vmload(vmcb_pa: u64)
# AMD SVM: loads guest state from the VMCB at the given physical address
.globl vmload
vmload:
movq %rdi, %rax
vmload %rax
ret
# vmsave(vmcb_pa: u64)
# AMD SVM: saves guest state back to the VMCB at the given physical address
.globl vmsave
vmsave:
movq %rdi, %rax
vmsave %rax
ret
# vmrun(vmcb_pa: u64)
# AMD SVM: enters the guest. Does not return until a #VMEXIT
.globl vmrun
vmrun:
movq %rdi, %rax
vmrun %rax
ret
# rdmsr(msr: u32) -> u64
# Reads the MSR number in edi; returns edx:eax packed into rax
.globl rdmsr
rdmsr:
movl %edi, %ecx
rdmsr
shlq $32, %rdx
orq %rdx, %rax
ret
# wrmsr(msr: u32, val: u64)
# msr in edi, 64-bit value in rsi
.globl wrmsr
wrmsr:
movl %edi, %ecx
movl %esi, %eax # low 32 bits
movq %rsi, %rdx
shrq $32, %rdx # high 32 bits
wrmsr
ret
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
##
##
#
#
#
#
##
#
#
#
# kurva