From: Gavin Shan <gshan@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: Aldy Hernandez <aldyh@redhat.com>, Thomas Huth <thuth@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
Laurent Vivier <laurent@vivier.eu>,
qemu-arm <qemu-arm@nongnu.org>, Shan Gavin <shan.gavin@gmail.com>,
Philippe Mathieu Daude <philmd@redhat.com>
Subject: Re: [PATCH] configure: Improve alias attribute check
Date: Mon, 22 Mar 2021 21:54:36 +1100 [thread overview]
Message-ID: <4231d15c-493f-cb3d-39ef-aff40e3618ee@redhat.com> (raw)
In-Reply-To: <0cad2de8-1150-be7c-237b-9f3ddea52473@linaro.org>
Hi Richard and Paolo,
On 3/22/21 5:23 AM, Richard Henderson wrote:
> On 3/21/21 11:46 AM, Paolo Bonzini wrote:
>> HRM, what about biting the bullet and making exec-vary.c a C++ source?... Then instead of making it conditional an attribute((alias)), we make it conditional on having a C++ compiler.
>
> Doesn't help. The gcc bug I filed talks about c++, because that's the closest analogy.
>
> But set_preferred_target_page_bits is called *much* later than a constructor. Though still before any use of the variable in question, for which we have an --enable-debug-tcg assertion.
>
It looks this issue can be avoided after "volatile" is applied to
@target_page. However, I'm not sure if it's the correct fix to have.
If it is, I can post a formal patch so that it can be included.
--- a/exec-vary.c
+++ b/exec-vary.c
-extern const TargetPageBits target_page
+extern const TargetPageBits volatile target_page
__attribute__((alias("init_target_page")));
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
-extern const TargetPageBits target_page;
+extern const TargetPageBits volatile target_page;
According to the experiments I did, it would be function call
to set_preferred_target_page_bits() is dropped when the machine
is created. The following c files are used in the experiment:
--- a.c ---
static int x;
const extern int VOLATILE y __attribute__((alias("x")));
extern int read_y(void);
void write_x(int val) { x = 1; }
int main(void) { return read_y(); }
--- b.c---
extern const int VOLATILE y;
extern void write_x(int val);
int read_y(void) { write_x(1); return y; }
# gcc a.c b.c -O2 -flto=auto -DVOLATILE= -o a; ./a; echo $?
0
# gdb -nw ./a
(gdb) disassem main
Dump of assembler code for function main:
0x0000000000400480 <+0>: adrp x1, 0x420000 <__libc_start_main@got.plt>
0x0000000000400484 <+4>: mov w2, #0x1 // #1
0x0000000000400488 <+8>: mov w0, #0x0 // #0
0x000000000040048c <+12>: str w2, [x1, #32]
0x0000000000400490 <+16>: ret
End of assembler dump.
# gcc a.c b.c -O2 -flto=auto -DVOLATILE=volatile -o a; ./a; echo $?
1
# gdb -nw ./a
(gdb) disassem main
Dump of assembler code for function main:
0x0000000000400480 <+0>: adrp x1, 0x420000 <__libc_start_main@got.plt>
0x0000000000400484 <+4>: mov w2, #0x1 // #1
0x0000000000400488 <+8>: adrp x0, 0x420000 <__libc_start_main@got.plt>
0x000000000040048c <+12>: str w2, [x1, #32]
0x0000000000400490 <+16>: ldr w0, [x0, #32]
0x0000000000400494 <+20>: ret
Thanks,
Gavin
next prev parent reply other threads:[~2021-03-22 7:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-20 4:27 [PATCH] configure: Improve alias attribute check Gavin Shan
2021-03-20 4:48 ` Thomas Huth
2021-03-20 23:32 ` Gavin Shan
2021-03-20 17:52 ` Paolo Bonzini
2021-03-20 22:33 ` Richard Henderson
2021-03-20 23:36 ` Gavin Shan
2021-03-21 15:49 ` Richard Henderson
2021-03-21 16:50 ` Paolo Bonzini
2021-03-21 17:34 ` Richard Henderson
2021-03-21 17:43 ` Paolo Bonzini
2021-03-21 17:46 ` Paolo Bonzini
2021-03-21 18:23 ` Richard Henderson
2021-03-22 10:54 ` Gavin Shan [this message]
2021-03-22 20:59 ` Richard Henderson
2021-03-23 3:13 ` Gavin Shan
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=4231d15c-493f-cb3d-39ef-aff40e3618ee@redhat.com \
--to=gshan@redhat.com \
--cc=aldyh@redhat.com \
--cc=laurent@vivier.eu \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=shan.gavin@gmail.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;
as well as URLs for NNTP newsgroup(s).