From patchwork Thu Jul 24 11:30:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiejun Chen X-Patchwork-Id: 373375 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 07A2514007D for ; Thu, 24 Jul 2014 21:35:41 +1000 (EST) Received: from localhost ([::1]:49286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAHJC-0000ks-6j for incoming@patchwork.ozlabs.org; Thu, 24 Jul 2014 07:35:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAHHC-0005mV-6q for qemu-devel@nongnu.org; Thu, 24 Jul 2014 07:33:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAHH6-00036U-Lf for qemu-devel@nongnu.org; Thu, 24 Jul 2014 07:33:34 -0400 Received: from mga03.intel.com ([143.182.124.21]:6809) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAHH6-00035y-F8 for qemu-devel@nongnu.org; Thu, 24 Jul 2014 07:33:28 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 24 Jul 2014 04:33:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,723,1400050800"; d="scan'208";a="460837168" Received: from tchen0-linux.bj.intel.com ([10.238.154.58]) by azsmga001.ch.intel.com with ESMTP; 24 Jul 2014 04:33:08 -0700 From: Tiejun Chen To: mst@redhat.com, stefano.stabellini@eu.citrix.com, pbonzini@redhat.com Date: Thu, 24 Jul 2014 19:30:29 +0800 Message-Id: <1406201429-21700-5-git-send-email-tiejun.chen@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1406201429-21700-1-git-send-email-tiejun.chen@intel.com> References: <1406201429-21700-1-git-send-email-tiejun.chen@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 143.182.124.21 Cc: qemu-devel@nongnu.org, xen-devel@lists.xen.org Subject: [Qemu-devel] [PATCH 4/4] xen:hw:i386:pc_piix: introduce new machine for IGD passthrough X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now we can introduce a new machine, xenigd, specific to IGD passthrough. This can avoid involving other common codes. Signed-off-by: Tiejun Chen --- hw/i386/pc_piix.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 2391fda..46e5901 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -206,6 +206,33 @@ static void pc_machine_pci_bus_init(MachineState *machine, } } +static void xen_igd_pc_machine_pci_bus_init(MachineState *machine, + int pci_enabled, + PCII440FXState *i440fx_state, + int piix3_devfn, + PCIBus *pci_bus, + ISABus *isa_bus, + qemu_irq *gsi, + MemoryRegion *pci_memory, + MemoryRegion *ram_memory) +{ + MemoryRegion *system_memory = get_system_memory(); + MemoryRegion *system_io = get_system_io(); + + if (pci_enabled) { + pci_bus = xen_igd_i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, + gsi, system_memory, system_io, machine->ram_size, + below_4g_mem_size, + above_4g_mem_size, + pci_memory, ram_memory); + } else { + pci_bus = NULL; + i440fx_state = NULL; + isa_bus = isa_bus_new(NULL, system_io); + no_hpet = 1; + } +} + static void pc_machine_device_init(MachineState *machine, int pci_enabled, GSIState *gsi_state, @@ -337,11 +364,39 @@ static void pc_init1(MachineState *machine, piix3_devfn, fw_cfg, pci_bus, isa_bus, gsi); } +static void xen_igd_pc_init1(MachineState *machine, + int pci_enabled, + int kvmclock_enabled) +{ + PCIBus *pci_bus = NULL; + ISABus *isa_bus = NULL; + PCII440FXState *i440fx_state = NULL; + int piix3_devfn = -1; + qemu_irq *gsi = NULL; + GSIState *gsi_state = NULL; + MemoryRegion *ram_memory = NULL; + MemoryRegion *pci_memory = NULL; + DeviceState *icc_bridge = NULL; + FWCfgState *fw_cfg = NULL; + + pc_machine_base_init(machine, pci_enabled, kvmclock_enabled, icc_bridge, + ram_memory, pci_memory, gsi, gsi_state, fw_cfg); + xen_igd_pc_machine_pci_bus_init(machine, pci_enabled, i440fx_state, + piix3_devfn, pci_bus, isa_bus, gsi, pci_memory, ram_memory); + pc_machine_device_init(machine, pci_enabled, gsi_state, icc_bridge, + piix3_devfn, fw_cfg, pci_bus, isa_bus, gsi); +} + static void pc_init_pci(MachineState *machine) { pc_init1(machine, 1, 1); } +static void xen_igd_pc_init_pci(MachineState *machine) +{ + xen_igd_pc_init1(machine, 1, 1); +} + static void pc_compat_2_0(MachineState *machine) { smbios_legacy_mode = true; @@ -470,6 +525,17 @@ static void pc_xen_hvm_init(MachineState *machine) pci_create_simple(bus, -1, "xen-platform"); } } +static void xen_igd_pc_hvm_init(MachineState *machine) +{ + PCIBus *bus; + + xen_igd_pc_init_pci(machine); + + bus = pci_find_primary_bus(); + if (bus != NULL) { + pci_create_simple(bus, -1, "xen-platform"); + } +} #endif #define PC_I440FX_MACHINE_OPTIONS \ @@ -919,6 +985,26 @@ static QEMUMachine xenfv_machine = { { /* end of list */ } }, }; +static QEMUMachine xenigd_machine = { + PC_COMMON_MACHINE_OPTIONS, + .name = "xenigd", + .desc = "Xen Fully-virtualized PC specific to IGD", + .init = xen_igd_pc_hvm_init, + .max_cpus = HVM_MAX_VCPUS, + .default_machine_opts = "accel=xen", + .hot_add_cpu = pc_hot_add_cpu, + .compat_props = (GlobalProperty[]) { + /* xenfv has no fwcfg and so does not load acpi from QEMU. + * as such new acpi features don't work. + */ + { + .driver = "PIIX4_PM", + .property = "acpi-pci-hotplug-with-bridge-support", + .value = "off", + }, + { /* end of list */ } + }, +}; #endif static void pc_machine_init(void) @@ -942,6 +1028,7 @@ static void pc_machine_init(void) qemu_register_pc_machine(&isapc_machine); #ifdef CONFIG_XEN qemu_register_pc_machine(&xenfv_machine); + qemu_register_pc_machine(&xenigd_machine); #endif }