diff mbox

[2/2] qemu-kvm/pci-assign: 64 bits bar emulation

Message ID 1351834702-25937-2-git-send-email-xudong.hao@intel.com
State New
Headers show

Commit Message

Hao, Xudong Nov. 2, 2012, 5:38 a.m. UTC
Enable 64 bits bar emulation.

Signed-off-by: Xudong Hao <xudong.hao@intel.com>
---
 hw/kvm/pci-assign.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

Comments

Blue Swirl Nov. 3, 2012, 10:44 a.m. UTC | #1
On Fri, Nov 2, 2012 at 5:38 AM, Xudong Hao <xudong.hao@intel.com> wrote:
> Enable 64 bits bar emulation.
>
> Signed-off-by: Xudong Hao <xudong.hao@intel.com>
> ---
>  hw/kvm/pci-assign.c |   18 ++++++++++++------
>  1 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c
> index 05b93d9..f1f8d1e 100644
> --- a/hw/kvm/pci-assign.c
> +++ b/hw/kvm/pci-assign.c
> @@ -46,6 +46,7 @@
>  #define IORESOURCE_IRQ      0x00000400
>  #define IORESOURCE_DMA      0x00000800
>  #define IORESOURCE_PREFETCH 0x00002000  /* No side effects */
> +#define IORESOURCE_MEM_64   0x00100000
>
>  //#define DEVICE_ASSIGNMENT_DEBUG
>
> @@ -442,9 +443,13 @@ static int assigned_dev_register_regions(PCIRegion *io_regions,
>
>          /* handle memory io regions */
>          if (cur_region->type & IORESOURCE_MEM) {
> -            int t = cur_region->type & IORESOURCE_PREFETCH
> -                ? PCI_BASE_ADDRESS_MEM_PREFETCH
> -                : PCI_BASE_ADDRESS_SPACE_MEMORY;
> +            int t = PCI_BASE_ADDRESS_SPACE_MEMORY;
> +            if (cur_region->type & IORESOURCE_PREFETCH) {
> +                t |= PCI_BASE_ADDRESS_MEM_PREFETCH;
> +            }
> +            if (cur_region->type & IORESOURCE_MEM_64) {
> +                t |= PCI_BASE_ADDRESS_MEM_TYPE_64;
> +            }
>
>              /* map physical memory */
>              pci_dev->v_addrs[i].u.r_virtbase = mmap(NULL, cur_region->size,
> @@ -468,8 +473,8 @@ static int assigned_dev_register_regions(PCIRegion *io_regions,
>                  (cur_region->base_addr & 0xFFF);
>
>              if (cur_region->size & 0xFFF) {
> -                error_report("PCI region %d at address 0x%" PRIx64 " has "
> -                             "size 0x%" PRIx64 ", which is not a multiple of "
> +                error_report("PCI region %d at address 0lx%" PRIx64 " has "
> +                             "size 0lx%" PRIx64 ", which is not a multiple of "

Adding 'l' to '0x' prefix does not make sense.

>                               "4K.  You might experience some performance hit "
>                               "due to that.",
>                               i, cur_region->base_addr, cur_region->size);
> @@ -638,7 +643,8 @@ again:
>          rp->valid = 0;
>          rp->resource_fd = -1;
>          size = end - start + 1;
> -        flags &= IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH;
> +        flags &= IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH
> +                 | IORESOURCE_MEM_64;
>          if (size == 0 || (flags & ~IORESOURCE_PREFETCH) == 0) {
>              continue;
>          }
> --
> 1.5.5
>
>
Hao, Xudong Nov. 5, 2012, 7:42 a.m. UTC | #2
> -----Original Message-----

> From: Blue Swirl [mailto:blauwirbel@gmail.com]

> Sent: Saturday, November 03, 2012 6:44 PM

> To: Hao, Xudong

> Cc: qemu-devel@nongnu.org; avi@redhat.com; kvm@vger.kernel.org

> Subject: Re: [Qemu-devel] [PATCH 2/2] qemu-kvm/pci-assign: 64 bits bar

> emulation

> 

> On Fri, Nov 2, 2012 at 5:38 AM, Xudong Hao <xudong.hao@intel.com> wrote:

> > Enable 64 bits bar emulation.

> >

> > Signed-off-by: Xudong Hao <xudong.hao@intel.com>

> > ---

> >  hw/kvm/pci-assign.c |   18 ++++++++++++------

> >  1 files changed, 12 insertions(+), 6 deletions(-)

> >

> > diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c

> > index 05b93d9..f1f8d1e 100644

> > --- a/hw/kvm/pci-assign.c

> > +++ b/hw/kvm/pci-assign.c

> > @@ -46,6 +46,7 @@

> >  #define IORESOURCE_IRQ      0x00000400

> >  #define IORESOURCE_DMA      0x00000800

> >  #define IORESOURCE_PREFETCH 0x00002000  /* No side effects */

> > +#define IORESOURCE_MEM_64   0x00100000

> >

> >  //#define DEVICE_ASSIGNMENT_DEBUG

> >

> > @@ -442,9 +443,13 @@ static int assigned_dev_register_regions(PCIRegion

> *io_regions,

> >

> >          /* handle memory io regions */

> >          if (cur_region->type & IORESOURCE_MEM) {

> > -            int t = cur_region->type & IORESOURCE_PREFETCH

> > -                ? PCI_BASE_ADDRESS_MEM_PREFETCH

> > -                : PCI_BASE_ADDRESS_SPACE_MEMORY;

> > +            int t = PCI_BASE_ADDRESS_SPACE_MEMORY;

> > +            if (cur_region->type & IORESOURCE_PREFETCH) {

> > +                t |= PCI_BASE_ADDRESS_MEM_PREFETCH;

> > +            }

> > +            if (cur_region->type & IORESOURCE_MEM_64) {

> > +                t |= PCI_BASE_ADDRESS_MEM_TYPE_64;

> > +            }

> >

> >              /* map physical memory */

> >              pci_dev->v_addrs[i].u.r_virtbase = mmap(NULL,

> cur_region->size,

> > @@ -468,8 +473,8 @@ static int assigned_dev_register_regions(PCIRegion

> *io_regions,

> >                  (cur_region->base_addr & 0xFFF);

> >

> >              if (cur_region->size & 0xFFF) {

> > -                error_report("PCI region %d at address 0x%" PRIx64 "

> has "

> > -                             "size 0x%" PRIx64 ", which is not a

> multiple of "

> > +                error_report("PCI region %d at address 0lx%" PRIx64 "

> has "

> > +                             "size 0lx%" PRIx64 ", which is not a

> multiple of "

> 

> Adding 'l' to '0x' prefix does not make sense.

> 


Thanks review it, changes to: 
+                error_report("PCI region %d at address 0x%016" PRIx64 " has "
+                             "size 0x%016" PRIx64 ", which is not a multiple of "
diff mbox

Patch

diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c
index 05b93d9..f1f8d1e 100644
--- a/hw/kvm/pci-assign.c
+++ b/hw/kvm/pci-assign.c
@@ -46,6 +46,7 @@ 
 #define IORESOURCE_IRQ      0x00000400
 #define IORESOURCE_DMA      0x00000800
 #define IORESOURCE_PREFETCH 0x00002000  /* No side effects */
+#define IORESOURCE_MEM_64   0x00100000
 
 //#define DEVICE_ASSIGNMENT_DEBUG
 
@@ -442,9 +443,13 @@  static int assigned_dev_register_regions(PCIRegion *io_regions,
 
         /* handle memory io regions */
         if (cur_region->type & IORESOURCE_MEM) {
-            int t = cur_region->type & IORESOURCE_PREFETCH
-                ? PCI_BASE_ADDRESS_MEM_PREFETCH
-                : PCI_BASE_ADDRESS_SPACE_MEMORY;
+            int t = PCI_BASE_ADDRESS_SPACE_MEMORY;
+            if (cur_region->type & IORESOURCE_PREFETCH) {
+                t |= PCI_BASE_ADDRESS_MEM_PREFETCH;
+            }
+            if (cur_region->type & IORESOURCE_MEM_64) {
+                t |= PCI_BASE_ADDRESS_MEM_TYPE_64;
+            }
 
             /* map physical memory */
             pci_dev->v_addrs[i].u.r_virtbase = mmap(NULL, cur_region->size,
@@ -468,8 +473,8 @@  static int assigned_dev_register_regions(PCIRegion *io_regions,
                 (cur_region->base_addr & 0xFFF);
 
             if (cur_region->size & 0xFFF) {
-                error_report("PCI region %d at address 0x%" PRIx64 " has "
-                             "size 0x%" PRIx64 ", which is not a multiple of "
+                error_report("PCI region %d at address 0lx%" PRIx64 " has "
+                             "size 0lx%" PRIx64 ", which is not a multiple of "
                              "4K.  You might experience some performance hit "
                              "due to that.",
                              i, cur_region->base_addr, cur_region->size);
@@ -638,7 +643,8 @@  again:
         rp->valid = 0;
         rp->resource_fd = -1;
         size = end - start + 1;
-        flags &= IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH;
+        flags &= IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH
+                 | IORESOURCE_MEM_64;
         if (size == 0 || (flags & ~IORESOURCE_PREFETCH) == 0) {
             continue;
         }