From patchwork Thu Aug 19 12:56: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: 62152 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 D6413B70DC for ; Thu, 19 Aug 2010 23:01:09 +1000 (EST) Received: from localhost ([127.0.0.1]:48538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Om4jx-0006J0-En for incoming@patchwork.ozlabs.org; Thu, 19 Aug 2010 09:01:06 -0400 Received: from [140.186.70.92] (port=44194 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Om4gB-0005IK-K3 for qemu-devel@nongnu.org; Thu, 19 Aug 2010 08:57:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Om4g5-0005Qf-JD for qemu-devel@nongnu.org; Thu, 19 Aug 2010 08:57:06 -0400 Received: from demumfd002.nsn-inter.net ([93.183.12.31]:14872) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Om4g5-0005QQ-4P for qemu-devel@nongnu.org; Thu, 19 Aug 2010 08:57:05 -0400 Received: from demuprx017.emea.nsn-intra.net ([10.150.129.56]) by demumfd002.nsn-inter.net (8.12.11.20060308/8.12.11) with ESMTP id o7JCv2pE023088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 19 Aug 2010 14:57:03 +0200 Received: from localhost.localdomain ([10.148.23.89]) by demuprx017.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id o7JCv2Jx002990; Thu, 19 Aug 2010 14:57:02 +0200 From: Bernhard Kohl To: qemu-devel@nongnu.org Date: Thu, 19 Aug 2010 14:56:51 +0200 Message-Id: <1282222611-21192-1-git-send-email-bernhard.kohl@nsn.com> X-Mailer: git-send-email 1.7.2.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: Bernhard Kohl , mst@redhat.com Subject: [Qemu-devel] [PATCH RESENT] 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(-) 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); } 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. */