From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058309688250.9620578082272; Thu, 9 Mar 2017 03:18:29 -0800 (PST) Received: from localhost ([::1]:33284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw5U-0005B0-Cw for importer@patchew.org; Thu, 09 Mar 2017 06:18:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4G-0005AJ-R8 for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4C-0006SR-DM for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:12 -0500 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:34993) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4C-0006Rl-6y for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:08 -0500 Received: by mail-wm0-x229.google.com with SMTP id v186so136671760wmd.0 for ; Thu, 09 Mar 2017 03:17:06 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id e72sm8430905wma.5.2017.03.09.03.17.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:03 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 171253E0145; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=SkTd3CH7l8UHPbuv8BPHdFHw4/IN/vrT/NDTweOjPNk=; b=cQToEygcCB3j/x4Ghzi0K5vdOwLiC3GiC8g7SuV7pXhke13/KNo1gtMY615dGJZXNs LofB9+Aj0kCM/sHk7jxCZT2hMH2FEjY4mCj0FVhsfJxtrDgJK1fxG0hmk5odN7e/FsRU QjVnXcc77X5l/InuhQSJUH6CCZ0DR5Mc6yygc= 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=SkTd3CH7l8UHPbuv8BPHdFHw4/IN/vrT/NDTweOjPNk=; b=WfthanT7eQFNbqtda45aYiMcjXozaAlgPwHpPfdy0RzbuKuZFHAFMuw3j7tiSB6aLB ghvgqJY14ZO4NP5cm6PUugNR4dwzWiCE+ZyBFbQPyEbkZlW9IkMemShHZSS7/GcBnIpl 56wTveOloMLLTV2C7rWty1rrS70W/FQL/tWtbjIMbz8+QG6bMaBXkPnctVpKE0T9f+7c vtbDricZDis2oYad1y5WDMJrbyoNt6DeU+KR1iBg/x4/V58LMBhc1z6IyvLIM1caOmda Xm2NCzkkWVuQwW3eDMqBLKyyIIA9QN0q2GX3N99YW6y5jCPPCdNHRAs4A2qL7JAD7Qw6 pTFA== X-Gm-Message-State: AMke39kNTrgCJykZ1xd2C8ssR5uKt/mciCOEAePtrxBZY2rRvRRluI4d78W0zZG0xzd7z28V X-Received: by 10.28.91.82 with SMTP id p79mr9667348wmb.130.1489058225462; Thu, 09 Mar 2017 03:17:05 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:04 +0000 Message-Id: <20170309111714.20394-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::229 Subject: [Qemu-devel] [PULL 01/11] vl/cpus: be smarter with icount and MTTCG 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: Paolo Bonzini , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The sense of the test was inverted. Make it simple, if icount is enabled then we disabled MTTCG by default. If the user tries to force MTTCG upon us then we tell them "no". Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by tags added. --- cpus.c | 7 +++---- vl.c | 7 ++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/cpus.c b/cpus.c index c857ad2957..6a817fec13 100644 --- a/cpus.c +++ b/cpus.c @@ -181,10 +181,7 @@ static bool check_tcg_memory_orders_compatible(void) =20 static bool default_mttcg_enabled(void) { - QemuOpts *icount_opts =3D qemu_find_opts_singleton("icount"); - const char *rr =3D qemu_opt_get(icount_opts, "rr"); - - if (rr || TCG_OVERSIZED_GUEST) { + if (use_icount || TCG_OVERSIZED_GUEST) { return false; } else { #ifdef TARGET_SUPPORTS_MTTCG @@ -202,6 +199,8 @@ void qemu_tcg_configure(QemuOpts *opts, Error **errp) if (strcmp(t, "multi") =3D=3D 0) { if (TCG_OVERSIZED_GUEST) { error_setg(errp, "No MTTCG when guest word size > hosts"); + } else if (use_icount) { + error_setg(errp, "No MTTCG when icount is enabled"); } else { if (!check_tcg_memory_orders_compatible()) { error_report("Guest expects a stronger memory ordering= " diff --git a/vl.c b/vl.c index 7f1644a2be..1a95500ac7 100644 --- a/vl.c +++ b/vl.c @@ -4055,8 +4055,6 @@ int main(int argc, char **argv, char **envp) =20 replay_configure(icount_opts); =20 - qemu_tcg_configure(accel_opts, &error_fatal); - machine_class =3D select_machine(); =20 set_memory_options(&ram_slots, &maxram_size, machine_class); @@ -4423,14 +4421,13 @@ int main(int argc, char **argv, char **envp) if (!tcg_enabled()) { error_report("-icount is not allowed with hardware virtualizat= ion"); exit(1); - } else if (qemu_tcg_mttcg_enabled()) { - error_report("-icount does not currently work with MTTCG"); - exit(1); } configure_icount(icount_opts, &error_abort); qemu_opts_del(icount_opts); } =20 + qemu_tcg_configure(accel_opts, &error_fatal); + if (default_net) { QemuOptsList *net =3D qemu_find_opts("net"); qemu_opts_set(net, NULL, "type", "nic", &error_abort); --=20 2.11.0 From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058309551995.2029475781698; Thu, 9 Mar 2017 03:18:29 -0800 (PST) Received: from localhost ([::1]:33285 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw5T-0005BC-O2 for importer@patchew.org; Thu, 09 Mar 2017 06:18:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4G-0005AL-RR for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4E-0006So-1t for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:12 -0500 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:35009) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4D-0006Sc-SO for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:09 -0500 Received: by mail-wm0-x22c.google.com with SMTP id v186so136672816wmd.0 for ; Thu, 09 Mar 2017 03:17:09 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k8sm7786218wre.19.2017.03.09.03.17.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 2D6993E0586; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=MdMi8KNCiemhHpgMyexcrOo+qojUX7VErc8d71M+Kjs=; b=BQGmtqrqpbDHlQcI6aLvp+y9Ym27AfjZMF2j87t5an1Olq2UeyxTVdNDGkXytphnju ozcz1TpuagR3lmygR3rzNGIvRjo7jjaqs3DtJ49l65TfUdM9FkIZHVim64Ln+QqDBR9x JsNzWNxbGT68Wnnkugmt3kkrmPqRhPKYy4Mn0= 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=MdMi8KNCiemhHpgMyexcrOo+qojUX7VErc8d71M+Kjs=; b=YpAIZ7QBw1WZbdzTxQW7cefcQNAV9nuzre8g9JR8FWEaRt/A2PkEhWjW7gfExixXbE nRFev/4tXnF2SEWFq6CJ2i5TNkb4qB3vrfXiU0dIobqjKBVqw9HinUF0pG7UHtCl8/Nu RkTySHqgKobQTeVxhLIw43808bpGMymx+v58FOUBn1AB3QwaZTnuk0rzxc054I83iY7W uDzLuoZ/xJ9QWXK1lgi9cTe7qrML4SoQJzyTViqLE8as/cXJSng1xW8+wtYL+v/21YjG 9bWnwOzPHW2afn+H+skrKf43gVLEyt+pG7RJkuWNHHk1hAvz9i8Ru94anMt6Hh/1QAUJ XOEg== X-Gm-Message-State: AMke39m90UxgWfJcxpR9il60CBiTbVrdM4m1BgyYxskL8UYJ9MDWTBAgr9Z3mxj8AYqWo0a0 X-Received: by 10.28.140.135 with SMTP id o129mr9940866wmd.101.1489058228724; Thu, 09 Mar 2017 03:17:08 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:05 +0000 Message-Id: <20170309111714.20394-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22c Subject: [Qemu-devel] [PULL 02/11] target/i386/cpu.h: declare TCG_GUEST_DEFAULT_MO 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: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 This suppresses the incorrect warning when forcing MTTCG for x86 guests on x86 hosts. A future patch will still warn when TARGET_SUPPORT_MTTCG hasn't been defined for the guest (which is still pending for x86). Reported-by: Paolo Bonzini Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Eduardo Habkost Acked-by: Eduardo Habkost Reviewed-by tags added. --- target/i386/cpu.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index ac2ad6d443..fb09aee7f8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -30,6 +30,9 @@ #define TARGET_LONG_BITS 32 #endif =20 +/* The x86 has a strong memory model with some store-after-load re-orderin= g */ +#define TCG_GUEST_DEFAULT_MO (TCG_MO_ALL & ~TCG_MO_ST_LD) + /* Maximum instruction code size */ #define TARGET_MAX_INSN_SIZE 16 =20 --=20 2.11.0 From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058312727148.17582668702312; Thu, 9 Mar 2017 03:18:32 -0800 (PST) Received: from localhost ([::1]:33286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw5W-0005Dk-EE for importer@patchew.org; Thu, 09 Mar 2017 06:18:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4G-0005AK-RV for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4C-0006SX-Nr for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:12 -0500 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:37812) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4C-0006SC-IE for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:08 -0500 Received: by mail-wm0-x231.google.com with SMTP id n11so53342715wma.0 for ; Thu, 09 Mar 2017 03:17:08 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id n187sm8417231wmd.4.2017.03.09.03.17.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 41D173E07A7; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=p5/6ndff1rdJZj2ErRc4keeAto2otbY0VYtakoX29oI=; b=be7XHVn6PoIs/JPLraNnxbT+qlFG2umAx42XRKEMfcQbR2zPF9Mma/rpbIun+bZKVk pJ28m48ZqCkfjHiPcVb57bBKGLsPUvOOzQeyBa6EuBJHIIKAPyx+Siz8vJVWC3xFJFiu Dbos1SfsJqP1POLDwOcDXkIM5Hi86Aak8I/eE= 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=p5/6ndff1rdJZj2ErRc4keeAto2otbY0VYtakoX29oI=; b=c83wN+RpCvcOoaF4a3C2wiTByFiwMq0cjuZn1D9Ja+GlG+t//d07mqKo+oMs1u1xEn +O3xY5KkISTjg4ZiG6NbI4bktWNwKPwHK/r5fFHmDpl7mtQJaRvfq1sIclAucjtgXwia uX5B1xQQ+aZM+0V4YL4n0vgkNhTVrB9zRs5Z8uQT2c3G2iEDJkCoj0I8+027J+/ky88K BXkYdIFX46OpDQOPYMtY17JzCxOngiXBbmMr1oJTBPGwNv2qHRjAQutZHMEIgvyw7dun 1BUV/u0dJzd+mJw7+572FWCsDhiACNKwpyAvYymG//15mwg/kIt/EPdGyoMcGK2M/wb6 zrkQ== X-Gm-Message-State: AMke39lGUlw5hro12XHNRlEgi/SNpjHo00L5FAS63I5HwRVvSS20B/LcFKbaZz9hwhSKdRXB X-Received: by 10.28.100.193 with SMTP id y184mr9804161wmb.2.1489058227601; Thu, 09 Mar 2017 03:17:07 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:06 +0000 Message-Id: <20170309111714.20394-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::231 Subject: [Qemu-devel] [PULL 03/11] cpus.c: add additional error_report when !TARGET_SUPPORT_MTTCG 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: Paolo Bonzini , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 While we may fail the memory ordering check later that can be confusing. So in cases where TARGET_SUPPORT_MTTCG has yet to be defined we should say so specifically. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by tags added. --- cpus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpus.c b/cpus.c index 6a817fec13..69e21858b8 100644 --- a/cpus.c +++ b/cpus.c @@ -202,6 +202,10 @@ void qemu_tcg_configure(QemuOpts *opts, Error **errp) } else if (use_icount) { error_setg(errp, "No MTTCG when icount is enabled"); } else { +#ifndef TARGET_SUPPORT_MTTCG + error_report("Guest not yet converted to MTTCG - " + "you may get unexpected results"); +#endif if (!check_tcg_memory_orders_compatible()) { error_report("Guest expects a stronger memory ordering= " "than the host provides"); --=20 2.11.0 From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058445699327.2056803816888; Thu, 9 Mar 2017 03:20:45 -0800 (PST) Received: from localhost ([::1]:33295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw7g-0007G0-FY for importer@patchew.org; Thu, 09 Mar 2017 06:20:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4G-0005AN-Rt for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4C-0006SJ-8t for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:12 -0500 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:35000) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4B-0006S0-W1 for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:08 -0500 Received: by mail-wm0-x22d.google.com with SMTP id v186so136672183wmd.0 for ; Thu, 09 Mar 2017 03:17:07 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id p185sm26955752wme.20.2017.03.09.03.17.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 56F273E07D6; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=HBXZcKBSh37CvoIBgrNh/T0qCFmUoKCc8P/7p6rRcoE=; b=JXUma1Qy54d4l9wkXh5H+Hxt23py45zMbwqg2K11Ik/T/E3x3fH0kk0MVg9X3LX2Fa /EJ3x7oVkjPSnua34gYb88tmjzDoMxWT0/wB2RMEMXj//wqHpuudNgb5eYQCVOClRdbm lKa8Jebvmj2+exSnjrm7HO8f0loeQ1ix1PS6Y= 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=HBXZcKBSh37CvoIBgrNh/T0qCFmUoKCc8P/7p6rRcoE=; b=e9RFRyf7mcUKwG5odGD9pI+XXGiz73DvbyKbm8Pbpqcn0J5uLUqu09dIlowx2Wy5hq lwe4QVuMTHS+aM7gXQM9nFK3Hufc8zHlSsW0ARCpV8tR9sn3cDp0W7YTykbdinyd5b26 6/axa/loCfYDml0B47ooF2+1ctL/1dDbepcZRNMQmfT6gA10vii8iTX8z10bLkIcWCBg RO6H3wEbKs+CvyqJtgceMt5evPsHS20BccA3/dlaPtKZbioYMfMbcvTzK/crCSstyBD0 YWyPovSdbRDiiFl0MVrNEFtiQlrFBC8qAfLlQhbR4BiLnHQWe4P7fVx6Q+vfLipxt5QE 2eHg== X-Gm-Message-State: AMke39lL3pQUfx+lyldo+mClSjeDdrFuoG7Z9VHyL3tVpe6+7G/iwAR44pkmcCdkx13+2+Zz X-Received: by 10.28.15.202 with SMTP id 193mr9375400wmp.99.1489058226853; Thu, 09 Mar 2017 03:17:06 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:07 +0000 Message-Id: <20170309111714.20394-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22d Subject: [Qemu-devel] [PULL 04/11] sparc/sparc64: grab BQL before calling cpu_check_irqs 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: Mark Cave-Ayland , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Artyom Tarasenko Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 IRQ modification is part of device emulation and should be done while the BQL is held to prevent races when MTTCG is enabled. This adds assertions in the hw emulation layer and wraps the calls from helpers in the BQL. Reported-by: Mark Cave-Ayland Signed-off-by: Alex Benn=C3=A9e Reviewed-by tags added. --- hw/sparc/sun4m.c | 3 +++ hw/sparc64/sparc64.c | 3 +++ target/sparc/int64_helper.c | 3 +++ target/sparc/win_helper.c | 13 +++++++++++++ 4 files changed, 22 insertions(+) diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 61416a6426..873cd7df9a 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -142,6 +142,9 @@ void cpu_check_irqs(CPUSPARCState *env) { CPUState *cs; =20 + /* We should be holding the BQL before we mess with IRQs */ + g_assert(qemu_mutex_iothread_locked()); + if (env->pil_in && (env->interrupt_index =3D=3D 0 || (env->interrupt_index & ~15) =3D=3D TT_EXTINT)) { unsigned int i; diff --git a/hw/sparc64/sparc64.c b/hw/sparc64/sparc64.c index b3d219c769..4e4fdab065 100644 --- a/hw/sparc64/sparc64.c +++ b/hw/sparc64/sparc64.c @@ -55,6 +55,9 @@ void cpu_check_irqs(CPUSPARCState *env) uint32_t pil =3D env->pil_in | (env->softint & ~(SOFTINT_TIMER | SOFTINT_STIMER)); =20 + /* We should be holding the BQL before we mess with IRQs */ + g_assert(qemu_mutex_iothread_locked()); + /* TT_IVEC has a higher priority (16) than TT_EXTINT (31..17) */ if (env->ivec_status & 0x20) { return; diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index 605747c93c..f942973c22 100644 --- a/target/sparc/int64_helper.c +++ b/target/sparc/int64_helper.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "cpu.h" #include "exec/helper-proto.h" #include "exec/log.h" @@ -208,7 +209,9 @@ static bool do_modify_softint(CPUSPARCState *env, uint3= 2_t value) env->softint =3D value; #if !defined(CONFIG_USER_ONLY) if (cpu_interrupts_enabled(env)) { + qemu_mutex_lock_iothread(); cpu_check_irqs(env); + qemu_mutex_unlock_iothread(); } #endif return true; diff --git a/target/sparc/win_helper.c b/target/sparc/win_helper.c index 71b3dd37e8..154279ecda 100644 --- a/target/sparc/win_helper.c +++ b/target/sparc/win_helper.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "cpu.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" @@ -82,6 +83,7 @@ void cpu_put_psr_raw(CPUSPARCState *env, target_ulong val) #endif } =20 +/* Called with BQL held */ void cpu_put_psr(CPUSPARCState *env, target_ulong val) { cpu_put_psr_raw(env, val); @@ -153,7 +155,10 @@ void helper_wrpsr(CPUSPARCState *env, target_ulong new= _psr) if ((new_psr & PSR_CWP) >=3D env->nwindows) { cpu_raise_exception_ra(env, TT_ILL_INSN, GETPC()); } else { + /* cpu_put_psr may trigger interrupts, hence BQL */ + qemu_mutex_lock_iothread(); cpu_put_psr(env, new_psr); + qemu_mutex_unlock_iothread(); } } =20 @@ -368,7 +373,9 @@ void helper_wrpstate(CPUSPARCState *env, target_ulong n= ew_state) =20 #if !defined(CONFIG_USER_ONLY) if (cpu_interrupts_enabled(env)) { + qemu_mutex_lock_iothread(); cpu_check_irqs(env); + qemu_mutex_unlock_iothread(); } #endif } @@ -381,7 +388,9 @@ void helper_wrpil(CPUSPARCState *env, target_ulong new_= pil) env->psrpil =3D new_pil; =20 if (cpu_interrupts_enabled(env)) { + qemu_mutex_lock_iothread(); cpu_check_irqs(env); + qemu_mutex_unlock_iothread(); } #endif } @@ -408,7 +417,9 @@ void helper_done(CPUSPARCState *env) =20 #if !defined(CONFIG_USER_ONLY) if (cpu_interrupts_enabled(env)) { + qemu_mutex_lock_iothread(); cpu_check_irqs(env); + qemu_mutex_unlock_iothread(); } #endif } @@ -435,7 +446,9 @@ void helper_retry(CPUSPARCState *env) =20 #if !defined(CONFIG_USER_ONLY) if (cpu_interrupts_enabled(env)) { + qemu_mutex_lock_iothread(); cpu_check_irqs(env); + qemu_mutex_unlock_iothread(); } #endif } --=20 2.11.0 From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058444316557.5673263782973; Thu, 9 Mar 2017 03:20:44 -0800 (PST) Received: from localhost ([::1]:33294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw7f-0007Eu-3O for importer@patchew.org; Thu, 09 Mar 2017 06:20:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4G-0005AM-Ro for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4E-0006TH-So for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:12 -0500 Received: from mail-wr0-x22a.google.com ([2a00:1450:400c:c0c::22a]:34484) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4E-0006Sl-MF for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:10 -0500 Received: by mail-wr0-x22a.google.com with SMTP id l37so42724786wrc.1 for ; Thu, 09 Mar 2017 03:17:10 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k195sm8432987wmd.7.2017.03.09.03.17.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 6B52A3E37E6; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=o+iISoHkGMlLEnstkJENEX81QRfw9xvgPQ+/4dvOxoc=; b=I4Z9EKZzqNCoTsmeyFJqJDRcmSMlJOyHxv7pn3iF8iymVFSyUuKtFyE50EuPM5HH4c pwcTQWfbfedj6HB8rOE0WLlIGYVl6jyMKtePRJNARrLJ7D9mY7YY9ycaByKiCeVLV0Id +n9WEAhoLxDjutlYend/jb28qijKewTXu0NdE= 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=o+iISoHkGMlLEnstkJENEX81QRfw9xvgPQ+/4dvOxoc=; b=EnmU2Ru4FmCTF33bm4e9ZrsicYletecl+Mvb5XteY4UOltVWT9un7BX10IynBj3ib7 wgiBKt5XUuoDbSzAVdtciJz07M8PDT36HYFIKuvnIrwFcFn/tjunVN+lPg4Q/C2kq4DA lmHK7uBwsOKFsnmw6KNW58yHY8JlnoK7Xz3TCOrO1oNmi4UGBVsjRkYoQzQDz4l48ST7 lReMfA3y3gLh/HvmSXcPV4M54tTY0kYBagq1o5Ir1p0JDo1At0KXbcLn4ZaV95pu0v1E UHYEFMSpIcYj6EZqyoDcQo7qCl8HfsQolZxME/vpwN3PzaTmM6wn88HfnTFJO8Kfy/TO s+1A== X-Gm-Message-State: AMke39m9ai5nRIquInARD95oh4UjQmaRZgvhNmYdn1nCQn4rimmcpvhX3J3z9h+NXOwMMd85 X-Received: by 10.223.171.239 with SMTP id s102mr9801290wrc.23.1489058229598; Thu, 09 Mar 2017 03:17:09 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:08 +0000 Message-Id: <20170309111714.20394-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: 2a00:1450:400c:c0c::22a Subject: [Qemu-devel] [PULL 05/11] s390x/misc_helper.c: wrap IO instructions in BQL 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: Alexander Graf , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Helpers that can trigger IO events (including interrupts) need to be protected by the BQL. I've updated all the helpers that call into an ioinst_handle_* functions. Reported-by: Thomas Huth Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by tags added. --- target/s390x/misc_helper.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index 3cb942e8bb..93b0e61366 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -19,6 +19,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "cpu.h" #include "exec/memory.h" #include "qemu/host-utils.h" @@ -551,61 +552,81 @@ uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t or= der_code, uint32_t r1, void HELPER(xsch)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D s390_env_get_cpu(env); + qemu_mutex_lock_iothread(); ioinst_handle_xsch(cpu, r1); + qemu_mutex_unlock_iothread(); } =20 void HELPER(csch)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D s390_env_get_cpu(env); + qemu_mutex_lock_iothread(); ioinst_handle_csch(cpu, r1); + qemu_mutex_unlock_iothread(); } =20 void HELPER(hsch)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D s390_env_get_cpu(env); + qemu_mutex_lock_iothread(); ioinst_handle_hsch(cpu, r1); + qemu_mutex_unlock_iothread(); } =20 void HELPER(msch)(CPUS390XState *env, uint64_t r1, uint64_t inst) { S390CPU *cpu =3D s390_env_get_cpu(env); + qemu_mutex_lock_iothread(); ioinst_handle_msch(cpu, r1, inst >> 16); + qemu_mutex_unlock_iothread(); } =20 void HELPER(rchp)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D s390_env_get_cpu(env); + qemu_mutex_lock_iothread(); ioinst_handle_rchp(cpu, r1); + qemu_mutex_unlock_iothread(); } =20 void HELPER(rsch)(CPUS390XState *env, uint64_t r1) { S390CPU *cpu =3D s390_env_get_cpu(env); + qemu_mutex_lock_iothread(); ioinst_handle_rsch(cpu, r1); + qemu_mutex_unlock_iothread(); } =20 void HELPER(ssch)(CPUS390XState *env, uint64_t r1, uint64_t inst) { S390CPU *cpu =3D s390_env_get_cpu(env); + qemu_mutex_lock_iothread(); ioinst_handle_ssch(cpu, r1, inst >> 16); + qemu_mutex_unlock_iothread(); } =20 void HELPER(stsch)(CPUS390XState *env, uint64_t r1, uint64_t inst) { S390CPU *cpu =3D s390_env_get_cpu(env); + qemu_mutex_lock_iothread(); ioinst_handle_stsch(cpu, r1, inst >> 16); + qemu_mutex_unlock_iothread(); } =20 void HELPER(tsch)(CPUS390XState *env, uint64_t r1, uint64_t inst) { S390CPU *cpu =3D s390_env_get_cpu(env); + qemu_mutex_lock_iothread(); ioinst_handle_tsch(cpu, r1, inst >> 16); + qemu_mutex_unlock_iothread(); } =20 void HELPER(chsc)(CPUS390XState *env, uint64_t inst) { S390CPU *cpu =3D s390_env_get_cpu(env); + qemu_mutex_lock_iothread(); ioinst_handle_chsc(cpu, inst >> 16); + qemu_mutex_unlock_iothread(); } #endif =20 --=20 2.11.0 From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058444342191.62831297494313; Thu, 9 Mar 2017 03:20:44 -0800 (PST) Received: from localhost ([::1]:33293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw7f-0007El-3P for importer@patchew.org; Thu, 09 Mar 2017 06:20:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4I-0005AY-9o for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4G-0006Uq-3m for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:14 -0500 Received: from mail-wr0-x235.google.com ([2a00:1450:400c:c0c::235]:35041) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4F-0006U7-TP for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:12 -0500 Received: by mail-wr0-x235.google.com with SMTP id g10so42711830wrg.2 for ; Thu, 09 Mar 2017 03:17:11 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t103sm7865007wrc.43.2017.03.09.03.17.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:05 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7E1483E380B; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=8lpWRwy8UPmdlWUz+lQvEwbITj3/HElyc7FbfuzGx+A=; b=kqINzQelatHYgsxL0kB/hoHGEA+QTmiU3BNqwqJJ99SW8rxZrSfPo9tvJQWxyxLL/d eSQ5OPCSDiATPrHlnwGMReR8gY0ihkdCbFHHxFjPSFNIkMay2q9yPUPHTLTCXO/RSY81 Rihx2IqgSdphC9Et834TKwpF7j0q7svcIaV1A= 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=8lpWRwy8UPmdlWUz+lQvEwbITj3/HElyc7FbfuzGx+A=; b=A/ro3NKD9hX4GKEljf+h+P9xGf3Tw0uGNguHIYTH1oYczGi3PXPnLD+cCyf6xN6unD cx8ltmbqiSdlgTbfdBXW3BTWCfA7EIfEFQYfYob7RFDNvKdgwdSKSlpSoElOHujNZVNE RzHhzeEjCfAuxdCULGmHrsKha2ko/C5lD0k2eyCnj0kuYlEo9QoxNCL8ZooJLZmC4pU+ /5NBs+NjE64ZC81TSq7twlfwZjzx+ZfhKJ5FRFG569SoArYteHRDUuDnbamHBu6dD7KH blvHHlcdCI03xg8y8jtfhhynQAZ3MPP8UG+Lot/D4hQmGEOdozQqd0sKSaTWKXn757Dk o93w== X-Gm-Message-State: AMke39lYsP9rADNspW8nua0nFtxoMedhdQoIYp0ZiUZFkrdtW6uWux+rqXnENrTilFZNjV8X X-Received: by 10.223.164.16 with SMTP id d16mr9764242wra.47.1489058230818; Thu, 09 Mar 2017 03:17:10 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:09 +0000 Message-Id: <20170309111714.20394-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: 2a00:1450:400c:c0c::235 Subject: [Qemu-devel] [PULL 06/11] target/xtensa: hold BQL for interrupt processing 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: Max Filippov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Make sure we have the BQL held when processing interrupts. Reported-by: Thomas Huth Signed-off-by: Alex Benn=C3=A9e Acked-by: Max Filippov Reviewed-by tags added. --- target/xtensa/helper.c | 1 + target/xtensa/op_helper.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index c67d715c4b..bcd0b7738d 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -217,6 +217,7 @@ static void handle_interrupt(CPUXtensaState *env) } } =20 +/* Called from cpu_handle_interrupt with BQL held */ void xtensa_cpu_do_interrupt(CPUState *cs) { XtensaCPU *cpu =3D XTENSA_CPU(cs); diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c index af2723445d..519fbeddd6 100644 --- a/target/xtensa/op_helper.c +++ b/target/xtensa/op_helper.c @@ -26,6 +26,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "cpu.h" #include "exec/helper-proto.h" #include "qemu/host-utils.h" @@ -381,7 +382,11 @@ void HELPER(waiti)(CPUXtensaState *env, uint32_t pc, u= int32_t intlevel) env->pc =3D pc; env->sregs[PS] =3D (env->sregs[PS] & ~PS_INTLEVEL) | (intlevel << PS_INTLEVEL_SHIFT); + + qemu_mutex_lock_iothread(); check_interrupts(env); + qemu_mutex_unlock_iothread(); + if (env->pending_irq_level) { cpu_loop_exit(CPU(xtensa_env_get_cpu(env))); return; @@ -426,7 +431,9 @@ void HELPER(update_ccompare)(CPUXtensaState *env, uint3= 2_t i) =20 void HELPER(check_interrupts)(CPUXtensaState *env) { + qemu_mutex_lock_iothread(); check_interrupts(env); + qemu_mutex_unlock_iothread(); } =20 void HELPER(itlb_hit_test)(CPUXtensaState *env, uint32_t vaddr) --=20 2.11.0 From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058585283328.9387517673173; Thu, 9 Mar 2017 03:23:05 -0800 (PST) Received: from localhost ([::1]:33311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw9w-0000o0-5E for importer@patchew.org; Thu, 09 Mar 2017 06:23:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4I-0005AX-7n for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4H-0006Wa-1I for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:14 -0500 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:35047) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4G-0006V1-Rn for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:12 -0500 Received: by mail-wr0-x231.google.com with SMTP id g10so42712134wrg.2 for ; Thu, 09 Mar 2017 03:17:12 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x69sm26908815wma.15.2017.03.09.03.17.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 945243E3838; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=B6IfAUpuybThZyhE/y1JnejoN8rZdEowQ9InfAzJpYc=; b=aBU36IKwKGqG5Dln2NFnwIVtmpsqN+qUBTPxOOx+T4xf6+G5M/dyutXfmsaf/hi9l3 ep7mw+SG6ck7mXErN6lv35k4td2MCiNLMt5jDkGtg3skfcWbG3OzPBpVdn+Aq5Vy6yuV fSetceDvpuMDfW4yagfVcYgxIrcs+MWxNuNZA= 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=B6IfAUpuybThZyhE/y1JnejoN8rZdEowQ9InfAzJpYc=; b=K5TBcyWoAtXnApvQNXMVxYm/LYrrJX01vZUFQJuLhls09n256Yu+INRK1KKajxVOxr yEHWh3lyHH6GqLMuRTQ6ZPJc8YYfgjhS5Pef8zCG2QzUlf4ofgYhi1BtZ7aoVY3yLuZr 7nBIdfadtlFjxFGz0f5CRSatWC81nB1mU6HdQs6ibEpIxcSer59uw7xRmmEE3b1w3QcF 7x3mrh8dHbEpLsqVG7rYmpF5Vbd6ylT1Qyw8wTuwkLtW5QqhWSwWkGPQ0ULmYt31hasS mb4W9/o+crXxufIfmrOn/2MHyOmVvq0QXlNMwTrCa1cEylW1FhwcB2LKOyJQGKYPFEaW UCag== X-Gm-Message-State: AMke39l2CRnegp0H+FpqJCViJd2icR8MQcMsruZ09mO6FjmO9jBTR1UxVu9dtAj8Sw+XleaZ X-Received: by 10.223.136.183 with SMTP id f52mr9599386wrf.68.1489058231746; Thu, 09 Mar 2017 03:17:11 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:10 +0000 Message-Id: <20170309111714.20394-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: 2a00:1450:400c:c0c::231 Subject: [Qemu-devel] [PULL 07/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: Paolo Bonzini , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Peter Crosthwaite Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The translation code uses cpu_ld*_code which can trigger a tlb_fill which if it fails will erroneously attempts a fault resolution. This never works during translation as the TB being generated hasn't been added yet. The target should have checked retaddr before calling cpu_restore_state but for those that have yet to be fixed we do it here to avoid a recursive tb_lock() under MTTCG's new locking regime. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by tags added. --- translate-all.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/translate-all.c b/translate-all.c index d42d003e67..34480aebba 100644 --- a/translate-all.c +++ b/translate-all.c @@ -333,6 +333,19 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t retadd= r) TranslationBlock *tb; bool r =3D false; =20 + /* A retaddr of zero is invalid so we really shouldn't have ended + * up here. The target code has likely forgotten to check retaddr + * !=3D 0 before attempting to restore state. We return early to + * avoid blowing up on a recursive tb_lock(). The target must have + * previously survived a failed cpu_restore_state because + * tb_find_pc(0) would have failed anyway. It still should be + * fixed though. + */ + + if (!retaddr) { + return r; + } + tb_lock(); tb =3D tb_find_pc(retaddr); if (tb) { --=20 2.11.0 From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058673770324.1520961722249; Thu, 9 Mar 2017 03:24:33 -0800 (PST) Received: from localhost ([::1]:33317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clwBM-0001mA-9A for importer@patchew.org; Thu, 09 Mar 2017 06:24:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4J-0005BO-Qo for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4I-0006X3-6N for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:15 -0500 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:34500) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4I-0006Wj-0r for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:14 -0500 Received: by mail-wr0-x233.google.com with SMTP id l37so42725835wrc.1 for ; Thu, 09 Mar 2017 03:17:13 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k8sm7786345wre.19.2017.03.09.03.17.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id AAA993E3839; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=lqIJRrk/MiAeLGXU0QWeBzmVS+Q5JNcluDWHVR4aeBE=; b=c6DGpJCdgKHTjEwlcy09Z5YYEgSjR4qB5rOALqowteJCRrL98poxq6O5Ykw7jOmqAY /SbBTKnsPfE/mnnbV/GRvz62vkM8b23Rl5zWMazOh6h+KzbnVhE64W0bsa9Nfpz5o2DZ jV2UDKy2kZaSwjGnJFS877ypQpL8ToJkrZvvw= 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=lqIJRrk/MiAeLGXU0QWeBzmVS+Q5JNcluDWHVR4aeBE=; b=rvT1FUvA/jPDeE0ZxVfgF8zbmVMuhrb0T/YaoYwtkfM1+BPUUsnyCHW9yxvzst+bpY feGEjnSeEFhfAsOuAtAjmd8rzsWMXMh3n0hg7bDWPveYzKs2mcEEb/Dg05yz7RWENOU3 vEaAsBcmuxgE1gdZjiE7gakuLFzXzKNvevJyQb0PY3ggbYd0VJAX/kc/+8c2BQFWdfCg IqJm7yTZEZxSsXp7sWUXRlC9o2QxhoX6Jj4yfZeEO2joNMG9zkyjyzWUQMB6MiR+/bjk xcuePGSjTqdevpZWHqnb83FoQ6ZmtoAjv7lbl/LBTMOsjYDN/nUek2afldaM9BtAHHZ5 6Dug== X-Gm-Message-State: AMke39kFLfLTE5ebptUehc1s4eZKb1w7EwLQI4hDeNe6UBGuhDcDHnLrZKDNdInOk5N4Mj4D X-Received: by 10.223.155.17 with SMTP id b17mr9709927wrc.181.1489058232943; Thu, 09 Mar 2017 03:17:12 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:11 +0000 Message-Id: <20170309111714.20394-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: 2a00:1450:400c:c0c::233 Subject: [Qemu-devel] [PULL 08/11] target/mips: hold BQL for timer interrupts 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: Yongbok Kim , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Yongbok Kim Hold BQL when accessing timer which can cause interrupts Signed-off-by: Yongbok Kim Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Reviewed-by tags added. --- target/mips/op_helper.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index b683fcb025..e5f3ea4042 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -17,6 +17,7 @@ * License along with this library; if not, see . */ #include "qemu/osdep.h" +#include "qemu/main-loop.h" #include "cpu.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" @@ -827,7 +828,11 @@ target_ulong helper_mftc0_tcschefback(CPUMIPSState *en= v) =20 target_ulong helper_mfc0_count(CPUMIPSState *env) { - return (int32_t)cpu_mips_get_count(env); + int32_t count; + qemu_mutex_lock_iothread(); + count =3D (int32_t) cpu_mips_get_count(env); + qemu_mutex_unlock_iothread(); + return count; } =20 target_ulong helper_mftc0_entryhi(CPUMIPSState *env) @@ -1375,7 +1380,9 @@ void helper_mtc0_hwrena(CPUMIPSState *env, target_ulo= ng arg1) =20 void helper_mtc0_count(CPUMIPSState *env, target_ulong arg1) { + qemu_mutex_lock_iothread(); cpu_mips_store_count(env, arg1); + qemu_mutex_unlock_iothread(); } =20 void helper_mtc0_entryhi(CPUMIPSState *env, target_ulong arg1) @@ -1424,7 +1431,9 @@ void helper_mttc0_entryhi(CPUMIPSState *env, target_u= long arg1) =20 void helper_mtc0_compare(CPUMIPSState *env, target_ulong arg1) { + qemu_mutex_lock_iothread(); cpu_mips_store_compare(env, arg1); + qemu_mutex_unlock_iothread(); } =20 void helper_mtc0_status(CPUMIPSState *env, target_ulong arg1) @@ -1475,7 +1484,9 @@ void helper_mtc0_srsctl(CPUMIPSState *env, target_ulo= ng arg1) =20 void helper_mtc0_cause(CPUMIPSState *env, target_ulong arg1) { + qemu_mutex_lock_iothread(); cpu_mips_store_cause(env, arg1); + qemu_mutex_unlock_iothread(); } =20 void helper_mttc0_cause(CPUMIPSState *env, target_ulong arg1) @@ -2296,12 +2307,16 @@ target_ulong helper_rdhwr_synci_step(CPUMIPSState *= env) =20 target_ulong helper_rdhwr_cc(CPUMIPSState *env) { + int32_t count; check_hwrena(env, 2, GETPC()); #ifdef CONFIG_USER_ONLY - return env->CP0_Count; + count =3D env->CP0_Count; #else - return (int32_t)cpu_mips_get_count(env); + qemu_mutex_lock_iothread(); + count =3D (int32_t)cpu_mips_get_count(env); + qemu_mutex_unlock_iothread(); #endif + return count; } =20 target_ulong helper_rdhwr_ccres(CPUMIPSState *env) --=20 2.11.0 From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058740873129.44624239027803; Thu, 9 Mar 2017 03:25:40 -0800 (PST) Received: from localhost ([::1]:33329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clwCR-0002if-LV for importer@patchew.org; Thu, 09 Mar 2017 06:25:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4L-0005Fk-SX for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4K-0006Yr-2C for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:17 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:36657) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4J-0006YP-PS for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:15 -0500 Received: by mail-wm0-x232.google.com with SMTP id n11so136796302wma.1 for ; Thu, 09 Mar 2017 03:17:15 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 36sm7877136wrz.8.2017.03.09.03.17.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id C0A273E383A; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=3TTT4ZNU+mhr/sFuYyEUX9LGNuyRL3xCauXi28ZNfCs=; b=QozyHJfupum5bUEVgn3bDWB9BQ+XwFTJCjfOzMaBcCthQl6rwgLbvFcZlE319EA4DR I95IMed/hgmpHcRmIp5FCYj9UebxbjuwtDZNMpyjzHnmLm0gN8w9I/mWYxvut+lKOEa1 5DwTnB4wlQJQfkxIpz3tWHJwJqPQ0JDLHHSWc= 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=3TTT4ZNU+mhr/sFuYyEUX9LGNuyRL3xCauXi28ZNfCs=; b=NkEJi0ncxMwGIb5Vl2qjxyAyfWZSD0Jp0kPoKoFd7Dkw2ixl6AKpawO52if+MGGpjb 7Mh65HG1Cn64YkjnH/J66whgw+ZdQyeCKFE+M3ZbKt1dhupvNum0O4AtMIf/LGNewiVq aR+tf9dvdLCq+XAighT6lauG6ItVIsKCABBtfD3xH51moYp6jTK4U8dmlTbU5jUiwzkz +AR8yiUmWYwkc4AMgI9j7Cbw+Iv41bX/sjQE9HTKGG8Ms8NUm+k0Ttap3vDGLYm42WI5 pfRrm0RzDhvI5YuJ8zp4QyXfTmTjoHRJ3vBWHmXu2JHe8M/joKH1KyN22lmH1U+NbnCY CbAw== X-Gm-Message-State: AMke39nk60sk53O7bmowFGpVT9p2mO8fcDIXzuBa5s78DvV6Ve6TrwFxvpwWDV19MUwtP3Y7 X-Received: by 10.28.159.73 with SMTP id i70mr10066832wme.78.1489058234639; Thu, 09 Mar 2017 03:17:14 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:12 +0000 Message-Id: <20170309111714.20394-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::232 Subject: [Qemu-devel] [PULL 09/11] target-i386: defer VMEXIT to do_interrupt 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: Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Eduardo Habkost , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Paolo Bonzini Paths through the softmmu code during code generation now need to be audited to check for double locking of tb_lock. In particular, VMEXIT can take tb_= lock through cpu_vmexit -> cpu_x86_update_cr4 -> tlb_flush. To avoid this, split VMEXIT delivery in two parts, similar to what is done = with exceptions. cpu_vmexit only records the VMEXIT exit code and information, = and cc->do_interrupt can then deliver it when it is safe to take the lock. Reported-by: Alexander Boettcher Suggested-by: Richard Henderson Tested-by: Alexander Boettcher Signed-off-by: Paolo Bonzini Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by tags added. --- target/i386/cpu.h | 2 ++ target/i386/seg_helper.c | 20 +++++++++++--------- target/i386/svm_helper.c | 22 +++++++++++++--------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index fb09aee7f8..406cb24301 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -697,6 +697,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS]; =20 #define EXCP_SYSCALL 0x100 /* only happens in user only emulation for syscall instruction */ +#define EXCP_VMEXIT 0x100 =20 /* i386-specific interrupt pending bits. */ #define CPU_INTERRUPT_POLL CPU_INTERRUPT_TGT_EXT_1 @@ -1632,6 +1633,7 @@ void cpu_svm_check_intercept_param(CPUX86State *env1,= uint32_t type, uint64_t param, uintptr_t retaddr); void cpu_vmexit(CPUX86State *nenv, uint32_t exit_code, uint64_t exit_info_= 1, uintptr_t retaddr); +void do_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1); =20 /* seg_helper.c */ void do_interrupt_x86_hardirq(CPUX86State *env, int intno, int is_hw); diff --git a/target/i386/seg_helper.c b/target/i386/seg_helper.c index 5c845dc25c..0374031ea2 100644 --- a/target/i386/seg_helper.c +++ b/target/i386/seg_helper.c @@ -1297,15 +1297,17 @@ void x86_cpu_do_interrupt(CPUState *cs) /* successfully delivered */ env->old_exception =3D -1; #else - /* simulate a real cpu exception. On i386, it can - trigger new exceptions, but we do not handle - double or triple faults yet. */ - do_interrupt_all(cpu, cs->exception_index, - env->exception_is_int, - env->error_code, - env->exception_next_eip, 0); - /* successfully delivered */ - env->old_exception =3D -1; + if (cs->exception_index >=3D EXCP_VMEXIT) { + assert(env->old_exception =3D=3D -1); + do_vmexit(env, cs->exception_index - EXCP_VMEXIT, env->error_code); + } else { + do_interrupt_all(cpu, cs->exception_index, + env->exception_is_int, + env->error_code, + env->exception_next_eip, 0); + /* successfully delivered */ + env->old_exception =3D -1; + } #endif } =20 diff --git a/target/i386/svm_helper.c b/target/i386/svm_helper.c index 78d8df4af6..59e8b5091c 100644 --- a/target/i386/svm_helper.c +++ b/target/i386/svm_helper.c @@ -580,12 +580,10 @@ void helper_svm_check_io(CPUX86State *env, uint32_t p= ort, uint32_t param, } } =20 -/* Note: currently only 32 bits of exit_code are used */ void cpu_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1, uintptr_t retaddr) { CPUState *cs =3D CPU(x86_env_get_cpu(env)); - uint32_t int_ctl; =20 if (retaddr) { cpu_restore_state(cs, retaddr); @@ -598,6 +596,19 @@ void cpu_vmexit(CPUX86State *env, uint32_t exit_code, = uint64_t exit_info_1, control.exit_info_2)), env->eip); =20 + cs->exception_index =3D EXCP_VMEXIT + exit_code; + env->error_code =3D exit_info_1; + + /* remove any pending exception */ + env->old_exception =3D -1; + cpu_loop_exit(cs); +} + +void do_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1) +{ + CPUState *cs =3D CPU(x86_env_get_cpu(env)); + uint32_t int_ctl; + if (env->hflags & HF_INHIBIT_IRQ_MASK) { x86_stl_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.int_state), @@ -759,13 +770,6 @@ void cpu_vmexit(CPUX86State *env, uint32_t exit_code, = uint64_t exit_info_1, /* If the host's rIP reloaded by #VMEXIT is outside the limit of the host's code segment or non-canonical (in the case of long mode), a #GP fault is delivered inside the host. */ - - /* remove any pending exception */ - cs->exception_index =3D -1; - env->error_code =3D 0; - env->old_exception =3D -1; - - cpu_loop_exit(cs); } =20 #endif --=20 2.11.0 From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058559137574.4364656019959; Thu, 9 Mar 2017 03:22:39 -0800 (PST) Received: from localhost ([::1]:33310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw9V-0000RI-Ua for importer@patchew.org; Thu, 09 Mar 2017 06:22:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4K-0005Bk-29 for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4I-0006Xw-Te for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:16 -0500 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:35035) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4I-0006Wu-Mc for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:14 -0500 Received: by mail-wm0-x22d.google.com with SMTP id v186so136674438wmd.0 for ; Thu, 09 Mar 2017 03:17:14 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d42sm7859079wrd.37.2017.03.09.03.17.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id D54D83E383B; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=eU2O1Zx5guqaE6UGKrGguBjoB0S0+5FuIvjtYTVgldE=; b=TwNBWGYgz2BjPYHBkPevJUW6GZHTjmmcY+Ge5vqR3IN+0iY8M+KP7cAtukRSGUOrwU xOXxbkSYghhTA3c2uNrjFGonw1y02HLGJERK4OW0N6Lrqs7bgAoQZWp7Sb/zJMl+VqnI gYNwvm07MngATZG3VomfvIU1kLWivlzVOPUTI= 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=eU2O1Zx5guqaE6UGKrGguBjoB0S0+5FuIvjtYTVgldE=; b=BDTnks5JmsNBIeF635jCCUk/HPp/6w3VQc9dqZ5tinLHhItKoEiAhiiY+Lt5CnsRVA mp9yenaZBIIBmSUomDCAGO1etJSqosP5vkkrXQgt2oQW062bQTYLxO3O8doubaZ5tZqd 1ESe0UkiSMhJT9JmYSiHfqGzYmCNktdv7GPC7KVbW+zklJ0ztGJ1ea1mfPcSPQkv1lSX yQbevCrwCVeqQALD3Z9utwsr8kfcr9YqP6hThnkRFOFNmZjacdx5wDgfRAqqU+mUz++d nuGOvZZi4Y71K81Qm4MLT+t4MHHC254T3dfjFf881v2tlv/TTvSOf+wQrAklC+yxp9sz 1X3Q== X-Gm-Message-State: AMke39k6ptPy6nWHWo7uF7GtZfeITIC2+UjZmN25k9E6gkLRsXyetWbyWJh/DZvHaA6ta6X7 X-Received: by 10.28.139.134 with SMTP id n128mr15807160wmd.132.1489058233718; Thu, 09 Mar 2017 03:17:13 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:13 +0000 Message-Id: <20170309111714.20394-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22d Subject: [Qemu-devel] [PULL 10/11] target/arm/helper: make it clear the EC field is also in hex 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: "open list:ARM" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 ..just like the rest of the displayed ESR register. Otherwise people might scratch their heads if a not obviously hex number is displayed for the EC field. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Reviewed-by: KONRAD Frederic Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by tags added. --- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 3f4211b572..76b608f0ba 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6857,7 +6857,7 @@ void arm_cpu_do_interrupt(CPUState *cs) new_el); if (qemu_loglevel_mask(CPU_LOG_INT) && !excp_is_internal(cs->exception_index)) { - qemu_log_mask(CPU_LOG_INT, "...with ESR %x/0x%" PRIx32 "\n", + qemu_log_mask(CPU_LOG_INT, "...with ESR 0x%x/0x%" PRIx32 "\n", env->exception.syndrome >> ARM_EL_EC_SHIFT, env->exception.syndrome); } --=20 2.11.0 From nobody Sat Apr 27 19:40:05 2024 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.zoho.com; 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 1489058654179843.8398190778856; Thu, 9 Mar 2017 03:24:14 -0800 (PST) Received: from localhost ([::1]:33316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clwB2-0001YB-9l for importer@patchew.org; Thu, 09 Mar 2017 06:24:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clw4M-0005GX-3u for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clw4K-0006a2-R9 for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:18 -0500 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:36662) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clw4K-0006Ym-KM for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:17:16 -0500 Received: by mail-wm0-x22b.google.com with SMTP id n11so136796593wma.1 for ; Thu, 09 Mar 2017 03:17:16 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w130sm6214702wmg.0.2017.03.09.03.17.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Mar 2017 03:17:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id E69A63E383C; Thu, 9 Mar 2017 11:17:15 +0000 (GMT) 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=1iOTsAVz7FhPncJf1PtH+If/ktocyzAz47wlOyDRxNg=; b=h4b9VqAXQjOlO7pQh2XZbDKen/PBiPozKNoFc9hVRqQUagvSmDDOaSCZssH+nwII0f 4gwZj4IUn0WjyrZK1SV4mMc6F3CwpOnJe8NGGyXaH8EFFGw1xdMg6zJGNNYzYb7tBHU+ IecUip/NulbXisMz83qm0nVCKxZufEN2xCDDE= 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=1iOTsAVz7FhPncJf1PtH+If/ktocyzAz47wlOyDRxNg=; b=II8JpX+0rvnu/9ezhvDHEKisLFv2AwfOZMAxkPGSgY1DrDiTwN8nLM44gdrAgsWz7t hugYsOhzpihnwb7wzfRkTcOW/6dC80vlXhpXqqcf1eYkRlvN0qs2STlsdjICOUYdoQ/j w+qo54T10QBgVFhp2pH2xkD2tzriwPGQc9Mqh9DpVnpu0hw0eAZwnyI1ILumx0B78V5A bHaPMXfV7Vf7yYRtIf2FsWWWZ70NezHsMTgzkNOo0E7oJeFvRRdIYH+B0tow2Qb+sAtk ULg0Cyurm2+o+Gqmu56SCvjQpTQPBqcn1Q2cwVhkKqtGt7o4HaNXtK/fLHIcUhAlYBBN v3ZA== X-Gm-Message-State: AMke39k3QvYy7SpyPsQKYxWL59H9pzv49Ulep3aKrjjDSTtD6w9/e0mkwZ2BE5p5w6wZTh+9 X-Received: by 10.28.158.193 with SMTP id h184mr10272338wme.59.1489058235551; Thu, 09 Mar 2017 03:17:15 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 9 Mar 2017 11:17:14 +0000 Message-Id: <20170309111714.20394-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309111714.20394-1-alex.bennee@linaro.org> References: <20170309111714.20394-1-alex.bennee@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: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22b Subject: [Qemu-devel] [PULL 11/11] hw/intc/arm_gic: modernise the DPRINTF 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: "open list:ARM cores" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 While I was debugging the icount issues I realised a bunch of the messages look quite similar. I've fixed this by including __func__ in the debug print. At the same time I move the a modern if (GATE) style printf which ensures the compiler can check for format string errors even if the code gets optimised away in the non-DEBUG_GIC case. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by tags added. --- hw/intc/arm_gic.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 8e5a9d8a3e..b305d9032a 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -26,15 +26,20 @@ #include "qemu/log.h" #include "trace.h" =20 -//#define DEBUG_GIC +/* #define DEBUG_GIC */ =20 #ifdef DEBUG_GIC -#define DPRINTF(fmt, ...) \ -do { fprintf(stderr, "arm_gic: " fmt , ## __VA_ARGS__); } while (0) +#define DEBUG_GIC_GATE 1 #else -#define DPRINTF(fmt, ...) do {} while(0) +#define DEBUG_GIC_GATE 0 #endif =20 +#define DPRINTF(fmt, ...) do { \ + if (DEBUG_GIC_GATE) { \ + fprintf(stderr, "%s: " fmt, __func__, ## __VA_ARGS__); \ + } \ + } while (0) + static const uint8_t gic_id_11mpcore[] =3D { 0x00, 0x00, 0x00, 0x00, 0x90, 0x13, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; --=20 2.11.0