Received: from eggs.gnu.org ([2001:4830:134:3::10]:52137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1rDR-0005ua-8r for qemu-devel@nongnu.org; Mon, 08 Jun 2015 03:11:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z1rDM-00048r-8J for qemu-devel@nongnu.org; Mon, 08 Jun 2015 03:11:25 -0400 Received: from mail.emea.novell.com ([130.57.118.101]:36083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1rDL-00045b-Vt for qemu-devel@nongnu.org; Mon, 08 Jun 2015 03:11:20 -0400 Message-Id: <55755C330200007800081CF4@mail.emea.novell.com> Date: Mon, 08 Jun 2015 08:11:15 +0100 From: "Jan Beulich" References: <5556059F020000780007A8D0@mail.emea.novell.com> <5571A6D802000078000814F5@mail.emea.novell.com> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: [Qemu-devel] [PATCH] xen/pass-through: ROM BAR handling adjustments List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefano Stabellini Cc: xen-devel , qemu-devel@nongnu.org >>> On 05.06.15 at 18:41, wrote: > On Fri, 5 Jun 2015, Jan Beulich wrote: >> >>> On 05.06.15 at 13:32, wrote: >> >> --- a/hw/xen/xen_pt.c >> >> +++ b/hw/xen/xen_pt.c >> >> @@ -248,7 +248,9 @@ 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) && >> >> + if ((index >=3D 0) && (val !=3D 0) && >> >> + (((index !=3D PCI_ROM_SLOT) ? >> >> + val : (val | (uint32_t)~PCI_ROM_ADDRESS_MASK)) !=3D=20 > XEN_PT_BAR_ALLF) && >> >=20 >> > The change seems looks good and in line with the commit message. But >> > this if statement looks like acrobatic circus to me now. >>=20 >> I think the alternative of splitting it up into multiple if()-s would = not >> be any better readable. >=20 > Would you be OK if I rewrote the statement as follows? >=20 > if ((index >=3D 0) && (val !=3D 0)) { > uint32_t vu; > =20 > if (index =3D=3D PCI_ROM_SLOT) { > vu =3D val | (uint32_t)~PCI_ROM_ADDRESS_MASK; > } else { > vu =3D val; > } >=20 > if ((vu !=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); > } > } Actually I agree that this indeed looks better. If I were to make the change, I'd do if ((index >=3D 0) && (val !=3D 0)) { uint32_t vu =3D val; =20 if (index =3D=3D PCI_ROM_SLOT) { vu |=3D (uint32_t)~PCI_ROM_ADDRESS_MASK; } if ((vu !=3D XEN_PT_BAR_ALLF) && ... though. But if you're going to do the edit without wanting me to re-submit, I'll certainly leave this to you. Just let me know which way you prefer it to be handled. Jan