From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [RFC v9 06/27] virtio-blk: Take PCI memory range into account Date: Wed, 18 Jul 2012 21:29:50 +0300 Message-ID: <20120718182950.GB2498@redhat.com> References: <1342624074-24650-1-git-send-email-stefanha@linux.vnet.ibm.com> <1342624074-24650-7-git-send-email-stefanha@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Kevin Wolf , Anthony Liguori , kvm@vger.kernel.org, qemu-devel@nongnu.org, Khoa Huynh , Paolo Bonzini , Asias He To: Stefan Hajnoczi Return-path: Content-Disposition: inline In-Reply-To: <1342624074-24650-7-git-send-email-stefanha@linux.vnet.ibm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org On Wed, Jul 18, 2012 at 04:07:33PM +0100, Stefan Hajnoczi wrote: > Support >4 GB physical memory accesses. > > Signed-off-by: Stefan Hajnoczi Need some sane APIs, this is just too scary. > --- > hw/virtio-blk.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c > index abd9386..99654f1 100644 > --- a/hw/virtio-blk.c > +++ b/hw/virtio-blk.c > @@ -64,6 +64,13 @@ static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev) > */ > static inline void *phys_to_host(VirtIOBlock *s, target_phys_addr_t phys) > { > + /* Adjust for 3.6-4 GB PCI memory range */ > + if (phys >= 0x100000000) { > + phys -= 0x100000000 - 0xe0000000; > + } else if (phys >= 0xe0000000) { > + fprintf(stderr, "phys_to_host bad physical address in PCI range %#lx\n", phys); > + exit(1); > + } > return s->phys_mem_zero_host_ptr + phys; > } > > -- > 1.7.10.4 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrYzx-0004Qx-SR for qemu-devel@nongnu.org; Wed, 18 Jul 2012 14:29:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrYzw-0002CC-NF for qemu-devel@nongnu.org; Wed, 18 Jul 2012 14:29:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrYzw-0002Bx-F8 for qemu-devel@nongnu.org; Wed, 18 Jul 2012 14:29:20 -0400 Date: Wed, 18 Jul 2012 21:29:50 +0300 From: "Michael S. Tsirkin" Message-ID: <20120718182950.GB2498@redhat.com> References: <1342624074-24650-1-git-send-email-stefanha@linux.vnet.ibm.com> <1342624074-24650-7-git-send-email-stefanha@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1342624074-24650-7-git-send-email-stefanha@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC v9 06/27] virtio-blk: Take PCI memory range into account List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Anthony Liguori , kvm@vger.kernel.org, qemu-devel@nongnu.org, Khoa Huynh , Paolo Bonzini , Asias He On Wed, Jul 18, 2012 at 04:07:33PM +0100, Stefan Hajnoczi wrote: > Support >4 GB physical memory accesses. > > Signed-off-by: Stefan Hajnoczi Need some sane APIs, this is just too scary. > --- > hw/virtio-blk.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c > index abd9386..99654f1 100644 > --- a/hw/virtio-blk.c > +++ b/hw/virtio-blk.c > @@ -64,6 +64,13 @@ static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev) > */ > static inline void *phys_to_host(VirtIOBlock *s, target_phys_addr_t phys) > { > + /* Adjust for 3.6-4 GB PCI memory range */ > + if (phys >= 0x100000000) { > + phys -= 0x100000000 - 0xe0000000; > + } else if (phys >= 0xe0000000) { > + fprintf(stderr, "phys_to_host bad physical address in PCI range %#lx\n", phys); > + exit(1); > + } > return s->phys_mem_zero_host_ptr + phys; > } > > -- > 1.7.10.4