[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: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 29 Oct 2021 19:06:43 +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=F8tuQP1wCJKzmiVJdXPyz0Wg+Sw6PLxCydlB4nvomCY=; b=HLGgIzkZs3XaTpI6RbIbhQofFmW8tZHkRS4L5zdYimcgxAcUgyGL6GBzJwYpx9RNaxd4+3QzU+GXm8Cnmo+mNn48cFzzZ7ifFocKdNWUvCbU3hUrZGAVqDjV1uLgE/C4/UeTvEwZ+A01aztJwh+JoxFdc2JzZqGsQkeLKtd824mAzcTkPqWGN2hXCsB8PlkC/kR9+DlJaYopEQaNZCqioaO6IB1ede8vUnHODDd7DUEn7w+9NUj+KeAVaoBk7KmZS5X0RmwoXfiFQaY5Y9nlZGK2FhgEkpPsiRaqQfj534At+u3X3KrZlskzY30kMgyORYWG+SJSYClJCJLl+gy1/g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QUWNq74NuKqu/uGY0Fm2tlQ2sBMoHkmAMjRw6B+S5hm25eZOpfAtw5AWaedYsa0jBGWClhKqk0Udj1myb62UZCspzqtrBIvCN7Zd/8ZmLh+eHGz5a+yLEezZ5Rna9xAoMI8BKIBUr0R88DIge14TTj3gUWCNQlx5qRRwNVkuxmwQecI4lpnNPonHGGO+x+oX9th783E+lr36/+RDlnHKxjqBQFjnc58dCR8l+SNfCzVZP9erGlMASqC6vSPgbRqEOet9uyU73LZGt5M7DJYrkzgaWyRjx0myMcN/h6IUwOJYeFtJCdrzUK6JkgO7o2XIXogQFGpyysTwwmtx4U5EKQ==
  • Authentication-results: esa3.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: Fri, 29 Oct 2021 18:07:14 +0000
  • Ironport-data: A9a23:uXsC0K4m0t8KD2Dq+jFwQgxRtMrAchMFZxGqfqrLsTDasY5as4F+v jNLCD+BPPyNNmShetskOdm0/UsO6MCEzocxHlQ/qSBkHi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuV3zyIQUBUjclkfJKlYAL/En03FVAMpBsJ00o5wrdh2N8w27BVPivW0 T/Mi5yHULOa82Yc3lI8s8pvfzs24ZweEBtB1rAPTagjUG32zhH5P7pGTU2FFFPqQ5E8IwKPb 72rIIdVXI/u10xF5tuNyt4Xe6CRK1LYFVDmZnF+A8BOjvXez8CbP2lS2Pc0MC9qZzu1c99Z4 /RujMScbCYSBKjNp7UecxBJORxxMvgTkFPHCSDXXc27ykTHdz3nwul0DVFwNoodkgp1KTgQr 7pCcmlLN03dwbLtqF64YrAEasALBc/nJo4A/FpnyinUF60OSpHfWaTao9Rf2V/cg+gTQ6iPO ptHMVKDajz+UyZFZw4aJqkGwuCDjELlIgF7pRGK8P9fD2/7k1UqjemF3MDuUv6gSNhRn02Yj nnb5Gm/CRYfXPSPxDzA/n+yi+vnmSLgRJlUBLC+7uRtglCY2ioUEhJ+fVqko9Gph0imQdVdJ kcIvC00osAa60iDXtT7GRqirxa5UgU0AoQKVbdgsUfUl/SSs13x6nU4oi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ygcy78 Zdm6gVMqyMMbB55/yKnDVRxbwbsaa6GKPDv5ah8590JzsaDJ2Jd21Ce32m+ksdfnghObMJUK Cyy+BgvDSadXEefq2AdwM4t7iqnayzqHr+CyR2fyIa1A==
  • Ironport-sdr: Al0/8wIbmijGEfX3bWy2gkfDkCCCwVEnmVXDy5TkJwJjDeakI0BRkW19esKUNCDa7qWusTWy07 l2dhI0Gq//UQrU82/z0LA7G/QJ6TlxD00aXgWyjMQqtFalKkZ3RhgB5IHmAwwyGn/IoifgVML8 +oSMWaktcANi+jT7TIGzceJnVeF/ChocVtTtElYJfSNXI0PzVn2bMiNqtxJmiMAvJUJ6gZOB8p k8XsxU4/p7WC6f6h9invz/srHXhWQMo6a/Z2xHRzYC4qDY2QiPeJUnMIlikDSuzCgx4g2vmUZI 57cOfLrjlRFlcCeQps6/lOtw
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

~Andrew




 


Rackspace

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