diff mbox

[8/8] KVM:PPC:booke: Allow debug interrupt injection to guest

Message ID 16DEE4DC-E963-49FB-B211-810D1068E6C4@suse.de
State New, archived
Headers show

Commit Message

Alexander Graf Jan. 31, 2013, 7:20 p.m. UTC
On 31.01.2013, at 20:05, Alexander Graf wrote:

> 
> On 31.01.2013, at 19:54, Scott Wood wrote:
> 
>> On 01/31/2013 12:52:41 PM, Alexander Graf wrote:
>>> On 31.01.2013, at 19:43, Scott Wood wrote:
>>>> On 01/31/2013 12:21:07 PM, Alexander Graf wrote:
>>>>> How about something like this? Then both targets at least suck as much :).
>>>> 
>>>> I'm not sure that should be the goal...
>>>> 
>>>>> Thanks to e500mc's awful hardware design, we don't know who sets the MSR_DE bit. Once we forced it onto the guest, we have no change to know whether the guest also set it or not. We could only guess.
>>>> 
>>>> MSRP[DEP] can prevent the guest from modifying MSR[DE] -- but we still need to set it in the first place.
>>>> 
>>>> According to ISA V2.06B, the hypervisor should set DBCR0[EDM] to let the guest know that the debug resources are not available, and that "the value of MSR[DE] is not specified and not modifiable".
>>> So what would the guest do then to tell the hypervisor that it actually wants to know about debug events?
>> 
>> The guest is out of luck, just as if a JTAG were in use.
> 
> Hrm.
> 
> Can we somehow generalize this "out of luck" behavior?
> 
> Every time we would set or clear an MSR bit in shadow_msr on e500v2, we would instead set or clear it in the real MSR. That way only e500mc is out of luck, but the code would still be shared.


Something like this. We could also define a SHADOW_MSR(vcpu) macro to hide the glorious details, but I think this way it's easier to understand what's going on.


Alex

To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 38a62ef..9bdb845 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -133,6 +133,29 @@  static void kvmppc_vcpu_sync_fpu(struct kvm_vcpu *vcpu)
 #endif
 }
 
+static void kvmppc_vcpu_sync_debug(struct kvm_vcpu *vcpu)
+{
+	u32 is_debug = vcpu->arch.shared->msr & MSR_DE;
+
+	/* Force debug to on in guest space when user space wants to debug */
+	if (vcpu->guest_debug)
+		is_debug = MSR_DE;
+
+#ifdef CONFIG_KVM_BOOKE_HV
+	/*
+	 * Since there is no shadow MSR, sync MSR_DE into the guest
+	 * visible MSR.
+	 */
+	vcpu->arch.shared->msr &= ~MSR_DE;
+	vcpu->arch.shared->msr |= is_debug;
+#endif
+
+#ifndef CONFIG_KVM_BOOKE_HV
+	vcpu->arch.shadow_msr &= ~MSR_DE;
+	vcpu->arch.shadow_msr |= is_debug;
+#endif
+}
+
 /*
  * Helper function for "full" MSR writes.  No need to call this if only
  * EE/CE/ME/DE/RI are changing.
@@ -150,6 +173,7 @@  void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
 	kvmppc_mmu_msr_notify(vcpu, old_msr);
 	kvmppc_vcpu_sync_spe(vcpu);
 	kvmppc_vcpu_sync_fpu(vcpu);
+	kvmppc_vcpu_sync_debug(vcpu);
 }
 
 static void kvmppc_booke_queue_irqprio(struct kvm_vcpu *vcpu,--