From nobody Sun May 5 15:55:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1569228206; cv=none; d=zoho.com; s=zohoarc; b=c+XpaVenk6zCpc9S+pMYv/T+1x/bu5P8C4FaaowNjaKWyf9SyknBiYH6rOvIbSmghLXhGtgQPheZOQy+Pwl4W6RXrwmPMEE2ITq/XzkUGe+Tz3NJB99hMd+vfi+g/4SJx4354akIJb1FUGnwZW7iE0wvrismH4xM1N0TzdCPmmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569228206; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=9gYorYdvrL6z3LEiLOWBGu6035E4cnEBrBWPtlMvosk=; b=cde/Lw/5s2gWcwK5v4g55R97JTPd5JJNYMLyEFDbMdz9X0W1raUbizXBJBEEwz8LL4E9yq2vafMHBUiKAmg+5wuaeDiC8E5KAM4ivM37zd9YJDkoFjospXgo2YoYEy1HOR6uE+bzOEL9eBIHt4YBecA3G+Jaq6+DHhHq3o2dXdE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569228206471732.9033021277344; Mon, 23 Sep 2019 01:43:26 -0700 (PDT) Received: from localhost ([::1]:53744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJwL-00032k-1h for importer@patchew.org; Mon, 23 Sep 2019 04:43:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48434) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCJun-0001bW-2t for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:41:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCJul-0005s7-HF for qemu-devel@nongnu.org; Mon, 23 Sep 2019 04:41:48 -0400 Received: from ozlabs.ru ([107.173.13.209]:44440) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iCJul-0005ll-Bn; Mon, 23 Sep 2019 04:41:47 -0400 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id B73ACAE80017; Mon, 23 Sep 2019 04:40:39 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Subject: [PATCH qemu] ppc/kvm: Skip writing DPDES back when in run time state Date: Mon, 23 Sep 2019 18:41:10 +1000 Message-Id: <20190923084110.34643-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 107.173.13.209 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" On POWER8 systems the Directed Privileged Door-bell Exception State register (DPDES) stores doorbell pending status, one bit per a thread of a core, set by "msgsndp" instruction. The register is shared among threads of the same core and KVM on POWER9 emulates it in a similar way (POWER9 does not have DPDES). DPDES is shared but QEMU assumes all SPRs are per thread so the only safe way to write DPDES back to VCPU before running a guest is doing so while all threads are pulled out of the guest so DPDES cannot change. There is only one situation when this condition is met: incoming migration when all threads are stopped. Otherwise any QEMU HMP/QMP command causing kvm_arch_put_registers() (for example printing registers or dumping memory) can clobber DPDES in a race with other vcpu threads. This changes DPDES handling so it is not written to KVM at runtime. Signed-off-by: Alexey Kardashevskiy --- target/ppc/kvm.c | 5 +++++ target/ppc/translate_init.inc.c | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 8c5b1f25cc95..820724cc7d15 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -993,6 +993,10 @@ int kvm_arch_put_registers(CPUState *cs, int level) } =20 kvm_set_one_reg(cs, KVM_REG_PPC_TB_OFFSET, &env->tb_env->tb_offset= ); + + if (level > KVM_PUT_RUNTIME_STATE) { + kvm_put_one_spr(cs, KVM_REG_PPC_DPDES, SPR_DPDES); + } #endif /* TARGET_PPC64 */ } =20 @@ -1297,6 +1301,7 @@ int kvm_arch_get_registers(CPUState *cs) } =20 kvm_get_one_reg(cs, KVM_REG_PPC_TB_OFFSET, &env->tb_env->tb_offset= ); + kvm_get_one_spr(cs, KVM_REG_PPC_DPDES, SPR_DPDES); #endif } =20 diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 0fb11c7ac6da..ba726dec4d00 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -8200,11 +8200,10 @@ static void gen_spr_power8_dpdes(CPUPPCState *env) { #if !defined(CONFIG_USER_ONLY) /* Directed Privileged Door-bell Exception State, used for IPI */ - spr_register_kvm_hv(env, SPR_DPDES, "DPDES", - SPR_NOACCESS, SPR_NOACCESS, - &spr_read_generic, SPR_NOACCESS, - &spr_read_generic, &spr_write_generic, - KVM_REG_PPC_DPDES, 0x00000000); + spr_register(env, SPR_DPDES, "DPDES", + SPR_NOACCESS, SPR_NOACCESS, + &spr_read_generic, SPR_NOACCESS, + 0x00000000); #endif } =20 --=20 2.17.1