[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.16] x86/passthrough: Fix hvm_gsi_eoi() build with GCC 12


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 4 Nov 2021 16:24:02 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fiKl2ChBbwozG+wJlw9dtbCio05pstTvIJjKNhROzDo=; b=Nqt8vwGabb6mtu/NPqTvzJHViFyEJehEr6eEYVsJ3URpcPJNo3XYbX6Zo2Hij4fRxfMyo9ePzIfndWGAOmG2X4ALoVCuBVPZYBkQJfLTLqVrHecu3Iel3T56AHpkajb1RfxYFV5dCujkpX0GCet/E2aXiJvuyr9aelS47vygQHkEvZ5kohuHw2mhSjEgj8/fVac7jyE3pdcVaCZIiePUNFUqIt4DwQamYFUv1rGXgjcNaIZqCkMBdF707F0zH1hWXQcmDjDuyuW4VfSiAGzdvtp/+fiLta5cb7FVXSiOly8bm3SLHmeRWOWmnVrAgwm9Kyatb1To58YzJTkYipr7Tg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N4EwORgvxkopVGKaI33XNFwu1n7xm1EFIkAJw7tm1lakseGBTm1zFPG93AUYoxnr81DVKiEttDCGomIqP9L/0yFMw+jOMLufUcezZuXDXpnTDOkXs0L/G023D8GOI0nw/Dry7wI/UILLiakTqPgyjyDx/S94ICdnJxwr0g74Z1W9ojKPo9yhrf/9iuG1GXOwjNS4ov5k/K4dHErXKE30+IAXgE9YbrtxXSFunWcQW3iNeM2EuAgFnSIEOFVwDFYTqGjmmhVHkKNu5jij+I8QqccwC00/nXPPGoRwM++EnrkL9qff2A7ilJfnK8r7gu/4Atvd+jxEhVE823L/K+LiMQ==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 04 Nov 2021 15:24:32 +0000
  • Ironport-data: A9a23:BhtVgqyCANd0PYqjGOx6t+fdwSrEfRIJ4+MujC+fZmUNrF6WrkVVz mMdWmCOa/6JNGCjfNpybY7j9kwE6p7Rx4NlQANtpCAxQypGp/SeCIXCJC8cHc8zwu4v7q5Dx 59DAjUVBJlsFhcwnvopW1TYhSEUOZugH9IQM8aZfHAuLeNYYH1500s6wrZl2tQAbeWRWGthh /uj+6UzB3f9s9JEGjp8B3Wr8U4HUFza4Vv0j3RmDRx5lAa2e0o9VfrzEZqZPXrgKrS4K8bhL wr1IBNVyUuCl/slIovNfr8W6STmSJaKVeSFoiI+t6RPHnGuD8H9u0o2HKN0VKtZt9mGt+x89 NtRrMPrcgtqEKDJiuAXfz9DFz4raMWq+JefSZS+mcmazkmAeHrw2fR+SkoxOOX0+M4uXzsIr 6ZBbmlQMFbT3Ipaw5riIgVort4kI8TxepsWp1lrzC3DDOZgSpfGK0nPzYIHhGlo15AedRrYT +cwThxocQrGWUYMFFQsMKwdo8jxjFCqJlW0r3rK/PFqsgA/1jdZz7zFINfTPNuQSq19jkue4 27L4Wn9KhUbL8CEjyqI9Gq2ge3Clj+9X5gdfJW6/PN3hFyYxkQIFQYbE1C8pJGRi1G8c8JSL VQO/SgjprR081akJuQRRDXh/iTC5ERFHYMNTatqs2lh15Y4/S6lC1QKUiceM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0EUMqyVMbEVt6fHCAnTKade/DGEmprY+9s3GR1WPHBXg6IL1XYINu6CeHcGPTWvnfACZe ehDswsnUvZRV0nKv6VK1MiROb5q9jChPvdEGI7705O0nj0sduwgoSKaSSl4g==
  • Ironport-sdr: jZ65L+xUk/df7csQKVPS1bZZ7FIiXT8egvUqpsuSJ20DZZK8z6tSe5CzZxasT+EdUT+/9Zs5zj Hw+EDKnt8QrJCKXNKX4fCjonnw49ZLRMggEL6Gg/3CFZGlCE5Y4kUMAvWCuws0yHHdyvfFP2TF vyFM0PRQPaEaEk/lyK0qVHgp23pw/3Sk6jDWmBjgAAM+mQ2Xy413O4FHjLxgkZts/3PNsGjpHt i2ilvPK+GOYV10qyKgg36evTLIsfFdkvjpVUP3f7kg56nQcQ2cs93YfF+3gHhlrMnau5uq35+r 0EEjo+zHGK4Zb/bcar5NdUD+
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Nov 04, 2021 at 01:17:53PM +0100, Jan Beulich wrote:
> On 04.11.2021 11:48, Andrew Cooper wrote:
> > On 04/11/2021 08:07, Jan Beulich wrote:
> >> On 03.11.2021 17:13, Ian Jackson wrote:
> >>> Jan Beulich writes ("Re: [PATCH] x86/passthrough: Fix hvm_gsi_eoi() build 
> >>> with GCC 12"):
> >>>> On 27.10.2021 22:07, Andrew Cooper wrote:
> >>>>>   if ( !((pirq) ? &(pirq)->arch.hvm.dpci : NULL) )
> >>>> I disagree with the compiler's analysis: While &(pirq)->arch.hvm.dpci
> >>>> indeed can't be NULL, that's not the operand of !. The operand of !
> >>>> can very well be NULL, when pirq is.
> >>>>
> >>>>> which is a hint that the code is should be simplified to just:
> >>>>>
> >>>>>   if ( !pirq )
> >>>>>
> >>>>> Do so.
> >>>> And I further agree with Roger's original reply (despite you
> >>>> apparently having managed to convince him): You shouldn't be open-
> >>>> coding pirq_dpci(). Your observation that the construct's result
> >>>> isn't otherwise used in the function is only one half of it. The
> >>>> other half is that hvm_pirq_eoi() gets called from here, and that
> >>>> one does require the result to be non-NULL.
> >>> Can you (collectively) please come to some agreement here ?
> >>> I think this is mostly a question of taste or style.
> >> Personally I don't think open-coding of constructs is merely a style /
> >> taste issue. The supposed construct changing and the open-coded
> >> instance then being forgotten (likely not even noticed) can lead to
> >> actual bugs. I guess the issue should at least be raised as one against
> >> gcc12, such that the compiler folks can provide their view on whether
> >> the warning is actually appropriate in that case (and if so, what their
> >> take is on a general approach towards silencing such warnings when
> >> they're identified as false positives).
> > 
> > This isn't opencoding anything.
> > 
> > The compiler has pointed out that the logic, as currently expressed, is
> > junk and doesn't do what you think it does.
> > 
> > And based on the, IMO dubious, argument that both you and Roger have
> > used to try and defend the current code, I agree with the compiler.
> > 
> > pirq_dpci() does not have the property that you seem expect of it,
> 
> Which property is that, exactly?

I honestly don't think we expect any property of pirq_dpci, it just
tells whether a pirq has a dpci associated with it or not. As I said
on my previous replies I think GCC is not correct in doing the check
after expanding the macro.

The relation between a pirq and it's dpci is an implementation detail
that could change at any point, and hence the complain by GCC would no
longer be true. That's exactly why we use a macro to get the dpci out
of a pirq, because how that's obtained is opaque to the caller.

So while it's true that a NULL pirq will always result in a NULL dpci,
a non-NULL pirq should not be assumed to result in a non-NULL dpci,
which is inferred by GCC by expanding the macro.

In this specific case I think the change is fine for two reasons:

 * The pirq is obtained from the domain struct.
 * The domain is known to be HVM because the only caller of
   hvm_gsi_eoi is hvm_dpci_eoi which in
   turn is only called by the vIO-APIC and the vPIC emulation code.

I dislike of GCC doing those checks to expanded macros. In this case I
think the change is fine due to my reasoning above.

It might be appropriate to switch pirq_dpci to:

#define pirq_dpci(d, pirq) \
    ((is_hvm_domain(d) && (pirq)) ? &(pirq)->arch.hvm.dpci : NULL)

Or to an inline helper.

Regards, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.