From patchwork Thu Oct 8 14:52:33 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 35453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 554CCB7082 for ; Fri, 9 Oct 2009 02:04:30 +1100 (EST) Received: from localhost ([127.0.0.1]:60370 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvuXa-0006HV-F3 for incoming@patchwork.ozlabs.org; Thu, 08 Oct 2009 11:04:26 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MvuOB-00044o-TG for qemu-devel@nongnu.org; Thu, 08 Oct 2009 10:54:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MvuO6-0003z8-Mz for qemu-devel@nongnu.org; Thu, 08 Oct 2009 10:54:43 -0400 Received: from [199.232.76.173] (port=58575 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvuO6-0003yS-2K for qemu-devel@nongnu.org; Thu, 08 Oct 2009 10:54:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24803) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MvuO4-0005X1-QW for qemu-devel@nongnu.org; Thu, 08 Oct 2009 10:54:37 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n98EsauR005337; Thu, 8 Oct 2009 10:54:36 -0400 Received: from redhat.com (vpn-10-126.str.redhat.com [10.32.10.126]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n98EsXHe027830; Thu, 8 Oct 2009 10:54:34 -0400 Date: Thu, 8 Oct 2009 16:52:33 +0200 From: "Michael S. Tsirkin" To: Avi Kivity Message-ID: <20091008145233.GB12275@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Anthony Liguori , "qemu-devel@nongnu.org" , kvm-devel Subject: [Qemu-devel] [PATCH 1/3] pc-bios: enable io/memory unconditionally X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org VGA adapters need to claim memory and i/o transactions even if they do not have any i/o or memory bars. E.g. PCI spec, page 297, gives an example of such a device: Programming interface 0000 0000b VGA-compatible controller. Memory addresses 0A 0000h through 0B FFFFh. I/O addresses 3B0h to 3BBh and 3C0h to 3DFh and all aliases of these addresses. While we could check for these devices and special-case them, it is easier to fix this by enabling i/o and memory space unconditionally: devices that do not support it will just ignore this setting. Signed-off-by: Michael S. Tsirkin --- kvm/bios/rombios32.c | 18 +++++++----------- 1 files changed, 7 insertions(+), 11 deletions(-) diff --git a/kvm/bios/rombios32.c b/kvm/bios/rombios32.c index 0b3556c..747a97b 100755 --- a/kvm/bios/rombios32.c +++ b/kvm/bios/rombios32.c @@ -700,6 +700,7 @@ void smp_probe(void) #define PCI_COMMAND 0x04 /* 16 bits */ #define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ #define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ +#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ #define PCI_CLASS_DEVICE 0x0a /* Device class */ #define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ #define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ @@ -767,7 +768,6 @@ static uint32_t pci_config_readb(PCIDevice *d, uint32_t addr) static void pci_set_io_region_addr(PCIDevice *d, int region_num, uint32_t addr) { - uint16_t cmd; uint32_t ofs, old_addr; if ( region_num == PCI_ROM_SLOT ) { @@ -780,16 +780,6 @@ static void pci_set_io_region_addr(PCIDevice *d, int region_num, uint32_t addr) pci_config_writel(d, ofs, addr); BX_INFO("region %d: 0x%08x\n", region_num, addr); - - /* enable memory mappings */ - cmd = pci_config_readw(d, PCI_COMMAND); - if ( region_num == PCI_ROM_SLOT ) - cmd |= 2; - else if (old_addr & PCI_ADDRESS_SPACE_IO) - cmd |= 1; - else - cmd |= 2; - pci_config_writew(d, PCI_COMMAND, cmd); } /* return the global irq number corresponding to a given device irq @@ -946,6 +936,7 @@ static void pci_bios_init_device(PCIDevice *d) { int class; uint32_t *paddr; + uint16_t cmd; int i, pin, pic_irq, vendor_id, device_id; class = pci_config_readw(d, PCI_CLASS_DEVICE); @@ -1024,6 +1015,11 @@ static void pci_bios_init_device(PCIDevice *d) break; } + /* enable memory mappings */ + cmd = pci_config_readw(d, PCI_COMMAND); + cmd |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY; + pci_config_writew(d, PCI_COMMAND, cmd); + /* map the interrupt */ pin = pci_config_readb(d, PCI_INTERRUPT_PIN); if (pin != 0) {