From patchwork Mon Apr 3 12:45:21 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: 746431 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vxX3R5VLnz9rxm for ; Mon, 3 Apr 2017 22:48:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="M6nPITXY"; dkim-atps=neutral Received: from localhost ([::1]:59136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv1Pd-0003gh-A3 for incoming@patchwork.ozlabs.org; Mon, 03 Apr 2017 08:48:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv1MU-0001LY-1Q for qemu-devel@nongnu.org; Mon, 03 Apr 2017 08:45:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv1MS-00012z-HM for qemu-devel@nongnu.org; Mon, 03 Apr 2017 08:45:34 -0400 Received: from mail-wr0-x230.google.com ([2a00:1450:400c:c0c::230]:36763) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cv1MS-00012h-9u for qemu-devel@nongnu.org; Mon, 03 Apr 2017 08:45:32 -0400 Received: by mail-wr0-x230.google.com with SMTP id w11so166921235wrc.3 for ; Mon, 03 Apr 2017 05:45:32 -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=5Zyia4swC0JOobgpDucFntVBLU3O1JbW0nRHNQA2zfk=; b=M6nPITXYojwxabaobpSfIQfxvsVtC8gfspZsimR743gVsncAHXibqw7bXXYWX6nkWC 29sGbrvukeHRRJd1e5FFsPMyBtHpo1AfgCftI7xvGZagLd/bTtOP+Es/A3xtYuDsjNbU PAmuPsxhLRAC0VsEeCuBvNNSYgM4i/0Bnmcmc= 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=5Zyia4swC0JOobgpDucFntVBLU3O1JbW0nRHNQA2zfk=; b=tKqcTrJFfwmSxf59qwIVbAHAjeTKYAkUtsOTDwqBEy+YmhrEkr5NsdadGGHsJSZoKv puaEWpHbPwur0zW9a3hMztpdtgBGW7DFjrZTCz6uKgNbey9f57PfpCPEFlNnKVFV9E1c bMkwtpceVCqZVB2iT1YFJgkjgmJQFulTrFrqkdK0MVWnAc17tjf9am2UcEAFAJHHSf41 3Fa8dFDIjP7F2G3ZlP0yATOTMvo1X0fPKyLwxeAMDwbSBbn9ebk+5BtHk6ABZDPNDEo9 vowy+nlzmhNpixHqzApeRC8JqUpDTKenbjBY49lCyb96grbsf3BWp0DPL+prqtn9dTQr D2+Q== X-Gm-Message-State: AFeK/H04JCyBGZvEt+wyRVM2bTDZctjn8aKdAOqxBpnQ5usN92mGLIZWmbHEsHGn9t+Da3OR X-Received: by 10.28.165.147 with SMTP id o141mr9713759wme.67.1491223531162; Mon, 03 Apr 2017 05:45:31 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j2sm15527696wrd.26.2017.04.03.05.45.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 05:45:26 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 317143E109E; Mon, 3 Apr 2017 13:45:25 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: dovgaluk@ispras.ru, rth@twiddle.net, pbonzini@redhat.com Date: Mon, 3 Apr 2017 13:45:21 +0100 Message-Id: <20170403124524.10824-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170403124524.10824-1-alex.bennee@linaro.org> References: <20170403124524.10824-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::230 Subject: [Qemu-devel] [RFC PATCH v1 6/9] cpus: check cpu->running in cpu_get_icount_raw() 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, peter.maydell@linaro.org, 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=20Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The lifetime of current_cpu is now the lifetime of the vCPU thread. However get_icount_raw() can apply a fudge factor if called while code is running to take into account the current executed instruction count. To ensure this is always the case we also check cpu->running. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- cpus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index 4e48b9c4ad..18b1746770 100644 --- a/cpus.c +++ b/cpus.c @@ -229,7 +229,7 @@ int64_t cpu_get_icount_raw(void) CPUState *cpu = current_cpu; icount = timers_state.qemu_icount; - if (cpu) { + if (cpu && cpu->running) { if (!cpu->can_do_io) { fprintf(stderr, "Bad icount read\n"); exit(1);