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

Re: Xen reliance on non-standard GCC features


  • To: Roberto Bagnara <bagnara@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 9 Jun 2023 10:54:39 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=VE1oF5I5wbN4sICMzWI5ENwPeCVLgxBi+LEDXnKy5Vw=; b=nuBVhTSmQaJRe31MSjxwivDa8x5Zz4cAYUEtBHcb8hdhoZ74iwuWERYHT0/WnDnuleriKlLrGAyNri4AmrsGXWA2P6byC+4pGOU1ahu4JsJxmP5d5/hCct9ahlLfcvgs7EuicDk3RpKwSwJZ3zGoAyXjZtjrxcQy59DqzfECxTaGMsBUK2A8LlpPIc0dN7dLFKK6v0mClp/zhsVf+Dcp46AZdpwSD9XuPeCEJH2aoXUxvdffUmKnwvqzFS8g2VLwZj7WG55uculxDinTBh8uPObxG5/Of1IvrgyIqQExHBHzc1EuKgmVyhZdwb8j8QTK0dGk+8kjOhxp171YoaMl1g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PYGav2Syd7eBIxdqT7kpVXKUD8iJWZU3zbz0lYWq2XtH2RsSDEtuGz668ySB+xDXGXsZrUXC70pxC2fACdya8XzXyPcjP3Hi1DWqIad4JDsIeXlg134yTmyAZZM1R9RMIivHUj63GWRkLSMjcd9Oc3hqm7c8UqREzfcGCu3lsQm4AcZjP8KQFwOMWbF+jAwJZRcZKSp3EU66BA5+szSIU/fvY3xg8TjJkfXkuXOuzjJwgLx8i9enJPSsNHGxi7RoLB5IS6OR3A5WPIjQmES96KSSboIKyuI9cNRPq1I1Z21LVzxZGJ4TMiCswoPtkKkNJ9kEKREr8Ro6uhFyDmG/qw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <stefano.stabellini@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "consulting@xxxxxxxxxxx" <consulting@xxxxxxxxxxx>
  • Delivery-date: Fri, 09 Jun 2023 08:54:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 08.06.2023 14:18, Roberto Bagnara wrote:
> On 07/06/23 09:39, Jan Beulich wrote:
>> On 05.06.2023 15:26, Roberto Bagnara wrote:
>>> On 05/06/23 11:28, Jan Beulich wrote:
>>>> On 05.06.2023 07:28, Roberto Bagnara wrote:
>>> You are right: here are a few examples for U2:
>>>
>>> xen/arch/arm/cpuerrata.c:92.12-92.35:
>>> empty initializer list (ill-formed for the C99 standard, ISO/IEC 9899:1999 
>>> Section 6.7.8: "An empty initialization list." [STD.emptinit]). Tool used 
>>> is `/usr/bin/aarch64-linux-gnu-gcc-12'
>>> xen/include/xen/spinlock.h:31.21-31.23: expanded from macro `_LOCK_DEBUG'
>>> xen/include/xen/spinlock.h:143.57-143.67: expanded from macro 
>>> `SPIN_LOCK_UNLOCKED'
>>> xen/include/xen/spinlock.h:144.43-144.60: expanded from macro 
>>> `DEFINE_SPINLOCK'
>>
>> I'm afraid this is a bad example, as it goes hand-in-hand with using
>> another extension. I don't think using a non-empty initialization list
>> is going to work with
>>
>> union lock_debug { };
> 
> Yes, this is C99 undefined behavior 58:
> "A structure or union is defined as containing no named members (6.7.2.1)."
> 
> Here is another example:
> 
> lpae_t pte = {};
> 
> whereas we have
> 
> typedef union {
>      uint64_t bits;
>      lpae_pt_t pt;
>      lpae_p2m_t p2m;
>      lpae_walk_t walk;
> } lpae_t;
> 
> 
>>> xen/arch/arm/cpuerrata.c:678.5-678.6:
>>> empty initializer list (ill-formed for the C99 standard, ISO/IEC 9899:1999 
>>> Section 6.7.8: "An empty initialization list." [STD.emptinit]). Tool used 
>>> is `/usr/bin/aarch64-linux-gnu-gcc-12'
>>>
>>> xen/arch/arm/cpufeature.c:33.5-33.6:
>>> empty initializer list (ill-formed for the C99 standard, ISO/IEC 9899:1999 
>>> Section 6.7.8: "An empty initialization list." [STD.emptinit]). Tool used 
>>> is `/usr/bin/aarch64-linux-gnu-gcc-12'
>>
>> Both of these are a common idiom we use: The "sentinel" of an array
>> of compound type initializer.
> 
> Wouldn't it be possible writing such sentinels in a standard-compliant
> way, like {0} or similar, instead of {}?

I would be possible, sure, but the question is whether we want that. Iirc
in review comments we've been asking to preferably use {}, for being
shorter / less clutter without resulting in any ambiguity.

>>>>> U6) Empty declarations.
>>>
>>> Examples:
>>>
>>> xen/arch/arm/arm64/lib/find_next_bit.c:57.29:
>>> empty declaration (ill-formed for the C99 standard, ISO/IEC 9899:1999 
>>> Section 6.7: "An empty declaration." [STD.emptdecl]). Tool used is 
>>> `/usr/bin/aarch64-linux-gnu-gcc-12'
>>>
>>> xen/arch/arm/arm64/lib/find_next_bit.c:103.34:
>>> empty declaration (ill-formed for the C99 standard, ISO/IEC 9899:1999 
>>> Section 6.7: "An empty declaration." [STD.emptdecl]). Tool used is 
>>> `/usr/bin/aarch64-linux-gnu-gcc-12'
>>
>> Looks like these could be taken care of by finally purging our
>> EXPORT_SYMBOL() stub.
>>
>>> xen/arch/arm/include/asm/vreg.h:143.26:
>>> empty declaration (ill-formed for the C99 standard, ISO/IEC 9899:1999 
>>> Section 6.7: "An empty declaration." [STD.emptdecl]). Tool used is 
>>> `/usr/bin/aarch64-linux-gnu-gcc-12'
>>>
>>> xen/arch/arm/include/asm/vreg.h:144.26:
>>> empty declaration (ill-formed for the C99 standard, ISO/IEC 9899:1999 
>>> Section 6.7: "An empty declaration." [STD.emptdecl]). Tool used is 
>>> `/usr/bin/aarch64-linux-gnu-gcc-12'
>>
>> I'm having trouble spotting anything suspicious there.
> 
> The macro expands to definitions of inline functions
> and after the macro invocation there is a ";".
> 
> The preprocessed code is then:
> 
> static inline void foo() { ... }
> ;
> 
> where the final ";" is an empty declaration not allowed by
> the C99 language standard.

Oh, I see.

> Removing the ";" after the macro invocation is a possible solution,
> but other possibilities exist if this is strongly unwanted.

We have other macros to instantiate functions, and there no stray
semicolons are used. I think this wants doing the same way here, but it
being Arm code the ultimate say is with the Arm maintainers.

Jan



 


Rackspace

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