Received: from eggs.gnu.org ([2001:4830:134:3::10]:56872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoCH2-0001PZ-42 for qemu-devel@nongnu.org; Thu, 07 Apr 2016 11:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoCGz-0002tz-TV for qemu-devel@nongnu.org; Thu, 07 Apr 2016 11:55:12 -0400 Received: from mail-lb0-x234.google.com ([2a00:1450:4010:c04::234]:36559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoCGz-0002tg-Lt for qemu-devel@nongnu.org; Thu, 07 Apr 2016 11:55:09 -0400 Received: by mail-lb0-x234.google.com with SMTP id bk9so25580138lbc.3 for ; Thu, 07 Apr 2016 08:55:09 -0700 (PDT) From: Sergey Fedorov Date: Thu, 7 Apr 2016 18:53:52 +0300 Message-Id: <1460044433-19282-11-git-send-email-sergey.fedorov@linaro.org> In-Reply-To: <1460044433-19282-1-git-send-email-sergey.fedorov@linaro.org> References: <1460044433-19282-1-git-send-email-sergey.fedorov@linaro.org> Subject: [Qemu-devel] [PATCH 10/11] tcg/mips: Make direct jump patching thread-safe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Sergey Fedorov , Peter Crosthwaite , Paolo Bonzini , Sergey Fedorov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno , Richard Henderson From: Sergey Fedorov Ensure direct jump patching in MIPS is atomic by using atomic_read()/atomic_set() for code patching. Signed-off-by: Sergey Fedorov Signed-off-by: Sergey Fedorov --- tcg/mips/tcg-target.inc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c index 682e19897db0..e65835d2096b 100644 --- a/tcg/mips/tcg-target.inc.c +++ b/tcg/mips/tcg-target.inc.c @@ -1886,6 +1886,7 @@ static void tcg_target_init(TCGContext *s) void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) { uint32_t *ptr = (uint32_t *)jmp_addr; - *ptr = deposit32(*ptr, 0, 26, addr >> 2); + uint32_t insn = atomic_read(ptr); + atomic_write(ptr, deposit32(insn, 0, 26, addr >> 2)); flush_icache_range(jmp_addr, jmp_addr + 4); } -- 2.8.1