From nobody Mon May 6 13:54:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1600760673; cv=none; d=zohomail.com; s=zohoarc; b=DqlluA0HYQ3KBUKw15387fg+jcfKxIkk+0C+iM/HJCfbZqUgXFY1kkdJFk7KR4Fcub/yrg+CisRrEcuCZCkqSOwdgfPcB1uAXOG3uwE9wakfDJkFB9tZxFFn9FaaXnXHCKNbK33y1mythmwTa6lJ4+DnjaBgRD8LMloCXFhgqg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600760673; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=4pyLUDbmj6I7eMZ7x7x0ozNKB9umLsMNn/6zkeDzIJA=; b=Cy/ADMApKkTzMvKw6vYeit55zUKy8LQFi+U6psSIMuNtMHcRIIjEX7zpeLM9x8zu5DXYXWJop2CO7PkNt/T6CpZuDIH9sGA5vbUDGhA6B/Y9hFmxwoHtvjUSHe6pmEELspf9CIaLF4AsMHzO86TO/ipe6F6w2PFneckZ1y2lE3o= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160076067375476.5990220992312; Tue, 22 Sep 2020 00:44:33 -0700 (PDT) Received: from localhost ([::1]:53794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKcyW-0002ho-4a for importer@patchew.org; Tue, 22 Sep 2020 03:44:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKcws-0002Gy-0P for qemu-devel@nongnu.org; Tue, 22 Sep 2020 03:42:50 -0400 Received: from gw1.scieneer.com ([2001:470:5:c1c::1]:37996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKcwo-0001Gl-FE for qemu-devel@nongnu.org; Tue, 22 Sep 2020 03:42:49 -0400 Received: from dtc-pc.scieneer.com (dtc-pc.scieneer.com [192.168.2.100]) by gw1.scieneer.com (8.14.7/8.14.7) with ESMTP id 08M7gfah011025 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Tue, 22 Sep 2020 17:42:44 +1000 To: qemu-devel@nongnu.org From: Douglas Crosher Subject: [PATCH] cpu_exec_step_atomic: update the cpu running flag Message-ID: Date: Tue, 22 Sep 2020 17:42:41 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:470:5:c1c::1; envelope-from=dtc-ubuntu@scieneer.com; helo=gw1.scieneer.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8"; format="flowed" The cpu_exec_step_atomic() function is called with the cpu->running clear and proceeds to run target code without setting this flag. If this target code generates an exception then handle_cpu_signal() will unnecessarily abort. For example if atomic code generates a memory protection fault. This patch at least sets and clears this running flag. The related code paths look rather convoluted and it is not immediately=20 clear that this patch comprehensively addresses the issue, but it might=20 at least direct people to a problem, and it might be an incremental=20 improvement, and it gets some code running here. The patch adds some=20 assertions to help detect other cases. Signed-off-by: Douglas Crosher --- accel/tcg/cpu-exec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 66d38f9d85..c1cf1a01cb 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -241,6 +241,9 @@ void cpu_exec_step_atomic(CPUState *cpu) if (sigsetjmp(cpu->jmp_env, 0) =3D=3D 0) { start_exclusive(); + g_assert(cpu =3D=3D current_cpu); + g_assert(!cpu->running); + cpu->running =3D true; tb =3D tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask); if (tb =3D=3D NULL) { @@ -279,6 +282,7 @@ void cpu_exec_step_atomic(CPUState *cpu) */ g_assert(cpu_in_exclusive_context(cpu)); parallel_cpus =3D true; + cpu->running =3D false; end_exclusive(); } --=20 2.25.4