Skip to contentSkip to conversation

POWERPC: BOOK3S: KVM: Use the saved dsisr and dar values on book3s 64

PATCH Superseded Aneesh Kumar K.V 2 participants 2 messages Dec 30, 2013

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 POWERPC: BOOK3S: KVM: Use the saved dsisr and dar values on book3s 64

From: "Aneesh Kumar K.V" <[email protected]>

Although it's optional IBM POWER cpus always had DAR value set on alignment interrupt. So don't try to compute these values.

---
 arch/powerpc/kvm/book3s_emulate.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
arch/powerpc/kvm/book3s_emulate.c +28 -0
index 502a47ac4453..d8e2d079483d 100644
@@ -599,6 +599,19 @@ unprivileged:
 
 u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst)
 {
+#ifdef CONFIG_PPC_BOOK3S_64
+	return vcpu->arch.fault_dsisr;
+#else
+	/*
+	 * Mac OS X has some applications - namely the Finder - that require
+	 * alignment interrupts to work properly. So we need to implement them.
+
+	 * But the spec for 970 and 750 also looks different. While 750 requires
+	 * the DSISR and DAR fields to reflect some instruction bits (DSISR) and
+	 * the fault address (DAR), the 970 declares this as an optional feature.
+	 * So we need to reconstruct DSISR and DAR manually.
+	 */
+
 	u32 dsisr = 0;
 
 	/*
@@ -637,10 +650,24 @@ u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst)
 	dsisr |= (inst >> 16) & 0x03ff; /* bits 22:31 */
 
 	return dsisr;
+#endif
 }
 
 ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst)
 {
+#ifdef CONFIG_PPC_BOOK3S_64
+	return vcpu->arch.fault_dar;
+#else
+	/*
+	 * Mac OS X has some applications - namely the Finder - that require
+	 * alignment interrupts to work properly. So we need to implement them.
+
+	 * But the spec for 970 and 750 also looks different. While 750 requires
+	 * the DSISR and DAR fields to reflect some instruction bits (DSISR) and
+	 * the fault address (DAR), the 970 declares this as an optional feature.
+	 * So we need to reconstruct DSISR and DAR manually.
+	 */
+
 	ulong dar = 0;
 	ulong ra = get_ra(inst);
 	ulong rb = get_rb(inst);
@@ -665,4 +692,5 @@ ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst)
 	}
 
 	return dar;
+#endif
 }
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 19 lines

Am 30.12.2013 um 07:04 schrieb "Aneesh Kumar K.V" <[email protected]>:

From: "Aneesh Kumar K.V" <[email protected]>

Although it's optional IBM POWER cpus always had DAR value set on alignment interrupt. So don't try to compute these values.

---
arch/powerpc/kvm/book3s_emulate.c | 28 ++++++++++++++++++++++++++++

1 file changed, 28 insertions(+)
arch/powerpc/kvm/book3s_emulate.c +0 -0
index 502a47ac4453..d8e2d079483d 100644

arch/powerpc/kvm/book3s_emulate.c unprivileged: · line 603

Quoted 5 lines
arch/powerpc/kvm/book3s_emulate.c +2 -0
@@ -599,6 +599,19 @@ unprivileged:
 
 u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst)
 {
+#ifdef CONFIG_PPC_BOOK3S_64
+    return vcpu->arch.fault_dsisr;

This is still wrong when you virtualize a 750 on a 970 for example.

Alex

Quoted 48 lines
arch/powerpc/kvm/book3s_emulate.c +26 -0
+#else
+    /*
+     * Mac OS X has some applications - namely the Finder - that require
+     * alignment interrupts to work properly. So we need to implement them.
+
+     * But the spec for 970 and 750 also looks different. While 750 requires
+     * the DSISR and DAR fields to reflect some instruction bits (DSISR) and
+     * the fault address (DAR), the 970 declares this as an optional feature.
+     * So we need to reconstruct DSISR and DAR manually.
+     */
+
   u32 dsisr = 0;
 
   /*
@@ -637,10 +650,24 @@ u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst)
   dsisr |= (inst >> 16) & 0x03ff; /* bits 22:31 */
 
   return dsisr;
+#endif
 }
 
 ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst)
 {
+#ifdef CONFIG_PPC_BOOK3S_64
+    return vcpu->arch.fault_dar;
+#else
+    /*
+     * Mac OS X has some applications - namely the Finder - that require
+     * alignment interrupts to work properly. So we need to implement them.
+
+     * But the spec for 970 and 750 also looks different. While 750 requires
+     * the DSISR and DAR fields to reflect some instruction bits (DSISR) and
+     * the fault address (DAR), the 970 declares this as an optional feature.
+     * So we need to reconstruct DSISR and DAR manually.
+     */
+
   ulong dar = 0;
   ulong ra = get_ra(inst);
   ulong rb = get_rb(inst);
@@ -665,4 +692,5 @@ ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst)
   }
 
   return dar;
+#endif
 }
Signature · 1 line
1.8.3.2