From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59634 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnIBH-00008N-Tb for qemu-devel@nongnu.org; Sun, 22 Aug 2010 17:34:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnIBG-0006fg-Ij for qemu-devel@nongnu.org; Sun, 22 Aug 2010 17:34:19 -0400 Received: from mail-gx0-f173.google.com ([209.85.161.173]:53513) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnIBG-0006fc-Ex for qemu-devel@nongnu.org; Sun, 22 Aug 2010 17:34:18 -0400 Received: by gxk5 with SMTP id 5so2065163gxk.4 for ; Sun, 22 Aug 2010 14:34:18 -0700 (PDT) Message-ID: <4C7197D8.4070208@codemonkey.ws> Date: Sun, 22 Aug 2010 16:34:16 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH RESENT] msix: allow byte and word reading from mmio References: <1282222611-21192-1-git-send-email-bernhard.kohl@nsn.com> In-Reply-To: <1282222611-21192-1-git-send-email-bernhard.kohl@nsn.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bernhard Kohl Cc: qemu-devel@nongnu.org, mst@redhat.com On 08/19/2010 07:56 AM, Bernhard Kohl wrote: > 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 > Hi Michael, I'm looking for this to come through your tree unless you disagree. Regards, Anthony Liguori > --- > 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. */ >