Advertisement
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 19c5004..b390a85 100644
- --- a/arch/arm/kvm/arm.c
- +++ b/arch/arm/kvm/arm.c
- @@ -27,6 +27,7 @@
- #include <linux/mman.h>
- #include <linux/sched.h>
- #include <linux/kvm.h>
- +#include <linux/interrupt.h>
- #include <trace/events/kvm.h>
- #define CREATE_TRACE_POINTS
- @@ -561,6 +562,10 @@ static int kvm_vcpu_initialized(struct kvm_vcpu *vcpu)
- extern void inject_irq_l1(struct kvm_vcpu *vcpu);
- extern bool L2_running(struct kvm_vcpu *vcpu);
- extern void switch_vgic_vtimer(struct kvm_vcpu *vcpu, bool to_L2);
- +extern int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
- + bool val);
- +extern int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
- + bool *state);
- #endif
- /**
- * kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest code
- @@ -645,12 +650,32 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
- }
- #ifdef CONFIG_SUPPORT_EL1_HYP
- - if (L2_running(vcpu))
- + if (L2_running(vcpu)) {
- switch_vgic_vtimer(vcpu, true);
- + }
- +
- + {
- + bool state;
- + trace_printk("EXIT REASON is %d\n", run->exit_reason);
- + irq_get_irqchip_state(vcpu->arch.timer_cpu.map->irq,
- + IRQCHIP_STATE_ACTIVE,
- + &state);
- + bool state;
- + trace_printk("EXIT REASON is %d\n", run->exit_reason);
- + irq_get_irqchip_state(vcpu->arch.timer_cpu.map->irq,
- + IRQCHIP_STATE_ACTIVE,
- + &state);
- + trace_printk("exit to L0 irqchip state: %s\n", state?"active":"NOT active");
- + irq_get_irqchip_state(vcpu->arch.timer_cpu.map->irq,
- + IRQCHIP_STATE_PENDING,
- + &state);
- + trace_printk("exit to L0 irqchip state: %s\n", state?"pending":"NOT pending");
- +/*
- + irq_set_irqchip_state(vcpu->arch.timer_cpu.map->irq,
- + IRQCHIP_STATE_ACTIVE,
- + true);
- +*/
- + }
- #endif
- kvm_arm_setup_debug(vcpu);
- + trace_printk("-------------------------ENTER-------------------\n");
- /**************************************************************
- * Enter the guest
- */
- @@ -665,6 +690,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
- /*
- * Back from guest
- *************************************************************/
- + trace_printk("-------------------------EXIT-------------------\n");
- kvm_arm_clear_debug(vcpu);
- @@ -692,8 +718,14 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
- trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));
- #ifdef CONFIG_SUPPORT_EL1_HYP
- - if (L2_running(vcpu))
- + if (L2_running(vcpu)) {
- + /* TODO: vcpu->kvm->arch.timer.cntvoff should be L2's */
- + /*
- + if (kvm_timer_should_fire(vcpu))
- + L2_pending_timer_irq = true;
- + */
- switch_vgic_vtimer(vcpu, false);
- + }
- #endif
- /*
- diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
- index fa7f6de..f169ca0 100644
- --- a/arch/arm64/kvm/handle_exit.c
- +++ b/arch/arm64/kvm/handle_exit.c
- @@ -283,6 +283,12 @@ static void restore_from_shadow_vgic(struct kvm_vcpu *vcpu)
- trace_printk("before restore, lr%d: %x\n", i, cpu_if->vgic_lr[i]);
- cpu_if->vgic_lr[i] = vcpu_shadow_vgreg(vcpu, V_GICH_LR0 +i);
- trace_printk("restore %x to lr%d\n", cpu_if->vgic_lr[i], i);
- + if ((0x3ff & cpu_if->vgic_lr[i]) == 27) {
- + cpu_if->vgic_lr[i] &= ~0xffc00;
- + cpu_if->vgic_lr[i] |= 0x07800;
- + trace_printk("change lr%d to %x\n", i, cpu_if->vgic_lr[i]);
- + }
- +
- }
- }
- @@ -313,11 +319,19 @@ static void save_to_shadow_vgic(struct kvm_vcpu *vcpu)
- for (i = 0; i < nr_lr; i++) {
- vcpu_shadow_vgreg(vcpu, V_GICH_LR0 +i) = cpu_if->vgic_lr[i];
- trace_printk("save %x to shadow lr%d\n", cpu_if->vgic_lr[i], i);
- + if ((0x3ff & cpu_if->vgic_lr[i]) == 27) {
- + cpu_if->vgic_lr[i] &= ~0x10000000;
- + cpu_if->vgic_lr[i] &= ~0xffc00;
- + cpu_if->vgic_lr[i] |= 0x07800;
- + trace_printk("change lr%d to %x\n", i, cpu_if->vgic_lr[i]);
- + }
- +
- }
- memcpy (cpu_if, l1_vgic, sizeof(struct vgic_v2_cpu_if));
- }
- +u64 tmp_cntoff;
- static void restore_from_shadow_vtimer(struct kvm_vcpu *vcpu) {
- struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
- @@ -328,6 +342,7 @@ static void restore_from_shadow_vtimer(struct kvm_vcpu *vcpu) {
- timer->cntv_cval = vcpu_shadow_vtreg(vcpu, V_CNTV_CVAL_EL0);
- timer->cntv_ctl = vcpu_shadow_vtreg(vcpu, V_CNTV_CTL_EL0);
- + vcpu->kvm->arch.timer.cntvoff += vcpu_shadow_reg(vcpu, CNTVOFF_EL2);
- trace_printk("restore %llx to cval\n", (u64)(timer->cntv_cval));
- trace_printk("restore %llx to ctl\n", (u64)(timer->cntv_ctl));
- }
- @@ -344,11 +359,14 @@ static void save_to_shadow_vtimer(struct kvm_vcpu *vcpu)
- timer->cntv_cval = l1_timer->cntv_cval;
- timer->cntv_ctl = l1_timer->cntv_ctl;
- + vcpu->kvm->arch.timer.cntvoff -= vcpu_shadow_reg(vcpu, CNTVOFF_EL2);
- }
- /* switch vgic and vtimer registers */
- void switch_vgic_vtimer(struct kvm_vcpu *vcpu, bool to_L2)
- {
- + trace_printk("---- start vgic vtimer switch to %s\n", to_L2?"L2": "L1");
- + trace_printk("PC: %016lx, LR: %016lx\n", *vcpu_pc(vcpu), vcpu_get_reg(vcpu,30));
- if (to_L2) {
- restore_from_shadow_vgic(vcpu);
- restore_from_shadow_vtimer(vcpu);
- @@ -356,6 +374,7 @@ void switch_vgic_vtimer(struct kvm_vcpu *vcpu, bool to_L2)
- save_to_shadow_vgic(vcpu);
- save_to_shadow_vtimer(vcpu);
- }
- + trace_printk("---- end vgic vtimer switch to %s\n", to_L2?"L2": "L1");
- }
- static void switch_ctxt(struct kvm_vcpu *vcpu, bool to_low)
- @@ -538,11 +557,13 @@ static int emulate_dbg(struct kvm_vcpu *vcpu, u16 imm) {
- trace_printk("INTERRUPT L1 lowvisor gets interrupt\n");
- }
- + if (imm == 0x7b00) {
- + trace_printk("L2 ACK\n");
- + BUG();
- + }
- if (imm == 0x7739) {
- trace_printk("INTERRUPT L2 guest gets interrupt, but it shouldn't\n");
- trace_printk("cpsr is %016lx. I bit is 0x80\n", *vcpu_cpsr(vcpu));
- - BUG();
- - return 0;
- }
- return 1;
- @@ -607,9 +628,14 @@ static int emulate_vgic(struct kvm_vcpu *vcpu, u16 imm) {
- print_vgic(vcpu, imm, vregp, gpregp, gpreg_num);
- - if (is_write)
- + if (is_write) {
- *vregp = *gpregp;
- - else
- +/*
- + if (is_vgic && (vreg_num == V_GICH_VMCR)) {
- + *vregp |= 0xf0000001;
- + }
- +*/
- + } else
- *gpregp = *vregp;
- return 1;
- }
- @@ -805,6 +831,7 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
- switch (exception_index) {
- case ARM_EXCEPTION_IRQ:
- + trace_printk("Exit because of IRQ\n");
- return 1;
- case ARM_EXCEPTION_TRAP:
- /*
- diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
- index abf2ffa..0ea1fce 100644
- --- a/drivers/irqchip/irq-gic.c
- +++ b/drivers/irqchip/irq-gic.c
- @@ -176,8 +176,29 @@ static void gic_poke_irq(struct irq_data *d, u32 offset)
- :
- @@ -538,11 +557,13 @@ static int emulate_dbg(struct kvm_vcpu *vcpu, u16 imm) {
- trace_printk("INTERRUPT L1 lowvisor gets interrupt\n");
- }
- + if (imm == 0x7b00) {
- + trace_printk("L2 ACK\n");
- + BUG();
- + }
- if (imm == 0x7739) {
- trace_printk("INTERRUPT L2 guest gets interrupt, but it shouldn't\n");
- trace_printk("cpsr is %016lx. I bit is 0x80\n", *vcpu_cpsr(vcpu));
- - BUG();
- - return 0;
- }
- return 1;
- @@ -607,9 +628,14 @@ static int emulate_vgic(struct kvm_vcpu *vcpu, u16 imm) {
- print_vgic(vcpu, imm, vregp, gpregp, gpreg_num);
- - if (is_write)
- + if (is_write) {
- *vregp = *gpregp;
- - else
- +/*
- + if (is_vgic && (vreg_num == V_GICH_VMCR)) {
- + *vregp |= 0xf0000001;
- + }
- +*/
- + } else
- *gpregp = *vregp;
- return 1;
- }
- @@ -805,6 +831,7 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
- switch (exception_index) {
- case ARM_EXCEPTION_IRQ:
- + trace_printk("Exit because of IRQ\n");
- return 1;
- case ARM_EXCEPTION_TRAP:
- /*
- diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
- index abf2ffa..0ea1fce 100644
- --- a/drivers/irqchip/irq-gic.c
- +++ b/drivers/irqchip/irq-gic.c
- @@ -176,8 +176,29 @@ static void gic_poke_irq(struct irq_data *d, u32 offset)
- static int gic_peek_irq(struct irq_data *d, u32 offset)
- {
- + int ret;
- + int i = 0;
- + int max = 1020%32 +1;
- + char* reg;
- + u32 ispend;
- u32 mask = 1 << (gic_irq(d) % 32);
- - return !!(readl_relaxed(gic_dist_base(d) + offset + (gic_irq(d) / 32) * 4) & mask);
- + ret = !!(readl_relaxed(gic_dist_base(d) + offset + (gic_irq(d) / 32) * 4) & mask);
- +
- + if (offset == GIC_DIST_PENDING_SET)
- + reg = "GICD_ISPENDR";
- + else if (offset == GIC_DIST_ACTIVE_SET)
- + reg = "GICD_ISACTIVER";
- + else
- + reg ="GICD_ELSE";
- +
- + trace_printk("%s\n", __func__);
- + for (i = 0 ; i < max; i ++) {
- + ispend = readl_relaxed(gic_dist_base(d) + offset + i*4);
- + if (ispend)
- + trace_printk("%s %s%d %x\n", __func__, reg, i, ispend);
- + }
- +
- + return ret;
- }
- static void gic_mask_irq(struct irq_data *d)
- @@ -335,7 +356,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
- do {
- irqstat = readl_relaxed(cpu_base + GIC_CPU_INTACK);
- irqnr = irqstat & GICC_IAR_INT_ID_MASK;
- -
- +
- if (likely(irqnr > 15 && irqnr < 1021)) {
- if (static_key_true(&supports_deactivate))
- writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI);
- diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
- index ad16809..ba9f689 100644
- --- a/include/linux/interrupt.h
- +++ b/include/linux/interrupt.h
- @@ -371,6 +371,7 @@ enum irqchip_irq_state {
- IRQCHIP_STATE_ACTIVE, /* Is interrupt in progress? */
- IRQCHIP_STATE_MASKED, /* Is interrupt masked? */
- IRQCHIP_STATE_LINE_LEVEL, /* Is IRQ line high? */
- + IRQCHIP_STATE_PENDING_ALL, /* Is any interrupt pending? */
- };
- extern int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
- if (to_L2) {
- restore_from_shadow_vgic(vcpu);
- restore_from_shadow_vtimer(vcpu);
- @@ -356,6 +374,7 @@ void switch_vgic_vtimer(struct kvm_vcpu *vcpu, bool to_L2)
- save_to_shadow_vgic(vcpu);
- save_to_shadow_vtimer(vcpu);
- }
- + trace_printk("---- end vgic vtimer switch to %s\n", to_L2?"L2": "L1");
- }
- static void switch_ctxt(struct kvm_vcpu *vcpu, bool to_low)
- @@ -538,11 +557,13 @@ static int emulate_dbg(struct kvm_vcpu *vcpu, u16 imm) {
- trace_printk("INTERRUPT L1 lowvisor gets interrupt\n");
- }
- + if (imm == 0x7b00) {
- + trace_printk("L2 ACK\n");
- + BUG();
- + }
- if (imm == 0x7739) {
- trace_printk("INTERRUPT L2 guest gets interrupt, but it shouldn't\n");
- trace_printk("cpsr is %016lx. I bit is 0x80\n", *vcpu_cpsr(vcpu));
- - BUG();
- - return 0;
- }
- return 1;
- @@ -607,9 +628,14 @@ static int emulate_vgic(struct kvm_vcpu *vcpu, u16 imm) {
- print_vgic(vcpu, imm, vregp, gpregp, gpreg_num);
- - if (is_write)
- + if (is_write) {
- *vregp = *gpregp;
- - else
- +/*
- + if (is_vgic && (vreg_num == V_GICH_VMCR)) {
- + *vregp |= 0xf0000001;
- + }
- +*/
- + } else
- *gpregp = *vregp;
- return 1;
- }
- @@ -805,6 +831,7 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
- +*/
- + } else
- *gpregp = *vregp;
- return 1;
- }
- @@ -805,6 +831,7 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
- switch (exception_index) {
- case ARM_EXCEPTION_IRQ:
- + trace_printk("Exit because of IRQ\n");
- return 1;
- case ARM_EXCEPTION_TRAP:
- /*
- diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
- index abf2ffa..0ea1fce 100644
- --- a/drivers/irqchip/irq-gic.c
- +++ b/drivers/irqchip/irq-gic.c
- @@ -176,8 +176,29 @@ static void gic_poke_irq(struct irq_data *d, u32 offset)
- static int gic_peek_irq(struct irq_data *d, u32 offset)
- {
- + int ret;
- + int i = 0;
- + int max = 1020%32 +1;
- + char* reg;
- + u32 ispend;
- u32 mask = 1 << (gic_irq(d) % 32);
- - return !!(readl_relaxed(gic_dist_base(d) + offset + (gic_irq(d) / 32) * 4) & mask);
- + ret = !!(readl_relaxed(gic_dist_base(d) + offset + (gic_irq(d) / 32) * 4) & mask);
- +
- + if (offset == GIC_DIST_PENDING_SET)
- + reg = "GICD_ISPENDR";
- + else if (offset == GIC_DIST_ACTIVE_SET)
- + reg = "GICD_ISACTIVER";
- + else
- + reg ="GICD_ELSE";
- +
- + trace_printk("%s\n", __func__);
- + for (i = 0 ; i < max; i ++) {
- + ispend = readl_relaxed(gic_dist_base(d) + offset + i*4);
- + if (ispend)
- + trace_printk("%s %s%d %x\n", __func__, reg, i, ispend);
- + }
- +
- + return ret;
- }
- static void gic_mask_irq(struct irq_data *d)
- @@ -335,7 +356,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
- do {
- irqstat = readl_relaxed(cpu_base + GIC_CPU_INTACK);
- irqnr = irqstat & GICC_IAR_INT_ID_MASK;
- -
- +
- if (likely(irqnr > 15 && irqnr < 1021)) {
- if (static_key_true(&supports_deactivate))
- writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI);
- diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
- index ad16809..ba9f689 100644
- --- a/include/linux/interrupt.h
- +++ b/include/linux/interrupt.h
- @@ -371,6 +371,7 @@ enum irqchip_irq_state {
- IRQCHIP_STATE_ACTIVE, /* Is interrupt in progress? */
- IRQCHIP_STATE_MASKED, /* Is interrupt masked? */
- IRQCHIP_STATE_LINE_LEVEL, /* Is IRQ line high? */
- + IRQCHIP_STATE_PENDING_ALL, /* Is any interrupt pending? */
- };
- extern int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
- diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
- index ead0144..3060cba 100644
- --- a/virt/kvm/arm/arch_timer.c
- +++ b/virt/kvm/arm/arch_timer.c
- @@ -216,6 +216,7 @@ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu)
- {
- struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
- bool phys_active;
- + bool cur_phys_active;
- int ret;
- #ifdef CONFIG_EMUL_GUEST_GIC_TIMER
- return;
- @@ -248,6 +249,16 @@ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu)
- else
- phys_active = false;
- + irq_get_irqchip_state(timer->map->irq,
- + IRQCHIP_STATE_PENDING,
- + &cur_phys_active);
- + irq_get_irqchip_state(timer->map->irq,
- + IRQCHIP_STATE_ACTIVE,
- + &cur_phys_active);
- + trace_printk("L0 -> L1 irq: %d irqchip state %s to %s\n",
- + timer->map->irq,
- + cur_phys_active?"active":"NOT active",
- + phys_active?"active":"NOT active");
- ret = irq_set_irqchip_state(timer->map->irq,
- IRQCHIP_STATE_ACTIVE,
- phys_active);
- @@ -498,4 +509,5 @@ void kvm_timer_enable(struct kvm *kvm)
- void kvm_timer_init(struct kvm *kvm)
- {
- kvm->arch.timer.cntvoff = kvm_phys_timer_read();
- + printk("%s L1 cntvoff_el2 is %llx\n", __func__, kvm->arch.timer.cntvoff);
- }
- diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
- index 9daaf42..e148ff4 100644
- --- a/virt/kvm/arm/vgic.c
- +++ b/virt/kvm/arm/vgic.c
- @@ -1366,6 +1366,7 @@ static bool vgic_process_maintenance(struct kvm_vcpu *vcpu)
- kvm_debug("STATUS = %08x\n", status);
- [build-server ~/host]$git diff
- diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
- index 19c5004..b390a85 100644
- --- a/arch/arm/kvm/arm.c
- +++ b/arch/arm/kvm/arm.c
- @@ -27,6 +27,7 @@
- #include <linux/mman.h>
- #include <linux/sched.h>
- #include <linux/kvm.h>
- +#include <linux/interrupt.h>
- #include <trace/events/kvm.h>
- #define CREATE_TRACE_POINTS
- @@ -561,6 +562,10 @@ static int kvm_vcpu_initialized(struct kvm_vcpu *vcpu)
- extern void inject_irq_l1(struct kvm_vcpu *vcpu);
- extern bool L2_running(struct kvm_vcpu *vcpu);
- extern void switch_vgic_vtimer(struct kvm_vcpu *vcpu, bool to_L2);
- +extern int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
- + bool val);
- +extern int irq_get_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
- + bool *state);
- #endif
- /**
- * kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest code
- @@ -645,12 +650,32 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
- }
- #ifdef CONFIG_SUPPORT_EL1_HYP
- - if (L2_running(vcpu))
- + if (L2_running(vcpu)) {
- switch_vgic_vtimer(vcpu, true);
- + }
- +
- + {
- + bool state;
- + trace_printk("EXIT REASON is %d\n", run->exit_reason);
- + irq_get_irqchip_state(vcpu->arch.timer_cpu.map->irq,
- + IRQCHIP_STATE_ACTIVE,
- + &state);
- + trace_printk("exit to L0 irqchip state: %s\n", state?"active":"NOT active");
- + irq_get_irqchip_state(vcpu->arch.timer_cpu.map->irq,
- + IRQCHIP_STATE_PENDING,
- + &state);
- + trace_printk("exit to L0 irqchip state: %s\n", state?"pending":"NOT pending")
- +/*
- + irq_set_irqchip_state(vcpu->arch.timer_cpu.map->irq,
- + IRQCHIP_STATE_ACTIVE,
- + true);
- ...skipping...
- #endif
- kvm_arm_setup_debug(vcpu);
- + trace_printk("-------------------------ENTER-------------------\n");
- /**************************************************************
- * Enter the guest
- */
- @@ -665,6 +690,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
- /*
- * Back from guest
- *************************************************************/
- + trace_printk("-------------------------EXIT-------------------\n");
- kvm_arm_clear_debug(vcpu);
- @@ -692,8 +718,14 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
- trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));
- #ifdef CONFIG_SUPPORT_EL1_HYP
- - if (L2_running(vcpu))
- + if (L2_running(vcpu)) {
- + /* TODO: vcpu->kvm->arch.timer.cntvoff should be L2's */
- + /*
- + if (kvm_timer_should_fire(vcpu))
- + L2_pending_timer_irq = true;
- + */
- switch_vgic_vtimer(vcpu, false);
- + }
- #endif
- /*
- diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
- index fa7f6de..f169ca0 100644
- --- a/arch/arm64/kvm/handle_exit.c
- +++ b/arch/arm64/kvm/handle_exit.c
- @@ -283,6 +283,12 @@ static void restore_from_shadow_vgic(struct kvm_vcpu *vcpu)
- trace_printk("before restore, lr%d: %x\n", i, cpu_if->vgic_lr[i]);
- cpu_if->vgic_lr[i] = vcpu_shadow_vgreg(vcpu, V_GICH_LR0 +i);
- trace_printk("restore %x to lr%d\n", cpu_if->vgic_lr[i], i);
- + if ((0x3ff & cpu_if->vgic_lr[i]) == 27) {
- + cpu_if->vgic_lr[i] &= ~0xffc00;
- + cpu_if->vgic_lr[i] |= 0x07800;
- + trace_printk("change lr%d to %x\n", i, cpu_if->vgic_lr[i]);
- + }
- +
- }
- }
- @@ -313,11 +319,19 @@ static void save_to_shadow_vgic(struct kvm_vcpu *vcpu)
- for (i = 0; i < nr_lr; i++) {
- vcpu_shadow_vgreg(vcpu, V_GICH_LR0 +i) = cpu_if->vgic_lr[i];
- trace_printk("save %x to shadow lr%d\n", cpu_if->vgic_lr[i], i);
- + if ((0x3ff & cpu_if->vgic_lr[i]) == 27) {
- + cpu_if->vgic_lr[i] &= ~0x10000000;
- + cpu_if->vgic_lr[i] &= ~0xffc00;
- + cpu_if->vgic_lr[i] |= 0x07800;
- + trace_printk("change lr%d to %x\n", i, cpu_if->vgic_lr[i]);
- + }
- +
- }
- memcpy (cpu_if, l1_vgic, sizeof(struct vgic_v2_cpu_if));
- }
- +u64 tmp_cntoff;
- static void restore_from_shadow_vtimer(struct kvm_vcpu *vcpu) {
- struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
- @@ -328,6 +342,7 @@ static void restore_from_shadow_vtimer(struct kvm_vcpu *vcpu) {
- timer->cntv_cval = vcpu_shadow_vtreg(vcpu, V_CNTV_CVAL_EL0);
- timer->cntv_ctl = vcpu_shadow_vtreg(vcpu, V_CNTV_CTL_EL0);
- + vcpu->kvm->arch.timer.cntvoff += vcpu_shadow_reg(vcpu, CNTVOFF_EL2);
- trace_printk("restore %llx to cval\n", (u64)(timer->cntv_cval));
- trace_printk("restore %llx to ctl\n", (u64)(timer->cntv_ctl));
- }
- @@ -344,11 +359,14 @@ static void save_to_shadow_vtimer(struct kvm_vcpu *vcpu)
- timer->cntv_cval = l1_timer->cntv_cval;
- timer->cntv_ctl = l1_timer->cntv_ctl;
- + vcpu->kvm->arch.timer.cntvoff -= vcpu_shadow_reg(vcpu, CNTVOFF_EL2);
- }
- /* switch vgic and vtimer registers */
- void switch_vgic_vtimer(struct kvm_vcpu *vcpu, bool to_L2)
- {
- + trace_printk("---- start vgic vtimer switch to %s\n", to_L2?"L2": "L1");
- + trace_printk("PC: %016lx, LR: %016lx\n", *vcpu_pc(vcpu), vcpu_get_reg(vcpu,30));
- if (to_L2) {
- restore_from_shadow_vgic(vcpu);
- restore_from_shadow_vtimer(vcpu);
- @@ -356,6 +374,7 @@ void switch_vgic_vtimer(struct kvm_vcpu *vcpu, bool to_L2)
- save_to_shadow_vgic(vcpu);
- save_to_shadow_vtimer(vcpu);
- }
- + trace_printk("---- end vgic vtimer switch to %s\n", to_L2?"L2": "L1");
- }
- static void switch_ctxt(struct kvm_vcpu *vcpu, bool to_low)
- @@ -538,11 +557,13 @@ static int emulate_dbg(struct kvm_vcpu *vcpu, u16 imm) {
- trace_printk("INTERRUPT L1 lowvisor gets interrupt\n");
- }
- + if (imm == 0x7b00) {
- + trace_printk("L2 ACK\n");
- + BUG();
- + }
- if (imm == 0x7739) {
- trace_printk("INTERRUPT L2 guest gets interrupt, but it shouldn't\n");
- trace_printk("cpsr is %016lx. I bit is 0x80\n", *vcpu_cpsr(vcpu));
- - BUG();
- - return 0;
- }
- return 1;
- @@ -607,9 +628,14 @@ static int emulate_vgic(struct kvm_vcpu *vcpu, u16 imm) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement