Received: from eggs.gnu.org ([2001:4830:134:3::10]:52271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1wqO-00010i-Hf for qemu-devel@nongnu.org; Mon, 08 Jun 2015 09:12:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z1wqJ-0005A2-GZ for qemu-devel@nongnu.org; Mon, 08 Jun 2015 09:12:00 -0400 Received: from mail.emea.novell.com ([130.57.118.101]:58508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1wqJ-00059i-7J for qemu-devel@nongnu.org; Mon, 08 Jun 2015 09:11:55 -0400 Message-Id: <5575B0B7020000780008220A@mail.emea.novell.com> Date: Mon, 08 Jun 2015 14:11:51 +0100 From: "Jan Beulich" Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part5B6F7687.2__=" Subject: [Qemu-devel] [PATCH v2] xen/pass-through: ROM BAR handling adjustments List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: xen-devel , Stefano Stabellini This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part5B6F7687.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Expecting the ROM BAR to be written with an all ones value when sizing the region is wrong - the low bit has another meaning (enable/disable) and bits 1..10 are reserved. The PCI spec also mandates writing all ones to just the address portion of the register. Use suitable constants also for initializing the ROM BAR register field description. Signed-off-by: Jan Beulich --- v2: Convert complex if() into simpler ones. --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -249,10 +249,18 @@ static void xen_pt_pci_write_config(PCID =20 /* check unused BAR register */ index =3D xen_pt_bar_offset_to_index(addr); - if ((index >=3D 0) && (val > 0 && val < XEN_PT_BAR_ALLF) && - (s->bases[index].bar_flag =3D=3D XEN_PT_BAR_FLAG_UNUSED)) { - XEN_PT_WARN(d, "Guest attempt to set address to unused Base = Address " - "Register. (addr: 0x%02x, len: %d)\n", addr, len); + if ((index >=3D 0) && (val !=3D 0)) { + uint32_t chk =3D val; + + if (index =3D=3D PCI_ROM_SLOT) + chk |=3D (uint32_t)~PCI_ROM_ADDRESS_MASK; + + if ((chk !=3D XEN_PT_BAR_ALLF) && + (s->bases[index].bar_flag =3D=3D XEN_PT_BAR_FLAG_UNUSED)) { + XEN_PT_WARN(d, "Guest attempt to set address to unused " + "Base Address Register. (addr: 0x%02x, len: = %d)\n", + addr, len); + } } =20 /* find register group entry */ --- a/hw/xen/xen_pt_config_init.c +++ b/hw/xen/xen_pt_config_init.c @@ -729,8 +729,8 @@ static XenPTRegInfo xen_pt_emu_reg_heade .offset =3D PCI_ROM_ADDRESS, .size =3D 4, .init_val =3D 0x00000000, - .ro_mask =3D 0x000007FE, - .emu_mask =3D 0xFFFFF800, + .ro_mask =3D ~PCI_ROM_ADDRESS_MASK & ~PCI_ROM_ADDRESS_ENABLE, + .emu_mask =3D (uint32_t)PCI_ROM_ADDRESS_MASK, .init =3D xen_pt_bar_reg_init, .u.dw.read =3D xen_pt_long_reg_read, .u.dw.write =3D xen_pt_exp_rom_bar_reg_write, --=__Part5B6F7687.2__= Content-Type: text/plain; name="qemu-ROM-BAR-warning.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="qemu-ROM-BAR-warning.patch" xen/pass-through: ROM BAR handling adjustments=0A=0AExpecting the ROM BAR = to be written with an all ones value when sizing=0Athe region is wrong - = the low bit has another meaning (enable/disable)=0Aand bits 1..10 are = reserved. The PCI spec also mandates writing all=0Aones to just the = address portion of the register.=0A=0AUse suitable constants also for = initializing the ROM BAR register field=0Adescription.=0A=0ASigned-off-by: = Jan Beulich =0A---=0Av2: Convert complex if() into = simpler ones.=0A=0A--- a/hw/xen/xen_pt.c=0A+++ b/hw/xen/xen_pt.c=0A@@ = -249,10 +249,18 @@ static void xen_pt_pci_write_config(PCID=0A =0A /* = check unused BAR register */=0A index =3D xen_pt_bar_offset_to_index(ad= dr);=0A- if ((index >=3D 0) && (val > 0 && val < XEN_PT_BAR_ALLF) = &&=0A- (s->bases[index].bar_flag =3D=3D XEN_PT_BAR_FLAG_UNUSED)) = {=0A- XEN_PT_WARN(d, "Guest attempt to set address to unused Base = Address "=0A- "Register. (addr: 0x%02x, len: %d)\n", = addr, len);=0A+ if ((index >=3D 0) && (val !=3D 0)) {=0A+ = uint32_t chk =3D val;=0A+=0A+ if (index =3D=3D PCI_ROM_SLOT)=0A+ = chk |=3D (uint32_t)~PCI_ROM_ADDRESS_MASK;=0A+=0A+ if ((chk = !=3D XEN_PT_BAR_ALLF) &&=0A+ (s->bases[index].bar_flag =3D=3D = XEN_PT_BAR_FLAG_UNUSED)) {=0A+ XEN_PT_WARN(d, "Guest attempt to = set address to unused "=0A+ "Base Address Register. = (addr: 0x%02x, len: %d)\n",=0A+ addr, len);=0A+ = }=0A }=0A =0A /* find register group entry */=0A--- a/hw/xen/xen= _pt_config_init.c=0A+++ b/hw/xen/xen_pt_config_init.c=0A@@ -729,8 +729,8 = @@ static XenPTRegInfo xen_pt_emu_reg_heade=0A .offset =3D = PCI_ROM_ADDRESS,=0A .size =3D 4,=0A .init_val =3D = 0x00000000,=0A- .ro_mask =3D 0x000007FE,=0A- .emu_mask = =3D 0xFFFFF800,=0A+ .ro_mask =3D ~PCI_ROM_ADDRESS_MASK & = ~PCI_ROM_ADDRESS_ENABLE,=0A+ .emu_mask =3D (uint32_t)PCI_ROM_ADDRE= SS_MASK,=0A .init =3D xen_pt_bar_reg_init,=0A = .u.dw.read =3D xen_pt_long_reg_read,=0A .u.dw.write =3D xen_pt_exp= _rom_bar_reg_write,=0A --=__Part5B6F7687.2__=--