From patchwork Wed Sep 27 07:43:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 819013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="WJslrn5h"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y29Fb6Pb4z9t1G for ; Wed, 27 Sep 2017 17:59:15 +1000 (AEST) Received: from localhost ([::1]:53103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dx7FS-0006IX-2s for incoming@patchwork.ozlabs.org; Wed, 27 Sep 2017 03:59:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dx70P-0001Tx-G5 for qemu-devel@nongnu.org; Wed, 27 Sep 2017 03:43:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dx70O-000477-BF for qemu-devel@nongnu.org; Wed, 27 Sep 2017 03:43:41 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:42171) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dx70N-00044V-Sw; Wed, 27 Sep 2017 03:43:40 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3y28vP3pHkz9tXp; Wed, 27 Sep 2017 17:43:28 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1506498209; bh=YTmUffPhcybIINddkD5VnbNUmu8ektzggDO4uVoA+oc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WJslrn5hFabZZtzY8NFwTjK6wV5pBxZP6xiUjxY27DWQbI0e0Hq4wxNTTGXRvfZZL bowqK2V/B/WZQE+ASSmL4SMxvpecanGV0XjCAhAs4n0QCzVO350VjUGq89i3gI8yPa 47P6wG4ZVUgLPZNZ2mLZyCVahN0uprmRpU45fxAE= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 27 Sep 2017 17:43:04 +1000 Message-Id: <20170927074316.4454-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170927074316.4454-1-david@gibson.dropbear.id.au> References: <20170927074316.4454-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 14/26] spapr: introduce helpers to migrate HPT chunks and the end marker 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: agraf@suse.de, mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz This consolidates some duplicated code in a dedicated helpers. Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/spapr.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 90a94952c3..0ce3ec87ac 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1709,6 +1709,23 @@ static int htab_save_setup(QEMUFile *f, void *opaque) return 0; } +static void htab_save_chunk(QEMUFile *f, sPAPRMachineState *spapr, + int chunkstart, int n_valid, int n_invalid) +{ + qemu_put_be32(f, chunkstart); + qemu_put_be16(f, n_valid); + qemu_put_be16(f, n_invalid); + qemu_put_buffer(f, HPTE(spapr->htab, chunkstart), + HASH_PTE_SIZE_64 * n_valid); +} + +static void htab_save_end_marker(QEMUFile *f) +{ + qemu_put_be32(f, 0); + qemu_put_be16(f, 0); + qemu_put_be16(f, 0); +} + static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr, int64_t max_ns) { @@ -1740,11 +1757,7 @@ static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr, if (index > chunkstart) { int n_valid = index - chunkstart; - qemu_put_be32(f, chunkstart); - qemu_put_be16(f, n_valid); - qemu_put_be16(f, 0); - qemu_put_buffer(f, HPTE(spapr->htab, chunkstart), - HASH_PTE_SIZE_64 * n_valid); + htab_save_chunk(f, spapr, chunkstart, n_valid, 0); if (has_timeout && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) { @@ -1806,11 +1819,7 @@ static int htab_save_later_pass(QEMUFile *f, sPAPRMachineState *spapr, int n_valid = invalidstart - chunkstart; int n_invalid = index - invalidstart; - qemu_put_be32(f, chunkstart); - qemu_put_be16(f, n_valid); - qemu_put_be16(f, n_invalid); - qemu_put_buffer(f, HPTE(spapr->htab, chunkstart), - HASH_PTE_SIZE_64 * n_valid); + htab_save_chunk(f, spapr, chunkstart, n_valid, n_invalid); sent += index - chunkstart; if (!final && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) { @@ -1873,10 +1882,7 @@ static int htab_save_iterate(QEMUFile *f, void *opaque) rc = htab_save_later_pass(f, spapr, MAX_ITERATION_NS); } - /* End marker */ - qemu_put_be32(f, 0); - qemu_put_be16(f, 0); - qemu_put_be16(f, 0); + htab_save_end_marker(f); return rc; } @@ -1916,9 +1922,7 @@ static int htab_save_complete(QEMUFile *f, void *opaque) } /* End marker */ - qemu_put_be32(f, 0); - qemu_put_be16(f, 0); - qemu_put_be16(f, 0); + htab_save_end_marker(f); return 0; }