From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: Janosch Frank <frankja@linux.ibm.com>,
David Hildenbrand <david@redhat.com>,
kvm@vger.kernel.org, linux-s390@vger.kernel.org,
Sven Schnelle <svens@linux.ibm.com>
Subject: Re: [kvm-unit-tests PATCH] s390x: Ignore gcc 12 warnings for low addresses
Date: Fri, 20 May 2022 16:08:18 +0200 [thread overview]
Message-ID: <5e1924d9-9594-55f2-00db-414374dc3c7d@linux.ibm.com> (raw)
In-Reply-To: <52befa6f-409c-8ace-7aa7-7aa7837d6584@redhat.com>
On 5/19/22 11:46, Thomas Huth wrote:
> On 18/05/2022 13.07, Janis Schoetterl-Glausch wrote:
>> On 5/17/22 18:09, Thomas Huth wrote:
>>> On 17/05/2022 14.02, Claudio Imbrenda wrote:
>>>> On Mon, 16 May 2022 16:43:32 +0200
>>>> Janis Schoetterl-Glausch <scgl@linux.ibm.com> wrote:
>>>>
>>>>> gcc 12 warns if a memory operand to inline asm points to memory in the
>>>>> first 4k bytes. However, in our case, these operands are fine, either
>>>>> because we actually want to use that memory, or expect and handle the
>>>>> resulting exception.
>>>>> Therefore, silence the warning.
>>>>
>>>> I really dislike this
>>>
>>> I agree the pragmas are ugly. But maybe we should mimic what the kernel
>>> is doing here?
>>>
>>> $ git show 8b202ee218395
>>> commit 8b202ee218395319aec1ef44f72043e1fbaccdd6
>>> Author: Sven Schnelle <svens@linux.ibm.com>
>>> Date: Mon Apr 25 14:17:42 2022 +0200
>>>
>>> s390: disable -Warray-bounds
>>> gcc-12 shows a lot of array bound warnings on s390. This is caused
>>> by the S390_lowcore macro which uses a hardcoded address of 0.
>>> Wrapping that with absolute_pointer() works, but gcc no longer knows
>>> that a 12 bit displacement is sufficient to access lowcore. So it
>>> emits instructions like 'lghi %r1,0; l %rx,xxx(%r1)' instead of a
>>> single load/store instruction. As s390 stores variables often
>>> read/written in lowcore, this is considered problematic. Therefore
>>> disable -Warray-bounds on s390 for gcc-12 for the time being, until
>>> there is a better solution.
>>>
>>> ... so we should maybe disable it in the Makefile, too, until the
>>> kernel folks found a nicer solution?
>>>
>>> Thomas
>>>
>>
>> Neat, wasn't aware of that commit.
>>
>> I don't think we need to concern ourselves with performance in this case and can define
>>
>> +#define HIDE_PTR(ptr) \
>> +({ \
>> + uint64_t __ptr; \
>> + asm ("" : "=d" (__ptr) : "0" (ptr)); \
>> + (typeof(ptr))__ptr; \
>> +})
>> +
>>
>> in some header (which?).
>>
>> Another alternative would be to define some extern symbols for the addresses we want to use.
>> It might be nice to have a symbol for the lowcore anyway, then we can get rid of
>>
>> static struct lowcore *lc;
>> struct lowcore *lc = (struct lowcore *)0x0;
>> ...
>>
>> in a bunch of tests.
>
> I like that idea.
>
>> And use that symbol to derive the addresses we want to use.
>> emulator.c uses -1 to generate an addressing exception, we either need another symbol for
>> that or use another invalid address. (Can't get to -1 from lowcore/0 because the max array
>> size is signed int64 max)
>
> Maybe use INT64_MAX or something similar? Would that work?
I did it slightly different than in my prototype --- used a pointer instead of an array,
doesn't matter then.
>
> Thomas
>
prev parent reply other threads:[~2022-05-20 14:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 14:43 [kvm-unit-tests PATCH] s390x: Ignore gcc 12 warnings for low addresses Janis Schoetterl-Glausch
2022-05-17 12:02 ` Claudio Imbrenda
2022-05-17 16:09 ` Thomas Huth
2022-05-18 5:17 ` Claudio Imbrenda
2022-05-18 11:07 ` Janis Schoetterl-Glausch
2022-05-19 9:46 ` Thomas Huth
2022-05-20 14:08 ` Janis Schoetterl-Glausch [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5e1924d9-9594-55f2-00db-414374dc3c7d@linux.ibm.com \
--to=scgl@linux.ibm.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=svens@linux.ibm.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox