From nobody Mon Feb 9 14:08:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505992056188975.7069724926155; Thu, 21 Sep 2017 04:07:36 -0700 (PDT) Received: from localhost ([::1]:52919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duzKQ-0001mb-G3 for importer@patchew.org; Thu, 21 Sep 2017 07:07:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duzJa-0001NL-CW for qemu-devel@nongnu.org; Thu, 21 Sep 2017 07:06:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duzJW-0002Gj-HG for qemu-devel@nongnu.org; Thu, 21 Sep 2017 07:06:42 -0400 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:50464) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1duzJW-0002CS-BD for qemu-devel@nongnu.org; Thu, 21 Sep 2017 07:06:38 -0400 Received: by mail-wm0-x22b.google.com with SMTP id b195so701739wmb.5 for ; Thu, 21 Sep 2017 04:06:35 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 11sm1136272wmj.14.2017.09.21.04.06.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 04:06:33 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id C59323E05A7; Thu, 21 Sep 2017 12:06:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nHmZOEOf8b+ucbApdE9LO6cI3c40nr7UWJ1w+zWvhoc=; b=ZIGx2NF4z5+TZRmCePl1f3sKSnSxNpnYVKb/x+I5bWVlVCTiLfjVypUaXO3e6EdLqj NQUgvHfTqS5y6YuOUJd4es743g7BiF54oDepVUzgqfzlP6YyEgBrBnIKfbNxmmuHd0Sj 1Hng1ggeo5gEWOoSYAEeUhHkLTUe4Jx4ekmh8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nHmZOEOf8b+ucbApdE9LO6cI3c40nr7UWJ1w+zWvhoc=; b=fj85oWq7fTwhhFITufYQ16tArLfj2pWujytfot/mZrcbnS9hp7bOwH3VeS+ux3mZIZ kAnmGJeaelvKKWl5nwYqOe8FLX1YVlaz97RhRMKw/WmgbrakirRxcGO7tlouGUG1GM7I KBK4iH7YMdgJBTrUjTfvgwHacnEehFEzgBCUKzbVYj9w+MzfiyWTKYehMJExySHGEu42 4hsdrhk7nyaERjMrmH2VNR8zXMz9i0W4dTQymvhgUGDeK884mCA/pvsrxUsUDuUKzeX4 n9SmiC4Rddy+H2sopCZNrldB84HFlhNAFEb0NHMzUMmjSp8TPN/HDouM7P/9Y7SPaEUy kEqQ== X-Gm-Message-State: AHPjjUjh3NZ1dtb4AH4ET9vCSmHSYKn1UcYdBnfQi1uYk/wb37q6lJHD nv5cdgbg+6RJhCn7Eroeo8jttw== X-Google-Smtp-Source: AOwi7QB7MXhpGSFYKPYZ1RpGBLa3yTimZoC8fhHwx9g8Ejse/gtJ+0kWPj0RoxU3trR1AMstgggwtw== X-Received: by 10.28.152.70 with SMTP id a67mr628193wme.132.1505991994635; Thu, 21 Sep 2017 04:06:34 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 21 Sep 2017 12:06:25 +0100 Message-Id: <20170921110625.9500-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22b Subject: [Qemu-devel] [PATCH] accel/tcg/cputlb: avoid recursive BQL (fixes #1706296) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Paolo Bonzini , Peter Crosthwaite , Richard Jones , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 The mmio path (see exec.c:prepare_mmio_access) already protects itself against recursive locking and it makes sense to do the same for io_readx/writex. Otherwise any helper running in the BQL context will assert when it attempts to write to device memory as in the case of the bug report. Signed-off-by: Alex Benn=C3=A9e CC: Richard Jones CC: Paolo Bonzini Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- accel/tcg/cputlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index e72415a882..bcbcc4db6c 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -765,7 +765,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEnt= ry *iotlbentry, =20 cpu->mem_io_vaddr =3D addr; =20 - if (mr->global_locking) { + if (mr->global_locking && !qemu_mutex_iothread_locked()) { qemu_mutex_lock_iothread(); locked =3D true; } @@ -800,7 +800,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry = *iotlbentry, cpu->mem_io_vaddr =3D addr; cpu->mem_io_pc =3D retaddr; =20 - if (mr->global_locking) { + if (mr->global_locking && !qemu_mutex_iothread_locked()) { qemu_mutex_lock_iothread(); locked =3D true; } --=20 2.14.1