From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ7di-0002QD-EH for qemu-devel@nongnu.org; Fri, 01 Jul 2016 19:14:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJ7de-0003Q9-6I for qemu-devel@nongnu.org; Fri, 01 Jul 2016 19:14:25 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:33571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ7de-0003Q5-2R for qemu-devel@nongnu.org; Fri, 01 Jul 2016 19:14:22 -0400 Received: by mail-qk0-x243.google.com with SMTP id n132so26738898qka.0 for ; Fri, 01 Jul 2016 16:14:22 -0700 (PDT) Sender: Richard Henderson References: <1467389770-9738-1-git-send-email-alex.bennee@linaro.org> <1467389770-9738-2-git-send-email-alex.bennee@linaro.org> From: Richard Henderson Message-ID: <24629109-f1db-dcf3-9690-42f01d341712@twiddle.net> Date: Fri, 1 Jul 2016 16:14:17 -0700 MIME-Version: 1.0 In-Reply-To: <1467389770-9738-2-git-send-email-alex.bennee@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 1/2] tcg: Ensure safe tb_jmp_cache lookup out of 'tb_lock' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Alex_Benn=c3=a9e?= , mttcg@greensocs.com, qemu-devel@nongnu.org, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, serge.fdrv@gmail.com, cota@braap.org, bobby.prani@gmail.com Cc: mark.burton@greensocs.com, pbonzini@redhat.com, jan.kiszka@siemens.com, peter.maydell@linaro.org, claudio.fontana@huawei.com, Sergey Fedorov , Peter Crosthwaite On 07/01/2016 09:16 AM, Alex Bennée wrote: > From: Sergey Fedorov > > First, ensure atomicity of CPU's 'tb_jmp_cache' access by: > * using atomic_read() to look up a TB when not holding 'tb_lock'; > * using atomic_write() to remove a TB from each CPU's local cache on > TB invalidation. > > Second, add some memory barriers to ensure we don't put the TB being > invalidated back to CPU's 'tb_jmp_cache'. If we fail to look up a TB in > CPU's local cache because it is being invalidated by some other thread > then it must not be found in the shared TB hash table. Otherwise we'd > put it back to CPU's local cache. > > Note that this patch does *not* make CPU's TLB invalidation safe if it > is done from some other thread while the CPU is in its execution loop. > > Signed-off-by: Sergey Fedorov > Signed-off-by: Sergey Fedorov > [AJB: fixed missing atomic set, tweak title] > Signed-off-by: Alex Bennée > > --- > AJB: > - tweak title > - fixed missing set of tb_jmp_cache > --- > cpu-exec.c | 9 +++++++-- > translate-all.c | 7 ++++++- > 2 files changed, 13 insertions(+), 3 deletions(-) Reviewed-by: Richard Henderson r~