From nobody Sat May 4 09:47:38 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1506377928602632.446303083337; Mon, 25 Sep 2017 15:18:48 -0700 (PDT) Received: from localhost ([::1]:44538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwbi8-0007NQ-Pz for importer@patchew.org; Mon, 25 Sep 2017 18:18:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwbgR-0006SA-2A for qemu-devel@nongnu.org; Mon, 25 Sep 2017 18:17:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwbgN-0006Ue-JA for qemu-devel@nongnu.org; Mon, 25 Sep 2017 18:16:59 -0400 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]:54168) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dwbgN-0006Tc-Dv for qemu-devel@nongnu.org; Mon, 25 Sep 2017 18:16:55 -0400 Received: by mail-pf0-x22e.google.com with SMTP id x78so4513964pff.10 for ; Mon, 25 Sep 2017 15:16:55 -0700 (PDT) Received: from bigtime.twiddle.net ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id u27sm13650882pfl.76.2017.09.25.15.16.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Sep 2017 15:16:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gudj+B+anDTGJdmqtSi3mHI/PiIXeNaCNGuYO2nTUu8=; b=DEN/+BYzcbWos8Ts7HjmaG6HAeDVHmGIlPEu85M9y1LXdFVfIKstqeoVl2wPp1FCNx YpvcfQvYSTU/xHOwqO8KhfP0STzP8IMRMtYY9B0/xJawKpnMNG0LJT+dh2P/xuUB7Up5 XammMfRNDUp/rGB+OvzU9r0A3fxdh9bpqbn8Q= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=gudj+B+anDTGJdmqtSi3mHI/PiIXeNaCNGuYO2nTUu8=; b=pWP5BVH+3mM/KMQMqvBOBXS4Jiu/HPXf/fMJU10Q5DCBF+2OR4fMuNY2rFhkG2CNXM jUb4/1ZueLWVYHsu8lkrRUQUXaOA36nRcWXadD7V36UHhNE3a+MD+n5t7yYyKliVDBkD T1s9L7lfF/TsVPM2yvZWhmf7zNLOuiIcY6wgCIgcAMNo95u4BQw5VziYhPfUath30kUC 7Xw2QtukTE1Pk2K+RBm/M1BtRqTRgq6inFSlB6uaS4qPeQGiMOkVQc0a2IQmbKUYH3sj yMEV0qTBGjTku/al4Jc85lU+eer2ZTqyAVaOrMAUoLa+7cTvDPJ/13WNWHfQhAldtFTy o7kQ== X-Gm-Message-State: AHPjjUhm0mH2VztvTDWRn71P32QCgQ3d6P5GtXQ/W2eiENc8aetJSd3T BdWaDNgCJVnC3nt2NrOmqn4Yc4ga07Y= X-Google-Smtp-Source: AOwi7QBl3AHRhiqJ9xQWgUw5+RQAaTqzckwD7j0T9KxeqKwn9w3VDOxLzDGVyHX9o6UeDDjUr9mRYg== X-Received: by 10.101.93.65 with SMTP id e1mr9160654pgt.150.1506377814303; Mon, 25 Sep 2017 15:16:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 25 Sep 2017 15:16:50 -0700 Message-Id: <20170925221650.2190-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170925221650.2190-1-richard.henderson@linaro.org> References: <20170925221650.2190-1-richard.henderson@linaro.org> 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: 2607:f8b0:400e:c00::22e Subject: [Qemu-devel] [PULL 1/1] 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 , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Jones , qemu-stable@nongnu.org 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_6 Z_629925259 SPT_0 From: Alex Benn=C3=A9e 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. Reviewed-by: Peter Maydell Signed-off-by: Alex Benn=C3=A9e CC: Richard Jones CC: Paolo Bonzini CC: qemu-stable@nongnu.org Message-Id: <20170921110625.9500-1-alex.bennee@linaro.org> Signed-off-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.13.5