Skip to contentSkip to conversation

exec-all.h: Don't use stl_p for patching x86 jumps

PATCH In review Richard Henderson 3 participants 5 messages May 13, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exec-all.h: Don't use stl_p for patching x86 jumps

Partial revert of 86360ad71df0070283469b8ae59f33cdd013501d, because get the "wrong" version of stl_p, the one that does byte swapping appropriate for the target.

---
 include/exec/exec-all.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/exec/exec-all.h +2 -1
index 0766e24..2c0c2d5 100644
@@ -229,7 +229,8 @@ 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 */
-    stl_p((void*)jmp_addr, addr - (jmp_addr + 4));
+    int32_t disp = addr - (jmp_addr + 4);
+    memcpy((void*)jmp_addr, &disp, 4);
     /* no need to flush icache explicitly */
 }
 #elif defined(__aarch64__)
Signature · 1 line
1.9.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Richard Henderson

Partial revert of 86360ad71df0070283469b8ae59f33cdd013501d, because get the "wrong" version of stl_p, the one that does byte swapping appropriate for the target.

Whoops. We could alternatively commit the patch renaming the bswap.h functions to use _he_ infixes and then use stl_he_p() here, yes?

Probably best to commit this as an immediate fix though.

thanks
-- PMM

#2 lore raw
Quoted 8 lines · Peter Maydell
Quoted 3 lines · Richard Henderson

Partial revert of 86360ad71df0070283469b8ae59f33cdd013501d, because get the "wrong" version of stl_p, the one that does byte swapping appropriate for the target.

Whoops. We could alternatively commit the patch renaming the bswap.h functions to use _he_ infixes and then use stl_he_p() here, yes?

Yes.

Quoted 1 line

Probably best to commit this as an immediate fix though.

That's what I was thinking.

r~

#3 lore raw
In reply to Peter Maydell

Il 13/05/2014 18:10, Peter Maydell ha scritto:

Quoted 8 lines · Richard Henderson
Quoted 3 lines

Partial revert of 86360ad71df0070283469b8ae59f33cdd013501d, because get the "wrong" version of stl_p, the one that does byte swapping appropriate for the target.

Whoops. We could alternatively commit the patch renaming the bswap.h functions to use _he_ infixes and then use stl_he_p() here, yes?

Or use stl_le_p (a bit more readable that _he_).

Paolo

#4 lore raw
Quoted 1 line · Paolo Bonzini

Or use stl_le_p (a bit more readable that _he_).

Fair enough. Will re-send.

r~