From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asrxe-0000gB-C5 for qemu-devel@nongnu.org; Wed, 20 Apr 2016 09:14:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asrxY-0001ho-FB for qemu-devel@nongnu.org; Wed, 20 Apr 2016 09:14:30 -0400 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:38401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asrxY-0001gY-9K for qemu-devel@nongnu.org; Wed, 20 Apr 2016 09:14:24 -0400 Received: by mail-wm0-x22d.google.com with SMTP id u206so80907593wme.1 for ; Wed, 20 Apr 2016 06:14:23 -0700 (PDT) References: <1460044433-19282-1-git-send-email-sergey.fedorov@linaro.org> <1460044433-19282-4-git-send-email-sergey.fedorov@linaro.org> <87shygvcot.fsf@linaro.org> <57176AA0.2030803@gmail.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <57176AA0.2030803@gmail.com> Date: Wed, 20 Apr 2016 14:14:20 +0100 Message-ID: <87mvoov2vn.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 03/11] tci: Make direct jump patching thread-safe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov Cc: Sergey Fedorov , qemu-devel@nongnu.org, Paolo Bonzini , Peter Crosthwaite , Richard Henderson , Stefan Weil Sergey Fedorov writes: > On 20/04/16 12:42, Alex Bennée wrote: >> Sergey Fedorov writes: >>> diff --git a/tcg/tci/tcg-target.inc.c b/tcg/tci/tcg-target.inc.c >>> index 4afe4d7a8d59..7e6180e62898 100644 >>> --- a/tcg/tci/tcg-target.inc.c >>> +++ b/tcg/tci/tcg-target.inc.c >>> @@ -556,6 +556,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, >>> if (s->tb_jmp_offset) { >>> /* Direct jump method. */ >>> assert(args[0] < ARRAY_SIZE(s->tb_jmp_offset)); >>> + /* Align for atomic patching and thread safety */ >>> + s->code_ptr = (uint8_t *)(((uintptr_t)s->code_ptr + 3) & >>> ~3); >> Seeing this pattern is being used over and over again I wonder if we >> should have some utility helper functions for this? Perhaps we should >> steal the kernels ALIGN macros? > > Good point, really. I see such a macro in hw/display/qxl.c and > kvm-all.c. It'd be better a common definition. Any idea of where to > put it? Somewhere inside include/qemu. osdep.h has ROUND_UP/DOWN functions maybe there makes the most sense? > > Kind regards, > Sergey -- Alex Bennée