[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 08/11] tcg/aarch64: Make direct jump patching th
From: |
Sergey Fedorov |
Subject: |
Re: [Qemu-devel] [PATCH 08/11] tcg/aarch64: Make direct jump patching thread-safe |
Date: |
Thu, 21 Apr 2016 18:47:21 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
On 07/04/16 18:53, Sergey Fedorov wrote:
> 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>
> ---
> 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 0ed10a974121..15fdebec921f 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;
> + assert(offset == sextract64(offset, 0, 26));
I'd better use tcg_debug_assert() here as in this patch:
http://patchwork.ozlabs.org/patch/613020/
Kind regards,
Sergey
> + /* 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);
> }
>
- Re: [Qemu-devel] [PATCH 04/11] tcg/ppc: Make direct jump patching thread-safe, (continued)
Re: [Qemu-devel] [PATCH 08/11] tcg/aarch64: Make direct jump patching thread-safe,
Sergey Fedorov <=
[Qemu-devel] [PATCH 09/11] tcg/sparc: Make direct jump patching thread-safe, Sergey Fedorov, 2016/04/07
[Qemu-devel] [PATCH 10/11] tcg/mips: Make direct jump patching thread-safe, Sergey Fedorov, 2016/04/07
Re: [Qemu-devel] [PATCH 00/11] tcg: Make direct jump patching thread-safe, Sergey Fedorov, 2016/04/07
Re: [Qemu-devel] [PATCH 00/11] tcg: Make direct jump patching thread-safe, Alex Bennée, 2016/04/20