tcg/ppc: disable atomic write check on ppc32
PATCH 1/1 tcg/ppc: disable atomic write check on ppc32
this fixes building for ppc64 on ppc32 (changed in 5964fca8a12c):
qemu/tcg/ppc/tcg-target.inc.c: In function 'tb_target_set_jmp_target':
qemu/include/qemu/compiler.h:86:30: error: static assertion failed: "not expecting: sizeof(*(uint64_t *)jmp_addr) > ATOMIC_REG_SIZE"
QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \
^
qemu/tcg/ppc/tcg-target.inc.c:1377:9: note: in expansion of macro 'atomic_set'
atomic_set((uint64_t *)jmp_addr, pair);
^---
This fixes Shippable builds, see:
https://app.shippable.com/github/qemu/qemu/runs/434/10/console
tcg/ppc/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tcg/ppc/tcg-target.inc.c +1 -1
@@ -1374,7 +1374,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, pair = (uint64_t )i2 <<32 | i1;#endif -atomic_set ((uint64_t *)jmp_addr, pair); +atomic_set__nocheck ((uint64_t *)jmp_addr, pair);flush_icache_range (jmp_addr, jmp_addr +8 ); }else {intptr_t diff = addr - jmp_addr;
Signature · 1 line
2.14.1
Quoted 24 lines · Philippe Mathieu-Daudé
this fixes building for ppc64 on ppc32 (changed in
5964fca8a12c):
qemu/tcg/ppc/tcg-target.inc.c: In function 'tb_target_set_jmp_target':
qemu/include/qemu/compiler.h:86:30: error: static assertion failed: "not expecting:sizeof(*(uint64_t *)jmp_addr)>ATOMIC_REG_SIZE"QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ ^ qemu/tcg/ppc/tcg-target.inc.c:1377:9: note: in expansion of macro 'atomic_set' atomic_set((uint64_t *)jmp_addr, pair); ^Suggested-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
This fixes Shippable builds, see:
https://app.shippable.com/github/qemu/qemu/runs/434/10/consoletcg/ppc/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tcg/ppc/tcg-target.inc.c +0
-0
tcg/ppc/tcg-target.inc.c void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, · line 1380
Quoted 8 lines
tcg/ppc/tcg-target.inc.c +1
-1@@ -1374,7 +1374,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, pair = (uint64_t )i2 <<32 | i1;#endif -atomic_set ((uint64_t *)jmp_addr, pair); +atomic_set__nocheck ((uint64_t *)jmp_addr, pair);flush_icache_range (jmp_addr, jmp_addr +8 ); }else {intptr_t diff = addr - jmp_addr;
Can you explain why this is the right thing? On the face of it it looks correct to insist that we don't try to do an atomic set of something that's bigger than the host can actually handle...
thanks
-- PMM
Quoted 28 lines · Peter Maydell
Quoted 27 lines · Philippe Mathieu-Daudé
this fixes building for ppc64 on ppc32 (changed in
5964fca8a12c):
qemu/tcg/ppc/tcg-target.inc.c: In function 'tb_target_set_jmp_target':
qemu/include/qemu/compiler.h:86:30: error: static assertion failed: "not expecting:sizeof(*(uint64_t *)jmp_addr)>ATOMIC_REG_SIZE"QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ ^ qemu/tcg/ppc/tcg-target.inc.c:1377:9: note: in expansion of macro 'atomic_set' atomic_set((uint64_t *)jmp_addr, pair); ^Suggested-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
This fixes Shippable builds, see:
https://app.shippable.com/github/qemu/qemu/runs/434/10/consoletcg/ppc/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tcg/ppc/tcg-target.inc.c +0
-0@@ -1374,7 +1374,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, pair = (uint64_t )i2 <<32 | i1;#endif
Quoted 10 lines
tcg/ppc/tcg-target.inc.c void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, · line 1380
Quoted 5 lines
tcg/ppc/tcg-target.inc.c +1
-1-atomic_set ((uint64_t *)jmp_addr, pair); +atomic_set__nocheck ((uint64_t *)jmp_addr, pair);flush_icache_range (jmp_addr, jmp_addr +8 ); }else {intptr_t diff = addr - jmp_addr;Can you explain why this is the right thing? On the face of it it looks correct to insist that we don't try to do an atomic set of something that's bigger than the host can actually handle...
It is the correct thing because ppc32 is handled earlier in the function; only ppc64 can reach here, therefore a 64-bit atomic_set is always available.
However, I wrote the function intending to minimize the ifdefs so that we can be sure that it all compiles -- especially the ppc32 bits which I cannot test on gcc cfarm machines. I didn't think about the fact that ppc32 could not compile the _Static_assert within the 64-bit atomic_set here in the ppc64 section.
r~
Quoted 40 lines · Richard Henderson
Quoted 28 lines · Peter Maydell
Quoted 27 lines · Philippe Mathieu-Daudé
this fixes building for ppc64 on ppc32 (changed in
5964fca8a12c):
qemu/tcg/ppc/tcg-target.inc.c: In function 'tb_target_set_jmp_target':
qemu/include/qemu/compiler.h:86:30: error: static assertion failed: "not expecting:sizeof(*(uint64_t *)jmp_addr)>ATOMIC_REG_SIZE"QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ ^ qemu/tcg/ppc/tcg-target.inc.c:1377:9: note: in expansion of macro 'atomic_set' atomic_set((uint64_t *)jmp_addr, pair); ^Suggested-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
This fixes Shippable builds, see:
https://app.shippable.com/github/qemu/qemu/runs/434/10/consoletcg/ppc/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tcg/ppc/tcg-target.inc.c +0
-0@@ -1374,7 +1374,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, pair = (uint64_t )i2 <<32 | i1;#endif Quoted 10 lines
tcg/ppc/tcg-target.inc.c void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, · line 1380
Quoted 5 lines
tcg/ppc/tcg-target.inc.c +1
-1-atomic_set ((uint64_t *)jmp_addr, pair); +atomic_set__nocheck ((uint64_t *)jmp_addr, pair);flush_icache_range (jmp_addr, jmp_addr +8 ); }else {intptr_t diff = addr - jmp_addr;Can you explain why this is the right thing? On the face of it it looks correct to insist that we don't try to do an atomic set of something that's bigger than the host can actually handle...
Quoted 7 lines
It is the correct thing because ppc32 is handled earlier in the function; only ppc64 can reach here, therefore a 64-bit
atomic_setis always available.However, I wrote the function intending to minimize the ifdefs so that we can be sure that it all compiles -- especially the ppc32 bits which I cannot test on gcc cfarm machines. I didn't think about the fact that ppc32 could not compile the
_Static_assertwithin the 64-bitatomic_sethere in the ppc64 section.
Ah, I see. Can we have a comment about why the __nocheck is ok here, then, please?
thanks
-- PMM
Quoted 28 lines · Peter Maydell
Quoted 27 lines · Philippe Mathieu-Daudé
this fixes building for ppc64 on ppc32 (changed in
5964fca8a12c):
qemu/tcg/ppc/tcg-target.inc.c: In function 'tb_target_set_jmp_target':
qemu/include/qemu/compiler.h:86:30: error: static assertion failed: "not expecting:sizeof(*(uint64_t *)jmp_addr)>ATOMIC_REG_SIZE"QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ ^ qemu/tcg/ppc/tcg-target.inc.c:1377:9: note: in expansion of macro 'atomic_set' atomic_set((uint64_t *)jmp_addr, pair); ^Suggested-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
This fixes Shippable builds, see:
https://app.shippable.com/github/qemu/qemu/runs/434/10/consoletcg/ppc/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tcg/ppc/tcg-target.inc.c +0
-0@@ -1374,7 +1374,7 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, pair = (uint64_t )i2 <<32 | i1;#endif
Quoted 10 lines
tcg/ppc/tcg-target.inc.c void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, · line 1380
Quoted 5 lines
tcg/ppc/tcg-target.inc.c +1
-1-atomic_set ((uint64_t *)jmp_addr, pair); +atomic_set__nocheck ((uint64_t *)jmp_addr, pair);flush_icache_range (jmp_addr, jmp_addr +8 ); }else {intptr_t diff = addr - jmp_addr;Can you explain why this is the right thing? On the face of it it looks correct to insist that we don't try to do an atomic set of something that's bigger than the host can actually handle...
Probably because this code is guarded by "if (TCG_TARGET_REG_BITS == 64)", so actually it only ever runs with 64-bit targets.
I wonder if QEMU_BUILD_BUG_ON (at least in atomics) should not use a static assertion, but rather the 'error ("MESSAGE")' attribute instead. This way, if the code is dead it does not cause a build failure.
Paolo
Quoted 3 lines · Paolo Bonzini
I wonder if
QEMU_BUILD_BUG_ON(at least in atomics) should not use a static assertion, but rather the 'error ("MESSAGE")' attribute instead. This way, if the code is dead it does not cause a build failure.
I think that would be an excellent idea.
r~
Quoted 10 lines · Philippe Mathieu-Daudé
this fixes building for ppc64 on ppc32 (changed in
5964fca8a12c):
qemu/tcg/ppc/tcg-target.inc.c: In function 'tb_target_set_jmp_target':
qemu/include/qemu/compiler.h:86:30: error: static assertion failed: "not expecting:sizeof(*(uint64_t *)jmp_addr)>ATOMIC_REG_SIZE"QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ ^ qemu/tcg/ppc/tcg-target.inc.c:1377:9: note: in expansion of macro 'atomic_set' atomic_set((uint64_t *)jmp_addr, pair); ^
Quoted 5 lines
Suggested-by Richard Henderson <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
This fixes Shippable builds, see:
https://app.shippable.com/github/qemu/qemu/runs/434/10/console
r~
Richard Henderson
Appliedtcg/ppc/tcg-target.inc.c void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, · line 1380
Quoted 6 lines · Philippe Mathieu-Daudé
tcg/ppc/tcg-target.inc.c +1
-1-atomic_set ((uint64_t *)jmp_addr, pair); +atomic_set__nocheck ((uint64_t *)jmp_addr, pair);flush_icache_range (jmp_addr, jmp_addr +8 ); }else {intptr_t diff = addr - jmp_addr;
Queued, thanks.
r~
Quoted 9 lines · Richard Henderson
tcg/ppc/tcg-target.inc.c void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, · line 1380
Quoted 6 lines · Philippe Mathieu-Daudé
tcg/ppc/tcg-target.inc.c +1
-1-atomic_set ((uint64_t *)jmp_addr, pair); +atomic_set__nocheck ((uint64_t *)jmp_addr, pair);flush_icache_range (jmp_addr, jmp_addr +8 ); }else {intptr_t diff = addr - jmp_addr;Queued, thanks.
Thanks Richard for adding the comment requested by Peter!