All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: avi@redhat.com
Cc: kvm@vger.kernel.org
Subject: [PATCH][RESEND] Add kvm_set_boot_cpu_id() API.
Date: Mon, 6 Jul 2009 17:35:46 +0300	[thread overview]
Message-ID: <20090706143546.GB28046@redhat.com> (raw)

Old kernel assumed that apic id of a boot cpus is zero, recent kernels
have an IOCTL to configure BSP's apic id. The patch adds API function to
use this capability. The BSP apic id is set to zero (now explicitly)
since QEMU/BIOS not ready yet to take full advantage of the new API.

diff --git a/hw/pc.c b/hw/pc.c
index 43e2f29..cf84416 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1131,6 +1131,7 @@ static void pc_init1(ram_addr_t ram_size,
 #endif
     }
 
+    kvm_set_boot_cpu_id(0);
     for (i = 0; i < smp_cpus; i++) {
         env = pc_new_cpu(cpu_model);
     }
diff --git a/qemu-kvm.c b/qemu-kvm.c
index c5cd038..c57df57 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -441,6 +441,18 @@ err:
 	return NULL;
 }
 
+static int kvm_set_boot_vcpu_id(kvm_context_t kvm, uint32_t id)
+{
+#ifdef KVM_CAP_SET_BOOT_CPU_ID
+    int r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_SET_BOOT_CPU_ID);
+    if (r > 0)
+        return ioctl(kvm->vm_fd, KVM_SET_BOOT_CPU_ID, id);
+    return -ENOSYS;
+#else
+    return -ENOSYS;
+#endif
+}
+
 int kvm_create_vm(kvm_context_t kvm)
 {
 	int fd = kvm->fd;
@@ -2923,3 +2935,8 @@ void qemu_kvm_cpu_stop(CPUState *env)
     if (kvm_enabled())
         env->kvm_cpu_state.stopped = 1;
 }
+
+int kvm_set_boot_cpu_id(uint32_t id)
+{
+	return kvm_set_boot_vcpu_id(kvm_context, id);
+}
diff --git a/qemu-kvm.h b/qemu-kvm.h
index eb99bc4..ce22bed 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -80,6 +80,7 @@ int kvm_arch_try_push_interrupts(void *opaque);
 void kvm_arch_push_nmi(void *opaque);
 void kvm_arch_update_regs_for_sipi(CPUState *env);
 void kvm_arch_cpu_reset(CPUState *env);
+int kvm_set_boot_cpu_id(uint32_t id);
 
 struct kvm_guest_debug;
 struct kvm_debug_exit_arch;
--
			Gleb.

             reply	other threads:[~2009-07-06 14:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-06 14:35 Gleb Natapov [this message]
2009-07-07  9:56 ` [PATCH][RESEND] Add kvm_set_boot_cpu_id() API Avi Kivity
2009-07-07 18:45   ` Jan Kiszka
2009-07-07 19:47     ` buildbot Avi Kivity
2009-07-07 20:53       ` buildbot Daniel Gollub
2009-07-08  4:54         ` buildbot Avi Kivity
2009-07-08 14:45           ` buildbot Daniel Gollub
2009-07-08 15:07             ` buildbot Avi Kivity
2009-07-08 15:18             ` buildbot Jan Kiszka
2009-07-08 15:51               ` buildbot Daniel Gollub

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=20090706143546.GB28046@redhat.com \
    --to=gleb@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@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.