Advertisement
jintack

simple fix for vhe-guest state. (Just for record)

Oct 30th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. diff --git a/arch/arm64/kvm/emulate.c b/arch/arm64/kvm/emulate.c
  2. index 43473d7..a8dfe9f 100644
  3. --- a/arch/arm64/kvm/emulate.c
  4. +++ b/arch/arm64/kvm/emulate.c
  5. @@ -380,7 +380,7 @@ static void sync_shadow_el1_state(struct kvm_vcpu *vcpu, bool setup)
  6. sys_regs[sr] = s_sys_regs[sr];
  7. }
  8. }
  9. -
  10. +int is_el0 = 0;
  11. /**
  12. * kvm_arm_setup_shadow_state -- prepare shadow state based on emulated mode
  13. * @vcpu: The VCPU pointer
  14. @@ -394,6 +394,7 @@ void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu)
  15. if (unlikely(vcpu_mode_el2(vcpu))) {
  16. ctxt->hw_pstate = *vcpu_cpsr(vcpu) & ~PSR_MODE_MASK;
  17.  
  18. + if (!is_el0) {
  19. /*
  20. * We emulate virtual EL2 mode in hardware EL1 mode using the
  21. * same stack pointer mode as the guest expects.
  22. @@ -402,6 +403,9 @@ void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu)
  23. ctxt->hw_pstate |= PSR_MODE_EL1h;
  24. else
  25. ctxt->hw_pstate |= PSR_MODE_EL1t;
  26. + } else {
  27. + ctxt->hw_pstate |= PSR_MODE_EL0t;
  28. + }
  29.  
  30. sync_shadow_el1_state(vcpu, true);
  31. create_shadow_el1_sysregs(vcpu);
  32. @@ -432,12 +436,16 @@ void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu)
  33. void kvm_arm_restore_shadow_state(struct kvm_vcpu *vcpu)
  34. {
  35. struct kvm_cpu_context *ctxt = &vcpu->arch.ctxt;
  36. + is_el0 = 0;
  37. if (unlikely(vcpu_mode_el2(vcpu))) {
  38. sync_shadow_el1_state(vcpu, false);
  39. sync_shadow_el1_sysregs(vcpu);
  40. *vcpu_cpsr(vcpu) &= PSR_MODE_MASK;
  41. *vcpu_cpsr(vcpu) |= ctxt->hw_pstate & ~PSR_MODE_MASK;
  42. ctxt->el2_regs[SP_EL2] = ctxt->hw_sp_el1;
  43. + if ((ctxt->hw_pstate & PSR_MODE_MASK) == PSR_MODE_EL0t) {
  44. + is_el0 = 1;
  45. + }
  46. } else {
  47. *vcpu_cpsr(vcpu) = ctxt->hw_pstate;
  48. ctxt->gp_regs.sp_el1 = ctxt->hw_sp_el1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement