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

Re: Xen reliance on non-standard GCC features


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Roberto Bagnara <bagnara@xxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Fri, 9 Jun 2023 11:36:33 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=yoqt0ZH7gZsrkAN5dbkVkm74ZnmBovzVLSU6Qi9oBuo=; b=KGc8BCX/FOL0mdYGRgC0LbHkuzDPxx99cN8we6Uv8l424hDQLcNTksQCNUjtBeQSW50NA+6GOaSx1iiBLO0ib21rpSuvacsPmP8fudf+Rl0s5PVvgk90MB1jpFkMvLY5sIFcyeXZD4JKhfuz4VvyRjOdueOgMXplITIJGSKxF0/NHt0vxoHQ00iNtBsulR6Am261P5ax4NiWp79ERvjUNOSVlON02EP4kzd5PlTLBkhrbqh2VYlNnGRLuM9By14HCH/IUy1DJ2FUbaY15ECuRy9zHifv0nXYLvbrEgSIgeD/CXpHIYJ5YFlWv4thrYaEqvewr5k7qosgeOijQhuOEg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jAP3h2S3/PN9hEFmMbuRmNYzH96gmtv5D8Dh+fyicDAWIGM5BWaMl6CPx4b6XOgHlgz6CP1rCma2G2nCoFaB62zPa6FXeMtPu1cDRrXaXK2plftpCavEH9w/8Z8EuD/Z5eEVoJnUw5PsXgRPYQmutxUxtfOWYAKHjCsS7nrh0eiqbwHXL5/+V/BOulQE49h9nSmbevAg9FGGD3ulM2VCiw9xDf29mJqpizCWWyx+ENcdvP3J4VGQxZWbdLe/qnhnyNm2RAmUWyag5rINIZsumSBlx7UhBbSxGcR3whoU8YOq7n7AMA0wANVsnNnrtgoVe4MXKZGeUjYTpbGanE9wFQ==
  • Cc: Stefano Stabellini <stefano.stabellini@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "consulting@xxxxxxxxxxx" <consulting@xxxxxxxxxxx>
  • Delivery-date: Fri, 09 Jun 2023 09:36:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 09/06/2023 10:54, Jan Beulich wrote:
> 
> 
> 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.
Apart from vreg.h the same applies to TLB_HELPER of arm32/arm64.
I think also TYPE_SAFE would want to be fixed.

~Michal



 


Rackspace

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