From patchwork Mon Sep 25 22:16:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 114197 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3118723qgf; Mon, 25 Sep 2017 15:18:59 -0700 (PDT) X-Received: by 10.55.87.135 with SMTP id l129mr2142669qkb.182.1506377939577; Mon, 25 Sep 2017 15:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506377939; cv=none; d=google.com; s=arc-20160816; b=YoGaRYohrJn6tqlAvuciuDb+5Zo5PTsleyKVo6CcbOxxQNbwvuAs7EKUfzxCBME11b lJ7gwdqUilp5mvkYl/8+EHVqATXqL4H7ZPiSIUD+X/zli+cTL/xOjvjaTYXUkl4qGE2y cQp0tNE5eC/KKDeO/KtUW19MZDIOIuqjtU/lkTpcRuo6Wj0SQvMBmY8SkgSHWTTkyrmQ B4TxcqR3R5sJd1MEjBv8VYx9Wq5ypgZnEn+krAHl9XaaK0zmd/YDEIuDj9KOT/9eOA2d gsY/+fAS/K/HKkGtbHFVk2XVRCNI3LTixvbAsiK/gnaBpEY1AjtFSQMFTYCkLjEfggNy TNRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=gudj+B+anDTGJdmqtSi3mHI/PiIXeNaCNGuYO2nTUu8=; b=DV/FaHrVjPOBJxQfecG7pmUszipOXgP517Jv++Fz7q14OY4VFoLl3fEoIUYw0FYhPT 9faF9gXA5pAIKQ42kqsQN6G7gSgpDtpFpNNimezmBBdyEWc5eOcD8segreXs2zoY+o+N zeMt81pv6Rvz80xc3JGo9Vb1ncidXYO2cQYCLBitLS1fcHtxwgso6qZTYfND+L6dSpKy ubnAkE+Z+4CliCqRHNIBFxXR7THYxdyFgTCW/uW4kwRzoskHVqA5G/lu2T3x+zmNwGfu cZYxEueznDOrbP2QMUjoCWZeIVW4aco4VxMY0ycExaIQhIYXXgea9ZZnleqj8bxso2WJ VPgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DEN/+BYz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h63si1925262qke.332.2017.09.25.15.18.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 25 Sep 2017 15:18:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DEN/+BYz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwbiL-0007NQ-4o for patch@linaro.org; Mon, 25 Sep 2017 18:18:57 -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) 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) 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) 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 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?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Richard Jones , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée 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ée 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(-) -- 2.13.5 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, CPUIOTLBEntry *iotlbentry, cpu->mem_io_vaddr = addr; - if (mr->global_locking) { + if (mr->global_locking && !qemu_mutex_iothread_locked()) { qemu_mutex_lock_iothread(); locked = true; } @@ -800,7 +800,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, cpu->mem_io_vaddr = addr; cpu->mem_io_pc = retaddr; - if (mr->global_locking) { + if (mr->global_locking && !qemu_mutex_iothread_locked()) { qemu_mutex_lock_iothread(); locked = true; }