From patchwork Mon Jul 6 14:35:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 34250 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n66EZtdo015732 for ; Mon, 6 Jul 2009 14:35:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754829AbZGFOfp (ORCPT ); Mon, 6 Jul 2009 10:35:45 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754778AbZGFOfo (ORCPT ); Mon, 6 Jul 2009 10:35:44 -0400 Received: from mx2.redhat.com ([66.187.237.31]:45702 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754742AbZGFOfo (ORCPT ); Mon, 6 Jul 2009 10:35:44 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n66EZmu1011302 for ; Mon, 6 Jul 2009 10:35:48 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n66EZlRZ032496; Mon, 6 Jul 2009 10:35:47 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n66EZkYA002417; Mon, 6 Jul 2009 10:35:47 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 18B5A18D479; Mon, 6 Jul 2009 17:35:46 +0300 (IDT) Date: Mon, 6 Jul 2009 17:35:46 +0300 From: Gleb Natapov To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH][RESEND] Add kvm_set_boot_cpu_id() API. Message-ID: <20090706143546.GB28046@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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. --- Gleb. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;