Tim Moore
2009-Apr-13 14:12 UTC
[Xen-devel] pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4]
Hi Ian, I noticed that you updated the qemu-dm passthrough debug messages recently and was wondering if you could help me with this issue? (Please see xen-devel postings for further info) To sum things up, I have a non-hvm DomU with PCI Passthrough working successfully. The problem is that this is not working for any hvm DomU. Is this BAR warning related to my issue? I`m assume the vendor driver is attempting to set BAR and not just accepting the values passed in. What I find strange is that I am using the vendor driver under the non-hvm DomU also. Maybe pcifront is doing something that qemu-dm is not ? Here is the qemu-dm log output ... (relevant parts) register_real_device: Assigning real physical device 03:00.0 ... pt_register_regions: IO region registered (size=0x01000000 base_addr=0xb2000000) pt_register_regions: IO region registered (size=0x10000000 base_addr=0xe000000c) pt_register_regions: IO region registered (size=0x02000000 base_addr=0xb0000004) pt_register_regions: IO region registered (size=0x00000080 base_addr=0x00001001) pt_msi_setup: msi mapped with pirq ff register_real_device: Real physical device 03:00.0 registered successfuly! IRQ type = MSI-INTx Register xen platform. Done register platform. platform_fixed_ioport: changed ro/rw state of ROM memory area. now is rw state. xs_read(/local/domain/0/device-model/3/xen_extended_power_mgmt): read error xs_read(): vncpasswd get error. /vm/900c41f9-a3f6-d78f-2270-93e116ee07e7/vncpasswd. I/O request not ready: 0, ptr: 0, port: 0, data: 0, count: 0, size: 0 pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4] pt_iomem_map: e_phys=e0000000 maddr=e0000000 type=8 len=268435456 index=1 first_map=1 cirrus vga map change while on lfb mode pt_iomem_map: e_phys=f2000000 maddr=b0000000 type=0 len=33554432 index=3 first_map=1 pt_iomem_map: e_phys=f4000000 maddr=b2000000 type=0 len=16777216 index=0 first_map=1 pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4] pt_ioport_map: e_phys=c200 pio_base=1000 len=128 index=5 first_map=1 mapping vram to f0000000 - f0400000 platform_fixed_ioport: changed ro/rw state of ROM memory area. now is rw state. platform_fixed_ioport: changed ro/rw state of ROM memory area. now is ro state. track_dirty_vram(f0000000, 26) failed (-1, 22) track_dirty_vram(f0000000, 26) failed (-1, 22) track_dirty_vram(f0000000, 26) failed (-1, 22) track_dirty_vram(f0000000, 26) failed (-1, 22) Many Thanks, Tim _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Leonard Michelet
2009-Apr-14 14:17 UTC
Re: [Xen-devel] pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4]
Hi, I can''t tell you why it''s not working but I might help you to understand the error message. Your driver is trying to write something at the address 0x30 in the PCI port. This address correspond to the ROM''s card address in the address space (http://pficheux.free.fr/articles/lmf/pci/registres_pci.gif). Does your card use ROM? Usually, BARs and ROM are set while VM is starting (with remapping) and Xen flag unset BARs as "unused". So when strange drivers write things in unused PCI registers this error message warn you, but I''m not sure it stop the writing order. I have a card which work great despite these messages, so I don''t think this is the problem. I hope this will help you. Can I ask you what card do you try to use? Good luck. Léonard http://pficheux.free.fr/articles/lmf/pci/registres_pci.gif Tim Moore-13 wrote:> > Hi Ian, > > I noticed that you updated the qemu-dm passthrough debug messages recently > and was wondering if you could help me with this issue? > (Please see xen-devel postings for further info) > > To sum things up, I have a non-hvm DomU with PCI Passthrough working > successfully. The problem is that this is not working for any hvm DomU. Is > this BAR warning related to my issue? I`m assume the vendor driver is > attempting to set BAR and not just accepting the values passed in. > > What I find strange is that I am using the vendor driver under the non-hvm > DomU also. Maybe pcifront is doing something that qemu-dm is not ? > > Here is the qemu-dm log output ... (relevant parts) > > register_real_device: Assigning real physical device 03:00.0 ... > pt_register_regions: IO region registered (size=0x01000000 > base_addr=0xb2000000) > pt_register_regions: IO region registered (size=0x10000000 > base_addr=0xe000000c) > pt_register_regions: IO region registered (size=0x02000000 > base_addr=0xb0000004) > pt_register_regions: IO region registered (size=0x00000080 > base_addr=0x00001001) > pt_msi_setup: msi mapped with pirq ff > register_real_device: Real physical device 03:00.0 registered successfuly! > IRQ type = MSI-INTx > Register xen platform. > Done register platform. > platform_fixed_ioport: changed ro/rw state of ROM memory area. now is rw > state. > xs_read(/local/domain/0/device-model/3/xen_extended_power_mgmt): read > error > xs_read(): vncpasswd get error. > /vm/900c41f9-a3f6-d78f-2270-93e116ee07e7/vncpasswd. > I/O request not ready: 0, ptr: 0, port: 0, data: 0, count: 0, size: 0 > pt_pci_write_config: Warning: Guest attempt to set address to unused Base > Address Register. [00:03.0][Offset:30h][Length:4] > pt_iomem_map: e_phys=e0000000 maddr=e0000000 type=8 len=268435456 index=1 > first_map=1 > cirrus vga map change while on lfb mode > pt_iomem_map: e_phys=f2000000 maddr=b0000000 type=0 len=33554432 index=3 > first_map=1 > pt_iomem_map: e_phys=f4000000 maddr=b2000000 type=0 len=16777216 index=0 > first_map=1 > pt_pci_write_config: Warning: Guest attempt to set address to unused Base > Address Register. [00:03.0][Offset:30h][Length:4] > pt_ioport_map: e_phys=c200 pio_base=1000 len=128 index=5 first_map=1 > mapping vram to f0000000 - f0400000 > platform_fixed_ioport: changed ro/rw state of ROM memory area. now is rw > state. > platform_fixed_ioport: changed ro/rw state of ROM memory area. now is ro > state. > track_dirty_vram(f0000000, 26) failed (-1, 22) > track_dirty_vram(f0000000, 26) failed (-1, 22) > track_dirty_vram(f0000000, 26) failed (-1, 22) > track_dirty_vram(f0000000, 26) failed (-1, 22) > > Many Thanks, > Tim > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > >-- View this message in context: http://www.nabble.com/pt_pci_write_config%3A-Warning%3A-Guest-attempt-to-set-address-to-unused-Base-Address-Register.--00%3A03.0--Offset%3A30h--Length%3A4--tp23022929p23040258.html Sent from the Xen - Dev mailing list archive at Nabble.com. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Tim Moore
2009-Apr-14 18:42 UTC
RE: [Xen-devel] pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4]
Hi Léonard, Thank you for your reply. I do understand the driver is trying to write to 0x30 and also that it is more than likely vBar / pBar related. (not sure what the difference is!!) Yes I''m pretty sure the card has a ROM, I flashed it with the latest bios recently (Nvidia Geforce 8800 GTS 512). I also have a Nvidia Geforce 9500 GT which exhibits the same symptoms, although it does use the same driver. I`m very new to developing at this level, with PCI bus etc .. I have a great understanding otherwise and I didnt write Xen so i`m finding it difficult to overcome these last obstacles! Does your card work with HVM ? What model is it ? Again - Thanks, Tim ________________________________________ From: xen-devel-bounces@lists.xensource.com [xen-devel-bounces@lists.xensource.com] On Behalf Of Leonard Michelet [leonard.michelet@gmail.com] Sent: 14 April 2009 15:17 To: xen-devel@lists.xensource.com Subject: Re: [Xen-devel] pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4] Hi, I can''t tell you why it''s not working but I might help you to understand the error message. Your driver is trying to write something at the address 0x30 in the PCI port. This address correspond to the ROM''s card address in the address space (http://pficheux.free.fr/articles/lmf/pci/registres_pci.gif). Does your card use ROM? Usually, BARs and ROM are set while VM is starting (with remapping) and Xen flag unset BARs as "unused". So when strange drivers write things in unused PCI registers this error message warn you, but I''m not sure it stop the writing order. I have a card which work great despite these messages, so I don''t think this is the problem. I hope this will help you. Can I ask you what card do you try to use? Good luck. Léonard http://pficheux.free.fr/articles/lmf/pci/registres_pci.gif Tim Moore-13 wrote:> > Hi Ian, > > I noticed that you updated the qemu-dm passthrough debug messages recently > and was wondering if you could help me with this issue? > (Please see xen-devel postings for further info) > > To sum things up, I have a non-hvm DomU with PCI Passthrough working > successfully. The problem is that this is not working for any hvm DomU. Is > this BAR warning related to my issue? I`m assume the vendor driver is > attempting to set BAR and not just accepting the values passed in. > > What I find strange is that I am using the vendor driver under the non-hvm > DomU also. Maybe pcifront is doing something that qemu-dm is not ? > > Here is the qemu-dm log output ... (relevant parts) > > register_real_device: Assigning real physical device 03:00.0 ... > pt_register_regions: IO region registered (size=0x01000000 > base_addr=0xb2000000) > pt_register_regions: IO region registered (size=0x10000000 > base_addr=0xe000000c) > pt_register_regions: IO region registered (size=0x02000000 > base_addr=0xb0000004) > pt_register_regions: IO region registered (size=0x00000080 > base_addr=0x00001001) > pt_msi_setup: msi mapped with pirq ff > register_real_device: Real physical device 03:00.0 registered successfuly! > IRQ type = MSI-INTx > Register xen platform. > Done register platform. > platform_fixed_ioport: changed ro/rw state of ROM memory area. now is rw > state. > xs_read(/local/domain/0/device-model/3/xen_extended_power_mgmt): read > error > xs_read(): vncpasswd get error. > /vm/900c41f9-a3f6-d78f-2270-93e116ee07e7/vncpasswd. > I/O request not ready: 0, ptr: 0, port: 0, data: 0, count: 0, size: 0 > pt_pci_write_config: Warning: Guest attempt to set address to unused Base > Address Register. [00:03.0][Offset:30h][Length:4] > pt_iomem_map: e_phys=e0000000 maddr=e0000000 type=8 len=268435456 index=1 > first_map=1 > cirrus vga map change while on lfb mode > pt_iomem_map: e_phys=f2000000 maddr=b0000000 type=0 len=33554432 index=3 > first_map=1 > pt_iomem_map: e_phys=f4000000 maddr=b2000000 type=0 len=16777216 index=0 > first_map=1 > pt_pci_write_config: Warning: Guest attempt to set address to unused Base > Address Register. [00:03.0][Offset:30h][Length:4] > pt_ioport_map: e_phys=c200 pio_base=1000 len=128 index=5 first_map=1 > mapping vram to f0000000 - f0400000 > platform_fixed_ioport: changed ro/rw state of ROM memory area. now is rw > state. > platform_fixed_ioport: changed ro/rw state of ROM memory area. now is ro > state. > track_dirty_vram(f0000000, 26) failed (-1, 22) > track_dirty_vram(f0000000, 26) failed (-1, 22) > track_dirty_vram(f0000000, 26) failed (-1, 22) > track_dirty_vram(f0000000, 26) failed (-1, 22) > > Many Thanks, > Tim > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > >-- View this message in context: http://www.nabble.com/pt_pci_write_config%3A-Warning%3A-Guest-attempt-to-set-address-to-unused-Base-Address-Register.--00%3A03.0--Offset%3A30h--Length%3A4--tp23022929p23040258.html Sent from the Xen - Dev mailing list archive at Nabble.com. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Yuji Shimada
2009-Apr-16 05:53 UTC
[Xen-devel] [PATCH] ioemu: make unused Base Address Register 0 hardwired.
Hi Tim,> pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4]The warning message is originated from my patch. But I think your booting failure is not caused by it as Leonard say. This patch modifies to make unused Base Address Register 0 hardwired. Because unused BAR should not be changed by guest software. The warning message will be disappeared with this patch. Unfortunately I don''t have a device which causes the same symptom. Could you test this patch? Thanks, -- Yuji Shimada Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp> diff --git a/hw/pass-through.c b/hw/pass-through.c index 11382fd..20c7ebc 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -416,11 +416,9 @@ static struct pt_reg_info_tbl pt_emu_reg_header0_tbl[] = { .offset = PCI_ROM_ADDRESS, .size = 4, .init_val = 0x00000000, - .ro_mask = 0x000007FE, - .emu_mask = 0xFFFFF800, .init = pt_bar_reg_init, - .u.dw.read = pt_long_reg_read, - .u.dw.write = pt_exp_rom_bar_reg_write, + .u.dw.read = pt_bar_reg_read, + .u.dw.write = pt_bar_reg_write, .u.dw.restore = pt_exp_rom_bar_reg_restore, }, { @@ -1776,7 +1774,7 @@ static int pt_bar_reg_parse( /* for ExpROM BAR */ if (index == PCI_ROM_SLOT) { - bar_flag = PT_BAR_FLAG_MEM; + bar_flag = PT_BAR_FLAG_EXP; goto out; } @@ -1819,11 +1817,13 @@ static void pt_bar_mapping(struct pt_dev *ptdev, int io_enable, int mem_enable) /* need unmapping in case I/O Space or Memory Space disable */ if (((base->bar_flag == PT_BAR_FLAG_IO) && !io_enable ) || - ((base->bar_flag == PT_BAR_FLAG_MEM) && !mem_enable )) + ((base->bar_flag == PT_BAR_FLAG_MEM) && !mem_enable ) || + ((base->bar_flag == PT_BAR_FLAG_EXP) && !mem_enable )) r_addr = -1; /* prevent guest software mapping memory resource to 00000000h */ - if ((base->bar_flag == PT_BAR_FLAG_MEM) && (r_addr == 0)) + if (((base->bar_flag == PT_BAR_FLAG_MEM) && (r_addr == 0)) || + ((base->bar_flag == PT_BAR_FLAG_EXP) && (r_addr == 0))) r_addr = -1; /* align resource size (memory type only) */ @@ -2408,7 +2408,6 @@ static uint32_t pt_irqpin_reg_init(struct pt_dev *ptdev, static uint32_t pt_bar_reg_init(struct pt_dev *ptdev, struct pt_reg_info_tbl *reg, uint32_t real_offset) { - int reg_field = 0; int index; /* get BAR index */ @@ -2426,10 +2425,8 @@ static uint32_t pt_bar_reg_init(struct pt_dev *ptdev, /* set BAR flag */ ptdev->bases[index].bar_flag = pt_bar_reg_parse(ptdev, reg); - if (ptdev->bases[index].bar_flag == PT_BAR_FLAG_UNUSED) - reg_field = PT_INVALID_REG; - return reg_field; + return 0; } /* initialize Power Management Capabilities register */ @@ -2896,6 +2893,12 @@ static int pt_bar_reg_read(struct pt_dev *ptdev, case PT_BAR_FLAG_UPPER: bar_emu_mask = PT_BAR_ALLF; break; + case PT_BAR_FLAG_EXP: + bar_emu_mask = PT_BAR_EXP_EMU_MASK; + break; + case PT_BAR_FLAG_UNUSED: + bar_emu_mask = PT_BAR_ALLF; + break; default: break; } @@ -3083,6 +3086,14 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, bar_emu_mask = PT_BAR_ALLF; bar_ro_mask = 0; /* all upper 32bit are R/W */ break; + case PT_BAR_FLAG_EXP: + bar_emu_mask = PT_BAR_EXP_EMU_MASK; + bar_ro_mask = PT_BAR_EXP_RO_MASK | (r_size -1); + break; + case PT_BAR_FLAG_UNUSED: + bar_emu_mask = PT_BAR_ALLF; + bar_ro_mask = PT_BAR_ALLF; + break; default: break; } @@ -3119,6 +3130,9 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, goto exit; } break; + case PT_BAR_FLAG_EXP: + goto exit; + break; case PT_BAR_FLAG_UPPER: if (cfg_entry->data) { @@ -3157,6 +3171,9 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, */ r->addr = -1; goto exit; + case PT_BAR_FLAG_UNUSED: + /* nothing to do */ + break; default: break; } @@ -3172,45 +3189,6 @@ exit: return 0; } -/* write Exp ROM BAR */ -static int pt_exp_rom_bar_reg_write(struct pt_dev *ptdev, - struct pt_reg_tbl *cfg_entry, - uint32_t *value, uint32_t dev_value, uint32_t valid_mask) -{ - struct pt_reg_info_tbl *reg = cfg_entry->reg; - struct pt_region *base = NULL; - PCIDevice *d = (PCIDevice *)&ptdev->dev; - PCIIORegion *r; - uint32_t writable_mask = 0; - uint32_t throughable_mask = 0; - uint32_t r_size = 0; - uint32_t bar_emu_mask = 0; - uint32_t bar_ro_mask = 0; - - r = &d->io_regions[PCI_ROM_SLOT]; - r_size = r->size; - base = &ptdev->bases[PCI_ROM_SLOT]; - /* align memory type resource size */ - PT_GET_EMUL_SIZE(base->bar_flag, r_size); - - /* set emulate mask and read-only mask */ - bar_emu_mask = reg->emu_mask; - bar_ro_mask = reg->ro_mask | (r_size - 1); - - /* modify emulate register */ - writable_mask = bar_emu_mask & ~bar_ro_mask & valid_mask; - cfg_entry->data = PT_MERGE_VALUE(*value, cfg_entry->data, writable_mask); - - /* update the corresponding virtual region address */ - r->addr = cfg_entry->data; - - /* create value for writing to I/O device register */ - throughable_mask = ~bar_emu_mask & valid_mask; - *value = PT_MERGE_VALUE(*value, dev_value, throughable_mask); - - return 0; -} - /* write Power Management Control/Status register */ static int pt_pmcsr_reg_write(struct pt_dev *ptdev, struct pt_reg_tbl *cfg_entry, diff --git a/hw/pass-through.h b/hw/pass-through.h index a503e80..c747828 100644 --- a/hw/pass-through.h +++ b/hw/pass-through.h @@ -131,10 +131,13 @@ #define PT_BAR_MEM_EMU_MASK 0xFFFFFFF0 /* BAR emul mask(Memory) */ #define PT_BAR_IO_RO_MASK 0x00000003 /* BAR ReadOnly mask(I/O) */ #define PT_BAR_IO_EMU_MASK 0xFFFFFFFC /* BAR emul mask(I/O) */ +#define PT_BAR_EXP_RO_MASK 0x000007FE /* BAR ReadOnly mask(Exp ROM) */ +#define PT_BAR_EXP_EMU_MASK 0xFFFFF800 /* BAR emul mask(Exp ROM) */ enum { PT_BAR_FLAG_MEM = 0, /* Memory type BAR */ PT_BAR_FLAG_IO, /* I/O type BAR */ PT_BAR_FLAG_UPPER, /* upper 64bit BAR */ + PT_BAR_FLAG_EXP, /* Exp ROM type BAR */ PT_BAR_FLAG_UNUSED, /* unused BAR */ }; enum { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Tim Moore
2009-Apr-17 20:18 UTC
[Xen-devel] RE: [PATCH] ioemu: make unused Base Address Register 0 hardwired.
Hi Yuji, This patch doesnt remove the error and also its not fixed my problem. Do you know also what these messages are? they seem to have increased after your patch ... track_dirty_vram(f0000000, 26) failed (-1, 22) track_dirty_vram(f0000000, 26) failed (-1, 22) track_dirty_vram(f0000000, 26) failed (-1, 22) track_dirty_vram(f0000000, 26) failed (-1, 22) track_dirty_vram(f0000000, 240) failed (-1, 22) track_dirty_vram(f0000000, 240) failed (-1, 22) track_dirty_vram(f0000000, 240) failed (-1, 22) track_dirty_vram(f0000000, 240) failed (-1, 22) Thanks Tim ________________________________________ From: Yuji Shimada [shimada-yxb@necst.nec.co.jp] Sent: 16 April 2009 06:53 To: Tim Moore; Ian Jackson Cc: Leonard Michelet; xen-devel@lists.xensource.com Subject: [PATCH] ioemu: make unused Base Address Register 0 hardwired. Hi Tim,> pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4]The warning message is originated from my patch. But I think your booting failure is not caused by it as Leonard say. This patch modifies to make unused Base Address Register 0 hardwired. Because unused BAR should not be changed by guest software. The warning message will be disappeared with this patch. Unfortunately I don''t have a device which causes the same symptom. Could you test this patch? Thanks, -- Yuji Shimada Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp> diff --git a/hw/pass-through.c b/hw/pass-through.c index 11382fd..20c7ebc 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -416,11 +416,9 @@ static struct pt_reg_info_tbl pt_emu_reg_header0_tbl[] = { .offset = PCI_ROM_ADDRESS, .size = 4, .init_val = 0x00000000, - .ro_mask = 0x000007FE, - .emu_mask = 0xFFFFF800, .init = pt_bar_reg_init, - .u.dw.read = pt_long_reg_read, - .u.dw.write = pt_exp_rom_bar_reg_write, + .u.dw.read = pt_bar_reg_read, + .u.dw.write = pt_bar_reg_write, .u.dw.restore = pt_exp_rom_bar_reg_restore, }, { @@ -1776,7 +1774,7 @@ static int pt_bar_reg_parse( /* for ExpROM BAR */ if (index == PCI_ROM_SLOT) { - bar_flag = PT_BAR_FLAG_MEM; + bar_flag = PT_BAR_FLAG_EXP; goto out; } @@ -1819,11 +1817,13 @@ static void pt_bar_mapping(struct pt_dev *ptdev, int io_enable, int mem_enable) /* need unmapping in case I/O Space or Memory Space disable */ if (((base->bar_flag == PT_BAR_FLAG_IO) && !io_enable ) || - ((base->bar_flag == PT_BAR_FLAG_MEM) && !mem_enable )) + ((base->bar_flag == PT_BAR_FLAG_MEM) && !mem_enable ) || + ((base->bar_flag == PT_BAR_FLAG_EXP) && !mem_enable )) r_addr = -1; /* prevent guest software mapping memory resource to 00000000h */ - if ((base->bar_flag == PT_BAR_FLAG_MEM) && (r_addr == 0)) + if (((base->bar_flag == PT_BAR_FLAG_MEM) && (r_addr == 0)) || + ((base->bar_flag == PT_BAR_FLAG_EXP) && (r_addr == 0))) r_addr = -1; /* align resource size (memory type only) */ @@ -2408,7 +2408,6 @@ static uint32_t pt_irqpin_reg_init(struct pt_dev *ptdev, static uint32_t pt_bar_reg_init(struct pt_dev *ptdev, struct pt_reg_info_tbl *reg, uint32_t real_offset) { - int reg_field = 0; int index; /* get BAR index */ @@ -2426,10 +2425,8 @@ static uint32_t pt_bar_reg_init(struct pt_dev *ptdev, /* set BAR flag */ ptdev->bases[index].bar_flag = pt_bar_reg_parse(ptdev, reg); - if (ptdev->bases[index].bar_flag == PT_BAR_FLAG_UNUSED) - reg_field = PT_INVALID_REG; - return reg_field; + return 0; } /* initialize Power Management Capabilities register */ @@ -2896,6 +2893,12 @@ static int pt_bar_reg_read(struct pt_dev *ptdev, case PT_BAR_FLAG_UPPER: bar_emu_mask = PT_BAR_ALLF; break; + case PT_BAR_FLAG_EXP: + bar_emu_mask = PT_BAR_EXP_EMU_MASK; + break; + case PT_BAR_FLAG_UNUSED: + bar_emu_mask = PT_BAR_ALLF; + break; default: break; } @@ -3083,6 +3086,14 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, bar_emu_mask = PT_BAR_ALLF; bar_ro_mask = 0; /* all upper 32bit are R/W */ break; + case PT_BAR_FLAG_EXP: + bar_emu_mask = PT_BAR_EXP_EMU_MASK; + bar_ro_mask = PT_BAR_EXP_RO_MASK | (r_size -1); + break; + case PT_BAR_FLAG_UNUSED: + bar_emu_mask = PT_BAR_ALLF; + bar_ro_mask = PT_BAR_ALLF; + break; default: break; } @@ -3119,6 +3130,9 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, goto exit; } break; + case PT_BAR_FLAG_EXP: + goto exit; + break; case PT_BAR_FLAG_UPPER: if (cfg_entry->data) { @@ -3157,6 +3171,9 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, */ r->addr = -1; goto exit; + case PT_BAR_FLAG_UNUSED: + /* nothing to do */ + break; default: break; } @@ -3172,45 +3189,6 @@ exit: return 0; } -/* write Exp ROM BAR */ -static int pt_exp_rom_bar_reg_write(struct pt_dev *ptdev, - struct pt_reg_tbl *cfg_entry, - uint32_t *value, uint32_t dev_value, uint32_t valid_mask) -{ - struct pt_reg_info_tbl *reg = cfg_entry->reg; - struct pt_region *base = NULL; - PCIDevice *d = (PCIDevice *)&ptdev->dev; - PCIIORegion *r; - uint32_t writable_mask = 0; - uint32_t throughable_mask = 0; - uint32_t r_size = 0; - uint32_t bar_emu_mask = 0; - uint32_t bar_ro_mask = 0; - - r = &d->io_regions[PCI_ROM_SLOT]; - r_size = r->size; - base = &ptdev->bases[PCI_ROM_SLOT]; - /* align memory type resource size */ - PT_GET_EMUL_SIZE(base->bar_flag, r_size); - - /* set emulate mask and read-only mask */ - bar_emu_mask = reg->emu_mask; - bar_ro_mask = reg->ro_mask | (r_size - 1); - - /* modify emulate register */ - writable_mask = bar_emu_mask & ~bar_ro_mask & valid_mask; - cfg_entry->data = PT_MERGE_VALUE(*value, cfg_entry->data, writable_mask); - - /* update the corresponding virtual region address */ - r->addr = cfg_entry->data; - - /* create value for writing to I/O device register */ - throughable_mask = ~bar_emu_mask & valid_mask; - *value = PT_MERGE_VALUE(*value, dev_value, throughable_mask); - - return 0; -} - /* write Power Management Control/Status register */ static int pt_pmcsr_reg_write(struct pt_dev *ptdev, struct pt_reg_tbl *cfg_entry, diff --git a/hw/pass-through.h b/hw/pass-through.h index a503e80..c747828 100644 --- a/hw/pass-through.h +++ b/hw/pass-through.h @@ -131,10 +131,13 @@ #define PT_BAR_MEM_EMU_MASK 0xFFFFFFF0 /* BAR emul mask(Memory) */ #define PT_BAR_IO_RO_MASK 0x00000003 /* BAR ReadOnly mask(I/O) */ #define PT_BAR_IO_EMU_MASK 0xFFFFFFFC /* BAR emul mask(I/O) */ +#define PT_BAR_EXP_RO_MASK 0x000007FE /* BAR ReadOnly mask(Exp ROM) */ +#define PT_BAR_EXP_EMU_MASK 0xFFFFF800 /* BAR emul mask(Exp ROM) */ enum { PT_BAR_FLAG_MEM = 0, /* Memory type BAR */ PT_BAR_FLAG_IO, /* I/O type BAR */ PT_BAR_FLAG_UPPER, /* upper 64bit BAR */ + PT_BAR_FLAG_EXP, /* Exp ROM type BAR */ PT_BAR_FLAG_UNUSED, /* unused BAR */ }; enum { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Tim Moore
2009-Apr-18 13:05 UTC
[Xen-devel] RE: pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4]
Yuri, I have attached some more logs that may help identify where these messages are coming from. These are from XCI using the latest Xen, qemu log is in the xenvm-debug-0000# The patch you provided is NOT applied here .... Tim ________________________________________ From: Yuji Shimada [shimada-yxb@necst.nec.co.jp] Sent: 16 April 2009 06:53 To: Tim Moore; Ian Jackson Cc: Leonard Michelet; xen-devel@lists.xensource.com Subject: [PATCH] ioemu: make unused Base Address Register 0 hardwired. Hi Tim,> pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4]The warning message is originated from my patch. But I think your booting failure is not caused by it as Leonard say. This patch modifies to make unused Base Address Register 0 hardwired. Because unused BAR should not be changed by guest software. The warning message will be disappeared with this patch. Unfortunately I don''t have a device which causes the same symptom. Could you test this patch? Thanks, -- Yuji Shimada Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp> diff --git a/hw/pass-through.c b/hw/pass-through.c index 11382fd..20c7ebc 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -416,11 +416,9 @@ static struct pt_reg_info_tbl pt_emu_reg_header0_tbl[] = { .offset = PCI_ROM_ADDRESS, .size = 4, .init_val = 0x00000000, - .ro_mask = 0x000007FE, - .emu_mask = 0xFFFFF800, .init = pt_bar_reg_init, - .u.dw.read = pt_long_reg_read, - .u.dw.write = pt_exp_rom_bar_reg_write, + .u.dw.read = pt_bar_reg_read, + .u.dw.write = pt_bar_reg_write, .u.dw.restore = pt_exp_rom_bar_reg_restore, }, { @@ -1776,7 +1774,7 @@ static int pt_bar_reg_parse( /* for ExpROM BAR */ if (index == PCI_ROM_SLOT) { - bar_flag = PT_BAR_FLAG_MEM; + bar_flag = PT_BAR_FLAG_EXP; goto out; } @@ -1819,11 +1817,13 @@ static void pt_bar_mapping(struct pt_dev *ptdev, int io_enable, int mem_enable) /* need unmapping in case I/O Space or Memory Space disable */ if (((base->bar_flag == PT_BAR_FLAG_IO) && !io_enable ) || - ((base->bar_flag == PT_BAR_FLAG_MEM) && !mem_enable )) + ((base->bar_flag == PT_BAR_FLAG_MEM) && !mem_enable ) || + ((base->bar_flag == PT_BAR_FLAG_EXP) && !mem_enable )) r_addr = -1; /* prevent guest software mapping memory resource to 00000000h */ - if ((base->bar_flag == PT_BAR_FLAG_MEM) && (r_addr == 0)) + if (((base->bar_flag == PT_BAR_FLAG_MEM) && (r_addr == 0)) || + ((base->bar_flag == PT_BAR_FLAG_EXP) && (r_addr == 0))) r_addr = -1; /* align resource size (memory type only) */ @@ -2408,7 +2408,6 @@ static uint32_t pt_irqpin_reg_init(struct pt_dev *ptdev, static uint32_t pt_bar_reg_init(struct pt_dev *ptdev, struct pt_reg_info_tbl *reg, uint32_t real_offset) { - int reg_field = 0; int index; /* get BAR index */ @@ -2426,10 +2425,8 @@ static uint32_t pt_bar_reg_init(struct pt_dev *ptdev, /* set BAR flag */ ptdev->bases[index].bar_flag = pt_bar_reg_parse(ptdev, reg); - if (ptdev->bases[index].bar_flag == PT_BAR_FLAG_UNUSED) - reg_field = PT_INVALID_REG; - return reg_field; + return 0; } /* initialize Power Management Capabilities register */ @@ -2896,6 +2893,12 @@ static int pt_bar_reg_read(struct pt_dev *ptdev, case PT_BAR_FLAG_UPPER: bar_emu_mask = PT_BAR_ALLF; break; + case PT_BAR_FLAG_EXP: + bar_emu_mask = PT_BAR_EXP_EMU_MASK; + break; + case PT_BAR_FLAG_UNUSED: + bar_emu_mask = PT_BAR_ALLF; + break; default: break; } @@ -3083,6 +3086,14 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, bar_emu_mask = PT_BAR_ALLF; bar_ro_mask = 0; /* all upper 32bit are R/W */ break; + case PT_BAR_FLAG_EXP: + bar_emu_mask = PT_BAR_EXP_EMU_MASK; + bar_ro_mask = PT_BAR_EXP_RO_MASK | (r_size -1); + break; + case PT_BAR_FLAG_UNUSED: + bar_emu_mask = PT_BAR_ALLF; + bar_ro_mask = PT_BAR_ALLF; + break; default: break; } @@ -3119,6 +3130,9 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, goto exit; } break; + case PT_BAR_FLAG_EXP: + goto exit; + break; case PT_BAR_FLAG_UPPER: if (cfg_entry->data) { @@ -3157,6 +3171,9 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, */ r->addr = -1; goto exit; + case PT_BAR_FLAG_UNUSED: + /* nothing to do */ + break; default: break; } @@ -3172,45 +3189,6 @@ exit: return 0; } -/* write Exp ROM BAR */ -static int pt_exp_rom_bar_reg_write(struct pt_dev *ptdev, - struct pt_reg_tbl *cfg_entry, - uint32_t *value, uint32_t dev_value, uint32_t valid_mask) -{ - struct pt_reg_info_tbl *reg = cfg_entry->reg; - struct pt_region *base = NULL; - PCIDevice *d = (PCIDevice *)&ptdev->dev; - PCIIORegion *r; - uint32_t writable_mask = 0; - uint32_t throughable_mask = 0; - uint32_t r_size = 0; - uint32_t bar_emu_mask = 0; - uint32_t bar_ro_mask = 0; - - r = &d->io_regions[PCI_ROM_SLOT]; - r_size = r->size; - base = &ptdev->bases[PCI_ROM_SLOT]; - /* align memory type resource size */ - PT_GET_EMUL_SIZE(base->bar_flag, r_size); - - /* set emulate mask and read-only mask */ - bar_emu_mask = reg->emu_mask; - bar_ro_mask = reg->ro_mask | (r_size - 1); - - /* modify emulate register */ - writable_mask = bar_emu_mask & ~bar_ro_mask & valid_mask; - cfg_entry->data = PT_MERGE_VALUE(*value, cfg_entry->data, writable_mask); - - /* update the corresponding virtual region address */ - r->addr = cfg_entry->data; - - /* create value for writing to I/O device register */ - throughable_mask = ~bar_emu_mask & valid_mask; - *value = PT_MERGE_VALUE(*value, dev_value, throughable_mask); - - return 0; -} - /* write Power Management Control/Status register */ static int pt_pmcsr_reg_write(struct pt_dev *ptdev, struct pt_reg_tbl *cfg_entry, diff --git a/hw/pass-through.h b/hw/pass-through.h index a503e80..c747828 100644 --- a/hw/pass-through.h +++ b/hw/pass-through.h @@ -131,10 +131,13 @@ #define PT_BAR_MEM_EMU_MASK 0xFFFFFFF0 /* BAR emul mask(Memory) */ #define PT_BAR_IO_RO_MASK 0x00000003 /* BAR ReadOnly mask(I/O) */ #define PT_BAR_IO_EMU_MASK 0xFFFFFFFC /* BAR emul mask(I/O) */ +#define PT_BAR_EXP_RO_MASK 0x000007FE /* BAR ReadOnly mask(Exp ROM) */ +#define PT_BAR_EXP_EMU_MASK 0xFFFFF800 /* BAR emul mask(Exp ROM) */ enum { PT_BAR_FLAG_MEM = 0, /* Memory type BAR */ PT_BAR_FLAG_IO, /* I/O type BAR */ PT_BAR_FLAG_UPPER, /* upper 64bit BAR */ + PT_BAR_FLAG_EXP, /* Exp ROM type BAR */ PT_BAR_FLAG_UNUSED, /* unused BAR */ }; enum { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Yuji Shimada
2009-Apr-21 08:46 UTC
Re: [Xen-devel] RE: [PATCH] ioemu: make unused Base Address Register 0 hardwired.
On Fri, 17 Apr 2009 21:18:32 +0100 Tim Moore <timothy.moore@expidas.net> wrote:> Hi Yuji, > > This patch doesnt remove the error and also its not fixed my problem. > > Do you know also what these messages are? they seem to have increased after your patch ... > > track_dirty_vram(f0000000, 26) failed (-1, 22) > track_dirty_vram(f0000000, 26) failed (-1, 22) > track_dirty_vram(f0000000, 26) failed (-1, 22) > track_dirty_vram(f0000000, 26) failed (-1, 22) > track_dirty_vram(f0000000, 240) failed (-1, 22) > track_dirty_vram(f0000000, 240) failed (-1, 22) > track_dirty_vram(f0000000, 240) failed (-1, 22) > track_dirty_vram(f0000000, 240) failed (-1, 22)Hi Tim, I''m not sure why "track_dirty_vram" messages are shown. I don''t think my patch is direct cause of these messages. I updated the patch. This patch modifies to make unused Base Address Register 0 hardwired. Unused BAR should not be changed by guest software. The warning message will be disappeared with this patch. This patch also changed the check of unused BAR to (*value > 0 && *value < PT_BAR_ALLF-1). Because Linux writes PT_BAR_ALLF-1 when it checks the BAR. I also moved the warning message from pt_pci_write_config to pt_bar_reg_write. Could you test this patch? Thanks, -- Yuji Shimada Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp> diff --git a/hw/pass-through.c b/hw/pass-through.c index 710acbf..b19b94c 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -416,11 +416,9 @@ static struct pt_reg_info_tbl pt_emu_reg_header0_tbl[] = { .offset = PCI_ROM_ADDRESS, .size = 4, .init_val = 0x00000000, - .ro_mask = 0x000007FE, - .emu_mask = 0xFFFFF800, .init = pt_bar_reg_init, - .u.dw.read = pt_long_reg_read, - .u.dw.write = pt_exp_rom_bar_reg_write, + .u.dw.read = pt_bar_reg_read, + .u.dw.write = pt_bar_reg_write, .u.dw.restore = pt_exp_rom_bar_reg_restore, }, { @@ -1218,17 +1216,6 @@ static void pt_pci_write_config(PCIDevice *d, uint32_t address, uint32_t val, goto exit; } - /* check unused BAR register */ - index = pt_bar_offset_to_index(address); - if ((index >= 0) && (val > 0 && val < PT_BAR_ALLF) && - (assigned_device->bases[index].bar_flag == PT_BAR_FLAG_UNUSED)) - { - PT_LOG("Warning: Guest attempt to set address to unused Base Address " - "Register. [%02x:%02x.%x][Offset:%02xh][Length:%d]\n", - pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F), - (d->devfn & 0x7), address, len); - } - /* check power state transition flags */ if (pm_state != NULL && pm_state->flags & PT_FLAG_TRANSITING) /* can''t accept untill previous power state transition is completed. @@ -1776,7 +1763,7 @@ static int pt_bar_reg_parse( /* for ExpROM BAR */ if (index == PCI_ROM_SLOT) { - bar_flag = PT_BAR_FLAG_MEM; + bar_flag = PT_BAR_FLAG_EXP; goto out; } @@ -1819,11 +1806,13 @@ static void pt_bar_mapping(struct pt_dev *ptdev, int io_enable, int mem_enable) /* need unmapping in case I/O Space or Memory Space disable */ if (((base->bar_flag == PT_BAR_FLAG_IO) && !io_enable ) || - ((base->bar_flag == PT_BAR_FLAG_MEM) && !mem_enable )) + ((base->bar_flag == PT_BAR_FLAG_MEM) && !mem_enable ) || + ((base->bar_flag == PT_BAR_FLAG_EXP) && !mem_enable )) r_addr = -1; /* prevent guest software mapping memory resource to 00000000h */ - if ((base->bar_flag == PT_BAR_FLAG_MEM) && (r_addr == 0)) + if (((base->bar_flag == PT_BAR_FLAG_MEM) && (r_addr == 0)) || + ((base->bar_flag == PT_BAR_FLAG_EXP) && (r_addr == 0))) r_addr = -1; /* align resource size (memory type only) */ @@ -2408,7 +2397,6 @@ static uint32_t pt_irqpin_reg_init(struct pt_dev *ptdev, static uint32_t pt_bar_reg_init(struct pt_dev *ptdev, struct pt_reg_info_tbl *reg, uint32_t real_offset) { - int reg_field = 0; int index; /* get BAR index */ @@ -2426,10 +2414,8 @@ static uint32_t pt_bar_reg_init(struct pt_dev *ptdev, /* set BAR flag */ ptdev->bases[index].bar_flag = pt_bar_reg_parse(ptdev, reg); - if (ptdev->bases[index].bar_flag == PT_BAR_FLAG_UNUSED) - reg_field = PT_INVALID_REG; - return reg_field; + return 0; } /* initialize Power Management Capabilities register */ @@ -2896,6 +2882,12 @@ static int pt_bar_reg_read(struct pt_dev *ptdev, case PT_BAR_FLAG_UPPER: bar_emu_mask = PT_BAR_ALLF; break; + case PT_BAR_FLAG_EXP: + bar_emu_mask = PT_BAR_EXP_EMU_MASK; + break; + case PT_BAR_FLAG_UNUSED: + bar_emu_mask = PT_BAR_ALLF; + break; default: break; } @@ -3083,6 +3075,14 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, bar_emu_mask = PT_BAR_ALLF; bar_ro_mask = 0; /* all upper 32bit are R/W */ break; + case PT_BAR_FLAG_EXP: + bar_emu_mask = PT_BAR_EXP_EMU_MASK; + bar_ro_mask = PT_BAR_EXP_RO_MASK | (r_size -1); + break; + case PT_BAR_FLAG_UNUSED: + bar_emu_mask = PT_BAR_ALLF; + bar_ro_mask = PT_BAR_ALLF; + break; default: break; } @@ -3119,6 +3119,9 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, goto exit; } break; + case PT_BAR_FLAG_EXP: + goto exit; + break; case PT_BAR_FLAG_UPPER: if (cfg_entry->data) { @@ -3157,6 +3160,16 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, */ r->addr = -1; goto exit; + case PT_BAR_FLAG_UNUSED: + /* check unused BAR register */ + if (*value > 0 && *value < PT_BAR_ALLF-1) + { + PT_LOG("Warning: Guest attempt to set address to unused Base " + "Address Register. [%02x:%02x.%x][Offset:%02xh]\n", + pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F), + (d->devfn & 0x7), reg->offset); + } + break; default: break; } @@ -3172,45 +3185,6 @@ exit: return 0; } -/* write Exp ROM BAR */ -static int pt_exp_rom_bar_reg_write(struct pt_dev *ptdev, - struct pt_reg_tbl *cfg_entry, - uint32_t *value, uint32_t dev_value, uint32_t valid_mask) -{ - struct pt_reg_info_tbl *reg = cfg_entry->reg; - struct pt_region *base = NULL; - PCIDevice *d = (PCIDevice *)&ptdev->dev; - PCIIORegion *r; - uint32_t writable_mask = 0; - uint32_t throughable_mask = 0; - uint32_t r_size = 0; - uint32_t bar_emu_mask = 0; - uint32_t bar_ro_mask = 0; - - r = &d->io_regions[PCI_ROM_SLOT]; - r_size = r->size; - base = &ptdev->bases[PCI_ROM_SLOT]; - /* align memory type resource size */ - PT_GET_EMUL_SIZE(base->bar_flag, r_size); - - /* set emulate mask and read-only mask */ - bar_emu_mask = reg->emu_mask; - bar_ro_mask = reg->ro_mask | (r_size - 1); - - /* modify emulate register */ - writable_mask = bar_emu_mask & ~bar_ro_mask & valid_mask; - cfg_entry->data = PT_MERGE_VALUE(*value, cfg_entry->data, writable_mask); - - /* update the corresponding virtual region address */ - r->addr = cfg_entry->data; - - /* create value for writing to I/O device register */ - throughable_mask = ~bar_emu_mask & valid_mask; - *value = PT_MERGE_VALUE(*value, dev_value, throughable_mask); - - return 0; -} - /* write Power Management Control/Status register */ static int pt_pmcsr_reg_write(struct pt_dev *ptdev, struct pt_reg_tbl *cfg_entry, diff --git a/hw/pass-through.h b/hw/pass-through.h index a503e80..c747828 100644 --- a/hw/pass-through.h +++ b/hw/pass-through.h @@ -131,10 +131,13 @@ #define PT_BAR_MEM_EMU_MASK 0xFFFFFFF0 /* BAR emul mask(Memory) */ #define PT_BAR_IO_RO_MASK 0x00000003 /* BAR ReadOnly mask(I/O) */ #define PT_BAR_IO_EMU_MASK 0xFFFFFFFC /* BAR emul mask(I/O) */ +#define PT_BAR_EXP_RO_MASK 0x000007FE /* BAR ReadOnly mask(Exp ROM) */ +#define PT_BAR_EXP_EMU_MASK 0xFFFFF800 /* BAR emul mask(Exp ROM) */ enum { PT_BAR_FLAG_MEM = 0, /* Memory type BAR */ PT_BAR_FLAG_IO, /* I/O type BAR */ PT_BAR_FLAG_UPPER, /* upper 64bit BAR */ + PT_BAR_FLAG_EXP, /* Exp ROM type BAR */ PT_BAR_FLAG_UNUSED, /* unused BAR */ }; enum { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Yuji Shimada
2009-Apr-28 08:07 UTC
[Xen-devel] [PATCH] [RESEND] ioemu: make unused Base Address Register 0 hardwired.
Hi Ian, This patch modifies to make unused Base Address Register 0 hardwired. Unused BAR should not be changed by guest software. This patch also changed the check value of unused BAR to (*value > 0 && *value < PT_BAR_ALLF-1). Because Linux writes PT_BAR_ALLF-1 when it checks the BAR. When I forced ioemu to hide expansion ROM, ioemu output the following warning message which is the same with Tim''s one.> pt_pci_write_config: Warning: Guest attempt to set address to unused Base Address Register. [00:03.0][Offset:30h][Length:4]But when I changed the check value of unused BAR to PT_BAR_ALLF-1, ioemu didn''t output the warning message. I am taking days off from April 29th to May 6th. So I can''t answer any question by then. Thanks, -- Yuji Shimada Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp> diff --git a/hw/pass-through.c b/hw/pass-through.c index 7bd2feb..601cd8a 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -416,11 +416,9 @@ static struct pt_reg_info_tbl pt_emu_reg_header0_tbl[] = { .offset = PCI_ROM_ADDRESS, .size = 4, .init_val = 0x00000000, - .ro_mask = 0x000007FE, - .emu_mask = 0xFFFFF800, .init = pt_bar_reg_init, - .u.dw.read = pt_long_reg_read, - .u.dw.write = pt_exp_rom_bar_reg_write, + .u.dw.read = pt_bar_reg_read, + .u.dw.write = pt_bar_reg_write, .u.dw.restore = pt_exp_rom_bar_reg_restore, }, { @@ -1218,17 +1216,6 @@ static void pt_pci_write_config(PCIDevice *d, uint32_t address, uint32_t val, goto exit; } - /* check unused BAR register */ - index = pt_bar_offset_to_index(address); - if ((index >= 0) && (val > 0 && val < PT_BAR_ALLF) && - (assigned_device->bases[index].bar_flag == PT_BAR_FLAG_UNUSED)) - { - PT_LOG("Warning: Guest attempt to set address to unused Base Address " - "Register. [%02x:%02x.%x][Offset:%02xh][Length:%d]\n", - pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F), - (d->devfn & 0x7), address, len); - } - /* check power state transition flags */ if (pm_state != NULL && pm_state->flags & PT_FLAG_TRANSITING) /* can''t accept untill previous power state transition is completed. @@ -1776,7 +1763,7 @@ static int pt_bar_reg_parse( /* for ExpROM BAR */ if (index == PCI_ROM_SLOT) { - bar_flag = PT_BAR_FLAG_MEM; + bar_flag = PT_BAR_FLAG_EXP; goto out; } @@ -1819,11 +1806,13 @@ static void pt_bar_mapping(struct pt_dev *ptdev, int io_enable, int mem_enable) /* need unmapping in case I/O Space or Memory Space disable */ if (((base->bar_flag == PT_BAR_FLAG_IO) && !io_enable ) || - ((base->bar_flag == PT_BAR_FLAG_MEM) && !mem_enable )) + ((base->bar_flag == PT_BAR_FLAG_MEM) && !mem_enable ) || + ((base->bar_flag == PT_BAR_FLAG_EXP) && !mem_enable )) r_addr = -1; /* prevent guest software mapping memory resource to 00000000h */ - if ((base->bar_flag == PT_BAR_FLAG_MEM) && (r_addr == 0)) + if (((base->bar_flag == PT_BAR_FLAG_MEM) && (r_addr == 0)) || + ((base->bar_flag == PT_BAR_FLAG_EXP) && (r_addr == 0))) r_addr = -1; /* align resource size (memory type only) */ @@ -2408,7 +2397,6 @@ static uint32_t pt_irqpin_reg_init(struct pt_dev *ptdev, static uint32_t pt_bar_reg_init(struct pt_dev *ptdev, struct pt_reg_info_tbl *reg, uint32_t real_offset) { - int reg_field = 0; int index; /* get BAR index */ @@ -2426,10 +2414,8 @@ static uint32_t pt_bar_reg_init(struct pt_dev *ptdev, /* set BAR flag */ ptdev->bases[index].bar_flag = pt_bar_reg_parse(ptdev, reg); - if (ptdev->bases[index].bar_flag == PT_BAR_FLAG_UNUSED) - reg_field = PT_INVALID_REG; - return reg_field; + return 0; } /* initialize Power Management Capabilities register */ @@ -2896,6 +2882,12 @@ static int pt_bar_reg_read(struct pt_dev *ptdev, case PT_BAR_FLAG_UPPER: bar_emu_mask = PT_BAR_ALLF; break; + case PT_BAR_FLAG_EXP: + bar_emu_mask = PT_BAR_EXP_EMU_MASK; + break; + case PT_BAR_FLAG_UNUSED: + bar_emu_mask = PT_BAR_ALLF; + break; default: break; } @@ -3083,6 +3075,14 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, bar_emu_mask = PT_BAR_ALLF; bar_ro_mask = 0; /* all upper 32bit are R/W */ break; + case PT_BAR_FLAG_EXP: + bar_emu_mask = PT_BAR_EXP_EMU_MASK; + bar_ro_mask = PT_BAR_EXP_RO_MASK | (r_size -1); + break; + case PT_BAR_FLAG_UNUSED: + bar_emu_mask = PT_BAR_ALLF; + bar_ro_mask = PT_BAR_ALLF; + break; default: break; } @@ -3119,6 +3119,9 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, goto exit; } break; + case PT_BAR_FLAG_EXP: + goto exit; + break; case PT_BAR_FLAG_UPPER: if (cfg_entry->data) { @@ -3157,6 +3160,16 @@ static int pt_bar_reg_write(struct pt_dev *ptdev, */ r->addr = -1; goto exit; + case PT_BAR_FLAG_UNUSED: + /* check unused BAR register */ + if (*value > 0 && *value < PT_BAR_ALLF-1) + { + PT_LOG("Warning: Guest attempt to set address to unused Base " + "Address Register. [%02x:%02x.%x][Offset:%02xh]\n", + pci_bus_num(d->bus), ((d->devfn >> 3) & 0x1F), + (d->devfn & 0x7), reg->offset); + } + break; default: break; } @@ -3181,45 +3194,6 @@ exit: return 0; } -/* write Exp ROM BAR */ -static int pt_exp_rom_bar_reg_write(struct pt_dev *ptdev, - struct pt_reg_tbl *cfg_entry, - uint32_t *value, uint32_t dev_value, uint32_t valid_mask) -{ - struct pt_reg_info_tbl *reg = cfg_entry->reg; - struct pt_region *base = NULL; - PCIDevice *d = (PCIDevice *)&ptdev->dev; - PCIIORegion *r; - uint32_t writable_mask = 0; - uint32_t throughable_mask = 0; - uint32_t r_size = 0; - uint32_t bar_emu_mask = 0; - uint32_t bar_ro_mask = 0; - - r = &d->io_regions[PCI_ROM_SLOT]; - r_size = r->size; - base = &ptdev->bases[PCI_ROM_SLOT]; - /* align memory type resource size */ - PT_GET_EMUL_SIZE(base->bar_flag, r_size); - - /* set emulate mask and read-only mask */ - bar_emu_mask = reg->emu_mask; - bar_ro_mask = reg->ro_mask | (r_size - 1); - - /* modify emulate register */ - writable_mask = bar_emu_mask & ~bar_ro_mask & valid_mask; - cfg_entry->data = PT_MERGE_VALUE(*value, cfg_entry->data, writable_mask); - - /* update the corresponding virtual region address */ - r->addr = cfg_entry->data; - - /* create value for writing to I/O device register */ - throughable_mask = ~bar_emu_mask & valid_mask; - *value = PT_MERGE_VALUE(*value, dev_value, throughable_mask); - - return 0; -} - /* write Power Management Control/Status register */ static int pt_pmcsr_reg_write(struct pt_dev *ptdev, struct pt_reg_tbl *cfg_entry, diff --git a/hw/pass-through.h b/hw/pass-through.h index a503e80..c747828 100644 --- a/hw/pass-through.h +++ b/hw/pass-through.h @@ -131,10 +131,13 @@ #define PT_BAR_MEM_EMU_MASK 0xFFFFFFF0 /* BAR emul mask(Memory) */ #define PT_BAR_IO_RO_MASK 0x00000003 /* BAR ReadOnly mask(I/O) */ #define PT_BAR_IO_EMU_MASK 0xFFFFFFFC /* BAR emul mask(I/O) */ +#define PT_BAR_EXP_RO_MASK 0x000007FE /* BAR ReadOnly mask(Exp ROM) */ +#define PT_BAR_EXP_EMU_MASK 0xFFFFF800 /* BAR emul mask(Exp ROM) */ enum { PT_BAR_FLAG_MEM = 0, /* Memory type BAR */ PT_BAR_FLAG_IO, /* I/O type BAR */ PT_BAR_FLAG_UPPER, /* upper 64bit BAR */ + PT_BAR_FLAG_EXP, /* Exp ROM type BAR */ PT_BAR_FLAG_UNUSED, /* unused BAR */ }; enum { _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2009-Apr-29 15:54 UTC
[Xen-devel] Re: [PATCH] [RESEND] ioemu: make unused Base Address Register 0 hardwired.
Yuji Shimada writes ("[PATCH] [RESEND] ioemu: make unused Base Address Register 0 hardwired."):> This patch modifies to make unused Base Address Register 0 hardwired. > Unused BAR should not be changed by guest software.Thanks.> I am taking days off from April 29th to May 6th. So I can''t answer any > question by then.That''s unfortunate. I''ve just come back from a few days away myself. In this thread it appeared that you were trying to fix a bug reported by Tim Moore. Have I misread that. Tim, does Yuji''s latest patch fix your problem ? I assume this patch is intended for the 3.4 release ? Keir: what''s your view on this ? Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel