Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/arch/arm64/kvm/emulate.c b/arch/arm64/kvm/emulate.c
- index 43473d7..a8dfe9f 100644
- --- a/arch/arm64/kvm/emulate.c
- +++ b/arch/arm64/kvm/emulate.c
- @@ -380,7 +380,7 @@ static void sync_shadow_el1_state(struct kvm_vcpu *vcpu, bool setup)
- sys_regs[sr] = s_sys_regs[sr];
- }
- }
- -
- +int is_el0 = 0;
- /**
- * kvm_arm_setup_shadow_state -- prepare shadow state based on emulated mode
- * @vcpu: The VCPU pointer
- @@ -394,6 +394,7 @@ void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu)
- if (unlikely(vcpu_mode_el2(vcpu))) {
- ctxt->hw_pstate = *vcpu_cpsr(vcpu) & ~PSR_MODE_MASK;
- + if (!is_el0) {
- /*
- * We emulate virtual EL2 mode in hardware EL1 mode using the
- * same stack pointer mode as the guest expects.
- @@ -402,6 +403,9 @@ void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu)
- ctxt->hw_pstate |= PSR_MODE_EL1h;
- else
- ctxt->hw_pstate |= PSR_MODE_EL1t;
- + } else {
- + ctxt->hw_pstate |= PSR_MODE_EL0t;
- + }
- sync_shadow_el1_state(vcpu, true);
- create_shadow_el1_sysregs(vcpu);
- @@ -432,12 +436,16 @@ void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu)
- void kvm_arm_restore_shadow_state(struct kvm_vcpu *vcpu)
- {
- struct kvm_cpu_context *ctxt = &vcpu->arch.ctxt;
- + is_el0 = 0;
- if (unlikely(vcpu_mode_el2(vcpu))) {
- sync_shadow_el1_state(vcpu, false);
- sync_shadow_el1_sysregs(vcpu);
- *vcpu_cpsr(vcpu) &= PSR_MODE_MASK;
- *vcpu_cpsr(vcpu) |= ctxt->hw_pstate & ~PSR_MODE_MASK;
- ctxt->el2_regs[SP_EL2] = ctxt->hw_sp_el1;
- + if ((ctxt->hw_pstate & PSR_MODE_MASK) == PSR_MODE_EL0t) {
- + is_el0 = 1;
- + }
- } else {
- *vcpu_cpsr(vcpu) = ctxt->hw_pstate;
- ctxt->gp_regs.sp_el1 = ctxt->hw_sp_el1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement