From nobody Sat May 4 01:23:58 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 1512359462842120.1972084492661; Sun, 3 Dec 2017 19:51:02 -0800 (PST) Received: from localhost ([::1]:41093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLhmW-0007t6-7H for importer@patchew.org; Sun, 03 Dec 2017 22:51:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLhjm-0005Yu-LE for qemu-devel@nongnu.org; Sun, 03 Dec 2017 22:48:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eLhjl-0004LR-SJ for qemu-devel@nongnu.org; Sun, 03 Dec 2017 22:48:10 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:43095) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eLhjl-0004KD-DT; Sun, 03 Dec 2017 22:48:09 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yqrSQ0m3Nz9s1h; Mon, 4 Dec 2017 14:48:05 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1512359286; bh=ZufHmrU0VMUKMfI3iCSJcAYDasUCIPJZgqlqwWHI/Z0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fqDS1XkmGVti/pBgsLbj/td2R91OC+t583gMdyDfHKDEk0Rg6GwyOXvbYiziYh6PC mF2ZJPwYEPdTDbkLarwkWnL2sKBVeLlet2NxxhgEEPDHP7DZp6Qn52q3tcXqjE9Vua pN1fuqRjpBfum95FYiEWxKiEz6JUYuUH2NQIwUwI= From: David Gibson To: peter.maydell@linaro.org Date: Mon, 4 Dec 2017 14:48:00 +1100 Message-Id: <20171204034802.7336-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171204034802.7336-1-david@gibson.dropbear.id.au> References: <20171204034802.7336-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 1/3] pseries: fix TCG migration 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: Laurent Vivier , qemu-devel@nongnu.org, agraf@suse.de, groug@kaod.org, 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: Laurent Vivier Migration of pseries is broken with TCG because QEMU tries to restore KVM MMU state unconditionally. The result is a SIGSEGV in kvm_vm_ioctl(): #0 kvm_vm_ioctl (s=3D0x0, type=3D-2146390353) at qemu/accel/kvm/kvm-all.c:2032 #1 0x00000001003e3e2c in kvmppc_configure_v3_mmu (cpu=3D, radix=3D, gtse=3D, proc_tbl=3D) at qemu/target/ppc/kvm.c:396 #2 0x00000001002f8b88 in spapr_post_load (opaque=3D0x1019103c0, version_id=3D) at qemu/hw/ppc/spapr.c:1578 #3 0x000000010059e4cc in vmstate_load_state (f=3D0x106230000, vmsd=3D0x1009479e0 , opaque=3D0x1019103c0, version_id=3D) at qemu/migration/vmstate.c:165 #4 0x00000001005987e0 in vmstate_load (f=3D, se=3D) at qemu/migration/savevm.c:748 This patch fixes the problem by not calling the KVM function with the TCG mode. Fixes: d39c90f5f3 ("spapr: Fix migration of Radix guests") Signed-off-by: Laurent Vivier Reviewed-by: Suraj Jitindar Singh Signed-off-by: David Gibson --- hw/ppc/spapr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 9efddeaee5..a471de6cab 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1570,7 +1570,7 @@ static int spapr_post_load(void *opaque, int version_= id) err =3D spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset); } =20 - if (spapr->patb_entry) { + if (kvm_enabled() && spapr->patb_entry) { PowerPCCPU *cpu =3D POWERPC_CPU(first_cpu); bool radix =3D !!(spapr->patb_entry & PATBE1_GR); bool gtse =3D !!(cpu->env.spr[SPR_LPCR] & LPCR_GTSE); --=20 2.14.3 From nobody Sat May 4 01:23:58 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151235938667640.447562859750406; Sun, 3 Dec 2017 19:49:46 -0800 (PST) Received: from localhost ([::1]:41080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLhl9-0006Sb-VM for importer@patchew.org; Sun, 03 Dec 2017 22:49:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLhjn-0005Z0-Nv for qemu-devel@nongnu.org; Sun, 03 Dec 2017 22:48:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eLhjl-0004Lb-TF for qemu-devel@nongnu.org; Sun, 03 Dec 2017 22:48:11 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:39841) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eLhjl-0004KE-AH; Sun, 03 Dec 2017 22:48:09 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yqrSQ1rb0z9s7g; Mon, 4 Dec 2017 14:48:05 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1512359286; bh=zNgiOSO79BunZjDw5Y3ag0Mlh4OAk6hEBg6HmEQ49g4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WekyV/FUaN1yNgc/CfI8QbDFlXTezk/kVOA8+ZrD9wZtaKcrFhKCiLvHpPXYQjXtS XuEJxs8y0SGEVcxZgICwtJf91aWkzl4CRp6OaW+M0rHKyLOsJJ4LCEj/xyPMSX7y1L NKf/IgFsoxLFNxD40k0dgBB0/vDrU4xdm0ktivqA= From: David Gibson To: peter.maydell@linaro.org Date: Mon, 4 Dec 2017 14:48:01 +1100 Message-Id: <20171204034802.7336-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171204034802.7336-1-david@gibson.dropbear.id.au> References: <20171204034802.7336-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/3] target-ppc: Don't invalidate non-supported msr bits 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: Kurban Mallachiev , qemu-devel@nongnu.org, agraf@suse.de, groug@kaod.org, 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: Kurban Mallachiev The msr invalidation code (commits 993eb and 2360b) inverts all bits except MSR_TGPR and MSR_HVB. On non PowerPC 601 processors this leads to incorrect change of excp_prefix in hreg_store_msr() function. The problem is that new msr value get multiplied by msr_mask and inverted msr does not, thus values of MSR_EP bit in new msr value and inverted msr are distinct, so that excp_prefix changes but should not. Signed-off-by: Kurban Mallachiev Signed-off-by: David Gibson --- target/ppc/machine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/ppc/machine.c b/target/ppc/machine.c index 24117e8f31..e475206c6a 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -300,9 +300,9 @@ static int cpu_post_load(void *opaque, int version_id) ppc_store_sdr1(env, env->spr[SPR_SDR1]); } =20 - /* Invalidate all msr bits except MSR_TGPR/MSR_HVB before restoring */ + /* Invalidate all supported msr bits except MSR_TGPR/MSR_HVB before re= storing */ msr =3D env->msr; - env->msr ^=3D ~((1ULL << MSR_TGPR) | MSR_HVB); + env->msr ^=3D env->msr_mask & ~((1ULL << MSR_TGPR) | MSR_HVB); ppc_store_msr(env, msr); =20 hreg_compute_mem_idx(env); --=20 2.14.3 From nobody Sat May 4 01:23:58 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 151235953920945.48433291574656; Sun, 3 Dec 2017 19:52:19 -0800 (PST) Received: from localhost ([::1]:41096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLhnh-0000OS-Je for importer@patchew.org; Sun, 03 Dec 2017 22:52:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48393) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLhjq-0005Zp-2G for qemu-devel@nongnu.org; Sun, 03 Dec 2017 22:48:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eLhjl-0004LM-Sb for qemu-devel@nongnu.org; Sun, 03 Dec 2017 22:48:14 -0500 Received: from ozlabs.org ([103.22.144.67]:41235) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eLhjl-0004KI-90; Sun, 03 Dec 2017 22:48:09 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3yqrSQ2kwdz9s83; Mon, 4 Dec 2017 14:48:06 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1512359286; bh=vhdY7NkC/HfZAdGhoOHqNeEreFonYzVLpJvLXw9XUt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=evb/SyIS+mHF6OpftBQJhLprd1MKvO+XdQykhS0F+w81/ifJuCfxyY43qRv1WBrux vc8BefF9wrDCxKSwM+sHIvXXkKcJonsSPIjYd4hHOO/I4rP3A263g6imLrFUhr5cYc Sn0YPXCCID38Hurwkp1pDPgQd14oEqKEjdr3J1mM= From: David Gibson To: peter.maydell@linaro.org Date: Mon, 4 Dec 2017 14:48:02 +1100 Message-Id: <20171204034802.7336-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171204034802.7336-1-david@gibson.dropbear.id.au> References: <20171204034802.7336-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 3/3] spapr: Include "pre-plugged" DIMMS in ram size calculation at reset 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: qemu-devel@nongnu.org, David Gibson , qemu-ppc@nongnu.org, agraf@suse.de, groug@kaod.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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" At guest reset time, we allocate a hash page table (HPT) for the guest based on the guest's RAM size. If dynamic HPT resizing is not available we use the maximum RAM size, if it is we use the current RAM size. But the "current RAM size" calculation is incorrect - we just use the "base" ram_size from the machine structure. This doesn't include any pluggable DIMMs that are already plugged at reset time. This means that if you try to start a 'pseries' machine with a DIMM specified on the command line that's much larger than the "base" RAM size, then the guest will get a woefully inadequate HPT. This can lead to a guest freeze during boot as it runs out of HPT space during initial MMU setup. Signed-off-by: David Gibson Reviewed-by: Greg Kurz Tested-by: Greg Kurz --- hw/ppc/spapr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a471de6cab..1ac7eb0f8c 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1386,7 +1386,10 @@ void spapr_setup_hpt_and_vrma(sPAPRMachineState *spa= pr) && !spapr_ovec_test(spapr->ov5_cas, OV5_HPT_RESIZE))) { hpt_shift =3D spapr_hpt_shift_for_ramsize(MACHINE(spapr)->maxram_s= ize); } else { - hpt_shift =3D spapr_hpt_shift_for_ramsize(MACHINE(spapr)->ram_size= ); + uint64_t current_ram_size; + + current_ram_size =3D MACHINE(spapr)->ram_size + get_plugged_memory= _size(); + hpt_shift =3D spapr_hpt_shift_for_ramsize(current_ram_size); } spapr_reallocate_hpt(spapr, hpt_shift, &error_fatal); =20 --=20 2.14.3