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

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


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Sat, 30 Oct 2021 10:18:01 +0200
  • 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=ThJwByg0/5txHY7BxNW5mZlbW9ULEWYcHuMqtWwzpRc=; b=ItOyEQHATH4dnF7xRdFCacSFHRkPuHMBqvzWEHKcuvnZ2uTbuRsBHIa1R9dV34EyGcYS44UtvhO/ZtPlPMD6UATh0P44czYLaAujXJsedfidgsb4VmRystVlfqn0TsQEUfh959jbfjdI32JsOmOf23+3uIlo4tJiK7yCrIv1NaN0UOhWKtRPldnLO4KIbIdxl7NFy8m48GD8Xa+IFw5C63kkmQfssGJHZArsAGowars1XSvq9IRdrOoqeKO2Ph+fdOCJ9M+4n3UfbVAp4dpS+LslAZkvHLsvn/itKy2hgFJ3vZ5g8QR/uaE/d7K0lNirJgKoXD8PRCqLXIlg9F/Pzg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fzX4sEJaHB/AsAsyHXe06Hj0nsDX5E5rvGmz4hsuBgzK6Xm85buO1P5K5sJkO33Yseiv+o8rXixHdju+53+Zeye1B1jB+yMqqioP0Aujy6kAIBkDoyR+nSRaMEFN+JO+Y3osYj5uk81T038XzeCT2dDaHJoQt6m657KCcV6ScwaMNuSnHAaF/t6qh24jB9SrEhu1+UB6VyV6xLL8DnYA8+gsxCxyTN85YbygJ2ZjwOngp84t7IjsmVCL6XfjN/VGtl+Qg/BbXO5OGEpcuUiwr4yeOaZ40H9HjM/7U9s0wwmZwhil3JDZ2G14w4EmFmQPVqXcPqgO334HF+wif60UBQ==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>
  • Delivery-date: Sat, 30 Oct 2021 08:18:28 +0000
  • Ironport-data: A9a23:JOGg8KvrT2hRsOofQhIkyCi7JOfnVL1ZMUV32f8akzHdYApBsoF/q tZmKWGBO/vcZGbxKN8lbNjio0pSvcfXmoRgTwFoqy5jHylG+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZQP0VOZigHtIQMsadUsxKbVIiGHhJZS5LwbZj29cw24nhWGthh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0FnRnDRx6lAe2e0s9VfrzFonoR5fMeaFGH/bSe gr25OrRElU1XfsaIojNfr7TKiXmS1NJVOSEoiI+t6OK2nCuqsGuu0qS2TV1hUp/0l20c95NJ NpljJ7hbwoYMYf1vu0ZaAZSLitkHax3weqSSZS/mZT7I0zudnLtx7NlDV0sPJ1e8eFyaY1M3 aVGcnZXNEnF3r/ohuLgIgVvrp1LwM3DJoQQt2sm1TjEJf0nXYrCU+PB4towMDIY254UQa2DN 5ZxhTxHTj/+YCBTP24uDsgijaCDoyCkfT11gQfAzUYwyzeKl1EguFT3C/LKfvSaSMMTmVyXz krH4GbREhwcLMaYyzeO7jSrnOCntTP2XsceGaO18tZugUaP3SoDBRsOT1y5rPKlzEmkVLp3C WYZ5y4vpqga71GwQ5/2WBjQnZKflkdCAZwKSbR8sVzTjPqPi+qEOoQaZgdDOfor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xeOk9K1kJ 0QD5SWa+eAfGSS7/yKmTVQeuxIqLLskNHK9JfjJjVWPHlXgslbnnlE422gYytLrWd9dP4E/M 323Ls5m9PsQwVcUu2LQl0+G8TTrdzCk5zrJTYAGh4c8QGLyRel8qTzHRS01goXF2on+8ZvzU H11yjCoomzufCyzRHRk0fV8pRtgdPkjv9OHtaFhMQ5IijlziyoeINicbufuy1dmpDj1H8a1P 335zswNcV67H3cOkmzvBvWwgHllA0j7nfzoGXoyEfLkIjcfnYXGsBBjYVWfl/y8Ew7puxx16 pNwiawq4dXJQmoplW92/H4EzVR0makq3srluAey1ZFV5EFVbNXpYsDuGtIDZY7Gj7g4oxPKp ghMCjl3ocUTbqmVQGagoE2q+bcG0jbXy32DXTqg/blkwS/xxtCvg8lLM92pAZ3yHtycegC2w 3+CNUbqFh5dL5gUUtMPpZzfSKJMB25ffvtChPbHb21LtBNB5ryw6SHlIndotvaPqA18A==
  • Ironport-sdr: AVpZ3E+KDDQeK9B22SNoHiNKdUbZVM0/rGiNtca8X4wWBpljgNjZK9I4RhrWhAYj94JXaxJ6jx V8+Mt/TuPQhMuQuJIfjRj03NU1Z6MKP3AySuVa/B5vENk52FoKxpeHOD2GvN2y9Pczv9wpHqkU hFGewgSsZZd6r5CH7dgK9J+vL08fn35vpAqREpu9N1PPwSsDS+xfCl930c2f+zFdycPHcYvthm MZDkB6DJXzgkWaz72cDXh5X0uyMQKe1mmHHyfTWJfctHi44YuTnfvO2X2H/Rk59sUP7C7zHxvn t8QE7ORM17FA/PMIj7ZCyquq
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Oct 29, 2021 at 07:06:43PM +0100, Andrew Cooper wrote:
> On 28/10/2021 14:26, Roger Pau Monné wrote:
> > On Thu, Oct 28, 2021 at 01:15:13PM +0100, Andrew Cooper wrote:
> >> On 28/10/2021 08:31, Roger Pau Monné wrote:
> >>> On Wed, Oct 27, 2021 at 09:07:13PM +0100, Andrew Cooper wrote:
> >>>> GCC master (nearly version 12) complains:
> >>>>
> >>>>   hvm.c: In function 'hvm_gsi_eoi':
> >>>>   hvm.c:905:10: error: the comparison will always evaluate as 'true' for 
> >>>> the
> >>>>   address of 'dpci' will never be NULL [-Werror=address]
> >>>>     905 |     if ( !pirq_dpci(pirq) )
> >>>>         |          ^
> >>>>   In file included from /local/xen.git/xen/include/xen/irq.h:73,
> >>>>                    from /local/xen.git/xen/include/xen/pci.h:13,
> >>>>                    from /local/xen.git/xen/include/asm/hvm/io.h:22,
> >>>>                    from /local/xen.git/xen/include/asm/hvm/domain.h:27,
> >>>>                    from /local/xen.git/xen/include/asm/domain.h:7,
> >>>>                    from /local/xen.git/xen/include/xen/domain.h:8,
> >>>>                    from /local/xen.git/xen/include/xen/sched.h:11,
> >>>>                    from /local/xen.git/xen/include/xen/event.h:12,
> >>>>                    from hvm.c:20:
> >>>>   /local/xen.git/xen/include/asm/irq.h:140:34: note: 'dpci' declared here
> >>>>     140 |             struct hvm_pirq_dpci dpci;
> >>>>         |                                  ^~~~
> >>>>
> >>>> The location marker is unhelpfully positioned and upstream may get 
> >>>> around to
> >>>> fixing it.  The complaint is intended to be:
> >>>>
> >>>>   if ( !((pirq) ? &(pirq)->arch.hvm.dpci : NULL) )
> >>>>                   ^~~~~~~~~~~~~~~~~~~~~~
> >>>>
> >>>> which is a hint that the code is should be simplified to just:
> >>>>
> >>>>   if ( !pirq )
> >>> I likely need more coffee, but doesn't this exploit how the macro
> >>> (pirq_dpci) is currently coded?
> >> The way pirq_dpci() is currently coded, this is nonsense, which GCC is
> >> now highlighting.
> >>
> >> It would be a very different thing if the logic said:
> >>
> >> struct pirq *pirq = pirq_info(d, gsi);
> >> struct hvm_pirq_dpci *dpci = pirq_dpci(pirq);
> >>
> >> /* Check if GSI is actually mapped. */
> >> if ( !dpci )
> >>     return;
> >>
> >> but it doesn't. Getting a non-null pirq pointer from pirq_info(d, gsi)
> >> does identify that the GSI is mapped, and the dpci nested structure is
> >> not used in this function.  I would expect this property to remain true
> >> even if we alter the data layout.
> > I think we have further assertions that this will be true:
> >
> >  1. d can only be an HVM domain given the callers of the function.
> >  2. The pirq struct is obtained from the list of pirqs owned by d.
> >
> > In which case it's assured that the pirq will always have a dpci. I
> > think it might be better if the check was replaced with:
> >
> > if ( !is_hvm_domain(d) || !pirq )
> > {
> >     ASSERT(is_hvm_domain(d));
> >     return;
> > }
> >
> > Here Xen cares that pirq is not NULL and that d is an HVM domain
> > because hvm_gsi_deassert will assume so.
> 
> We're several calls deep in an hvm-named codepath, called exclusively
> from logic in arch/x86/hvm/
> 
> is_hvm_domain() is far from free, and while I'm in favour of having
> suitable sanity checks in appropriate places, I don't even think:
> 
> {
>     struct pirq *pirq = pirq_info(d, gsi);
> 
>     ASSERT(is_hvm_domain(d));
> 
>     if ( !pirq )
>         return;
> ...
> 
> would be appropriate in this case.

Fine:

Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

I think I would prefer if you could slightly adjust the commit message
to mention that is already exclusively called from HVM only paths,
and that as such the HVM related dpirq structures will always be
present.

Thanks, Roger.



 


Rackspace

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