From: Alexander Graf <agraf-l3A5Bk7waGM@public.gmane.org>
To: kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 12/15] KVM: PPC: Implement alignment interrupt
Date: Mon, 8 Mar 2010 19:03:19 +0100 [thread overview]
Message-ID: <1268071402-27112-13-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1268071402-27112-1-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
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 fields to reflect some instruction bits, the 970 declares this as an
optional feature. So we need to reconstruct DSISR manually.
Signed-off-by: Alexander Graf <agraf-l3A5Bk7waGM@public.gmane.org>
---
arch/powerpc/include/asm/kvm_book3s.h | 1 +
arch/powerpc/kvm/book3s.c | 9 +++++++
arch/powerpc/kvm/book3s_64_emulate.c | 40 +++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index b47b2f5..1a169f3 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -131,6 +131,7 @@ extern void kvmppc_rmcall(ulong srr0, ulong srr1);
extern void kvmppc_load_up_fpu(void);
extern void kvmppc_load_up_altivec(void);
extern void kvmppc_load_up_vsx(void);
+extern u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst);
static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
{
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index 585dc91..6b8b5ed 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -905,6 +905,15 @@ program_interrupt:
}
break;
}
+ case BOOK3S_INTERRUPT_ALIGNMENT:
+ vcpu->arch.dear = vcpu->arch.fault_dear;
+ if (kvmppc_read_inst(vcpu) == EMULATE_DONE) {
+ to_book3s(vcpu)->dsisr = kvmppc_alignment_dsisr(vcpu,
+ vcpu->arch.last_inst);
+ kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
+ }
+ r = RESUME_GUEST;
+ break;
case BOOK3S_INTERRUPT_MACHINE_CHECK:
case BOOK3S_INTERRUPT_TRACE:
kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
diff --git a/arch/powerpc/kvm/book3s_64_emulate.c b/arch/powerpc/kvm/book3s_64_emulate.c
index 39d5003..c401dd4 100644
--- a/arch/powerpc/kvm/book3s_64_emulate.c
+++ b/arch/powerpc/kvm/book3s_64_emulate.c
@@ -44,6 +44,8 @@
/* DCBZ is actually 1014, but we patch it to 1010 so we get a trap */
#define OP_31_XOP_DCBZ 1010
+#define OP_LFS 48
+
#define SPRN_GQR0 912
#define SPRN_GQR1 913
#define SPRN_GQR2 914
@@ -474,3 +476,41 @@ int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)
return emulated;
}
+u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst)
+{
+ u32 dsisr = 0;
+
+ /*
+ * This is what the spec says about DSISR bits (not mentioned = 0):
+ *
+ * 12:13 [DS] Set to bits 30:31
+ * 15:16 [X] Set to bits 29:30
+ * 17 [X] Set to bit 25
+ * [D/DS] Set to bit 5
+ * 18:21 [X] Set to bits 21:24
+ * [D/DS] Set to bits 1:4
+ * 22:26 Set to bits 6:10 (RT/RS/FRT/FRS)
+ * 27:31 Set to bits 11:15 (RA)
+ */
+
+ switch (get_op(inst)) {
+ /* D-form */
+ case OP_LFS:
+ dsisr |= (inst >> 12) & 0x4000; /* bit 17 */
+ dsisr |= (inst >> 17) & 0x3c00; /* bits 18:21 */
+ break;
+ /* X-form */
+ case 31:
+ dsisr |= (inst << 14) & 0x18000; /* bits 15:16 */
+ dsisr |= (inst << 8) & 0x04000; /* bit 17 */
+ dsisr |= (inst << 3) & 0x03c00; /* bits 18:21 */
+ break;
+ default:
+ printk(KERN_INFO "KVM: Unaligned instruction 0x%x\n", inst);
+ break;
+ }
+
+ dsisr |= (inst >> 16) & 0x03ff; /* bits 22:31 */
+
+ return dsisr;
+}
--
1.6.0.2
next prev parent reply other threads:[~2010-03-08 18:03 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-08 18:03 [PATCH 00/15] KVM: PPC: MOL bringup patches Alexander Graf
2010-03-08 18:03 ` [PATCH 02/15] KVM: PPC: Allow userspace to unset the IRQ line Alexander Graf
[not found] ` <1268071402-27112-3-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
2010-03-09 12:50 ` Avi Kivity
[not found] ` <4B964412.8030708-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-03-09 12:54 ` Alexander Graf
[not found] ` <954C5195-A8E4-4CA5-8D5E-AA21E2E21C5B-l3A5Bk7waGM@public.gmane.org>
2010-03-09 13:05 ` Avi Kivity
2010-03-08 18:03 ` [PATCH 04/15] KVM: PPC: Book3S_32 guest MMU fixes Alexander Graf
2010-03-08 18:03 ` [PATCH 06/15] KVM: PPC: Don't reload FPU with invalid values Alexander Graf
2010-03-08 18:03 ` [PATCH 09/15] KVM: PPC: Implement BAT reads Alexander Graf
2010-03-08 18:03 ` [PATCH 10/15] KVM: PPC: Make XER load 32 bit Alexander Graf
2010-03-08 18:03 ` [PATCH 11/15] KVM: PPC: Implement emulation for lbzux and lhax Alexander Graf
[not found] ` <1268071402-27112-1-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
2010-03-08 18:03 ` [PATCH 01/15] KVM: PPC: Ensure split mode works Alexander Graf
2010-03-08 18:03 ` [PATCH 03/15] KVM: PPC: Make DSISR 32 bits wide Alexander Graf
2010-03-08 18:03 ` [PATCH 05/15] KVM: PPC: Split instruction reading out Alexander Graf
2010-03-08 18:03 ` [PATCH 07/15] KVM: PPC: Load VCPU for register fetching Alexander Graf
2010-03-08 18:03 ` [PATCH 08/15] KVM: PPC: Implement mfsr emulation Alexander Graf
2010-03-08 18:03 ` Alexander Graf [this message]
2010-03-08 18:03 ` [PATCH 13/15] KVM: Add support for enabling capabilities per-vcpu Alexander Graf
2010-03-09 12:56 ` Avi Kivity
2010-03-09 13:01 ` Alexander Graf
2010-03-09 13:09 ` Avi Kivity
2010-03-08 18:03 ` [PATCH 14/15] KVM: PPC: Add OSI hypercall interface Alexander Graf
2010-03-09 13:00 ` Avi Kivity
2010-03-09 13:04 ` Alexander Graf
2010-03-09 13:11 ` Avi Kivity
2010-03-09 13:12 ` Alexander Graf
[not found] ` <3D0D6963-FEC8-4A53-ACCE-570BEAF3721B-l3A5Bk7waGM@public.gmane.org>
2010-03-09 13:19 ` Avi Kivity
[not found] ` <4B964ADE.5030200-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-03-09 13:20 ` Alexander Graf
2010-03-08 18:03 ` [PATCH 15/15] KVM: PPC: Make build work without CONFIG_VSX/ALTIVEC Alexander Graf
2010-03-08 18:06 ` [PATCH 00/15] KVM: PPC: MOL bringup patches Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1268071402-27112-13-git-send-email-agraf@suse.de \
--to=agraf-l3a5bk7wagm@public.gmane.org \
--cc=kvm-ppc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox