diff options
author | Peter Maydell | 2014-03-28 16:29:46 +0100 |
---|---|---|
committer | Richard Henderson | 2014-05-12 19:03:04 +0200 |
commit | 86360ad71df0070283469b8ae59f33cdd013501d (patch) | |
tree | 45f6fb13e9e2887e45ca70259a2cdc95ad8a0ea0 /include | |
parent | Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging (diff) | |
download | qemu-86360ad71df0070283469b8ae59f33cdd013501d.tar.gz qemu-86360ad71df0070283469b8ae59f33cdd013501d.tar.xz qemu-86360ad71df0070283469b8ae59f33cdd013501d.zip |
exec-all.h: Use stl_p to avoid undefined behaviour patching x86 jumps
The code which patches x86 jump instructions assumes it can do an
unaligned write of a uint32_t. This is actually safe on x86, but it's
still undefined behaviour. We have infrastructure for doing efficient
unaligned accesses which doesn't engage in undefined behaviour, so
use it.
This is technically fractionally less efficient, at least with gcc 4.6;
instead of one instruction:
7b2: 89 3e mov %edi,(%rsi)
we get an extra spurious store to the stack slot:
7b2: 89 7c 24 64 mov %edi,0x64(%rsp)
7b6: 89 3e mov %edi,(%rsi)
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/exec/exec-all.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index f9ac332f9d..1c49a21799 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -229,7 +229,7 @@ void ppc_tb_set_jmp_target(unsigned long jmp_addr, unsigned long addr); static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) { /* patch the branch destination */ - *(uint32_t *)jmp_addr = addr - (jmp_addr + 4); + stl_p((void*)jmp_addr, addr - (jmp_addr + 4)); /* no need to flush icache explicitly */ } #elif defined(__aarch64__) |