[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/39] tcg/aarch64: Make direct jump patching thread-
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PULL 09/39] tcg/aarch64: Make direct jump patching thread-safe |
Date: |
Thu, 12 May 2016 14:13:10 -1000 |
From: Sergey Fedorov <address@hidden>
Ensure direct jump patching in AArch64 is atomic by using
atomic_read()/atomic_set() for code patching.
Signed-off-by: Sergey Fedorov <address@hidden>
Signed-off-by: Sergey Fedorov <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
tcg/aarch64/tcg-target.inc.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c
index a8fb442..88183c8 100644
--- a/tcg/aarch64/tcg-target.inc.c
+++ b/tcg/aarch64/tcg-target.inc.c
@@ -73,6 +73,18 @@ static inline void reloc_pc26(tcg_insn_unit *code_ptr,
tcg_insn_unit *target)
*code_ptr = deposit32(*code_ptr, 0, 26, offset);
}
+static inline void reloc_pc26_atomic(tcg_insn_unit *code_ptr,
+ tcg_insn_unit *target)
+{
+ ptrdiff_t offset = target - code_ptr;
+ tcg_insn_unit insn;
+ tcg_debug_assert(offset == sextract64(offset, 0, 26));
+ /* read instruction, mask away previous PC_REL26 parameter contents,
+ set the proper offset, then write back the instruction. */
+ insn = atomic_read(code_ptr);
+ atomic_set(code_ptr, deposit32(insn, 0, 26, offset));
+}
+
static inline void reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *target)
{
ptrdiff_t offset = target - code_ptr;
@@ -835,7 +847,7 @@ void aarch64_tb_set_jmp_target(uintptr_t jmp_addr,
uintptr_t addr)
tcg_insn_unit *code_ptr = (tcg_insn_unit *)jmp_addr;
tcg_insn_unit *target = (tcg_insn_unit *)addr;
- reloc_pc26(code_ptr, target);
+ reloc_pc26_atomic(code_ptr, target);
flush_icache_range(jmp_addr, jmp_addr + 4);
}
--
2.5.5
- [Qemu-devel] [PULL 00/39] tcg-next patch queue, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 02/39] include/qemu/osdep.h: Add a macro to check for alignment, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 03/39] include/qemu/osdep.h: Add macros for pointer alignment, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 01/39] tb: consistently use uint32_t for tb->flags, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 04/39] tci: Make direct jump patching thread-safe, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 06/39] tcg/i386: Make direct jump patching thread-safe, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 08/39] tcg/arm: Make direct jump patching thread-safe, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 10/39] tcg/sparc: Make direct jump patching thread-safe, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 05/39] tcg/ppc: Make direct jump patching thread-safe, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 07/39] tcg/s390: Make direct jump patching thread-safe, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 09/39] tcg/aarch64: Make direct jump patching thread-safe,
Richard Henderson <=
- [Qemu-devel] [PULL 11/39] tcg/mips: Make direct jump patching thread-safe, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 12/39] tcg: Note requirement on atomic direct jump patching, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 13/39] translate-all: remove redundant setting of tcg_ctx.code_gen_buffer_size, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 15/39] translate-all: Adjust 256mb testing for mips64, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 14/39] translate-all: add missing munmap of the code_gen guard page for MIPS, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 16/39] tcg: Clean up direct block chaining data fields, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 17/39] tcg: Use uintptr_t type for jmp_list_{next|first} fields of TB, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 18/39] tcg: Rearrange tb_link_page() to avoid forward declaration, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 19/39] tcg: Init TB's direct jumps before making it visible, Richard Henderson, 2016/05/12
- [Qemu-devel] [PULL 21/39] tcg: Rename tb_jmp_remove() to tb_remove_from_jmp_list(), Richard Henderson, 2016/05/12