qemu/xen: Add 64 bits big bar support on qemu
PATCH v2 1/1 qemu/xen: Add 64 bits big bar support on qemu
Changes from v1:
- Rebase to qemu upstream from qemu-xen
Currently it is assumed PCI device BAR access < 4G memory. If there is such a device whose BAR size is larger than 4G, it must access > 4G memory address. This patch enable the 64bits big BAR support on qemu.
--- hw/xen_pt.c | 16 ++++++++-------- hw/xen_pt_config_init.c | 42 +++++++++++++++++++++++++++++-------------
hw/xen_pt.c +8 -8
@@ -403,21 +403,21 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s) s->bases[i].access.u = r->base_addr; -if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ; - }else { +else if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type =PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) + type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { - type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }memory_region_init_io (&s->bar[i], &ops, &s->dev,"xen-pci-pt-bar" , r->size);pci_register_bar (&s->dev, i, type, &s->bar[i]); -XEN_PT_LOG (&s->dev,"IO region %i registered (size=0x%08" PRIx64 -" base_addr=0x%08" PRIx64" type: %#x)\n" , +XEN_PT_LOG (&s->dev,"IO region %i registered (size=0x%lx" PRIx64 +" base_addr=0x%lx" PRIx64" type: %#x)\n" , i, r->size, r->base_addr, type); }
hw/xen_pt_config_init.c +29 -13
84 lines not on this page · raw message
Signature · 1 line
1.5.5
Quoted 2 lines · Xudong Hao
Changes from v1:
- Rebase to qemu upstream from qemu-xen
Thanks. Please run scripts/checkpatch.pl on this patch, you'll find some cody style issues that need to be fixed.
Quoted 22 lines
Currently it is assumed PCI device BAR access < 4G memory. If there is such a device whose BAR size is larger than 4G, it must access > 4G memory address. This patch enable the 64bits big BAR support on qemu.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>--- hw/xen_pt.c | 16 ++++++++-------- hw/xen_pt_config_init.c | 42 +++++++++++++++++++++++++++++-------------hw/xen_pt.c +1
-2@@ -403,21 +403,21 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s) s->bases[i].access.u = r->base_addr; -if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ; - }else {
hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s) · line 413
Quoted 10 lines
hw/xen_pt.c +5
-4+else if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type =PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) + type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { - type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }
Aside from the cody style issue here, this changes the behavior for type PCI_BASE_ADDRESS_SPACE_MEMORY. Before we could have:
type = PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_PREFETCH;
now we cannot anymore.
Quoted 16 lines
hw/xen_pt.c +2
-2memory_region_init_io (&s->bar[i], &ops, &s->dev,"xen-pci-pt-bar" , r->size);pci_register_bar (&s->dev, i, type, &s->bar[i]); -XEN_PT_LOG (&s->dev,"IO region %i registered (size=0x%08" PRIx64 -" base_addr=0x%08" PRIx64" type: %#x)\n" , +XEN_PT_LOG (&s->dev,"IO region %i registered (size=0x%lx" PRIx64 +" base_addr=0x%lx" PRIx64" type: %#x)\n" , i, r->size, r->base_addr, type); }hw/xen_pt_config_init.c +0
-0
hw/xen_pt_config_init.c static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 345
Quoted 4 lines
hw/xen_pt_config_init.c +1
-0@@ -342,6 +342,7 @@ static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,#define XEN_PT_BAR_IO_RO_MASK 0x00000003/* BAR ReadOnly mask(I/O) */ #define XEN_PT_BAR_IO_EMU_MASK 0xFFFFFFFC/* BAR emul mask(I/O) */ +static uint64_t xen_pt_get_bar_size (PCIIORegion *r);
there is just one user of xen_pt_get_bar_size, maybe you can just move the implementation here
Quoted 38 lines
hw/xen_pt_config_init.c +19
-1static XenPTBarFlag xen_pt_bar_reg_parse (XenPCIPassthroughState *s,XenPTRegInfo *reg) {@@ -366,7 +367,7 @@ static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s,/* check unused BAR */ r = &d->io_regions[index]; -if (r->size ==0 ) { +if (!xen_pt_get_bar_size (r)) {return XEN_PT_BAR_FLAG_UNUSED ; }@@ -383,6 +384,24 @@ static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s, } } +static bool is_64bit_bar (PCIIORegion *r) +{ +return !!(r->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ); +} + +static uint64_t xen_pt_get_bar_size (PCIIORegion *r) +{ +if (is_64bit_bar (r)) + { +uint64_t size64; + size64 = (r +1 )->size; + size64 <<=32 ; + size64 += r->size; +return size64; + } +return r->size; +} +static inline uint32_t base_address_with_flags (XenHostPCIIORegion *hr) {if (hr->type &XEN_HOST_PCI_REGION_TYPE_IO ) {
hw/xen_pt_config_init.c static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 507
Quoted 9 lines
hw/xen_pt_config_init.c +4
-1@@ -481,7 +500,10 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,switch (s->bases[index].bar_flag) {case XEN_PT_BAR_FLAG_MEM : bar_emu_mask =XEN_PT_BAR_MEM_EMU_MASK ; - bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 ); +if (!r_size) + bar_ro_mask =XEN_PT_BAR_ALLF ; +else + bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 );break ;
Is this an actual mistake everywhere?
There is at least another instance of
bar_ro_mask = something | (r_size - 1);
under the XEN_PT_BAR_FLAG_IO case.
Or is it only a problem with 64 bit bars? If so, could you please explain why?
hw/xen_pt_config_init.c static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 518
Quoted 12 lines
hw/xen_pt_config_init.c +4
-1case XEN_PT_BAR_FLAG_IO : bar_emu_mask =XEN_PT_BAR_IO_EMU_MASK ;@@ -489,7 +511,10 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,break ;case XEN_PT_BAR_FLAG_UPPER : bar_emu_mask =XEN_PT_BAR_ALLF ; - bar_ro_mask =0 ;/* all upper 32bit are R/W */ +if (!r_size) + bar_ro_mask =0 ; +else + bar_ro_mask = r_size -1 ;break ;
bar_ro_mask = r_size ? r_size - 1 : 0;
Quoted 29 lines
hw/xen_pt_config_init.c +1
-10default :break ;@@ -501,22 +526,13 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,/* check whether we need to update the virtual region address or not */ switch (s->bases[index].bar_flag) { +case XEN_PT_BAR_FLAG_UPPER :case XEN_PT_BAR_FLAG_MEM :/* nothing to do */ break ;case XEN_PT_BAR_FLAG_IO :/* nothing to do */ break ; -case XEN_PT_BAR_FLAG_UPPER : -if (cfg_entry->data) { -if (cfg_entry->data != (XEN_PT_BAR_ALLF & ~bar_ro_mask)) { -XEN_PT_WARN (d,"Guest attempt to set high MMIO Base Address. " -"Ignore mapping. " -"(offset: 0x%02x, high address: 0x%08x)\n" , - reg->offset, cfg_entry->data); - } - } -break ;default :break ; }Signature · 1 line
1.5.5
Quoted 2 lines · Xudong Hao
Changes from v1:
- Rebase to qemu upstream from qemu-xen
Thanks. Please run scripts/checkpatch.pl on this patch, you'll find some cody style issues that need to be fixed.
Quoted 22 lines
Currently it is assumed PCI device BAR access < 4G memory. If there is such a device whose BAR size is larger than 4G, it must access > 4G memory address. This patch enable the 64bits big BAR support on qemu.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>--- hw/xen_pt.c | 16 ++++++++-------- hw/xen_pt_config_init.c | 42 +++++++++++++++++++++++++++++-------------hw/xen_pt.c +1
-2@@ -403,21 +403,21 @@ static int xen_pt_register_regions(XenPCIPassthroughState *s) s->bases[i].access.u = r->base_addr; -if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ; - }else {
hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s) · line 413
Quoted 10 lines
hw/xen_pt.c +5
-4+else if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type =PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) + type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { - type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }
Aside from the cody style issue here, this changes the behavior for type PCI_BASE_ADDRESS_SPACE_MEMORY. Before we could have:
type = PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_PREFETCH;
now we cannot anymore.
Quoted 16 lines
hw/xen_pt.c +2
-2memory_region_init_io (&s->bar[i], &ops, &s->dev,"xen-pci-pt-bar" , r->size);pci_register_bar (&s->dev, i, type, &s->bar[i]); -XEN_PT_LOG (&s->dev,"IO region %i registered (size=0x%08" PRIx64 -" base_addr=0x%08" PRIx64" type: %#x)\n" , +XEN_PT_LOG (&s->dev,"IO region %i registered (size=0x%lx" PRIx64 +" base_addr=0x%lx" PRIx64" type: %#x)\n" , i, r->size, r->base_addr, type); }hw/xen_pt_config_init.c +0
-0
hw/xen_pt_config_init.c static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 345
Quoted 4 lines
hw/xen_pt_config_init.c +1
-0@@ -342,6 +342,7 @@ static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,#define XEN_PT_BAR_IO_RO_MASK 0x00000003/* BAR ReadOnly mask(I/O) */ #define XEN_PT_BAR_IO_EMU_MASK 0xFFFFFFFC/* BAR emul mask(I/O) */ +static uint64_t xen_pt_get_bar_size (PCIIORegion *r);
there is just one user of xen_pt_get_bar_size, maybe you can just move the implementation here
Quoted 38 lines
hw/xen_pt_config_init.c +19
-1static XenPTBarFlag xen_pt_bar_reg_parse (XenPCIPassthroughState *s,XenPTRegInfo *reg) {@@ -366,7 +367,7 @@ static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s,/* check unused BAR */ r = &d->io_regions[index]; -if (r->size ==0 ) { +if (!xen_pt_get_bar_size (r)) {return XEN_PT_BAR_FLAG_UNUSED ; }@@ -383,6 +384,24 @@ static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s, } } +static bool is_64bit_bar (PCIIORegion *r) +{ +return !!(r->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ); +} + +static uint64_t xen_pt_get_bar_size (PCIIORegion *r) +{ +if (is_64bit_bar (r)) + { +uint64_t size64; + size64 = (r +1 )->size; + size64 <<=32 ; + size64 += r->size; +return size64; + } +return r->size; +} +static inline uint32_t base_address_with_flags (XenHostPCIIORegion *hr) {if (hr->type &XEN_HOST_PCI_REGION_TYPE_IO ) {
hw/xen_pt_config_init.c static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 507
Quoted 9 lines
hw/xen_pt_config_init.c +4
-1@@ -481,7 +500,10 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,switch (s->bases[index].bar_flag) {case XEN_PT_BAR_FLAG_MEM : bar_emu_mask =XEN_PT_BAR_MEM_EMU_MASK ; - bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 ); +if (!r_size) + bar_ro_mask =XEN_PT_BAR_ALLF ; +else + bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 );break ;
Is this an actual mistake everywhere?
There is at least another instance of
bar_ro_mask = something | (r_size - 1);
under the XEN_PT_BAR_FLAG_IO case.
Or is it only a problem with 64 bit bars? If so, could you please explain why?
hw/xen_pt_config_init.c static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 518
Quoted 12 lines
hw/xen_pt_config_init.c +4
-1case XEN_PT_BAR_FLAG_IO : bar_emu_mask =XEN_PT_BAR_IO_EMU_MASK ;@@ -489,7 +511,10 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,break ;case XEN_PT_BAR_FLAG_UPPER : bar_emu_mask =XEN_PT_BAR_ALLF ; - bar_ro_mask =0 ;/* all upper 32bit are R/W */ +if (!r_size) + bar_ro_mask =0 ; +else + bar_ro_mask = r_size -1 ;break ;
bar_ro_mask = r_size ? r_size - 1 : 0;
Quoted 29 lines
hw/xen_pt_config_init.c +1
-10default :break ;@@ -501,22 +526,13 @@ static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,/* check whether we need to update the virtual region address or not */ switch (s->bases[index].bar_flag) { +case XEN_PT_BAR_FLAG_UPPER :case XEN_PT_BAR_FLAG_MEM :/* nothing to do */ break ;case XEN_PT_BAR_FLAG_IO :/* nothing to do */ break ; -case XEN_PT_BAR_FLAG_UPPER : -if (cfg_entry->data) { -if (cfg_entry->data != (XEN_PT_BAR_ALLF & ~bar_ro_mask)) { -XEN_PT_WARN (d,"Guest attempt to set high MMIO Base Address. " -"Ignore mapping. " -"(offset: 0x%02x, high address: 0x%08x)\n" , - reg->offset, cfg_entry->data); - } - } -break ;default :break ; }Signature · 1 line
1.5.5
Quoted 8 lines
-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Tuesday, September 25, 2012 6:52 PM
To: Hao, Xudong
Cc: Stefano Stabellini; [email protected]; [email protected]; Zhang, Xiantao
Subject: Re: [PATCH v2] qemu/xen: Add 64 bits big bar support on qemu
Quoted 7 lines
Quoted 2 lines · Xudong Hao
Changes from v1:
- Rebase to qemu upstream from qemu-xenThanks. Please run
scripts/checkpatch.plon this patch, you'll find some cody style issues that need to be fixed.
OK, will use this scripts to check code style.
Quoted 37 lines
Quoted 3 lines
Currently it is assumed PCI device BAR access < 4G memory. If there is such a device whose BAR size is larger than 4G, it must access > 4G memory
address.
Quoted 7 lines
This patch enable the 64bits big BAR support on qemu.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>--- hw/xen_pt.c | 16 ++++++++-------- hw/xen_pt_config_init.c | 42+++++++++++++++++++++++++++++-------------
hw/xen_pt.c static int
Quoted 6 lines
hw/xen_pt.c +0
-0@@ -403,21 +403,21 @@ static int
xen_pt_register_regions(XenPCIPassthroughState *s)Quoted 7 lines
hw/xen_pt.c +1
-2s->bases[i].access.u = r->base_addr; -if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ; - }else {hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s) · line 413
Quoted 10 lines
hw/xen_pt.c +5
-4+else if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type =PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) + type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { - type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }
Quoted 8 lines
Aside from the cody style issue here, this changes the behavior for type
PCI_BASE_ADDRESS_SPACE_MEMORY. Before we could have:type = PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_PREFETCH;
now we cannot anymore.
Will change to:
- if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) {
+ if (r->type & XEN_HOST_PCI_REGION_TYPE_IO)
type = PCI_BASE_ADDRESS_SPACE_IO;
- } else {
+ else
type = PCI_BASE_ADDRESS_SPACE_MEMORY;- if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) {
+ if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64)
+ type |= PCI_BASE_ADDRESS_MEM_TYPE_64;
+ else if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH)
type |= PCI_BASE_ADDRESS_MEM_PREFETCH;
- }
- }
Quoted 21 lines
hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s)
Quoted 6 lines
hw/xen_pt.c +0
-1memory_region_init_io (&s->bar[i], &ops, &s->dev,"xen-pci-pt-bar" , r->size);pci_register_bar (&s->dev, i, type, &s->bar[i]); - XEN_PT_LOG(&s->dev, "IO region %i registered(size=0x%08"PRIx64
hw/xen_pt.c static int · line 417
Quoted 2 lines
hw/xen_pt.c +1
-1- " base_addr=0x%08"PRIx64" type: %#x)\n", + XEN_PT_LOG(&s->dev, "IO region %i registered(size=0x%lx"PRIx64
hw/xen_pt_config_init.c static int
Quoted 9 lines
hw/xen_pt.c +1
-0+" base_addr=0x%lx" PRIx64" type: %#x)\n" , i, r->size, r->base_addr, type); }hw/xen_pt_config_init.c +0
-0@@ -342,6 +342,7 @@ static intxen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg
*cfg_entry,hw/xen_pt_config_init.c static int · line 342
Quoted 1 line
hw/xen_pt_config_init.c +0
-0#define XEN_PT_BAR_IO_RO_MASK 0x00000003/* BAR ReadOnly
Quoted 9 lines
mask(I/O) */
hw/xen_pt_config_init.c static int · line 343
Quoted 1 line
hw/xen_pt_config_init.c +0
-0#define XEN_PT_BAR_IO_EMU_MASK 0xFFFFFFFC/* BAR emul mask(I/O) */
hw/xen_pt_config_init.c static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 345
Quoted 2 lines
hw/xen_pt_config_init.c +1
-0+static uint64_t xen_pt_get_bar_size (PCIIORegion *r);there is just one user of
xen_pt_get_bar_size, maybe you can just move the implementation here
Ok, thanks.
Quoted 52 lines
hw/xen_pt_config_init.c static XenPTBarFlag
Quoted 5 lines
hw/xen_pt_config_init.c +0
-0static XenPTBarFlag xen_pt_bar_reg_parse (XenPCIPassthroughState *s,XenPTRegInfo *reg) {@@ -366,7 +367,7 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
hw/xen_pt_config_init.c static XenPTBarFlag
Quoted 9 lines
hw/xen_pt_config_init.c +1
-1/* check unused BAR */ r = &d->io_regions[index]; -if (r->size ==0 ) { +if (!xen_pt_get_bar_size (r)) {return XEN_PT_BAR_FLAG_UNUSED ; }@@ -383,6 +384,24 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
hw/xen_pt_config_init.c static int
Quoted 25 lines
hw/xen_pt_config_init.c +18
-0} } +static bool is_64bit_bar (PCIIORegion *r) +{ +return !!(r->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ); +} + +static uint64_t xen_pt_get_bar_size (PCIIORegion *r) +{ +if (is_64bit_bar (r)) + { +uint64_t size64; + size64 = (r +1 )->size; + size64 <<=32 ; + size64 += r->size; +return size64; + } +return r->size; +} +static inline uint32_t base_address_with_flags (XenHostPCIIORegion *hr) {if (hr->type &XEN_HOST_PCI_REGION_TYPE_IO ) {@@ -481,7 +500,10 @@ static intxen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg
*cfg_entry,hw/xen_pt_config_init.c static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 507
Quoted 9 lines
hw/xen_pt_config_init.c +4
-1switch (s->bases[index].bar_flag) {case XEN_PT_BAR_FLAG_MEM : bar_emu_mask =XEN_PT_BAR_MEM_EMU_MASK ; - bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 ); +if (!r_size) + bar_ro_mask =XEN_PT_BAR_ALLF ; +else + bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 );break ;
Quoted 1 line
Is this an actual mistake everywhere?
It's low 32bit mask for 64 bit bars.
Quoted 5 lines
There is at least another instance of
bar_ro_mask= something | (r_size- 1);under the
XEN_PT_BAR_FLAG_IOcase.
Bar_ro_mask under XEN_PT_BAR_FLAG_IO already be done, I don't change IO case.
Quoted 18 lines
Or is it only a problem with 64 bit bars? If so, could you please explain why?
hw/xen_pt_config_init.c static int
Quoted 3 lines
hw/xen_pt_config_init.c +0
-0case XEN_PT_BAR_FLAG_IO : bar_emu_mask =XEN_PT_BAR_IO_EMU_MASK ;@@ -489,7 +511,10 @@ static intxen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg
*cfg_entry,hw/xen_pt_config_init.c static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 518
Quoted 9 lines
hw/xen_pt_config_init.c +4
-1break ;case XEN_PT_BAR_FLAG_UPPER : bar_emu_mask =XEN_PT_BAR_ALLF ; - bar_ro_mask =0 ;/* all upper 32bit are R/W */ +if (!r_size) + bar_ro_mask =0 ; +else + bar_ro_mask = r_size -1 ;break ;
Quoted 2 lines
bar_ro_mask=r_size?r_size- 1 : 0;
Great. :)
Quoted 8 lines
-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Tuesday, September 25, 2012 6:52 PM
To: Hao, Xudong
Cc: Stefano Stabellini; [email protected]; [email protected]; Zhang, Xiantao
Subject: Re: [PATCH v2] qemu/xen: Add 64 bits big bar support on qemu
Quoted 7 lines
Quoted 2 lines · Xudong Hao
Changes from v1:
- Rebase to qemu upstream from qemu-xenThanks. Please run
scripts/checkpatch.plon this patch, you'll find some cody style issues that need to be fixed.
OK, will use this scripts to check code style.
Quoted 37 lines
Quoted 3 lines
Currently it is assumed PCI device BAR access < 4G memory. If there is such a device whose BAR size is larger than 4G, it must access > 4G memory
address.
Quoted 7 lines
This patch enable the 64bits big BAR support on qemu.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>--- hw/xen_pt.c | 16 ++++++++-------- hw/xen_pt_config_init.c | 42+++++++++++++++++++++++++++++-------------
hw/xen_pt.c static int
Quoted 6 lines
hw/xen_pt.c +0
-0@@ -403,21 +403,21 @@ static int
xen_pt_register_regions(XenPCIPassthroughState *s)Quoted 7 lines
hw/xen_pt.c +1
-2s->bases[i].access.u = r->base_addr; -if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ; - }else {hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s) · line 413
Quoted 10 lines
hw/xen_pt.c +5
-4+else if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type =PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) + type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { - type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }
Quoted 8 lines
Aside from the cody style issue here, this changes the behavior for type
PCI_BASE_ADDRESS_SPACE_MEMORY. Before we could have:type = PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_PREFETCH;
now we cannot anymore.
Will change to:
- if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) {
+ if (r->type & XEN_HOST_PCI_REGION_TYPE_IO)
type = PCI_BASE_ADDRESS_SPACE_IO;
- } else {
+ else
type = PCI_BASE_ADDRESS_SPACE_MEMORY;- if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) {
+ if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64)
+ type |= PCI_BASE_ADDRESS_MEM_TYPE_64;
+ else if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH)
type |= PCI_BASE_ADDRESS_MEM_PREFETCH;
- }
- }
Quoted 21 lines
hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s)
Quoted 6 lines
hw/xen_pt.c +0
-1memory_region_init_io (&s->bar[i], &ops, &s->dev,"xen-pci-pt-bar" , r->size);pci_register_bar (&s->dev, i, type, &s->bar[i]); - XEN_PT_LOG(&s->dev, "IO region %i registered(size=0x%08"PRIx64
hw/xen_pt.c static int · line 417
Quoted 2 lines
hw/xen_pt.c +1
-1- " base_addr=0x%08"PRIx64" type: %#x)\n", + XEN_PT_LOG(&s->dev, "IO region %i registered(size=0x%lx"PRIx64
hw/xen_pt_config_init.c static int
Quoted 9 lines
hw/xen_pt.c +1
-0+" base_addr=0x%lx" PRIx64" type: %#x)\n" , i, r->size, r->base_addr, type); }hw/xen_pt_config_init.c +0
-0@@ -342,6 +342,7 @@ static intxen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg
*cfg_entry,hw/xen_pt_config_init.c static int · line 342
Quoted 1 line
hw/xen_pt_config_init.c +0
-0#define XEN_PT_BAR_IO_RO_MASK 0x00000003/* BAR ReadOnly
Quoted 9 lines
mask(I/O) */
hw/xen_pt_config_init.c static int · line 343
Quoted 1 line
hw/xen_pt_config_init.c +0
-0#define XEN_PT_BAR_IO_EMU_MASK 0xFFFFFFFC/* BAR emul mask(I/O) */
hw/xen_pt_config_init.c static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 345
Quoted 2 lines
hw/xen_pt_config_init.c +1
-0+static uint64_t xen_pt_get_bar_size (PCIIORegion *r);there is just one user of
xen_pt_get_bar_size, maybe you can just move the implementation here
Ok, thanks.
Quoted 52 lines
hw/xen_pt_config_init.c static XenPTBarFlag
Quoted 5 lines
hw/xen_pt_config_init.c +0
-0static XenPTBarFlag xen_pt_bar_reg_parse (XenPCIPassthroughState *s,XenPTRegInfo *reg) {@@ -366,7 +367,7 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
hw/xen_pt_config_init.c static XenPTBarFlag
Quoted 9 lines
hw/xen_pt_config_init.c +1
-1/* check unused BAR */ r = &d->io_regions[index]; -if (r->size ==0 ) { +if (!xen_pt_get_bar_size (r)) {return XEN_PT_BAR_FLAG_UNUSED ; }@@ -383,6 +384,24 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
hw/xen_pt_config_init.c static int
Quoted 25 lines
hw/xen_pt_config_init.c +18
-0} } +static bool is_64bit_bar (PCIIORegion *r) +{ +return !!(r->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ); +} + +static uint64_t xen_pt_get_bar_size (PCIIORegion *r) +{ +if (is_64bit_bar (r)) + { +uint64_t size64; + size64 = (r +1 )->size; + size64 <<=32 ; + size64 += r->size; +return size64; + } +return r->size; +} +static inline uint32_t base_address_with_flags (XenHostPCIIORegion *hr) {if (hr->type &XEN_HOST_PCI_REGION_TYPE_IO ) {@@ -481,7 +500,10 @@ static intxen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg
*cfg_entry,hw/xen_pt_config_init.c static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 507
Quoted 9 lines
hw/xen_pt_config_init.c +4
-1switch (s->bases[index].bar_flag) {case XEN_PT_BAR_FLAG_MEM : bar_emu_mask =XEN_PT_BAR_MEM_EMU_MASK ; - bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 ); +if (!r_size) + bar_ro_mask =XEN_PT_BAR_ALLF ; +else + bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 );break ;
Quoted 1 line
Is this an actual mistake everywhere?
It's low 32bit mask for 64 bit bars.
Quoted 5 lines
There is at least another instance of
bar_ro_mask= something | (r_size- 1);under the
XEN_PT_BAR_FLAG_IOcase.
Bar_ro_mask under XEN_PT_BAR_FLAG_IO already be done, I don't change IO case.
Quoted 18 lines
Or is it only a problem with 64 bit bars? If so, could you please explain why?
hw/xen_pt_config_init.c static int
Quoted 3 lines
hw/xen_pt_config_init.c +0
-0case XEN_PT_BAR_FLAG_IO : bar_emu_mask =XEN_PT_BAR_IO_EMU_MASK ;@@ -489,7 +511,10 @@ static intxen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg
*cfg_entry,hw/xen_pt_config_init.c static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, · line 518
Quoted 9 lines
hw/xen_pt_config_init.c +4
-1break ;case XEN_PT_BAR_FLAG_UPPER : bar_emu_mask =XEN_PT_BAR_ALLF ; - bar_ro_mask =0 ;/* all upper 32bit are R/W */ +if (!r_size) + bar_ro_mask =0 ; +else + bar_ro_mask = r_size -1 ;break ;
Quoted 2 lines
bar_ro_mask=r_size?r_size- 1 : 0;
Great. :)
Quoted 67 lines · Xudong
Quoted 8 lines
-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Tuesday, September 25, 2012 6:52 PM
To: Hao, Xudong
Cc: Stefano Stabellini; [email protected]; [email protected]; Zhang, Xiantao
Subject: Re: [PATCH v2] qemu/xen: Add 64 bits big bar support on qemuQuoted 7 lines
Quoted 2 lines · Xudong Hao
Changes from v1:
- Rebase to qemu upstream from qemu-xenThanks. Please run
scripts/checkpatch.plon this patch, you'll find some cody style issues that need to be fixed.OK, will use this scripts to check code style.
Quoted 37 lines
Quoted 3 lines
Currently it is assumed PCI device BAR access < 4G memory. If there is such a device whose BAR size is larger than 4G, it must access > 4G memory
address.
Quoted 7 lines
This patch enable the 64bits big BAR support on qemu.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>--- hw/xen_pt.c | 16 ++++++++-------- hw/xen_pt_config_init.c | 42+++++++++++++++++++++++++++++-------------
hw/xen_pt.c static int
Quoted 6 lines
hw/xen_pt.c +0
-0@@ -403,21 +403,21 @@ static int
xen_pt_register_regions(XenPCIPassthroughState *s)Quoted 7 lines
hw/xen_pt.c +1
-2s->bases[i].access.u = r->base_addr; -if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ; - }else {hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s) · line 413
Quoted 10 lines
hw/xen_pt.c +5
-4+else if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type =PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) + type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { - type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }Quoted 8 lines
Aside from the cody style issue here, this changes the behavior for type
PCI_BASE_ADDRESS_SPACE_MEMORY. Before we could have:type = PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_PREFETCH;
now we cannot anymore.
Will change to:
hw/xen_pt.c +1
-1-if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ;
hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s) · line 413
Quoted 10 lines
hw/xen_pt.c +4
-4- }else { +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type |=PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }
Isn't it possible that both XEN_HOST_PCI_REGION_TYPE_MEM_64 and XEN_HOST_PCI_REGION_TYPE_PREFETCH are set? It doesn't look like this can cover that case.
The following seems to be what you are looking for:
if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) {
type = PCI_BASE_ADDRESS_SPACE_IO;
} else {
type = PCI_BASE_ADDRESS_SPACE_MEMORY;
if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) {
type |= PCI_BASE_ADDRESS_MEM_PREFETCH;
}
if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64) {
type |= PCI_BASE_ADDRESS_MEM_TYPE_64;
}
}Quoted 51 lines
Quoted 51 lines
hw/xen_pt.c static XenPTBarFlag
Quoted 4 lines
hw/xen_pt.c +0
-0static XenPTBarFlag xen_pt_bar_reg_parse (XenPCIPassthroughState *s,XenPTRegInfo *reg) {@@ -366,7 +367,7 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
hw/xen_pt.c static XenPTBarFlag
Quoted 9 lines
hw/xen_pt.c +1
-1/* check unused BAR */ r = &d->io_regions[index]; -if (r->size ==0 ) { +if (!xen_pt_get_bar_size (r)) {return XEN_PT_BAR_FLAG_UNUSED ; }@@ -383,6 +384,24 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
hw/xen_pt.c static int
Quoted 25 lines
hw/xen_pt.c +18
-0} } +static bool is_64bit_bar (PCIIORegion *r) +{ +return !!(r->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ); +} + +static uint64_t xen_pt_get_bar_size (PCIIORegion *r) +{ +if (is_64bit_bar (r)) + { +uint64_t size64; + size64 = (r +1 )->size; + size64 <<=32 ; + size64 += r->size; +return size64; + } +return r->size; +} +static inline uint32_t base_address_with_flags (XenHostPCIIORegion *hr) {if (hr->type &XEN_HOST_PCI_REGION_TYPE_IO ) {@@ -481,7 +500,10 @@ static intxen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg
*cfg_entry,Quoted 9 lines
hw/xen_pt.c +4
-1switch (s->bases[index].bar_flag) {case XEN_PT_BAR_FLAG_MEM : bar_emu_mask =XEN_PT_BAR_MEM_EMU_MASK ; - bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 ); +if (!r_size) + bar_ro_mask =XEN_PT_BAR_ALLF ; +else + bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 );break ;
Quoted 3 lines
Quoted 1 line
Is this an actual mistake everywhere?
It's low 32bit mask for 64 bit bars.
I see. It is a good idea to add a line of comment in the code saying that.
Quoted 67 lines · Xudong
Quoted 8 lines
-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Tuesday, September 25, 2012 6:52 PM
To: Hao, Xudong
Cc: Stefano Stabellini; [email protected]; [email protected]; Zhang, Xiantao
Subject: Re: [PATCH v2] qemu/xen: Add 64 bits big bar support on qemuQuoted 7 lines
Quoted 2 lines · Xudong Hao
Changes from v1:
- Rebase to qemu upstream from qemu-xenThanks. Please run
scripts/checkpatch.plon this patch, you'll find some cody style issues that need to be fixed.OK, will use this scripts to check code style.
Quoted 37 lines
Quoted 3 lines
Currently it is assumed PCI device BAR access < 4G memory. If there is such a device whose BAR size is larger than 4G, it must access > 4G memory
address.
Quoted 7 lines
This patch enable the 64bits big BAR support on qemu.
Signed-off-by Xudong Hao <[email protected]>Signed-off-by Xiantao Zhang <[email protected]>--- hw/xen_pt.c | 16 ++++++++-------- hw/xen_pt_config_init.c | 42+++++++++++++++++++++++++++++-------------
hw/xen_pt.c static int
Quoted 6 lines
hw/xen_pt.c +0
-0@@ -403,21 +403,21 @@ static int
xen_pt_register_regions(XenPCIPassthroughState *s)Quoted 7 lines
hw/xen_pt.c +1
-2s->bases[i].access.u = r->base_addr; -if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ; - }else {hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s) · line 413
Quoted 10 lines
hw/xen_pt.c +5
-4+else if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type =PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) + type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { - type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }Quoted 8 lines
Aside from the cody style issue here, this changes the behavior for type
PCI_BASE_ADDRESS_SPACE_MEMORY. Before we could have:type = PCI_BASE_ADDRESS_SPACE_MEMORY|PCI_BASE_ADDRESS_MEM_PREFETCH;
now we cannot anymore.
Will change to:
hw/xen_pt.c +1
-1-if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ;
hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s) · line 413
Quoted 10 lines
hw/xen_pt.c +4
-4- }else { +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type |=PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }
Isn't it possible that both XEN_HOST_PCI_REGION_TYPE_MEM_64 and XEN_HOST_PCI_REGION_TYPE_PREFETCH are set? It doesn't look like this can cover that case.
The following seems to be what you are looking for:
if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) {
type = PCI_BASE_ADDRESS_SPACE_IO;
} else {
type = PCI_BASE_ADDRESS_SPACE_MEMORY;
if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) {
type |= PCI_BASE_ADDRESS_MEM_PREFETCH;
}
if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64) {
type |= PCI_BASE_ADDRESS_MEM_TYPE_64;
}
}Quoted 51 lines
Quoted 51 lines
hw/xen_pt.c static XenPTBarFlag
Quoted 4 lines
hw/xen_pt.c +0
-0static XenPTBarFlag xen_pt_bar_reg_parse (XenPCIPassthroughState *s,XenPTRegInfo *reg) {@@ -366,7 +367,7 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
hw/xen_pt.c static XenPTBarFlag
Quoted 9 lines
hw/xen_pt.c +1
-1/* check unused BAR */ r = &d->io_regions[index]; -if (r->size ==0 ) { +if (!xen_pt_get_bar_size (r)) {return XEN_PT_BAR_FLAG_UNUSED ; }@@ -383,6 +384,24 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
hw/xen_pt.c static int
Quoted 25 lines
hw/xen_pt.c +18
-0} } +static bool is_64bit_bar (PCIIORegion *r) +{ +return !!(r->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ); +} + +static uint64_t xen_pt_get_bar_size (PCIIORegion *r) +{ +if (is_64bit_bar (r)) + { +uint64_t size64; + size64 = (r +1 )->size; + size64 <<=32 ; + size64 += r->size; +return size64; + } +return r->size; +} +static inline uint32_t base_address_with_flags (XenHostPCIIORegion *hr) {if (hr->type &XEN_HOST_PCI_REGION_TYPE_IO ) {@@ -481,7 +500,10 @@ static intxen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg
*cfg_entry,Quoted 9 lines
hw/xen_pt.c +4
-1switch (s->bases[index].bar_flag) {case XEN_PT_BAR_FLAG_MEM : bar_emu_mask =XEN_PT_BAR_MEM_EMU_MASK ; - bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 ); +if (!r_size) + bar_ro_mask =XEN_PT_BAR_ALLF ; +else + bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 );break ;
Quoted 3 lines
Quoted 1 line
Is this an actual mistake everywhere?
It's low 32bit mask for 64 bit bars.
I see. It is a good idea to add a line of comment in the code saying that.
Quoted 23 lines
-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Wednesday, September 26, 2012 6:57 PM
To: Hao, Xudong
Cc: Stefano Stabellini; [email protected]; [email protected]; Zhang, Xiantao
Subject: RE: [PATCH v2] qemu/xen: Add 64 bits big bar support on qemuQuoted 4 lines
Will change to:
hw/xen_pt.c +1
-1-if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ;hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s) · line 413
Quoted 10 lines
hw/xen_pt.c +4
-4- }else { +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type |=PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }
Quoted 3 lines
Isn't it possible that both
XEN_HOST_PCI_REGION_TYPE_MEM_64andXEN_HOST_PCI_REGION_TYPE_PREFETCHare set? It doesn't look like this can cover that case.
It's possible. Thanks comments.
Quoted 68 lines
The following seems to be what you are looking for:
if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) { type = PCI_BASE_ADDRESS_SPACE_IO; } else { type = PCI_BASE_ADDRESS_SPACE_MEMORY; if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) { type |= PCI_BASE_ADDRESS_MEM_PREFETCH; } if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64) { type |= PCI_BASE_ADDRESS_MEM_TYPE_64; } }Quoted 1 line
Quoted 1 line
Quoted 1 line
static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState
*s,
Quoted 28 lines
Quoted 28 lines
Review static XenPTBarFlag
Quoted 3 lines
XenPTRegInfo *reg)
{(quoted diff) +0
-0@@ -366,7 +367,7 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
hw/xen_pt_config_init.c static XenPTBarFlag
Quoted 9 lines
hw/xen_pt_config_init.c +1
-1/* check unused BAR */ r = &d->io_regions[index]; -if (r->size ==0 ) { +if (!xen_pt_get_bar_size (r)) {return XEN_PT_BAR_FLAG_UNUSED ; }@@ -383,6 +384,24 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
Quoted 14 lines
hw/xen_pt_config_init.c +11
-0} } +static bool is_64bit_bar (PCIIORegion *r) +{ +return !!(r->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ); +} + +static uint64_t xen_pt_get_bar_size (PCIIORegion *r) +{ +if (is_64bit_bar (r)) + { +uint64_t size64; + size64 = (r +1 )->size;Quoted 8 lines
Quoted 8 lines
hw/xen_pt_config_init.c static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s,
Quoted 8 lines
hw/xen_pt_config_init.c +7
-0+ size64 <<=32 ; + size64 += r->size; +return size64; + } +return r->size; +} + static inline uint32_t base_address_with_flags(XenHostPCIIORegion*hr)
Quoted 4 lines
Quoted 4 lines
hw/xen_pt_config_init.c static int
Quoted 3 lines
hw/xen_pt_config_init.c +0
-0{if (hr->type &XEN_HOST_PCI_REGION_TYPE_IO ) {@@ -481,7 +500,10 @@ static intxen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg
*cfg_entry,Quoted 8 lines
Quoted 8 lines
hw/xen_pt_config_init.c static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
Quoted 8 lines
hw/xen_pt_config_init.c +4
-1switch (s->bases[index].bar_flag) {case XEN_PT_BAR_FLAG_MEM : bar_emu_mask =XEN_PT_BAR_MEM_EMU_MASK ; - bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 ); +if (!r_size) + bar_ro_mask =XEN_PT_BAR_ALLF ; +else + bar_ro_mask = XEN_PT_BAR_MEM_RO_MASK | (r_size -1);
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Review static int · line 507
Quoted 1 line
(quoted diff) +0
-0break;Is this an actual mistake everywhere?
It's low 32bit mask for 64 bit bars.
I see. It is a good idea to add a line of comment in the code saying that.
OK, I'll add code comment.
Quoted 23 lines
-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Wednesday, September 26, 2012 6:57 PM
To: Hao, Xudong
Cc: Stefano Stabellini; [email protected]; [email protected]; Zhang, Xiantao
Subject: RE: [PATCH v2] qemu/xen: Add 64 bits big bar support on qemuQuoted 4 lines
Will change to:
hw/xen_pt.c +1
-1-if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_IO ) type =PCI_BASE_ADDRESS_SPACE_IO ;hw/xen_pt.c static int xen_pt_register_regions(XenPCIPassthroughState *s) · line 413
Quoted 10 lines
hw/xen_pt.c +4
-4- }else { +else type =PCI_BASE_ADDRESS_SPACE_MEMORY ; -if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) { +if (r->type &XEN_HOST_PCI_REGION_TYPE_MEM_64 ) + type |=PCI_BASE_ADDRESS_MEM_TYPE_64 ; +else if (r->type &XEN_HOST_PCI_REGION_TYPE_PREFETCH ) type |=PCI_BASE_ADDRESS_MEM_PREFETCH ; - } - }
Quoted 3 lines
Isn't it possible that both
XEN_HOST_PCI_REGION_TYPE_MEM_64andXEN_HOST_PCI_REGION_TYPE_PREFETCHare set? It doesn't look like this can cover that case.
It's possible. Thanks comments.
Quoted 68 lines
The following seems to be what you are looking for:
if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) { type = PCI_BASE_ADDRESS_SPACE_IO; } else { type = PCI_BASE_ADDRESS_SPACE_MEMORY; if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) { type |= PCI_BASE_ADDRESS_MEM_PREFETCH; } if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64) { type |= PCI_BASE_ADDRESS_MEM_TYPE_64; } }Quoted 1 line
Quoted 1 line
Quoted 1 line
static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState
*s,
Quoted 28 lines
Quoted 28 lines
Review static XenPTBarFlag
Quoted 3 lines
XenPTRegInfo *reg)
{(quoted diff) +0
-0@@ -366,7 +367,7 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
hw/xen_pt_config_init.c static XenPTBarFlag
Quoted 9 lines
hw/xen_pt_config_init.c +1
-1/* check unused BAR */ r = &d->io_regions[index]; -if (r->size ==0 ) { +if (!xen_pt_get_bar_size (r)) {return XEN_PT_BAR_FLAG_UNUSED ; }@@ -383,6 +384,24 @@ static XenPTBarFlagxen_pt_bar_reg_parse(XenPCIPassthroughState *s,
Quoted 14 lines
hw/xen_pt_config_init.c +11
-0} } +static bool is_64bit_bar (PCIIORegion *r) +{ +return !!(r->type &PCI_BASE_ADDRESS_MEM_TYPE_64 ); +} + +static uint64_t xen_pt_get_bar_size (PCIIORegion *r) +{ +if (is_64bit_bar (r)) + { +uint64_t size64; + size64 = (r +1 )->size;Quoted 8 lines
Quoted 8 lines
hw/xen_pt_config_init.c static XenPTBarFlag xen_pt_bar_reg_parse(XenPCIPassthroughState *s,
Quoted 8 lines
hw/xen_pt_config_init.c +7
-0+ size64 <<=32 ; + size64 += r->size; +return size64; + } +return r->size; +} + static inline uint32_t base_address_with_flags(XenHostPCIIORegion*hr)
Quoted 4 lines
Quoted 4 lines
hw/xen_pt_config_init.c static int
Quoted 3 lines
hw/xen_pt_config_init.c +0
-0{if (hr->type &XEN_HOST_PCI_REGION_TYPE_IO ) {@@ -481,7 +500,10 @@ static intxen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg
*cfg_entry,Quoted 8 lines
Quoted 8 lines
hw/xen_pt_config_init.c static int xen_pt_bar_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
Quoted 8 lines
hw/xen_pt_config_init.c +4
-1switch (s->bases[index].bar_flag) {case XEN_PT_BAR_FLAG_MEM : bar_emu_mask =XEN_PT_BAR_MEM_EMU_MASK ; - bar_ro_mask =XEN_PT_BAR_MEM_RO_MASK | (r_size -1 ); +if (!r_size) + bar_ro_mask =XEN_PT_BAR_ALLF ; +else + bar_ro_mask = XEN_PT_BAR_MEM_RO_MASK | (r_size -1);
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Review static int · line 507
Quoted 1 line
(quoted diff) +0
-0break;Is this an actual mistake everywhere?
It's low 32bit mask for 64 bit bars.
I see. It is a good idea to add a line of comment in the code saying that.
OK, I'll add code comment.