From patchwork Thu Mar 2 19:53:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 94803 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp322966qgd; Thu, 2 Mar 2017 11:54:50 -0800 (PST) X-Received: by 10.237.53.9 with SMTP id a9mr18505433qte.188.1488484490698; Thu, 02 Mar 2017 11:54:50 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h49si7710007qtc.167.2017.03.02.11.54.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 02 Mar 2017 11:54:50 -0800 (PST) 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; 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]:54262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjWoK-00085Q-Ds for patch@linaro.org; Thu, 02 Mar 2017 14:54:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjWnH-0007xw-Va for qemu-devel@nongnu.org; Thu, 02 Mar 2017 14:53:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjWnH-0002Tn-7N for qemu-devel@nongnu.org; Thu, 02 Mar 2017 14:53:44 -0500 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:33656) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjWnH-0002TM-1M for qemu-devel@nongnu.org; Thu, 02 Mar 2017 14:53:43 -0500 Received: by mail-wm0-x22e.google.com with SMTP id i17so4774107wmf.0 for ; Thu, 02 Mar 2017 11:53:42 -0800 (PST) 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=hvfEOJGYSnY5OpoSB8FY0H2tXO8IKjK4RW9UAyxCVuI=; b=DZqFy2O1XUjOlQH7L7iBfW83GcGZj71wrNVaSMIu5M4cp5jzjb1PLujS+X15ZR3ufV Sgxhh6dY+c+LMJGXbK+fGUJyJ9B8B+I1mga3TpsEa3i5P8RfANuTCg9nKXL/GwHN+kD9 juQmzg/KdQ5QpJsaRfR5kKWPQMXuoNwYAcVb0= 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=hvfEOJGYSnY5OpoSB8FY0H2tXO8IKjK4RW9UAyxCVuI=; b=Mk0f7pwmpaIAMw1te+nhAqsv3Z/3di5zYgBQgsm2ooca1RIL8LJDYdXFNbA3zr9EXL pf6pjhHjKhdKn/81LhyFzV3jsPcFJX6gGAJRXwfJKE8RWCuJQ3Y3Ll5Z8czZOp6quQka 5oQ8QJoZUau7x4/aHcTSUFXw7lXd0YNM+AT9MFao/MkW1q18i7tGp7/KXKxa8c9scelz lBqZds2sFHBn8u26FX96HHdrlzgD4O3N2QzKorzDlOqsiyFa4HmlLCWoxwGlQC59y1Tg sicsOq0p3/gzdo6Eu1kH7xZvJ+g2+viQ2e3aIwhpgkH/VLTwxBmvBLJUhXNbK6ACxShH BtaQ== X-Gm-Message-State: AMke39ktSfYyK+03x3uJwSG6SClWH7RPg7SoGhI3iq9nE3Hg8+wLD6tG+OHI+M+ZgYdCiVHh X-Received: by 10.28.211.200 with SMTP id k191mr9208630wmg.137.1488484421787; Thu, 02 Mar 2017 11:53:41 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 136sm12484085wms.32.2017.03.02.11.53.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 11:53:38 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 6F0283E05DA; Thu, 2 Mar 2017 19:53:37 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org, rth@twiddle.net, pbonzini@redhat.com Date: Thu, 2 Mar 2017 19:53:31 +0000 Message-Id: <20170302195337.31558-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170302195337.31558-1-alex.bennee@linaro.org> References: <20170302195337.31558-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22e Subject: [Qemu-devel] [PATCH v2 05/11] translate-all: exit cpu_restore_state early if translating 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: mttcg@listserver.greensocs.com, nikunj@linux.vnet.ibm.com, Peter Crosthwaite , a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, cota@braap.org, bobby.prani@gmail.com, =?utf-8?q?Alex_Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The translation code uses cpu_ld*_code which can trigger a tlb_fill which if it fails will attempt a fault resolution. This never works during translation as the TB being generated hasn't been added yet. However with the new locking regime we end up double locking the tb_lock(). As the tcg_ctx.cpu is only set during translation we use this to short circuit the restore code and return with a fail. Most front-ends seem to ignore the pass/fail result anyway but tolerate not having the cpu environment updated. This is arguably ugly but will do for now. Signed-off-by: Alex Bennée --- translate-all.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.11.0 diff --git a/translate-all.c b/translate-all.c index 7ee273410d..956d54b882 100644 --- a/translate-all.c +++ b/translate-all.c @@ -333,6 +333,13 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t retaddr) TranslationBlock *tb; bool r = false; + /* Don't attempt to restore state if we are translating already */ + if (tcg_ctx.cpu == cpu) { + qemu_log_mask(LOG_UNIMP, "Attempt to resolve CPU state @ 0x%" PRIxPTR + " while translating\n", retaddr); + return r; + } + tb_lock(); tb = tb_find_pc(retaddr); if (tb) {