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

Re: [PATCH] rombios: Work around GCC issue 99578


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 18 Aug 2023 12:09:44 +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=be7miB0zMoix+KB8bHKkeixlneqDcDvmw3XQR9SImSc=; b=GLvN56TcczRkeXLV+eLrAvKV880ykq/heRWM3calGrSY6ldWvLtf+T/8PyAaTfvZyL3wn8HQICmx1JL/9Mxb+54BtO0yVUn5OHUt653CcvnC0t+YJhapvQBbkYNTbTDm6kauHcy7I8YE6NsSVSfjSED0gadbxHgFBpigXrvKBWKCKenAxP9zA1rBcIXSLC6bgpjoC8jF1rNxOkNm176MnFAyBTFUXWomOdSC/d1dpvT58dFiYV00YWn10xkeawGlhLrzzKERUBSJx8ChD5zVBV6ugsJrEN/WofkQUna0Fwq4DSWHlywvHC8o0Biihx2d0IZCFk1xmbVvG34GIwBP6g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LGRXzqI25WETH3D2B1Y2QqLSwYAWNztmqVo8cqSJK2fhful8Sz/1YBu9fkD9fSp37b0zS5BhnCxA/pZWD+0OLsiFmaYmBRHzYK0ucmqp7B9FKvpVVu2nUki5WURWw2cg2BSOmGtfea8018eo3T8Ae/o3HVyBXuGax744oKfOhD0dWSGVtmhDO0M4RIG+Cxmq6x0H4rCqOKUWN4yNteRqUkF9tBIoKWwDUrIA4wZLewSuCe6hj/m1yKDK60Uy35rAwDlZ2kTq0OwtLJb//oUGn1qEizN1wJJVlFd2wk1stgh2l+atgkvBnHL/4epB/mzm0WoAf3cdsGgdKsYtrszRLA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 18 Aug 2023 10:10:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 18.08.2023 11:44, Andrew Cooper wrote:
> On 18/08/2023 7:50 am, Jan Beulich wrote:
>> On 17.08.2023 22:45, Andrew Cooper wrote:
>>> GCC 12 objects to pointers derived from a constant:
>>>
>>>   util.c: In function 'find_rsdp':
>>>   util.c:429:16: error: array subscript 0 is outside array bounds of 
>>> 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
>>>     429 |     ebda_seg = *(uint16_t *)ADDR_FROM_SEG_OFF(0x40, 0xe);
>>>   cc1: all warnings being treated as errors
>>>
>> Yet supposedly the bug was fixed in 12.1 (and the fix also backported to
>> 11.3). Did you spot anything in ADDR_FROM_SEG_OFF() and this particular
>> use of it that is different from the patterns mentioned in that bug?
> 
> $ gcc --version
> gcc (GCC) 12.2.1 20221121
> 
> At a guess, only a partial fix was backported into 12.1.  AIUI, it was
> an area of logic which had already seen significant development in 13
> before the behaviour was reverted.

Hmm, for 12 I didn't think there was any backporting involved.

> The only thing interesting about ADDR_FROM_SEG_OFF() is the constant
> folding required for the expression to become *(uint16_t *)0x40e, which
> (I suspect) is why it compiles fine at -Og but fails at -O2.

Oh, the relevant aspect may be that is is below 4k (which I think is
their heuristic offset to guess "almost NULL" dereferencing).

>>> This is a GCC bug, but work around it rather than turning array-bounds
>>> checking off generally.
>> I certainly agree here. I guess it's not worth trying to restrict the
>> workaround for rombios (I will want to try doing so in the hypervisor).
> 
> Can I translate this to an ack?

You can now:
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>

I wanted to at least have a vague idea of why this fails with gcc12,
when I thought it shouldn't. In light of the 4k aspect maybe the bug
reference wants adjusting / dropping.

Jan



 


Rackspace

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