From nobody Thu May 2 12:02:18 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.zohomail.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 1503448856706549.7794201534346; Tue, 22 Aug 2017 17:40:56 -0700 (PDT) Received: from localhost ([::1]:44404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJj5-0006Er-FF for importer@patchew.org; Tue, 22 Aug 2017 20:40:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJb6-0007G9-0L for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkJb3-0004e7-Cy for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:40 -0400 Received: from ozlabs.org ([103.22.144.67]:36195) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkJb3-0004bh-1F; Tue, 22 Aug 2017 20:32:37 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xcT0G5Yxgz9t2l; Wed, 23 Aug 2017 10:32:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1503448350; bh=Fah+unEUbwGWQiPIgpNMAabpEgyxQTgi/lZdEIJ+jzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lE48Ei/nkMep6n8z0TssEFvHusuWOYtvIMD3OtAH34lQBow60gpy0VNg3h73L1N4E AnAoW7RQRy30AFs04KSuIrZQ+Qp3OFBOVs/oy2RPBnb2brFevpA6bpteV7ebaw2QNw 6pMBrgo7bu3GiQre6+Cs9975eMUC7geLJjC8vwYw= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 23 Aug 2017 10:32:11 +1000 Message-Id: <20170823003217.6769-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170823003217.6769-1-david@gibson.dropbear.id.au> References: <20170823003217.6769-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 1/7] boot-serial-test: prefer tcg accelerator 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: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, David Gibson 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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Cornelia Huck Prefer to use the tcg accelarator if it is available: This is our only real smoke test for tcg, and fast enough to use it for that. Fixes: 480bc11e6 ("boot-serial-test: fallback to kvm accelerator") Reported-by: Richard Henderson Signed-off-by: Cornelia Huck Signed-off-by: David Gibson --- tests/boot-serial-test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index a8ca877168..b95c5e74ea 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -78,7 +78,11 @@ static void test_machine(const void *data) fd =3D mkstemp(tmpname); g_assert(fd !=3D -1); =20 - args =3D g_strdup_printf("-M %s,accel=3Dkvm:tcg " + /* + * Make sure that this test uses tcg if available: It is used as a + * fast-enough smoketest for that. + */ + args =3D g_strdup_printf("-M %s,accel=3Dtcg:kvm " "-chardev file,id=3Dserial0,path=3D%s " "-no-shutdown -serial chardev:serial0 %s", test->machine, tmpname, test->extra); --=20 2.13.5 From nobody Thu May 2 12:02:18 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.zohomail.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 1503448491224961.6439636489716; Tue, 22 Aug 2017 17:34:51 -0700 (PDT) Received: from localhost ([::1]:44294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJdB-0000Hg-Vv for importer@patchew.org; Tue, 22 Aug 2017 20:34:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJb2-0007EP-Io for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkJb1-0004bD-0Y for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:36 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:45335) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkJb0-0004Xd-BT; Tue, 22 Aug 2017 20:32:34 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xcT0G4JYFz9sRq; Wed, 23 Aug 2017 10:32:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1503448350; bh=QarLvp6himBKSvU6p9vu6bWONMUVChjma5Cw0sPWijE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GNJx3ocy0lRwUGFUyY7DiGGwpwIdEh0DAO+ZeIp1K/fZZIb85LLdAR6GgC3Vthur2 F3uIz7f4rYCns8kdYRBtvIRXygu0CaTm+HPX7bncca0F4BHeIEf12YBd7iQ+KZv1MH lBK6+gtvDtfYp7nyP9LWmvH+gCBZ+2G0d8imcXmU= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 23 Aug 2017 10:32:12 +1000 Message-Id: <20170823003217.6769-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170823003217.6769-1-david@gibson.dropbear.id.au> References: <20170823003217.6769-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 2/7] target/ppc: 'PVR != host PVR' in KVM_SET_SREGS workaround 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: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, Daniel Henrique Barboza , David Gibson 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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Commit d5fc133eed ("ppc: Rework CPU compatibility testing across migration") changed the way cpu_post_load behaves with the PVR setting, causing an unexpected bug in KVM-HV migrations between hosts that are compatible (POWER8 and POWER8E, for example). Even with pvr_match() returning true, the guest freezes right after cpu_post_load. The reason is that the guest kernel can't handle a different PVR value other that the running host in KVM_SET_SREGS. In [1] it was discussed the possibility of a new KVM capability that would indicate that the guest kernel can handle a different PVR in KVM_SET_SREGS. Even if such feature is implemented, there is still the problem with older kernels that will not have this capability and will fail to migrate. This patch implements a workaround for that scenario. If running with KVM, check if the guest kernel does not have the capability (named here as 'cap_ppc_pvr_compat'). If it doesn't, calls kvmppc_is_pr() to see if the guest is running in KVM-HV. If all this happens, set env->spr[SPR_PVR] to the same value as the current host PVR. This ensures that we allow migrations with 'close enough' PVRs to still work in KVM-HV but also makes the code ready for this new KVM capability when it is done. A new function called 'kvmppc_pvr_workaround_required' was created to encapsulate the conditions said above and to avoid calling too many kvm.c internals inside cpu_post_load. [1] https://lists.gnu.org/archive/html/qemu-ppc/2017-06/msg00503.html Signed-off-by: Daniel Henrique Barboza [dwg: Fix for the case of using TCG on a PPC host] Signed-off-by: David Gibson --- target/ppc/kvm.c | 38 ++++++++++++++++++++++++++++++++++++++ target/ppc/kvm_ppc.h | 1 + target/ppc/machine.c | 22 ++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 85713795de..f31c67e1b1 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -90,6 +90,7 @@ static int cap_htm; /* Hardware transactional= memory support */ static int cap_mmu_radix; static int cap_mmu_hash_v3; static int cap_resize_hpt; +static int cap_ppc_pvr_compat; =20 static uint32_t debug_inst_opcode; =20 @@ -147,6 +148,13 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_mmu_radix =3D kvm_vm_check_extension(s, KVM_CAP_PPC_MMU_RADIX); cap_mmu_hash_v3 =3D kvm_vm_check_extension(s, KVM_CAP_PPC_MMU_HASH_V3); cap_resize_hpt =3D kvm_vm_check_extension(s, KVM_CAP_SPAPR_RESIZE_HPT); + /* + * Note: setting it to false because there is not such capability + * in KVM at this moment. + * + * TODO: call kvm_vm_check_extension() with the right capability + * after the kernel starts implementing it.*/ + cap_ppc_pvr_compat =3D false; =20 if (!cap_interrupt_level) { fprintf(stderr, "KVM: Couldn't find level irq capability. Expect t= he " @@ -2785,3 +2793,33 @@ void kvmppc_update_sdr1(target_ulong sdr1) run_on_cpu(cs, kvmppc_pivot_hpt_cpu, RUN_ON_CPU_TARGET_PTR(sdr1)); } } + +/* + * This is a helper function to detect a post migration scenario + * in which a guest, running as KVM-HV, freezes in cpu_post_load because + * the guest kernel can't handle a PVR value other than the actual host + * PVR in KVM_SET_SREGS, even if pvr_match() returns true. + * + * If we don't have cap_ppc_pvr_compat and we're not running in PR + * (so, we're HV), return true. The workaround itself is done in + * cpu_post_load. + * + * The order here is important: we'll only check for KVM PR as a + * fallback if the guest kernel can't handle the situation itself. + * We need to avoid as much as possible querying the running KVM type + * in QEMU level. + */ +bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu) +{ + CPUState *cs =3D CPU(cpu); + + if (!kvm_enabled()) { + return false; + } + + if (cap_ppc_pvr_compat) { + return false; + } + + return !kvmppc_is_pr(cs->kvm_state); +} diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 6bc6fb3e2d..381afe6240 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -67,6 +67,7 @@ void kvmppc_check_papr_resize_hpt(Error **errp); int kvmppc_resize_hpt_prepare(PowerPCCPU *cpu, target_ulong flags, int shi= ft); int kvmppc_resize_hpt_commit(PowerPCCPU *cpu, target_ulong flags, int shif= t); void kvmppc_update_sdr1(target_ulong sdr1); +bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu); =20 bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path); =20 diff --git a/target/ppc/machine.c b/target/ppc/machine.c index abe0a1cdf0..e36b7100cb 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -9,6 +9,7 @@ #include "mmu-hash64.h" #include "migration/cpu.h" #include "qapi/error.h" +#include "kvm_ppc.h" =20 static int cpu_load_old(QEMUFile *f, void *opaque, int version_id) { @@ -249,6 +250,27 @@ static int cpu_post_load(void *opaque, int version_id) } } =20 + /* + * If we're running with KVM HV, there is a chance that the guest + * is running with KVM HV and its kernel does not have the + * capability of dealing with a different PVR other than this + * exact host PVR in KVM_SET_SREGS. If that happens, the + * guest freezes after migration. + * + * The function kvmppc_pvr_workaround_required does this verification + * by first checking if the kernel has the cap, returning true immedia= tely + * if that is the case. Otherwise, it checks if we're running in KVM P= R. + * If the guest kernel does not have the cap and we're not running KVM= -PR + * (so, it is running KVM-HV), we need to ensure that KVM_SET_SREGS wi= ll + * receive the PVR it expects as a workaround. + * + */ +#if defined(CONFIG_KVM) + if (kvmppc_pvr_workaround_required(cpu)) { + env->spr[SPR_PVR] =3D env->spr_cb[SPR_PVR].default_value; + } +#endif + env->lr =3D env->spr[SPR_LR]; env->ctr =3D env->spr[SPR_CTR]; cpu_write_xer(env, env->spr[SPR_XER]); --=20 2.13.5 From nobody Thu May 2 12:02:18 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.zohomail.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 1503448672101831.0621949350002; Tue, 22 Aug 2017 17:37:52 -0700 (PDT) Received: from localhost ([::1]:44318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJg6-0003Ko-Ps for importer@patchew.org; Tue, 22 Aug 2017 20:37:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJb5-0007Fb-6E for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkJb3-0004eu-VZ for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:39 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:40009) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkJb3-0004bq-JW; Tue, 22 Aug 2017 20:32:37 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xcT0G68wmz9t0j; Wed, 23 Aug 2017 10:32:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1503448350; bh=7vmon9MHCj523RmDa5A4nR1I3hcKB3xhBOUC8LubQuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bh8CYKr8DmZCwYTNxt6mAiXZKWpgDc2mEnWLQNaAEeuTpH+iDTG5Ra6bBhz8C1bVD 9MSplzZWZb5hs11aTTsAfaXQEGPF1oWu0pD3pAsIngcY44LlUdfpbaKoH+liaLLKV/ f+Eq4fE1Yvbm5sJuuo/B/mVD4sjEyD2AkoYOX06A= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 23 Aug 2017 10:32:13 +1000 Message-Id: <20170823003217.6769-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170823003217.6769-1-david@gibson.dropbear.id.au> References: <20170823003217.6769-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 3/7] ppc: fix ppc_set_compat() with KVM PR 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: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, Greg Kurz , qemu-ppc@nongnu.org, David Gibson 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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz When running in KVM PR mode, kvmppc_set_compat() always fail because the current PR implementation doesn't handle KVM_REG_PPC_ARCH_COMPAT. Now that the machine code inconditionally calls ppc_set_compat_all() at reset time to restore the compat mode default value (commit 66d5c492dd3a9), it is impossible to start a guest with PR: qemu-system-ppc64: Unable to set CPU compatibility mode in KVM: Invalid argument A tentative patch [1] was recently sent by Suraj to address the issue, but it would prevent the compat mode to be turned off on reset. And we really don't want to explicitely check for KVM PR. During the patch's review, David suggested that we should only call the KVM ioctl() if the compat PVR changes. This allows at least to run with KVM PR, provided no compat mode is requested from the command line (which should be the case when running PR nested). This is what this patch does. While here, we also fix the side effect where KVM would fail but we would change the CPU state in QEMU anyway. [1] http://patchwork.ozlabs.org/patch/782039/ Signed-off-by: Greg Kurz Reviewed-by: Suraj Jitindar Singh Signed-off-by: David Gibson --- target/ppc/compat.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/target/ppc/compat.c b/target/ppc/compat.c index f1b67faa97..f8729fe46d 100644 --- a/target/ppc/compat.c +++ b/target/ppc/compat.c @@ -140,16 +140,17 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_= pvr, Error **errp) =20 cpu_synchronize_state(CPU(cpu)); =20 - cpu->compat_pvr =3D compat_pvr; - env->spr[SPR_PCR] =3D pcr & pcc->pcr_mask; - - if (kvm_enabled()) { + if (kvm_enabled() && cpu->compat_pvr !=3D compat_pvr) { int ret =3D kvmppc_set_compat(cpu, cpu->compat_pvr); if (ret < 0) { error_setg_errno(errp, -ret, "Unable to set CPU compatibility mode in KVM"= ); + return; } } + + cpu->compat_pvr =3D compat_pvr; + env->spr[SPR_PCR] =3D pcr & pcc->pcr_mask; } =20 typedef struct { --=20 2.13.5 From nobody Thu May 2 12:02:18 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.zohomail.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 1503448487620178.05532181751266; Tue, 22 Aug 2017 17:34:47 -0700 (PDT) Received: from localhost ([::1]:44293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJd8-0000G0-2Z for importer@patchew.org; Tue, 22 Aug 2017 20:34:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJb2-0007ED-3n for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkJb0-0004b0-Vt for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:36 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:35185) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkJb0-0004Xc-9w; Tue, 22 Aug 2017 20:32:34 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xcT0G4vrgz9t1m; Wed, 23 Aug 2017 10:32:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1503448350; bh=yF564823BRjrqZoLWBAbakiz3uJApCpgwg0cQWUl7NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DZamBT4JTM3GMpWlgbLZ2m6tEZu7FeWNgzHXszZmz/561l5VWJ/1/D1naiQpthn5Z lu2xlUx+K5fsGqY0z5iVsIM3KPtEwFqyM3BOG5XDwNi7bzeLhi2y+/TaYG/EZtpuSi oP/cYNl0eGbHWyfymoIMIrwxWKJzTF/Z2X1TrAWY= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 23 Aug 2017 10:32:14 +1000 Message-Id: <20170823003217.6769-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170823003217.6769-1-david@gibson.dropbear.id.au> References: <20170823003217.6769-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 4/7] spapr: Allow configure-connector to be called multiple times 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: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, Bharata B Rao , David Gibson 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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Bharata B Rao In case of in-kernel memory hot unplug, when the guest is not able to remove all the LMBs that are requested for removal, it will add back any LMBs that have been successfully removed. The DR Connectors of these LMBs wouldn't have been unconfigured and hence the addition of these LMBs will result in configure-connector call being issued on LMB DR connectors that are already in configured state. Such configure-connector calls will fail resulting in a DIMM which is partially unplugged. This however worked till recently before we overhauled the DRC implementation in QEMU. Commit 9d4c0f4f0a71e: "spapr: Consolidate DRC state variables" is the first commit where this problem shows up as per git bisect. Ideally guest shouldn't be issuing configure-connector call on an already configured DR connector. However for now, work around this in QEMU by allowing configure-connector to be called multiple times for all types of DR connectors. Signed-off-by: Bharata B Rao [dwg: Corrected buglet that would have initialized fdt pointers ready for reading on a device not present at reset] Signed-off-by: David Gibson --- hw/ppc/spapr_drc.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 5260b5d363..605697d8bd 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -442,12 +442,17 @@ void spapr_drc_reset(sPAPRDRConnector *drc) if (drc->dev) { /* A device present at reset is ready to go, same as coldplugged */ drc->state =3D drck->ready_state; + /* + * Ensure that we are able to send the FDT fragment again + * via configure-connector call if the guest requests. + */ + drc->ccs_offset =3D drc->fdt_start_offset; + drc->ccs_depth =3D 0; } else { drc->state =3D drck->empty_state; + drc->ccs_offset =3D -1; + drc->ccs_depth =3D -1; } - - drc->ccs_offset =3D -1; - drc->ccs_depth =3D -1; } =20 static void drc_reset(void *opaque) @@ -1071,8 +1076,14 @@ static void rtas_ibm_configure_connector(PowerPCCPU = *cpu, } =20 if ((drc->state !=3D SPAPR_DRC_STATE_LOGICAL_UNISOLATE) - && (drc->state !=3D SPAPR_DRC_STATE_PHYSICAL_UNISOLATE)) { - /* Need to unisolate the device before configuring */ + && (drc->state !=3D SPAPR_DRC_STATE_PHYSICAL_UNISOLATE) + && (drc->state !=3D SPAPR_DRC_STATE_LOGICAL_CONFIGURED) + && (drc->state !=3D SPAPR_DRC_STATE_PHYSICAL_CONFIGURED)) { + /* + * Need to unisolate the device before configuring + * or it should already be in configured state to + * allow configure-connector be called repeatedly. + */ rc =3D SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE; goto out; } @@ -1108,8 +1119,13 @@ static void rtas_ibm_configure_connector(PowerPCCPU = *cpu, /* done sending the device tree, move to configured state = */ trace_spapr_drc_set_configured(drc_index); drc->state =3D drck->ready_state; - drc->ccs_offset =3D -1; - drc->ccs_depth =3D -1; + /* + * Ensure that we are able to send the FDT fragment + * again via configure-connector call if the guest request= s. + */ + drc->ccs_offset =3D drc->fdt_start_offset; + drc->ccs_depth =3D 0; + fdt_offset_next =3D drc->fdt_start_offset; resp =3D SPAPR_DR_CC_RESPONSE_SUCCESS; } else { resp =3D SPAPR_DR_CC_RESPONSE_PREV_PARENT; --=20 2.13.5 From nobody Thu May 2 12:02:18 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.zohomail.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 1503449014455678.7947393782583; Tue, 22 Aug 2017 17:43:34 -0700 (PDT) Received: from localhost ([::1]:44828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJld-0000Jh-3W for importer@patchew.org; Tue, 22 Aug 2017 20:43:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJb5-0007G3-Ly for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkJb4-0004fF-8H for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:39 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:43513) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkJb3-0004bv-Jy; Tue, 22 Aug 2017 20:32:38 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xcT0G6zd0z9t2S; Wed, 23 Aug 2017 10:32:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1503448350; bh=BJOFcTTwJRWIFaXmzibsN2HhCOaQVpzTni5MRZ1oG9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UCcAxLJStem9kuh3XwrHny4tEXvAr4tV5c3Cl/WPwYbqv/esVpfdQGyL+b0rxCn7M 5cQTpYwTAL6i3x5jgctN+YrybjWSIcWR2VegbdDeQdBtM1Ntr8z3pJ5fPW4EW7hDeo jH1wb+96vj+ylvuCqvBUHT9flN5UQHRPkDMpzjfc= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 23 Aug 2017 10:32:15 +1000 Message-Id: <20170823003217.6769-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170823003217.6769-1-david@gibson.dropbear.id.au> References: <20170823003217.6769-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 5/7] hw/ppc/spapr: Fix segfault when instantiating a 'pc-dimm' without 'memdev' 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: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, David Gibson 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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth QEMU currently crashes when trying to use a 'pc-dimm' on the pseries machine without specifying its 'memdev' property. This happens because pc_dimm_get_memory_region() does not check whether the 'memdev' property has properly been set by the user. Looking closer at this function, it's also obvious that it is using &error_abort to call another function - and this is bad in a function that is used in the hot-plugging calling chain since this can also cause QEMU to exit unexpectedly. So let's fix these issues in a proper way now: Add a "Error **errp" parameter to pc_dimm_get_memory_region() which we use in case the 'memdev' property has not been set by the user, and which we can use instead of the &error_abort, and change the callers of get_memory_region() to make use of this "errp" parameter for proper error checking. Signed-off-by: Thomas Huth Reviewed-by: Igor Mammedov Signed-off-by: David Gibson --- hw/i386/pc.c | 14 ++++++++++++-- hw/mem/nvdimm.c | 2 +- hw/mem/pc-dimm.c | 14 +++++++++++--- hw/ppc/spapr.c | 42 ++++++++++++++++++++++++++++++------------ include/hw/mem/pc-dimm.h | 2 +- 5 files changed, 55 insertions(+), 19 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 59435390ba..21081041d5 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1691,10 +1691,15 @@ static void pc_dimm_plug(HotplugHandler *hotplug_de= v, PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr =3D ddc->get_memory_region(dimm); + MemoryRegion *mr; uint64_t align =3D TARGET_PAGE_SIZE; bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); =20 + mr =3D ddc->get_memory_region(dimm, &local_err); + if (local_err) { + goto out; + } + if (memory_region_get_alignment(mr) && pcmc->enforce_aligned_dimm) { align =3D memory_region_get_alignment(mr); } @@ -1758,10 +1763,15 @@ static void pc_dimm_unplug(HotplugHandler *hotplug_= dev, PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr =3D ddc->get_memory_region(dimm); + MemoryRegion *mr; HotplugHandlerClass *hhc; Error *local_err =3D NULL; =20 + mr =3D ddc->get_memory_region(dimm, &local_err); + if (local_err) { + goto out; + } + hhc =3D HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); hhc->unplug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); =20 diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index db896b0bb6..952fce5ec8 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -71,7 +71,7 @@ static void nvdimm_init(Object *obj) NULL, NULL); } =20 -static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm) +static MemoryRegion *nvdimm_get_memory_region(PCDIMMDevice *dimm, Error **= errp) { NVDIMMDevice *nvdimm =3D NVDIMM(dimm); =20 diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index ea67b461c2..bdf6649083 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -363,7 +363,10 @@ static void pc_dimm_get_size(Object *obj, Visitor *v, = const char *name, PCDIMMDevice *dimm =3D PC_DIMM(obj); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(obj); =20 - mr =3D ddc->get_memory_region(dimm); + mr =3D ddc->get_memory_region(dimm, errp); + if (!mr) { + return; + } value =3D memory_region_size(mr); =20 visit_type_uint64(v, name, &value, errp); @@ -411,9 +414,14 @@ static void pc_dimm_unrealize(DeviceState *dev, Error = **errp) host_memory_backend_set_mapped(dimm->hostmem, false); } =20 -static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm) +static MemoryRegion *pc_dimm_get_memory_region(PCDIMMDevice *dimm, Error *= *errp) { - return host_memory_backend_get_memory(dimm->hostmem, &error_abort); + if (!dimm->hostmem) { + error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property must be set"); + return NULL; + } + + return host_memory_backend_get_memory(dimm->hostmem, errp); } =20 static MemoryRegion *pc_dimm_get_vmstate_memory_region(PCDIMMDevice *dimm) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f7a19720dc..cec441cbf4 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2772,10 +2772,15 @@ static void spapr_memory_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, sPAPRMachineState *ms =3D SPAPR_MACHINE(hotplug_dev); PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr =3D ddc->get_memory_region(dimm); - uint64_t align =3D memory_region_get_alignment(mr); - uint64_t size =3D memory_region_size(mr); - uint64_t addr; + MemoryRegion *mr; + uint64_t align, size, addr; + + mr =3D ddc->get_memory_region(dimm, &local_err); + if (local_err) { + goto out; + } + align =3D memory_region_get_alignment(mr); + size =3D memory_region_size(mr); =20 pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, &local_err); if (local_err) { @@ -2808,10 +2813,16 @@ static void spapr_memory_pre_plug(HotplugHandler *h= otplug_dev, DeviceState *dev, { PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr =3D ddc->get_memory_region(dimm); - uint64_t size =3D memory_region_size(mr); + MemoryRegion *mr; + uint64_t size; char *mem_dev; =20 + mr =3D ddc->get_memory_region(dimm, errp); + if (!mr) { + return; + } + size =3D memory_region_size(mr); + if (size % SPAPR_MEMORY_BLOCK_SIZE) { error_setg(errp, "Hotplugged memory size must be a multiple of " "%lld MB", SPAPR_MEMORY_BLOCK_SIZE / M_BYTE); @@ -2882,7 +2893,7 @@ static sPAPRDIMMState *spapr_recover_pending_dimm_sta= te(sPAPRMachineState *ms, { sPAPRDRConnector *drc; PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr =3D ddc->get_memory_region(dimm); + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); uint64_t size =3D memory_region_size(mr); uint32_t nr_lmbs =3D size / SPAPR_MEMORY_BLOCK_SIZE; uint32_t avail_lmbs =3D 0; @@ -2912,7 +2923,7 @@ void spapr_lmb_release(DeviceState *dev) sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_hotplug_handler(de= v)); PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr =3D ddc->get_memory_region(dimm); + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); sPAPRDIMMState *ds =3D spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(= dev)); =20 /* This information will get lost if a migration occurs @@ -2945,12 +2956,19 @@ static void spapr_memory_unplug_request(HotplugHand= ler *hotplug_dev, Error *local_err =3D NULL; PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); - MemoryRegion *mr =3D ddc->get_memory_region(dimm); - uint64_t size =3D memory_region_size(mr); - uint32_t nr_lmbs =3D size / SPAPR_MEMORY_BLOCK_SIZE; - uint64_t addr_start, addr; + MemoryRegion *mr; + uint32_t nr_lmbs; + uint64_t size, addr_start, addr; int i; sPAPRDRConnector *drc; + + mr =3D ddc->get_memory_region(dimm, &local_err); + if (local_err) { + goto out; + } + size =3D memory_region_size(mr); + nr_lmbs =3D size / SPAPR_MEMORY_BLOCK_SIZE; + addr_start =3D object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PRO= P, &local_err); if (local_err) { diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h index 1e483f2670..6f8c3eb1b3 100644 --- a/include/hw/mem/pc-dimm.h +++ b/include/hw/mem/pc-dimm.h @@ -71,7 +71,7 @@ typedef struct PCDIMMDeviceClass { =20 /* public */ void (*realize)(PCDIMMDevice *dimm, Error **errp); - MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm); + MemoryRegion *(*get_memory_region)(PCDIMMDevice *dimm, Error **errp); MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm); } PCDIMMDeviceClass; =20 --=20 2.13.5 From nobody Thu May 2 12:02:18 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.zohomail.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 1503448537121882.4917852787518; Tue, 22 Aug 2017 17:35:37 -0700 (PDT) Received: from localhost ([::1]:44299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJdv-00013N-RP for importer@patchew.org; Tue, 22 Aug 2017 20:35:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJb6-0007GG-31 for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkJb3-0004eJ-Dm for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:40 -0400 Received: from ozlabs.org ([103.22.144.67]:49869) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkJb3-0004bp-2l; Tue, 22 Aug 2017 20:32:37 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xcT0H1yXGz9t33; Wed, 23 Aug 2017 10:32:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1503448351; bh=JuQMaV6Rc8nQO5BZatrwbuRzOY5aPs2YEaG9bTCWVUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UHCuVnlIMCQSqtjsWH4PszWKc2MiNK/l/iSadbnx5kxITqlrdYXo2pHC/eVowMIoC OL8f0+h3cI3K9nESNoRl/p0V4PNZt36vsnDOJsyUQ6kHWPHMO/JHdC67afVFl94Hzq y2SNGQD+pRTe3Zs/F+M3v2PP6oCJ2HSnUKn7HoII= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 23 Aug 2017 10:32:16 +1000 Message-Id: <20170823003217.6769-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170823003217.6769-1-david@gibson.dropbear.id.au> References: <20170823003217.6769-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 6/7] hw/ppc/spapr_rtc: Mark the RTC device with user_creatable = false 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: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, David Gibson 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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth QEMU currently aborts unexpectedly when a user tries to do something like this: $ qemu-system-ppc64 -nographic -S -nodefaults -monitor stdio QEMU 2.9.92 monitor - type 'help' for more information (qemu) device_add spapr-rtc,id=3Dspapr-rtc (qemu) device_del spapr-rtc ** ERROR:qemu/qdev-monitor.c:872:qdev_unplug: assertion failed: (hotplug_ctrl) Aborted (core dumped) The RTC device is not meant to be hot-pluggable - it's an internal device only and it even should not be possible to create it a second time with the "-device" parameter, so let's mark this with "user_creatable =3D false". Signed-off-by: Thomas Huth Signed-off-by: David Gibson --- hw/ppc/spapr_rtc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/ppc/spapr_rtc.c b/hw/ppc/spapr_rtc.c index 00a4e4c717..9ec3078691 100644 --- a/hw/ppc/spapr_rtc.c +++ b/hw/ppc/spapr_rtc.c @@ -164,6 +164,8 @@ static void spapr_rtc_class_init(ObjectClass *oc, void = *data) =20 dc->realize =3D spapr_rtc_realize; dc->vmsd =3D &vmstate_spapr_rtc; + /* Reason: This is an internal device only for handling the hypercalls= */ + dc->user_creatable =3D false; =20 spapr_rtas_register(RTAS_GET_TIME_OF_DAY, "get-time-of-day", rtas_get_time_of_day); --=20 2.13.5 From nobody Thu May 2 12:02:18 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.zohomail.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 1503448668010777.5331538685581; Tue, 22 Aug 2017 17:37:48 -0700 (PDT) Received: from localhost ([::1]:44310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJg2-0003IR-8b for importer@patchew.org; Tue, 22 Aug 2017 20:37:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkJb6-0007GE-2F for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkJb3-0004eE-DQ for qemu-devel@nongnu.org; Tue, 22 Aug 2017 20:32:40 -0400 Received: from ozlabs.org ([103.22.144.67]:34345) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkJb3-0004bl-2C; Tue, 22 Aug 2017 20:32:37 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xcT0H1F7Xz9t2v; Wed, 23 Aug 2017 10:32:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1503448351; bh=Mah/vUqCLhcItaqBu28Ul1ertpxLOOUO2VC0ZSUEdlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgZkedicMTJUMqtknYWhToOdFAU680LJcXninFlsD1vX/w9+uHxZaNC61zZYHXDsr tXXi5bmmkPQDwE1zhKOt+Ys3QWNtrU3xqJdw+Amx6txbGqDCWcNlHb6ZPOz0ZxYDV1 ctAbzS842CBx/0q8sZjZzlgBw+89UwaRTQWZkPU4= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 23 Aug 2017 10:32:17 +1000 Message-Id: <20170823003217.6769-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170823003217.6769-1-david@gibson.dropbear.id.au> References: <20170823003217.6769-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 7/7] hw/ppc/spapr_iommu: Fix crash when removing the "spapr-tce-table" device 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: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, qemu-ppc@nongnu.org, David Gibson 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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth QEMU currently aborts unexpectedly when the user tries to add and remove a "spapr-tce-table" device: $ qemu-system-ppc64 -nographic -S -nodefaults -monitor stdio QEMU 2.9.92 monitor - type 'help' for more information (qemu) device_add spapr-tce-table,id=3Dx (qemu) device_del x ** ERROR:qemu/qdev-monitor.c:872:qdev_unplug: assertion failed: (hotplug_ctrl) Aborted (core dumped) The device should not be accessable for the users at all, it's just used internally, so mark it with user_creatable =3D false. Signed-off-by: Thomas Huth Signed-off-by: David Gibson --- hw/ppc/spapr_iommu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index e614621a83..ed2d53559a 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -618,6 +618,8 @@ static void spapr_tce_table_class_init(ObjectClass *kla= ss, void *data) dc->init =3D spapr_tce_table_realize; dc->reset =3D spapr_tce_reset; dc->unrealize =3D spapr_tce_table_unrealize; + /* Reason: This is just an internal device for handling the hypercalls= */ + dc->user_creatable =3D false; =20 QLIST_INIT(&spapr_tce_tables); =20 --=20 2.13.5