KVM: PPC: BOOKE: Guest and hardware visible debug registers are same
authorBharat Bhushan <Bharat.Bhushan@freescale.com>
Wed, 6 Aug 2014 06:38:55 +0000 (12:08 +0530)
committerAlexander Graf <agraf@suse.de>
Mon, 22 Sep 2014 08:11:30 +0000 (10:11 +0200)
Guest visible debug register and hardware visible debug registers are
same, so ther is no need to have arch->shadow_dbg_reg, instead use
arch->dbg_reg.

Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
arch/powerpc/include/asm/kvm_host.h
arch/powerpc/kvm/booke.c
arch/powerpc/kvm/booke_emulate.c

index 8a8da0acfd282f0e85878d5902eee30a6a7f8a8a..bad3491cc32ce9900f9dc21030b5a947b9763f08 100644 (file)
@@ -585,8 +585,6 @@ struct kvm_vcpu_arch {
        u32 crit_save;
        /* guest debug registers*/
        struct debug_reg dbg_reg;
-       /* hardware visible debug registers when in guest state */
-       struct debug_reg shadow_dbg_reg;
 #endif
        gpa_t paddr_accessed;
        gva_t vaddr_accessed;
index b4ab86cdb51d786330d196bc31b04fabd5e751a8..e47de01b0dbbd0aeeaf149fd9586b6939154f4cd 100644 (file)
@@ -668,10 +668,10 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
 #endif
 
        /* Switch to guest debug context */
-       debug = vcpu->arch.shadow_dbg_reg;
+       debug = vcpu->arch.dbg_reg;
        switch_booke_debug_regs(&debug);
        debug = current->thread.debug;
-       current->thread.debug = vcpu->arch.shadow_dbg_reg;
+       current->thread.debug = vcpu->arch.dbg_reg;
 
        vcpu->arch.pgdir = current->mm->pgd;
        kvmppc_fix_ee_before_entry();
@@ -732,7 +732,7 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
 
 static int kvmppc_handle_debug(struct kvm_run *run, struct kvm_vcpu *vcpu)
 {
-       struct debug_reg *dbg_reg = &(vcpu->arch.shadow_dbg_reg);
+       struct debug_reg *dbg_reg = &(vcpu->arch.dbg_reg);
        u32 dbsr = vcpu->arch.dbsr;
 
        /* Clear guest dbsr (vcpu->arch.dbsr) */
@@ -1848,7 +1848,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
        int n, b = 0, w = 0;
 
        if (!(dbg->control & KVM_GUESTDBG_ENABLE)) {
-               vcpu->arch.shadow_dbg_reg.dbcr0 = 0;
+               vcpu->arch.dbg_reg.dbcr0 = 0;
                vcpu->guest_debug = 0;
                kvm_guest_protect_msr(vcpu, MSR_DE, false);
                return 0;
@@ -1856,15 +1856,13 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
 
        kvm_guest_protect_msr(vcpu, MSR_DE, true);
        vcpu->guest_debug = dbg->control;
-       vcpu->arch.shadow_dbg_reg.dbcr0 = 0;
-       /* Set DBCR0_EDM in guest visible DBCR0 register. */
-       vcpu->arch.dbg_reg.dbcr0 = DBCR0_EDM;
+       vcpu->arch.dbg_reg.dbcr0 = 0;
 
        if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
-               vcpu->arch.shadow_dbg_reg.dbcr0 |= DBCR0_IDM | DBCR0_IC;
+               vcpu->arch.dbg_reg.dbcr0 |= DBCR0_IDM | DBCR0_IC;
 
        /* Code below handles only HW breakpoints */
-       dbg_reg = &(vcpu->arch.shadow_dbg_reg);
+       dbg_reg = &(vcpu->arch.dbg_reg);
 
 #ifdef CONFIG_KVM_BOOKE_HV
        /*
index 4b9a079927539ed1940334ba2b3a46ee8a2c226d..92bc668d3e08fac248a0cc018f82fc0eaee41be3 100644 (file)
@@ -293,6 +293,8 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val)
                break;
        case SPRN_DBCR0:
                *spr_val = vcpu->arch.dbg_reg.dbcr0;
+               if (vcpu->guest_debug)
+                       *spr_val = *spr_val | DBCR0_EDM;
                break;
        case SPRN_DBCR1:
                *spr_val = vcpu->arch.dbg_reg.dbcr1;