Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
- index 14a2e61..6c29fc0 100644
- --- a/arch/arm/kvm/arm.c
- +++ b/arch/arm/kvm/arm.c
- @@ -436,6 +436,8 @@ static void update_vttbr(struct kvm *kvm)
- * shareable domain to make sure all data structures are
- * clean.
- */
- +
- + asm volatile("hvc #0x7104");
- kvm_call_hyp(__kvm_flush_vm_context);
- }
- @@ -562,13 +564,16 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
- ret = 1;
- run->exit_reason = KVM_EXIT_UNKNOWN;
- + asm volatile("hvc #0x7100");
- while (ret > 0) {
- /*
- * Check conditions before entering the guest
- */
- cond_resched();
- + asm volatile("hvc #0x7101");
- update_vttbr(vcpu->kvm);
- + asm volatile("hvc #0x7102");
- if (vcpu->arch.power_off || vcpu->arch.pause)
- vcpu_sleep(vcpu);
- @@ -610,6 +615,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
- __kvm_guest_enter();
- vcpu->mode = IN_GUEST_MODE;
- + asm volatile("hvc #0x7103");
- ret = kvm_call_hyp(__kvm_vcpu_run, vcpu);
- vcpu->mode = OUTSIDE_GUEST_MODE;
- diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S
- index b27ca9b..35f4510 100644
- --- a/arch/arm64/kvm/hyp-init.S
- +++ b/arch/arm64/kvm/hyp-init.S
- @@ -202,6 +202,7 @@ merged:
- #ifndef CONFIG_EL1_HYP
- eret
- #else
- + hvc #0x7001
- hvc #0x6000
- #endif
- ENDPROC(__kvm_hyp_init)
- diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S
- index 1042d7e..7289ae6 100644
- --- a/arch/arm64/kvm/hyp/entry.S
- +++ b/arch/arm64/kvm/hyp/entry.S
- @@ -57,19 +57,24 @@ ENTRY(__guest_enter)
- // x0: vcpu
- // x1: host/guest context
- // x2-x18: clobbered by macros
- + hvc #0x7777
- // Store the host regs
- save_callee_saved_regs x1
- + hvc #0x7778
- // Preserve vcpu & host_ctxt for use at exit time
- stp x0, x1, [sp, #-16]!
- + hvc #0x7679
- add x1, x0, #VCPU_CONTEXT
- + hvc #0x7779
- // Prepare x0-x1 for later restore by pushing them onto the stack
- ldp x2, x3, [x1, #CPU_XREG_OFFSET(0)]
- stp x2, x3, [sp, #-16]!
- + hvc #0x7780
- // x2-x18
- ldp x2, x3, [x1, #CPU_XREG_OFFSET(2)]
- ldp x4, x5, [x1, #CPU_XREG_OFFSET(4)]
- @@ -81,12 +86,15 @@ ENTRY(__guest_enter)
- ldp x16, x17, [x1, #CPU_XREG_OFFSET(16)]
- ldr x18, [x1, #CPU_XREG_OFFSET(18)]
- + hvc #0x7781
- // x19-x29, lr
- restore_callee_saved_regs x1
- + hvc #0x7782
- // Last bits of the 64bit state
- ldp x0, x1, [sp], #16
- + hvc #0x7783
- // Do not touch any register after this!
- #ifndef CONFIG_EL1_HYP
- #ifndef CONFIG_EL1_HYP
- eret
- diff --git a/arch/arm64/kvm/hyp/hyp-entry.S b/arch/arm64/kvm/hyp/hyp-entry.S
- index c81fcd0..e758596 100644
- --- a/arch/arm64/kvm/hyp/hyp-entry.S
- +++ b/arch/arm64/kvm/hyp/hyp-entry.S
- @@ -39,6 +39,7 @@
- .endm
- el1_sync: // Guest trapped into EL2
- + hvc #0x7099
- save_x0_to_x3
- #ifndef CONFIG_EL1_HYP
- @@ -58,24 +59,30 @@ el1_sync: // Guest trapped into EL2
- #endif
- cbnz x3, el1_trap // called HVC
- + hvc #0x7098
- /* Here, we're pretty sure the host called HVC. */
- restore_x0_to_x3
- + hvc #0x7097
- /* Check for __hyp_get_vectors */
- cbnz x0, 1f
- + hvc #0x7096
- #ifndef CONFIG_EL1_HYP
- mrs x0, vbar_el2
- #else
- hvc #0xd3e0
- #endif
- + hvc #0x7095
- b 2f
- 1: stp lr, xzr, [sp, #-16]!
- + hvc #0x7094
- /*
- * Compute the function address in EL2, and shuffle the parameters.
- */
- kern_hyp_va x0
- + hvc #0x7093
- mov lr, x0
- mov x0, x1
- mov x1, x2
- diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
- index bf53131..dcf0f53 100644
- --- a/arch/arm64/kvm/hyp/switch.c
- +++ b/arch/arm64/kvm/hyp/switch.c
- @@ -16,6 +16,7 @@
- */
- #include "hyp.h"
- +#include <asm/hvc_encoding.h>
- static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
- {
- @@ -33,25 +34,45 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
- write_sysreg(1 << 30, fpexc32_el2);
- isb();
- }
- +#ifndef CONFIG_EL1_HYP
- write_sysreg(val, hcr_el2);
- /* Trap on AArch32 cp15 c15 accesses (EL1 or EL0) */
- write_sysreg(1 << 15, hstr_el2);
- write_sysreg(CPTR_EL2_TTA | CPTR_EL2_TFP, cptr_el2);
- write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2);
- +#else
- + write_s_sysreg(val, S_HCR_EL2);
- + /* Trap on AArch32 cp15 c15 accesses (EL1 or EL0) */
- + write_s_sysreg(1 << 15, S_HSTR_EL2);
- + write_s_sysreg(CPTR_EL2_TTA | CPTR_EL2_TFP, S_CPTR_EL2);
- + write_s_sysreg(vcpu->arch.mdcr_el2, S_MDCR_EL2);
- +#endif
- }
- static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu)
- {
- +#ifndef CONFIG_EL1_HYP
- write_sysreg(HCR_RW, hcr_el2);
- write_sysreg(0, hstr_el2);
- write_sysreg(read_sysreg(mdcr_el2) & MDCR_EL2_HPMN_MASK, mdcr_el2);
- write_sysreg(0, cptr_el2);
- +#else
- + write_s_sysreg(HCR_RW, S_HCR_EL2);
- + write_s_sysreg(0, S_HSTR_EL2);
- + write_s_sysreg(read_sysreg(mdcr_el2) & MDCR_EL2_HPMN_MASK, S_MDCR_EL2);
- + write_s_sysreg(0, S_CPTR_EL2);
- +#endif
- }
- static void __hyp_text __activate_vm(struct kvm_vcpu *vcpu)
- {
- struct kvm *kvm = kern_hyp_va(vcpu->kvm);
- + asm volatile("hvc #0x7010");
- +#ifndef CONFIG_EL1_HYP
- write_sysreg(kvm->arch.vttbr, vttbr_el2);
- +#else
- + write_s_sysreg(kvm->arch.vttbr, S_VTTBR_EL2);
- +#endif
- }
- static void __hyp_text __deactivate_vm(struct kvm_vcpu *vcpu)
- @@ -93,7 +114,11 @@ static int __hyp_text __guest_run(struct kvm_vcpu *vcpu)
- u64 exit_code;
- vcpu = kern_hyp_va(vcpu);
- +#ifndef CONFIG_EL1_HYP
- write_sysreg(vcpu, tpidr_el2);
- +#else
- + write_s_sysreg(vcpu, S_TPIDR_EL2);
- +#endif
- host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
- guest_ctxt = &vcpu->arch.ctxt;
- @@ -115,7 +140,9 @@ static int __hyp_text __guest_run(struct kvm_vcpu *vcpu)
- * We must restore the 32-bit state before the sysregs, thanks
- * to Cortex-A57 erratum #852523.
- */
- +#ifndef CONFIG_EL1_HYP
- __sysreg32_restore_state(vcpu);
- +#endif
- __sysreg_restore_state(guest_ctxt);
- #ifndef CONFIG_EL1_HYP
- __debug_restore_state(vcpu, kern_hyp_va(vcpu->arch.debug_ptr), guest_ctxt);
- diff --git a/arch/arm64/kvm/hyp/tlb.c b/arch/arm64/kvm/hyp/tlb.c
- index 2a7e0d8..94ca6df 100644
- --- a/arch/arm64/kvm/hyp/tlb.c
- +++ b/arch/arm64/kvm/hyp/tlb.c
- @@ -71,9 +71,15 @@ __alias(__tlb_flush_vmid) void __kvm_tlb_flush_vmid(struct kvm *kvm);
- static void __hyp_text __tlb_flush_vm_context(void)
- {
- + asm volatile("hvc #0x7092");
- dsb(ishst);
- +#ifndef CONFIG_EL1_HYP
- asm volatile("tlbi alle1is \n"
- "ic ialluis ": : );
- +#else
- + asm volatile("hvc #0x5000 \n"
- + "ic ialluis ": : );
- +#endif
- dsb(ish);
- }
Advertisement
Add Comment
Please, Sign In to add comment