From patchwork Tue Jul 7 15:50:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beth Kon X-Patchwork-Id: 34475 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 n67Fm77H004352 for ; Tue, 7 Jul 2009 15:48:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757055AbZGGPrw (ORCPT ); Tue, 7 Jul 2009 11:47:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754021AbZGGPrv (ORCPT ); Tue, 7 Jul 2009 11:47:51 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:47961 "EHLO e8.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756895AbZGGPrt (ORCPT ); Tue, 7 Jul 2009 11:47:49 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e8.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n67Fauwj029119 for ; Tue, 7 Jul 2009 11:36:56 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n67Flkkj113122 for ; Tue, 7 Jul 2009 11:47:48 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n67FjGHe029931 for ; Tue, 7 Jul 2009 11:45:16 -0400 Received: from localhost.localdomain (sig-9-65-127-31.mts.ibm.com [9.65.127.31]) by d01av02.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n67FjFXP029816; Tue, 7 Jul 2009 11:45:16 -0400 From: Beth Kon To: avi@redhat.com Cc: kvm@vger.kernel.org, Beth Kon Subject: [PATCH 2/5] Userspace changes for irq0->inti2 override support (v9) Date: Tue, 7 Jul 2009 11:50:35 -0400 Message-Id: <1246981838-20465-2-git-send-email-eak@us.ibm.com> X-Mailer: git-send-email 1.5.4.3 In-Reply-To: <1246981838-20465-1-git-send-email-eak@us.ibm.com> References: <1246981838-20465-1-git-send-email-eak@us.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Select irq0->irq2 override based on kernel gsi routing availability If the kernel does not support gsi routing, we cannot do the irq0->irq2 override, so disable it in that case. Signed-off-by: Beth Kon Signed-off-by: Avi Kivity --- hw/ioapic.c | 6 +++--- hw/pc.c | 2 ++ qemu-kvm-x86.c | 6 +++++- qemu-kvm.h | 2 ++ sysemu.h | 1 + vl.c | 11 +++++++++-- 6 files changed, 22 insertions(+), 6 deletions(-) -- 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/ioapic.c b/hw/ioapic.c index a7a5ef9..c894b72 100644 --- a/hw/ioapic.c +++ b/hw/ioapic.c @@ -23,6 +23,7 @@ #include "hw.h" #include "pc.h" +#include "sysemu.h" #include "qemu-timer.h" #include "host-utils.h" @@ -95,14 +96,13 @@ void ioapic_set_irq(void *opaque, int vector, int level) { IOAPICState *s = opaque; -#if 0 /* ISA IRQs map to GSI 1-1 except for IRQ0 which maps * to GSI 2. GSI maps to ioapic 1-1. This is not * the cleanest way of doing it but it should work. */ - if (vector == 0) + if (vector == 0 && irq0override) { vector = 2; -#endif + } if (vector >= 0 && vector < IOAPIC_NUM_PINS) { uint32_t mask = 1 << vector; diff --git a/hw/pc.c b/hw/pc.c index 05d05e0..043a0da 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -55,6 +55,7 @@ #define BIOS_CFG_IOPORT 0x510 #define FW_CFG_ACPI_TABLES (FW_CFG_ARCH_LOCAL + 0) #define FW_CFG_SMBIOS_ENTRIES (FW_CFG_ARCH_LOCAL + 1) +#define FW_CFG_IRQ0_OVERRIDE (FW_CFG_ARCH_LOCAL + 2) #define MAX_IDE_BUS 2 @@ -476,6 +477,7 @@ static void bochs_bios_init(void) fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, (uint8_t *)acpi_tables, acpi_tables_len); + fw_cfg_add_bytes(fw_cfg, FW_CFG_IRQ0_OVERRIDE, &irq0override, 1); smbios_table = smbios_get_table(&smbios_len); if (smbios_table) diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index a78073e..f7c66d1 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -1561,7 +1561,11 @@ int kvm_arch_init_irq_routing(void) return r; } for (i = 0; i < 24; ++i) { - r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_IOAPIC, i); + if (i == 0) { + r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_IOAPIC, 2); + } else if (i != 2) { + r = kvm_add_irq_route(kvm_context, i, KVM_IRQCHIP_IOAPIC, i); + } if (r < 0) return r; } diff --git a/qemu-kvm.h b/qemu-kvm.h index eb99bc4..b044ead 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -167,6 +167,7 @@ int kvm_has_sync_mmu(void); #define kvm_enabled() (kvm_allowed) #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context) #define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context) +#define qemu_kvm_has_gsi_routing() kvm_has_gsi_routing(kvm_context) void kvm_init_vcpu(CPUState *env); void kvm_load_tsc(CPUState *env); #else @@ -175,6 +176,7 @@ void kvm_load_tsc(CPUState *env); #define kvm_nested 0 #define qemu_kvm_irqchip_in_kernel() (0) #define qemu_kvm_pit_in_kernel() (0) +#define qemu_kvm_has_gsi_routing() (0) #define kvm_load_registers(env) do {} while(0) #define kvm_save_registers(env) do {} while(0) #define qemu_kvm_cpu_stop(env) do {} while(0) diff --git a/sysemu.h b/sysemu.h index 2824b0d..5b42506 100644 --- a/sysemu.h +++ b/sysemu.h @@ -111,6 +111,7 @@ extern int xenfb_enabled; extern int graphic_width; extern int graphic_height; extern int graphic_depth; +extern uint8_t irq0override; extern DisplayType display_type; extern const char *keyboard_layout; extern int win2k_install_hack; diff --git a/vl.c b/vl.c index df583b7..d8b7198 100644 --- a/vl.c +++ b/vl.c @@ -255,6 +255,7 @@ int no_reboot = 0; int no_shutdown = 0; int cursor_hide = 1; int graphic_rotate = 0; +uint8_t irq0override = 1; #ifndef _WIN32 int daemonize = 0; #endif @@ -6199,8 +6200,14 @@ int main(int argc, char **argv, char **envp) module_call_init(MODULE_INIT_DEVICE); - if (kvm_enabled()) - kvm_init_ap(); + if (kvm_enabled()) { + kvm_init_ap(); +#ifdef USE_KVM + if (kvm_irqchip && !qemu_kvm_has_gsi_routing()) { + irq0override = 0; + } +#endif + } machine->init(ram_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model);