From patchwork Mon Aug 2 13:53:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Kohl X-Patchwork-Id: 60537 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 E9E7F1007D4 for ; Mon, 2 Aug 2010 23:54:46 +1000 (EST) Received: from localhost ([127.0.0.1]:51260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OfvTX-0003LK-NG for incoming@patchwork.ozlabs.org; Mon, 02 Aug 2010 09:54:43 -0400 Received: from [140.186.70.92] (port=54737 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OfvSs-0003LB-5z for qemu-devel@nongnu.org; Mon, 02 Aug 2010 09:54:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OfvSp-0008V2-C4 for qemu-devel@nongnu.org; Mon, 02 Aug 2010 09:54:02 -0400 Received: from demumfd001.nsn-inter.net ([93.183.12.32]:14523) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OfvSo-0008Us-Up for qemu-devel@nongnu.org; Mon, 02 Aug 2010 09:53:59 -0400 Received: from demuprx017.emea.nsn-intra.net ([10.150.129.56]) by demumfd001.nsn-inter.net (8.12.11.20060308/8.12.11) with ESMTP id o72DruZm031404 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 2 Aug 2010 15:53:56 +0200 Received: from [10.148.23.89] ([10.148.23.89]) by demuprx017.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id o72DruxX019421 for ; Mon, 2 Aug 2010 15:53:56 +0200 Message-ID: <4C56CDEF.6040306@nsn.com> Date: Mon, 02 Aug 2010 15:53:51 +0200 From: Bernhard Kohl User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100720 Fedora/3.0.6-1.fc12 Thunderbird/3.0.6 MIME-Version: 1.0 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Subject: [Qemu-devel] [PATCH] msix: allow byte and word reading from mmio 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 It's legal that the guest reads a single byte or word from mmio. I have an OS which reads single bytes and it works fine on real hardware. Maybe this happens due to casting. Signed-off-by: Bernhard Kohl --- hw/msix.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) static uint8_t msix_pending_mask(int vector) @@ -198,7 +210,7 @@ static CPUWriteMemoryFunc * const msix_mmio_write[] = { }; static CPUReadMemoryFunc * const msix_mmio_read[] = { - msix_mmio_read_unallowed, msix_mmio_read_unallowed, msix_mmio_readl + msix_mmio_readb, msix_mmio_readw, msix_mmio_readl }; /* Should be called from device's map method. */ diff --git a/hw/msix.c b/hw/msix.c index d99403a..7dac7f7 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -100,10 +100,22 @@ static uint32_t msix_mmio_readl(void *opaque, target_phys_addr_t addr) return pci_get_long(page + offset); } -static uint32_t msix_mmio_read_unallowed(void *opaque, target_phys_addr_t addr) +static uint32_t msix_mmio_readw(void *opaque, target_phys_addr_t addr) { - fprintf(stderr, "MSI-X: only dword read is allowed!\n"); - return 0; + PCIDevice *dev = opaque; + unsigned int offset = addr & (MSIX_PAGE_SIZE - 1) & ~0x1; + void *page = dev->msix_table_page; + + return pci_get_word(page + offset); +} + +static uint32_t msix_mmio_readb(void *opaque, target_phys_addr_t addr) +{ + PCIDevice *dev = opaque; + unsigned int offset = addr & (MSIX_PAGE_SIZE - 1); + void *page = dev->msix_table_page; + + return pci_get_byte(page + offset); }