All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hollis Blanchard <hollisb@us.ibm.com>
To: kvm-ppc@vger.kernel.org
Subject: [kvm-ppc-devel] guest panic fixed
Date: Wed, 19 Mar 2008 23:25:20 +0000	[thread overview]
Message-ID: <1205969120.11366.67.camel@basalt> (raw)

Thanks to some excellent debugging by Christian, we found the cause of
our annoying guest panics. We had not implemented exception priorities
(my bad), so a userspace ITLB miss was being delivered immediately after
entry to the decrementer interrupt vector. Patch follows,
http://penguinppc.org/~hollisb/kvm/ updated.

NFS root with virtio-net still doesn't work for me, but it doesn't
crash. :)

diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -68,6 +68,44 @@ static const u32 interrupt_msr_mask[16] 
 	[BOOKE_INTERRUPT_DEBUG]         = MSR_ME,
 };
 
+const unsigned char exception_priority[] = {
+	[BOOKE_INTERRUPT_DATA_STORAGE] = 0,
+	[BOOKE_INTERRUPT_INST_STORAGE] = 1,
+	[BOOKE_INTERRUPT_ALIGNMENT] = 2,
+	[BOOKE_INTERRUPT_PROGRAM] = 3,
+	[BOOKE_INTERRUPT_FP_UNAVAIL] = 4,
+	[BOOKE_INTERRUPT_SYSCALL] = 5,
+	[BOOKE_INTERRUPT_AP_UNAVAIL] = 6,
+	[BOOKE_INTERRUPT_DTLB_MISS] = 7,
+	[BOOKE_INTERRUPT_ITLB_MISS] = 8,
+	[BOOKE_INTERRUPT_MACHINE_CHECK] = 9,
+	[BOOKE_INTERRUPT_DEBUG] = 10,
+	[BOOKE_INTERRUPT_CRITICAL] = 11,
+	[BOOKE_INTERRUPT_WATCHDOG] = 12,
+	[BOOKE_INTERRUPT_EXTERNAL] = 13,
+	[BOOKE_INTERRUPT_FIT] = 14,
+	[BOOKE_INTERRUPT_DECREMENTER] = 15,
+};
+
+const unsigned char priority_exception[] = {
+	BOOKE_INTERRUPT_DATA_STORAGE,
+	BOOKE_INTERRUPT_INST_STORAGE,
+	BOOKE_INTERRUPT_ALIGNMENT,
+	BOOKE_INTERRUPT_PROGRAM,
+	BOOKE_INTERRUPT_FP_UNAVAIL,
+	BOOKE_INTERRUPT_SYSCALL,
+	BOOKE_INTERRUPT_AP_UNAVAIL,
+	BOOKE_INTERRUPT_DTLB_MISS,
+	BOOKE_INTERRUPT_ITLB_MISS,
+	BOOKE_INTERRUPT_MACHINE_CHECK,
+	BOOKE_INTERRUPT_DEBUG,
+	BOOKE_INTERRUPT_CRITICAL,
+	BOOKE_INTERRUPT_WATCHDOG,
+	BOOKE_INTERRUPT_EXTERNAL,
+	BOOKE_INTERRUPT_FIT,
+	BOOKE_INTERRUPT_DECREMENTER,
+};
+
 
 gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
 {
@@ -183,19 +221,21 @@ static void kvmppc_check_and_deliver_int
 static void kvmppc_check_and_deliver_interrupts(struct kvm_vcpu *vcpu)
 {
 	unsigned long *pending = &vcpu->arch.pending_exceptions;
-	int exception;
-
-	exception = find_first_bit(pending, BITS_PER_BYTE * sizeof(*pending));
-	while (exception < BOOKE_MAX_INTERRUPT) {
+	unsigned int exception;
+	unsigned int priority;
+
+	priority = find_first_bit(pending, BITS_PER_BYTE * sizeof(*pending));
+	while (priority <= BOOKE_MAX_INTERRUPT) {
+		exception = priority_exception[priority];
 		if (kvmppc_can_deliver_interrupt(vcpu, exception)) {
 			kvmppc_clear_exception(vcpu, exception);
 			kvmppc_deliver_interrupt(vcpu, exception);
 			break;
 		}
 
-		exception = find_next_bit(pending,
-		                          BITS_PER_BYTE * sizeof(*pending),
-		                          exception + 1);
+		priority = find_next_bit(pending,
+		                         BITS_PER_BYTE * sizeof(*pending),
+		                         priority + 1);
 	}
 }
 
diff --git a/include/asm-powerpc/kvm_ppc.h b/include/asm-powerpc/kvm_ppc.h
--- a/include/asm-powerpc/kvm_ppc.h
+++ b/include/asm-powerpc/kvm_ppc.h
@@ -41,6 +41,9 @@ enum emulation_result {
 	EMULATE_FAIL,         /* can't emulate this instruction */
 };
 
+extern const unsigned char exception_priority[];
+extern const unsigned char priority_exception[];
+
 extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
 extern char kvmppc_handlers_start[];
 extern unsigned long kvmppc_handler_len;
@@ -65,12 +68,14 @@ extern void kvmppc_44x_tlb_trace(int act
 
 static inline void kvmppc_queue_exception(struct kvm_vcpu *vcpu, int exception)
 {
-	set_bit(exception, &vcpu->arch.pending_exceptions);
+	unsigned int priority = exception_priority[exception];
+	set_bit(priority, &vcpu->arch.pending_exceptions);
 }
 
 static inline void kvmppc_clear_exception(struct kvm_vcpu *vcpu, int exception)
 {
-	clear_bit(exception, &vcpu->arch.pending_exceptions);
+	unsigned int priority = exception_priority[exception];
+	clear_bit(priority, &vcpu->arch.pending_exceptions);
 }
 
 static inline void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)


-- 
Hollis Blanchard
IBM Linux Technology Center


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel

             reply	other threads:[~2008-03-19 23:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-19 23:25 Hollis Blanchard [this message]
2008-03-20  8:32 ` [kvm-ppc-devel] guest panic fixed Christian Ehrhardt
2008-03-20 11:08 ` Christian Ehrhardt
2008-03-20 14:58 ` Hollis Blanchard
2008-03-20 16:12 ` Hollis Blanchard

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=1205969120.11366.67.camel@basalt \
    --to=hollisb@us.ibm.com \
    --cc=kvm-ppc@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.