summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/svm/vmenter.S
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-09-26 23:09:29 +0200
committerLouis Burda <quent.burda@gmail.com>2022-09-26 23:09:29 +0200
commite902dc1ac4db1f4dc711fa12ad6976fb3fcddf1a (patch)
tree5b456f6c177c0ab36072ef21609020bdf0549142 /arch/x86/kvm/svm/vmenter.S
parent0aaa1e599bee256b3b15643bbb95e80ce7aa9be5 (diff)
downloadcachepc-linux-e902dc1ac4db1f4dc711fa12ad6976fb3fcddf1a.tar.gz
cachepc-linux-e902dc1ac4db1f4dc711fa12ad6976fb3fcddf1a.zip
Migrate patch
Diffstat (limited to 'arch/x86/kvm/svm/vmenter.S')
-rw-r--r--arch/x86/kvm/svm/vmenter.S91
1 files changed, 89 insertions, 2 deletions
diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S
index dfaeb47fcf2a..5e62795a4bc1 100644
--- a/arch/x86/kvm/svm/vmenter.S
+++ b/arch/x86/kvm/svm/vmenter.S
@@ -27,6 +27,48 @@
#define VCPU_R15 __VCPU_REGS_R15 * WORD_SIZE
#endif
+.macro load_tmp off reg
+ mov cachepc_regs_tmp(off), reg
+.endm
+
+.macro save_tmp off reg
+ mov reg, cachepc_regs_tmp(off)
+.endm
+
+.macro load_vm off reg
+ mov cachepc_regs_vm(off), reg
+.endm
+
+.macro save_vm off reg
+ mov reg, cachepc_regs_vm(off)
+.endm
+
+.macro apply_regs func
+ func 0x00, %rax
+ func 0x08, %rbx
+ func 0x10, %rcx
+ func 0x18, %rdx
+ func 0x20, %rbp
+ func 0x28, %rsp
+ func 0x30, %rdi
+ func 0x38, %rsi
+ func 0x40, %r8
+ func 0x48, %r9
+ func 0x50, %r10
+ func 0x58, %r11
+ func 0x60, %r12
+ func 0x68, %r13
+ func 0x70, %r14
+ func 0x78, %r15
+.endm
+
+.macro barrier
+ mfence
+ mov $0x80000005,%eax
+ cpuid
+.endm
+
+
.section .noinstr.text, "ax"
/**
@@ -35,6 +77,8 @@
* @regs: unsigned long * (to guest registers)
*/
SYM_FUNC_START(__svm_vcpu_run)
+ apply_regs save_tmp
+
push %_ASM_BP
#ifdef CONFIG_X86_64
push %r15
@@ -80,7 +124,27 @@ SYM_FUNC_START(__svm_vcpu_run)
/* Enter guest mode */
sti
-1: vmrun %_ASM_AX
+1:
+ //apply_regs save_vm
+ //apply_regs load_tmp
+ //mov cachepc_ds, %rsi
+ //mov 0x8(%rsi), %r15
+ //lea sev_prime_ret(%rip), %rdi
+ //jmp cachepc_prime_vcall+1 // skip stack pushs
+//sev_prime_ret:
+ //apply_regs save_tmp
+ //apply_regs load_vm
+
+ vmrun %_ASM_AX
+
+// apply_regs save_vm
+// apply_regs load_tmp
+// mov %r15, %rsi
+// lea sev_probe_ret(%rip), %rdi
+// jmp cachepc_probe_vcall+6 // skip stack pushs
+//sev_probe_ret:
+// apply_regs save_tmp
+// apply_regs load_vm
2: cli
@@ -163,6 +227,8 @@ SYM_FUNC_END(__svm_vcpu_run)
* @vmcb_pa: unsigned long
*/
SYM_FUNC_START(__svm_sev_es_vcpu_run)
+ apply_regs save_tmp
+
push %_ASM_BP
#ifdef CONFIG_X86_64
push %r15
@@ -181,7 +247,28 @@ SYM_FUNC_START(__svm_sev_es_vcpu_run)
/* Enter guest mode */
sti
-1: vmrun %_ASM_AX
+1:
+
+// apply_regs save_vm
+// apply_regs load_tmp
+// mov cachepc_ds, %rsi
+// mov 0x8(%rsi), %r15
+// lea sev_es_prime_ret(%rip), %rdi
+// jmp cachepc_prime_vcall+1 // skip stack pushes
+//sev_es_prime_ret:
+// apply_regs save_tmp
+// apply_regs load_vm
+//
+ vmrun %_ASM_AX
+//
+// apply_regs save_vm
+// apply_regs load_tmp
+// mov %r15, %rsi
+// lea sev_es_probe_ret(%rip), %rdi
+// jmp cachepc_probe_vcall+6 // skip stack pushs
+//sev_es_probe_ret:
+// apply_regs save_tmp
+// apply_regs load_vm
2: cli