From nobody Sat Apr 27 16:06:09 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; dkim=fail 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 1490699584752762.2950458102102; Tue, 28 Mar 2017 04:13:04 -0700 (PDT) Received: from localhost ([::1]:52425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp3f-0006ux-Ji for importer@patchew.org; Tue, 28 Mar 2017 07:13:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp0S-0004H0-4n for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csp0O-00035e-0Z for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:44 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:35786) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csp0N-00035S-Oo for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:39 -0400 Received: by mail-wr0-x22b.google.com with SMTP id u1so99368467wra.2 for ; Tue, 28 Mar 2017 04:09:39 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h76sm3149662wmd.33.2017.03.28.04.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 04:09:36 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 5F42A3E053E; Tue, 28 Mar 2017 12:09:36 +0100 (BST) 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=qK4nN2Njmu4l/6V8od0YE5nPUHYbs+OMRrbxKKlftvg=; b=dk/WOx6GkIb7BwhVePrjYbPmvbwEv9kDRuvHjecKAj9oSGyVSoUFHLVnst4A0p5Kok MSCpFkNuHWrM5ggesmbswoJa4UHjlXYOajbCftfAQVaDWSxthLke7yjX677U96AwSki1 h42RjdGhfQrHIHXpUyjwi4+viYaXpVG5Qmelw= 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=qK4nN2Njmu4l/6V8od0YE5nPUHYbs+OMRrbxKKlftvg=; b=O7jajs2hoGAMTwwjlTy1cfxd6AkoJKVBSbQNDZRdALzG2KH5pdk1G2WS/53/eEXGx1 6msR1LxxZHQSNZGVHe5bRE88lh8ExNuudmTpOKB8BJ5TH+RmD/mqEXFLdOou8fuuCBJi eBh2o4DdgNLVsr/DYZGUWotRIDcpYU7FscZlx2xLixtPuCkRx4xLu3JvJXjJKBGdchAo fBljVvT0Yt5CvJ7YucChQO+ZnkaYAs2H7F8SQQgn925nQ+gmKTqTVMKfyM28T4Q0Cd5m SgzP8N5xdX3vvoiqgoK4iNu0q4GppEYdkK+7DDlgfnkl17kYqx4d0AevJnhQcVs5qNTo kEUQ== X-Gm-Message-State: AFeK/H1ECR2KaiJv7J4x/oQDKE3xxUALpNiQ3GMbNzYK6K+TRQJkja/HCQXAK5Tx39sy8Zvf X-Received: by 10.28.208.7 with SMTP id h7mr13881190wmg.79.1490699378572; Tue, 28 Mar 2017 04:09:38 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 28 Mar 2017 12:09:31 +0100 Message-Id: <20170328110936.24806-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328110936.24806-1-alex.bennee@linaro.org> References: <20170328110936.24806-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::22b Subject: [Qemu-devel] [PULL 1/6] user-exec: handle synchronous signals from QEMU gracefully 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: Riku Voipio , =?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-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 When "tcg: enable thread-per-vCPU" (commit 3725794) was merged the lifetime of current_cpu was changed. Previously a broken linux-user call might abort() which can eventually escalate into a SIGSEGV which would then crash qemu as it attempted to deref a NULL current_cpu. After commit 3725794 it would attempt to fixup state and re-start the run-loop and much hilarity (i.e. a looping lockup) would ensue from jumping into a stale jmp_env. As we can actually tell if we are in the run-loop from looking at the cpu->running flag we should catch this badness first and abort() cleanly rather than try to soldier on. There is a theoretical race between the flag being set and sigsetjmp refreshing the jump buffer but we can try really hard to not introduce crashes into that code. [LV: setgroups03 fails on powerpc LTP] Reported-by: Laurent Vivier Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Reviewed-by: Paolo Bonzini --- user-exec.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/user-exec.c b/user-exec.c index 6db075884d..a8f95fa1e1 100644 --- a/user-exec.c +++ b/user-exec.c @@ -57,10 +57,23 @@ static void cpu_exit_tb_from_sighandler(CPUState *cpu, = sigset_t *old_set) static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, int is_write, sigset_t *old_set) { - CPUState *cpu; + CPUState *cpu =3D current_cpu; CPUClass *cc; int ret; =20 + /* For synchronous signals we expect to be coming from the vCPU + * thread (so current_cpu should be valid) and either from running + * code or during translation which can fault as we cross pages. + * + * If neither is true then something has gone wrong and we should + * abort rather than try and restart the vCPU execution. + */ + if (!cpu || !cpu->running) { + printf("qemu:%s received signal outside vCPU context @ pc=3D0x%" + PRIxPTR "\n", __func__, pc); + abort(); + } + #if defined(DEBUG_SIGNAL) printf("qemu: SIGSEGV pc=3D0x%08lx address=3D%08lx w=3D%d oldset=3D0x%= 08lx\n", pc, address, is_write, *(unsigned long *)old_set); @@ -83,7 +96,7 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigne= d long address, * currently executing TB was modified and must be exited * immediately. */ - cpu_exit_tb_from_sighandler(current_cpu, old_set); + cpu_exit_tb_from_sighandler(cpu, old_set); g_assert_not_reached(); default: g_assert_not_reached(); @@ -94,7 +107,6 @@ static inline int handle_cpu_signal(uintptr_t pc, unsign= ed long address, are still valid segv ones */ address =3D h2g_nocheck(address); =20 - cpu =3D current_cpu; cc =3D CPU_GET_CLASS(cpu); /* see if it is an MMU fault */ g_assert(cc->handle_mmu_fault); --=20 2.11.0 From nobody Sat Apr 27 16:06:09 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; dkim=fail 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 1490699492345319.6856032340205; Tue, 28 Mar 2017 04:11:32 -0700 (PDT) Received: from localhost ([::1]:52420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp2A-0005W1-VH for importer@patchew.org; Tue, 28 Mar 2017 07:11:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp0S-0004Gz-4K for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csp0O-000378-S1 for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:44 -0400 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:34507) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csp0O-00035a-Ko for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:40 -0400 Received: by mail-wr0-x22c.google.com with SMTP id l43so98993064wre.1 for ; Tue, 28 Mar 2017 04:09:40 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id u145sm3187822wmu.1.2017.03.28.04.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 04:09:38 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 705A63E058D; Tue, 28 Mar 2017 12:09:36 +0100 (BST) 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=BhWN+GJg6vfhONv8167YrJB0RZpP0V7q5wYdDw1Y4cU=; b=JuOXkvWYMyLYNH/bBRroreZRXhgIg3a5/7evLLi1EDUrpTBRh/mScgV1O4bUD1hlI0 GDOUhB1gLHPIjuav9G7/oTHnUKj5VG92D5DRlBs9/Ox2DDwCs+W+0F3Fxmo9TSonD6Kw Yn5Dcp8VQ8rDTIYdT91PgeCpGNe8f87Faad6c= 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=BhWN+GJg6vfhONv8167YrJB0RZpP0V7q5wYdDw1Y4cU=; b=Ge4YY4OyLfVtlZkns1miyZZPez7tQIjdsycqOAal2O792xeB5mChoT67D+/fvw0LPp fjID+IyaT2a0m/h623lxf8QljixP+KGWseKJPkrK1VP1OT/n7oeBjykApNKYOd6C635Y TtvFcU2ilKNvFhnSQED865g2wyGHYWCbUClITNek9zLr0RJGx/V+d4z2lIgsDHAKqkcQ 3wSjIotlw8Gea5XuIBOxbZfGgHkui3KQjIs5Bb+bFlWS+WgsIirNVlZAeFHobhNSm1MD 9iMSZqRZZ7jRAzvCwdnHI4fYPio9buByMZKJKP7UEqueBYsGeDspRElxxeEEyE6BoLtA iL2g== X-Gm-Message-State: AFeK/H2vgTJchArODuZNThnOqichtFSjOehvpGqdN/pqiaDLuv1Xu0JqzIT1YJSqg4sD7BLC X-Received: by 10.28.37.3 with SMTP id l3mr14004639wml.100.1490699379473; Tue, 28 Mar 2017 04:09:39 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 28 Mar 2017 12:09:32 +0100 Message-Id: <20170328110936.24806-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328110936.24806-1-alex.bennee@linaro.org> References: <20170328110936.24806-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::22c Subject: [Qemu-devel] [PULL 2/6] bsd-user: align use of mmap_lock to that of linux-user 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: =?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-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 The introduction of stricter mmap_lock checking in translate-all broke the BSD user build. The working mmap_lock functions were hidden behind CONFIG_USE_NPTL which is never defined. This patch brings them inline with linux-user. Despite the disapearence of the comment "We aren't threadsafe to start with..." this doesn't make bsd-user so. It will still need the rest of the fixes that have been done in linux-user ported over. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Paolo Bonzini --- bsd-user/mmap.c | 13 +------------ bsd-user/qemu.h | 2 -- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c index 1ad018a127..7f2018ede0 100644 --- a/bsd-user/mmap.c +++ b/bsd-user/mmap.c @@ -24,8 +24,7 @@ =20 //#define DEBUG_MMAP =20 -#if defined(CONFIG_USE_NPTL) -pthread_mutex_t mmap_mutex; +static pthread_mutex_t mmap_mutex =3D PTHREAD_MUTEX_INITIALIZER; static int __thread mmap_lock_count; =20 void mmap_lock(void) @@ -62,16 +61,6 @@ void mmap_fork_end(int child) else pthread_mutex_unlock(&mmap_mutex); } -#else -/* We aren't threadsafe to start with, so no need to worry about locking. = */ -void mmap_lock(void) -{ -} - -void mmap_unlock(void) -{ -} -#endif =20 /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect(abi_ulong start, abi_ulong len, int prot) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 2b2b9184e0..b550cee0cb 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -209,10 +209,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong o= ld_size, abi_ulong new_addr); int target_msync(abi_ulong start, abi_ulong len, int flags); extern unsigned long last_brk; -#if defined(CONFIG_USE_NPTL) void mmap_fork_start(void); void mmap_fork_end(int child); -#endif =20 /* main.c */ extern unsigned long x86_stack_size; --=20 2.11.0 From nobody Sat Apr 27 16:06:09 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; dkim=fail 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 1490699490523661.5266097873099; Tue, 28 Mar 2017 04:11:30 -0700 (PDT) Received: from localhost ([::1]:52419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp29-0005Vy-6F for importer@patchew.org; Tue, 28 Mar 2017 07:11:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp0S-0004Gx-41 for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csp0P-00037L-Dq for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:44 -0400 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]:35807) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csp0P-00036i-7F for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:41 -0400 Received: by mail-wr0-x22c.google.com with SMTP id u1so99369718wra.2 for ; Tue, 28 Mar 2017 04:09:41 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id w12sm4428919wra.21.2017.03.28.04.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 04:09:38 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 828E33E0600; Tue, 28 Mar 2017 12:09:36 +0100 (BST) 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=tu+woEqXaKcxPO94kYC7x+9A4DE+5k3GCrnqjhYHFbA=; b=jU18jNMjXorzhxZD8d5E3pbN8fR2w2SbPnrfmXyap9mtIZsfZdthrzG2GyqYlgwcRR Eah+88TTSb4ZcVQ7trCnIUwJU9/UL+b7rr11psAtzIXrrZiIwyRKYQ5csQ4aB/c8W8YY CjFGngAZR1eQmNpCnU2RyKJiabk2CTF+qWkLc= 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=tu+woEqXaKcxPO94kYC7x+9A4DE+5k3GCrnqjhYHFbA=; b=nRBQ7FOKumsR0JJ4coWtgrUANOHn5QH/htWCOPs2CWDVhVdmVL9gTfMcsgiwqzC4FA e7WCBBdFf5mMZLIhTL8u5/3W9pAlkxiTZbsi8za+elq6QtagVWIsMFGMaLlLe3rv2nCu CbCr1nJ43XnJ5a1aH/PBFVVhvjhmX5iCmuOn8YgUDppuX2BlxFH/yxRGGba623VxDRr1 jHTT40Xyce5uHISI9JrkNsZWEPot7WyAeWCAw5tJB73/QI2RXQRanv3ieysVCg4W8696 JOpFIJJ9d0cH4ucsrbqnfcLGSpNzh49tKpWlW9L6KO2EQ8EwDFgEUhtSgltFznh1IEm9 Tb2Q== X-Gm-Message-State: AFeK/H3hMjFWfk/3sBKV9t1+JuME36zoyZytq6+GaOWuK8WsnNlqtgWEIMjcamsWpTuFGgNy X-Received: by 10.28.95.87 with SMTP id t84mr13859396wmb.35.1490699380230; Tue, 28 Mar 2017 04:09:40 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 28 Mar 2017 12:09:33 +0100 Message-Id: <20170328110936.24806-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328110936.24806-1-alex.bennee@linaro.org> References: <20170328110936.24806-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::22c Subject: [Qemu-devel] [PULL 3/6] ui/console: ensure do_safe_dpy_refresh holds 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: Peter Crosthwaite , qemu-devel@nongnu.org, Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson 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_0 Z_629925259 SPT_0 I missed the fact that when an exclusive work item runs it drops the BQL to ensure all no vCPUs are stuck waiting for it, hence causing a deadlock. However the actual helper needs to take the BQL especially as we'll be messing with device emulation bits during the update which all assume BQL is held. We make a minor cpu_reloading_memory_map which must try and unlock the RCU if we are actually outside the running context. Reported-by: Laurent Desnogues Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Paolo Bonzini Reviewed-by: Gerd Hoffmann --- cpu-exec-common.c | 2 +- ui/console.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cpu-exec-common.c b/cpu-exec-common.c index 0504a9457b..e81da276bb 100644 --- a/cpu-exec-common.c +++ b/cpu-exec-common.c @@ -35,7 +35,7 @@ void cpu_loop_exit_noexc(CPUState *cpu) #if defined(CONFIG_SOFTMMU) void cpu_reloading_memory_map(void) { - if (qemu_in_vcpu_thread()) { + if (qemu_in_vcpu_thread() && current_cpu->running) { /* The guest can in theory prolong the RCU critical section as long * as it feels like. The major problem with this is that because it * can do multiple reconfigurations of the memory map within the diff --git a/ui/console.c b/ui/console.c index 937c950840..dd27c9501b 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1586,7 +1586,9 @@ bool dpy_gfx_check_format(QemuConsole *con, static void do_safe_dpy_refresh(CPUState *cpu, run_on_cpu_data opaque) { DisplayChangeListener *dcl =3D opaque.host_ptr; + qemu_mutex_lock_iothread(); dcl->ops->dpy_refresh(dcl); + qemu_mutex_unlock_iothread(); } =20 static void dpy_refresh(DisplayState *s) --=20 2.11.0 From nobody Sat Apr 27 16:06:09 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; dkim=fail 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 1490699769361897.6605186668277; Tue, 28 Mar 2017 04:16:09 -0700 (PDT) Received: from localhost ([::1]:52451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp6d-0000o2-RZ for importer@patchew.org; Tue, 28 Mar 2017 07:16:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp0S-0004Gw-3y for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csp0Q-00037y-GE for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:44 -0400 Received: from mail-wr0-x22a.google.com ([2a00:1450:400c:c0c::22a]:34529) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csp0Q-00037S-9p for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:42 -0400 Received: by mail-wr0-x22a.google.com with SMTP id l43so98994392wre.1 for ; Tue, 28 Mar 2017 04:09:42 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k139sm3187013wmg.11.2017.03.28.04.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 04:09:38 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 93A183E0632; Tue, 28 Mar 2017 12:09:36 +0100 (BST) 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=Ogyi5kz7Ku3eSPaW3zIGslmVSlz8ocnWz5FUjkgwixI=; b=Ufv5u5CTKVAqv5cidgY53QVOLcPwwJCKrUKnp+06/LfguCPMkPKUZr7OOF4TO5hHgS IQ9J296n/UZXbH2AJLbM3HaPXmfAHzDdD5R3w4A/XdvmtdvJPhshueLDOSUYuNg3bTeK PixOV1RncS7D6Taz5rU6K0fQs9v5V/MkZbd8c= 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=Ogyi5kz7Ku3eSPaW3zIGslmVSlz8ocnWz5FUjkgwixI=; b=S+LwfscKF7DXZWZtDvj229N3apBfOlD0Zc2j/vXI6SN3ZosdbEwbElLi86ejOSUZ7I W4ZopcJvlD2Jpq4efoqGJBWhlRYCAaaQyeWYtcgkaU+aAOp87jMTSwLBLwj0s/l7kW6d mv9MZvQivuJj0AU953Do6RNoE8lhoVavECZPX9NclGFf5FG3R2/gfBcQm3XI469/udME ybjnpVD15C9LKU2G8KEYabWVN/DN+kesU2ns8L8jT8p9f/hFpBe06B4DjVjCeFqdUm/U Dw6qSA/PzcwdQT6AWaZJAUrWgWsSpkEMapTf+cTrehxyd5vLOOA0YKyKA9A7BpDWExsh ovoQ== X-Gm-Message-State: AFeK/H2SzwneHyc04En7nNd7ugPdUwDCh/UuB7x0d96FAi2LHp+R2QN/HEodXfiCkMTf1lME X-Received: by 10.223.133.182 with SMTP id 51mr26270192wrt.39.1490699381204; Tue, 28 Mar 2017 04:09:41 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 28 Mar 2017 12:09:34 +0100 Message-Id: <20170328110936.24806-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328110936.24806-1-alex.bennee@linaro.org> References: <20170328110936.24806-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 4/6] ui/console: use exclusive mechanism directly 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Gerd Hoffmann 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_0 Z_629925259 SPT_0 The previous commit (8bb93c6f99) using async_safe_run_on_cpu() doesn't work on graphics sub-system which restrict which threads can do GUI updates. Rather the special casing MacOS we just directly call the helper and move all the exclusive handling into do_dafe_dpy_refresh(). The unfortunate bouncing of the BQL is to ensure there is no deadlock as vCPUs waiting on the BQL are kicked into their quiescent state. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Paolo Bonzini Reviewed-by: Gerd Hoffmann --- ui/console.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ui/console.c b/ui/console.c index dd27c9501b..419b098c11 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1576,19 +1576,22 @@ bool dpy_gfx_check_format(QemuConsole *con, } =20 /* - * Safe DPY refresh for TCG guests. This runs when the TCG vCPUs are - * quiescent so we can avoid races between dirty page tracking for - * direct frame-buffer access by the guest. + * Safe DPY refresh for TCG guests. We use the exclusive mechanism to + * ensure the TCG vCPUs are quiescent so we can avoid races between + * dirty page tracking for direct frame-buffer access by the guest. * * This is a temporary stopgap until we've fixed the dirty tracking * races in display adapters. */ -static void do_safe_dpy_refresh(CPUState *cpu, run_on_cpu_data opaque) +static void do_safe_dpy_refresh(DisplayChangeListener *dcl) { - DisplayChangeListener *dcl =3D opaque.host_ptr; + qemu_mutex_unlock_iothread(); + start_exclusive(); qemu_mutex_lock_iothread(); dcl->ops->dpy_refresh(dcl); qemu_mutex_unlock_iothread(); + end_exclusive(); + qemu_mutex_lock_iothread(); } =20 static void dpy_refresh(DisplayState *s) @@ -1598,8 +1601,7 @@ static void dpy_refresh(DisplayState *s) QLIST_FOREACH(dcl, &s->listeners, next) { if (dcl->ops->dpy_refresh) { if (tcg_enabled()) { - async_safe_run_on_cpu(first_cpu, do_safe_dpy_refresh, - RUN_ON_CPU_HOST_PTR(dcl)); + do_safe_dpy_refresh(dcl); } else { dcl->ops->dpy_refresh(dcl); } --=20 2.11.0 From nobody Sat Apr 27 16:06:09 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; dkim=fail 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 1490699690656363.1857651669094; Tue, 28 Mar 2017 04:14:50 -0700 (PDT) Received: from localhost ([::1]:52438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp5N-0008Gb-Ia for importer@patchew.org; Tue, 28 Mar 2017 07:14:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp0S-0004HB-Aa for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csp0R-00038F-6q for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:44 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:35827) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csp0R-00037s-0V for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:43 -0400 Received: by mail-wr0-x234.google.com with SMTP id u1so99371046wra.2 for ; Tue, 28 Mar 2017 04:09:42 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s26sm4411093wra.66.2017.03.28.04.09.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 04:09:38 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A4F033E0641; Tue, 28 Mar 2017 12:09:36 +0100 (BST) 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=uPRn5rzd3r197tZF8tokmGT8RCSgor33C8GRH7/+ym0=; b=Tn+dj7T+9QbbSZgmNqA+qBagiP0oYzdxi4aur9f47OmYXNd8skMs33b8YOWEujRf0w twC9s5dKcslnHi6Xl748+UCfa4hrgLjrwcyTLeIPURosW7tnybvMOdxAl8PArRDjD1mQ wIOBDnSzMfO+9Gy1DzqzTuzS1/5+LNCTbVVes= 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=uPRn5rzd3r197tZF8tokmGT8RCSgor33C8GRH7/+ym0=; b=Kq+drGTbOyZDMwzEKztYShRLnfYuSmndn23TMj2yzndRNX4UzArnrmBymZSN++hO6j DdfOO0huspFSoMb6WrpCPIuIhA9kaCtqACklW6x0Fhjdaf0gYUv7rz5Mvd9tn0jf7rIC HdYR4A8l/qRvwLXdP5AHOxpIUX/d83o8vfEwohTtfrLYIBjbAtUjt+H2phPab8dR0F/g iqRVUcmbkAjbrLg0eg4nZccvYR/udpxE/98LIROeTigiyZIyAnTc/7FuQBSQPM5JxnV6 q+YbfBmHsPshWC539kfo31j1GyDkhKZBu96HtYJU0kMk0jh0rVEIOSO0EuDKkyY+twxq TgTw== X-Gm-Message-State: AFeK/H3v5yuVxvBZ3d8vUxo2DdRzFjn+SZTqWCflXDKqNS3AgkcZDCxZD4tdiFq2RE7G6ZGP X-Received: by 10.223.134.98 with SMTP id 31mr27091294wrw.69.1490699382084; Tue, 28 Mar 2017 04:09:42 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 28 Mar 2017 12:09:35 +0100 Message-Id: <20170328110936.24806-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328110936.24806-1-alex.bennee@linaro.org> References: <20170328110936.24806-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::234 Subject: [Qemu-devel] [PULL 5/6] tcg: Add a new line after incompatibility warning 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 Crosthwaite , qemu-devel@nongnu.org, Paolo Bonzini , Pranith Kumar , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson 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_0 Z_629925259 SPT_0 From: Pranith Kumar Signed-off-by: Pranith Kumar Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Paolo Bonzini --- cpus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index 167d9615e1..68fdbc40b9 100644 --- a/cpus.c +++ b/cpus.c @@ -209,7 +209,7 @@ void qemu_tcg_configure(QemuOpts *opts, Error **errp) if (!check_tcg_memory_orders_compatible()) { error_report("Guest expects a stronger memory ordering= " "than the host provides"); - error_printf("This may cause strange/hard to debug err= ors"); + error_printf("This may cause strange/hard to debug err= ors\n"); } mttcg_enabled =3D true; } --=20 2.11.0 From nobody Sat Apr 27 16:06:09 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; dkim=fail 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 149069961578031.89166338169639; Tue, 28 Mar 2017 04:13:35 -0700 (PDT) Received: from localhost ([::1]:52426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp4A-0007KJ-Kr for importer@patchew.org; Tue, 28 Mar 2017 07:13:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csp0T-0004I5-Ff for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csp0S-00039M-Bd for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:45 -0400 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:34549) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csp0S-00038S-5C for qemu-devel@nongnu.org; Tue, 28 Mar 2017 07:09:44 -0400 Received: by mail-wr0-x233.google.com with SMTP id l43so98995837wre.1 for ; Tue, 28 Mar 2017 04:09:44 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g5sm4381405wrb.48.2017.03.28.04.09.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 04:09:38 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B5E6A3E0865; Tue, 28 Mar 2017 12:09:36 +0100 (BST) 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=QMUQf5TqOX7CCNQAEmdpRZFk+7rbo4QJDG6NnJJPYhU=; b=f/JfCDm47Fu5v5opmsEKGqklQpFtDhKBJMFme9eovL4eVw/6dkroJ8Jk343g20lw5a ej2NpoqOQfh1yssNElTOQ+DR+3H/cOPsIl6FRD2bt6DVSunXx+PTZSxkEvLtW7dCdSrB SDCTYbDwNMIXQT6GTxklf81beNNpuVzsn2XvU= 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=QMUQf5TqOX7CCNQAEmdpRZFk+7rbo4QJDG6NnJJPYhU=; b=AZnB87d9G7+jPNHJ96gwAEE+Tf9KdLQ2ZC2eGZoLBLn7jVBAJ9VnrBW6BX5ZGkFyfE t+qZi0J3L4VfbzxIbasuplQ847IaoUsk8D0+stIgatnwr1OMTtyyNjPM7hGDu1xX1rZH vmG4+XLkaIOwTg0G6pJ3Oz31xEMlLSBk40cQuFSbxhVHM1bEKmGPJoneWb3c9mx0ABQg Ir3ICr9gPz/i2UJ7ctbweFNgY9b1CqrAlemVFDOvIScR/NZy/PEIYJURKRnvPwshIfH5 vvPheJubk/QAZkpfFkwwjY6IyY35fUcVipC2GlomDAQD9ogbi9m6OEfroRw9drghb7oB z3Ww== X-Gm-Message-State: AFeK/H1LXH53tkutjCIquVvIAtdoUOx7393rlqgbZRpARFB2rxILzzFHTFA+yMiJ5/on7Fq7 X-Received: by 10.223.142.18 with SMTP id n18mr24863301wrb.188.1490699383087; Tue, 28 Mar 2017 04:09:43 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 28 Mar 2017 12:09:36 +0100 Message-Id: <20170328110936.24806-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170328110936.24806-1-alex.bennee@linaro.org> References: <20170328110936.24806-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 6/6] replay/replay.c: bump REPLAY_VERSION 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: =?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-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 A previous commit (3d4d16f4) added support for audio record/playback. However this breaks the logfile ABI due to the re-ordering of the ReplayEvents enum. The REPLAY_VERSION check is meant to prevent you from using old log files in newer QEMUs but this is currently broken. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Pavel Dovgalyuk Reviewed-by: Paolo Bonzini --- replay/replay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/replay/replay.c b/replay/replay.c index 78e2a7e570..9e0724e756 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -22,7 +22,7 @@ =20 /* Current version of the replay mechanism. Increase it when file format changes. */ -#define REPLAY_VERSION 0xe02005 +#define REPLAY_VERSION 0xe02006 /* Size of replay log header */ #define HEADER_SIZE (sizeof(uint32_t) + sizeof(uint64_t)) =20 --=20 2.11.0