From patchwork Wed May 31 11:26:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 9756685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8774A60360 for ; Wed, 31 May 2017 11:30:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81A06283D1 for ; Wed, 31 May 2017 11:30:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7698228484; Wed, 31 May 2017 11:30:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C5258283D1 for ; Wed, 31 May 2017 11:30:20 +0000 (UTC) Received: from localhost ([::1]:58612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG1pT-0005fS-Rr for patchwork-qemu-devel@patchwork.kernel.org; Wed, 31 May 2017 07:30:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG1n9-0004Pm-RX for qemu-devel@nongnu.org; Wed, 31 May 2017 07:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG1n6-0001J2-NL for qemu-devel@nongnu.org; Wed, 31 May 2017 07:27:55 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35132) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG1n6-0001Gw-Dw for qemu-devel@nongnu.org; Wed, 31 May 2017 07:27:52 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4VBPPxV087368 for ; Wed, 31 May 2017 07:27:51 -0400 Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142]) by mx0a-001b2d01.pphosted.com with ESMTP id 2asvxa8222-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 31 May 2017 07:27:51 -0400 Received: from localhost by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 May 2017 21:27:48 +1000 Received: from d23relay07.au.ibm.com (202.81.31.226) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 31 May 2017 21:27:46 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4VBRbq066650270; Wed, 31 May 2017 21:27:45 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v4VBRBIN022562; Wed, 31 May 2017 21:27:12 +1000 Received: from bharata.in.ibm.com ([9.195.40.209]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v4VBR7Tj021431; Wed, 31 May 2017 21:27:10 +1000 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 16:56:44 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496230005-12265-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1496230005-12265-1-git-send-email-bharata@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17053111-0052-0000-0000-0000024ABE06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17053111-0053-0000-0000-00000827C271 Message-Id: <1496230005-12265-2-git-send-email-bharata@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-31_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705310213 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v4 1/2] spapr: Add a "no HPT" encoding to HTAB migration stream 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: rnsastry@linux.vnet.ibm.com, qemu-ppc@nongnu.org, sjitindarsingh@gmail.com, Bharata B Rao , sam.bobroff@au1.ibm.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a "no HPT" encoding (using value -1) to the HTAB migration stream (in the place of HPT size) when the guest doesn't allocate HPT. This will help the target side to match target HPT with the source HPT and thus enable successful migration. A few more fixes to enable TCG migration to work correctly are also included in this commit: - HTAB savevm handlers have a few asserts on kvm_enabled() when spapr->htab != 0. Convert these into conditional checks as it is now possible to have no HTAB with TCG radix guests. - htab_save_setup() asserts for kvm_enabled() when spapr->htab != 0. Remove this as we can't assert this for TCG radix guests. Suggested-by: David Gibson [no HPT encoding suggestion] Signed-off-by: Bharata B Rao --- hw/ppc/spapr.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ab3aab1..b589ed4 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1559,17 +1559,18 @@ static int htab_save_setup(QEMUFile *f, void *opaque) { sPAPRMachineState *spapr = opaque; - /* "Iteration" header */ - qemu_put_be32(f, spapr->htab_shift); + /* "Iteration" header: no-HPT or HPT size encoding */ + if (!spapr->htab_shift) { + qemu_put_be32(f, -1); + } else { + qemu_put_be32(f, spapr->htab_shift); + } if (spapr->htab) { spapr->htab_save_index = 0; spapr->htab_first_pass = true; - } else { - assert(kvm_enabled()); } - return 0; } @@ -1714,9 +1715,7 @@ static int htab_save_iterate(QEMUFile *f, void *opaque) /* Iteration header */ qemu_put_be32(f, 0); - if (!spapr->htab) { - assert(kvm_enabled()); - + if (!spapr->htab && kvm_enabled()) { fd = get_htab_fd(spapr); if (fd < 0) { return fd; @@ -1748,7 +1747,7 @@ static int htab_save_complete(QEMUFile *f, void *opaque) /* Iteration header */ qemu_put_be32(f, 0); - if (!spapr->htab) { + if (!spapr->htab && kvm_enabled()) { int rc; assert(kvm_enabled()); @@ -1793,6 +1792,12 @@ static int htab_load(QEMUFile *f, void *opaque, int version_id) if (section_hdr) { Error *local_err = NULL; + if (section_hdr == -1) { + spapr_free_hpt(spapr); + unregister_savevm(NULL, "spapr/htab", spapr); + return 0; + } + /* First section gives the htab size */ spapr_reallocate_hpt(spapr, section_hdr, &local_err); if (local_err) { @@ -1802,9 +1807,7 @@ static int htab_load(QEMUFile *f, void *opaque, int version_id) return 0; } - if (!spapr->htab) { - assert(kvm_enabled()); - + if (!spapr->htab && kvm_enabled()) { fd = kvmppc_get_htab_fd(true); if (fd < 0) { error_report("Unable to open fd to restore KVM hash table: %s", @@ -1843,7 +1846,7 @@ static int htab_load(QEMUFile *f, void *opaque, int version_id) memset(HPTE(spapr->htab, index + n_valid), 0, HASH_PTE_SIZE_64 * n_invalid); } - } else { + } else if (kvm_enabled()) { int rc; assert(fd >= 0); @@ -1855,7 +1858,7 @@ static int htab_load(QEMUFile *f, void *opaque, int version_id) } } - if (!spapr->htab) { + if (!spapr->htab && kvm_enabled()) { assert(fd >= 0); close(fd); }