public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>, Avi Kivity <avi@qumranet.com>
Cc: kvm-devel <kvm-devel@lists.sourceforge.net>
Subject: QEMU/KVM: make kvm_arch_load_regs() aware of in kernel APIC
Date: Thu, 3 Apr 2008 20:24:37 -0300	[thread overview]
Message-ID: <20080403232437.GA24568@dmt> (raw)


kvm_arch_load_regs() might load APIC base and APIC TPR from the
uninitialized userspace APIC emulation.

This happened when running X11 on SMP guest in my case, disabling the
APIC for vcpu3:

vcpu not ready for apic_round_robin
vcpu not ready for apic_round_robin
vcpu not ready for apic_round_robin
...


Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>


diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c
index 78490c5..401fbc6 100644
--- a/qemu/qemu-kvm-x86.c
+++ b/qemu/qemu-kvm-x86.c
@@ -250,9 +250,15 @@ void kvm_arch_load_regs(CPUState *env)
     sregs.cr3 = env->cr[3];
     sregs.cr4 = env->cr[4];
 
-    sregs.apic_base = cpu_get_apic_base(env);
+    if (kvm_irqchip_in_kernel(kvm_context)) {
+        sregs.cr8 = kvm_get_cr8(kvm_context, env->cpu_index);
+        sregs.apic_base = kvm_get_apic_base(kvm_context, env->cpu_index);
+    } else {
+        sregs.cr8 = cpu_get_apic_tpr(env);
+        sregs.apic_base = cpu_get_apic_base(env);
+    }
+
     sregs.efer = env->efer;
-    sregs.cr8 = cpu_get_apic_tpr(env);
 
     kvm_set_sregs(kvm_context, env->cpu_index, &sregs);
 

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

             reply	other threads:[~2008-04-03 23:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-03 23:24 Marcelo Tosatti [this message]
2008-04-04 16:23 ` QEMU/KVM: make kvm_arch_load_regs() aware of in kernel APIC Ryan Harper
2008-04-04 21:23 ` Avi Kivity

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=20080403232437.GA24568@dmt \
    --to=mtosatti@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@qumranet.com \
    --cc=kvm-devel@lists.sourceforge.net \
    /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