Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
- index 3e3b694..ced650a 100644
- --- a/arch/arm64/kvm/handle_exit.c
- +++ b/arch/arm64/kvm/handle_exit.c
- @@ -151,7 +151,9 @@ static void update_sp(struct kvm_vcpu *vcpu, u64 val)
- if (!vcpu_shadow_reg(vcpu, SP_EL2))
- vcpu->arch.guest_sp = regs->sp_el1;
- vcpu_shadow_reg(vcpu, SP_EL2) = val;
- + printk("STACK: shadow SP_EL2 is now %llx\n", val);
- regs->sp_el1 = vcpu_shadow_reg(vcpu, SP_EL2);
- + printk("STACK: Set SP_EL1 too to SP_EL2\n");
- }
- static void switch_sp(struct kvm_vcpu *vcpu, bool to_low) {
- @@ -159,10 +161,14 @@ static void switch_sp(struct kvm_vcpu *vcpu, bool to_low) {
- if (to_low) {
- vcpu->arch.guest_sp = regs->sp_el1;
- + printk("STACK: Save SP_EL1 to guest's: %llx\n", regs->sp_el1);
- regs->sp_el1 = vcpu_shadow_reg(vcpu, SP_EL2);
- + printk("STACK: Set SP_EL1 to shadow SP_EL2: %llx\n", regs->sp_el1);
- } else {
- vcpu_shadow_reg(vcpu, SP_EL2) = regs->sp_el1;
- + printk("STACK: Save SP_EL1 to shadow SP_EL2: %llx\n", regs->sp_el1);
- regs->sp_el1 = vcpu->arch.guest_sp;
- + printk("STACK: Set SP_EL1 back to guest's: %llx\n", regs->sp_el1);
- }
- }
- @@ -226,16 +232,32 @@ static int kvm_inject_nested(struct kvm_vcpu *vcpu)
- /* If L1 lowvisor changes EL2 registers, we need to change corresponding
- * EL1 registers immediately */
- -static void emulate_msr(struct kvm_vcpu *vcpu, int sreg_num, u64 *sregp, u64 val)
- +static void emulate_msr(struct kvm_vcpu *vcpu, int sreg_num, bool is_el2, u64 *sregp, u64 val)
- {
- - if (sreg_num == SP_EL2)
- - update_sp(vcpu, val);
- - else if (sreg_num == TTBR0_EL2)
- - update_ttbr(vcpu, val);
- - else if (sreg_num == SCTLR_EL2)
- - update_sctlr(vcpu, val);
- - else
- - *sregp = val;
- + if (is_el2) {
- + if (sreg_num == SP_EL2)
- + update_sp(vcpu, val);
- + else if (sreg_num == TTBR0_EL2)
- + update_ttbr(vcpu, val);
- + else if (sreg_num == SCTLR_EL2)
- + update_sctlr(vcpu, val);
- + else
- + *sregp = val;
- + } else {
- + if (sreg_num == SP_EL1) {
- + printk("Change L2's stack pointer, not L1 low's: %llx\n", val);
- + vcpu->arch.guest_sp = val;
- + } else if (sreg_num == TTBR0_EL1) {
- + vcpu->arch.guest_ttbr0 = val;
- + printk("Change L2's TTBR. %llx\n", val);
- + }
- + else if (sreg_num == SCTLR_EL1) {
- + vcpu->arch.guest_sctlr = val;
- + printk("Change L2's SCTLR. %llx\n", val);
- + }
- + else
- + *sregp = val;
- + }
- }
- static int emulate_mov_sysreg(struct kvm_vcpu *vcpu, u16 imm, bool is_msr)
- @@ -246,6 +268,7 @@ static int emulate_mov_sysreg(struct kvm_vcpu *vcpu, u16 imm, bool is_msr)
- u32 sreg_num = (imm & HE_SYSREG_MASK)>>HE_SYSREG_SHIFT;
- bool is_imm = imm & HE_IMM;
- + printk("%s\n", __func__);
- gpregp = &vcpu->arch.ctxt.gp_regs.regs.regs[gpreg_num];
- if (unlikely(is_imm))
- *gpregp = imm & HE_IMM_MASK;
- @@ -260,7 +283,7 @@ static int emulate_mov_sysreg(struct kvm_vcpu *vcpu, u16 imm, bool is_msr)
- print_encoding(vcpu, is_msr, is_imm, imm&HE_EL2, sreg_num, gpreg_num, *gpregp);
- if (is_msr)
- - emulate_msr(vcpu, sreg_num, sregp, *gpregp);
- + emulate_msr(vcpu, sreg_num, imm&HE_EL2, sregp, *gpregp);
- else
- *gpregp = *sregp;
- @@ -452,6 +475,7 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu)
- u32 hsr = kvm_vcpu_get_hsr(vcpu);
- u8 hsr_ec = hsr >> ESR_ELx_EC_SHIFT;
- + printk("TRAP! exit_handler: %x\n", hsr_ec);
- if (hsr_ec >= ARRAY_SIZE(arm_exit_handlers) ||
- !arm_exit_handlers[hsr_ec]) {
- kvm_err("Unknown exception class: hsr: %#08x -- %s\n",
Advertisement
Add Comment
Please, Sign In to add comment