All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jes Sorensen <jes@sgi.com>
To: kvm-ia64@vger.kernel.org
Subject: Re: switching from KVM guest to the host .... TLBs not present?
Date: Thu, 09 Apr 2009 14:38:14 +0000	[thread overview]
Message-ID: <49DE0856.8010700@sgi.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 393 bytes --]

Zhang, Xiantao wrote:
> Yeah, that is very strange! I will check it tomorrow, and have to sleep now :-)
> Xiantao

Hi Xiantao,

I think I got it!

We were calling local_irqs_disable() before calling down_read(), but
down_read() can sleep and so may return with local interrupts
re-enabled.....

I have reordered things so now we should be safe.

How does this patch look to you?

Cheers,
Jes


[-- Attachment #2: 0001-kvm-ia64-vti-local-irq-disable.patch --]
[-- Type: text/x-patch, Size: 1237 bytes --]

Reorder locking as down_read() may return with local interrupts enabled,
which means we could go into vti_vcpu_run() with interrupts enabled.

This caused random crashes on the Altix as the timer interrupt tried
to read a memory mapped clock source, for which the TLB had not yet been
reinstated in the exit, before ipsr was retored.

Signed-off-by: Jes Sorensen <jes@sgi.com>

---
 arch/ia64/kvm/kvm-ia64.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Index: linux-2.6.git/arch/ia64/kvm/kvm-ia64.c
===================================================================
--- linux-2.6.git.orig/arch/ia64/kvm/kvm-ia64.c
+++ linux-2.6.git/arch/ia64/kvm/kvm-ia64.c
@@ -610,20 +610,22 @@
 	int r;
 
 again:
-	preempt_disable();
-	local_irq_disable();
-
 	if (signal_pending(current)) {
-		local_irq_enable();
-		preempt_enable();
 		r = -EINTR;
 		kvm_run->exit_reason = KVM_EXIT_INTR;
 		goto out;
 	}
 
+	/*
+	 * down_read() may sleep and return with interrupts enabled
+	 */
+	down_read(&vcpu->kvm->slots_lock);
+
+	preempt_disable();
+	local_irq_disable();
+
 	vcpu->guest_mode = 1;
 	kvm_guest_enter();
-	down_read(&vcpu->kvm->slots_lock);
 	r = vti_vcpu_run(vcpu, kvm_run);
 	if (r < 0) {
 		local_irq_enable();

             reply	other threads:[~2009-04-09 14:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-09 14:38 Jes Sorensen [this message]
2009-04-10 12:47 ` switching from KVM guest to the host .... TLBs not present? Zhang, Xiantao
2009-04-11 16:04 ` Avi Kivity
2009-04-14 11:43 ` Jes Sorensen
2009-04-16  8:43 ` Jes Sorensen
2009-04-16  8:59 ` Avi Kivity
2009-04-16  9:41 ` Zhang, Xiantao
2009-04-16  9:55 ` Avi Kivity
2009-04-16  9:57 ` Zhang, Xiantao

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=49DE0856.8010700@sgi.com \
    --to=jes@sgi.com \
    --cc=kvm-ia64@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.