From patchwork Thu Dec 19 14:06:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11303683 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D233D138D for ; Thu, 19 Dec 2019 14:08:28 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ACBA2206D8 for ; Thu, 19 Dec 2019 14:08:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="BZMk28Iv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACBA2206D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihwSD-000496-UK; Thu, 19 Dec 2019 14:07:01 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ihwSD-000491-7C for xen-devel@lists.xenproject.org; Thu, 19 Dec 2019 14:07:01 +0000 X-Inumbo-ID: d2ccd5fb-2268-11ea-91b5-12813bfff9fa Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d2ccd5fb-2268-11ea-91b5-12813bfff9fa; Thu, 19 Dec 2019 14:07:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1576764420; h=from:to:cc:subject:date:message-id:mime-version; bh=xjZWzoV7Mg4qg10dKcirQrIJj31tRiDX4/Of+4FOO4M=; b=BZMk28IvPfrw1LkZjhzF06jaIRa4zXlGtW8XiHpsvt6b3GJ42OScIFCh x+ma9nB2bdQCExlf1LmsdPfge6jSmu2rFuiE3ZfY5MkhDFwxyYJz3LkN7 iXOR+zImEkna/4dYiRRSh9dsUksZhu9U7woUTcOiVWZ1cuN2kL7tqFKYK Y=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: +m60mjyhU25ukkOOkJ9AF0JHATCW/cxRF1NZlnYfy0iAdar2k21J46H/9nUnXsWAuaMJrsmu0H YuYus5lscl2jxJJgfgcC+ntNSKWFy4C3s4nfJAdfh4kIS8s501YnDqEkdYDJErVMuZbT9ChYUj 29aYJGCfVwv+BSM5NLemSs2XHfbxr/xjb2Ge6ILZhHhd3ZxKtcQpVyoAJAynyceSI5Bi7/JgEo 3HiQaU351SyHC1suiTW4/zdyhKxkNs/SivZlk3uTpdYl2aLSVD1ZPkEZHsjyihQLYQ2UezVj1M 0lc= X-SBRS: 2.7 X-MesageID: 10351524 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,332,1571716800"; d="scan'208";a="10351524" From: Andrew Cooper To: Xen-devel Date: Thu, 19 Dec 2019 14:06:56 +0000 Message-ID: <20191219140656.9906-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] libxc/restore: Fix data auditing in handle_x86_pv_info() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" handle_x86_pv_info() has a subtle bug. It uses an 'else if' chain with a clause in the middle which doesn't exit unconditionally. In practice, this means that when restoring a 32bit PV guest, later sanity checks are skipped. Rework the logic a little to be simpler. There are exactly two valid combinations of fields in X86_PV_INFO, so factor this out and check them all in one go, before making adjustments to the current domain. Once adjustments have been completed successfully, sanity check the result against the X86_PV_INFO settings in one go, rather than piecewise. Signed-off-by: Andrew Cooper Reviewed-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu --- tools/libxc/xc_sr_restore_x86_pv.c | 69 ++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/tools/libxc/xc_sr_restore_x86_pv.c b/tools/libxc/xc_sr_restore_x86_pv.c index a2dbf85157..9e9ff32d47 100644 --- a/tools/libxc/xc_sr_restore_x86_pv.c +++ b/tools/libxc/xc_sr_restore_x86_pv.c @@ -582,6 +582,21 @@ static int update_guest_p2m(struct xc_sr_context *ctx) } /* + * The valid width/pt_levels values in X86_PV_INFO are inextricably linked. + * Cross-check the legitimate combinations. + */ +static bool valid_x86_pv_info_combination( + const struct xc_sr_rec_x86_pv_info *info) +{ + switch ( info->guest_width ) + { + case 4: return info->pt_levels == 3; + case 8: return info->pt_levels == 4; + default: return false; + } +} + +/* * Process an X86_PV_INFO record. */ static int handle_x86_pv_info(struct xc_sr_context *ctx, @@ -602,29 +617,31 @@ static int handle_x86_pv_info(struct xc_sr_context *ctx, rec->length, sizeof(*info)); return -1; } - else if ( info->guest_width != 4 && - info->guest_width != 8 ) + + if ( !valid_x86_pv_info_combination(info) ) { - ERROR("Unexpected guest width %u, Expected 4 or 8", - info->guest_width); + ERROR("Invalid X86_PV_INFO combination: width %u, pt_levels %u", + info->guest_width, info->pt_levels); return -1; } - else if ( info->guest_width != ctx->x86_pv.width ) + + /* + * PV domains default to native width. For an incomming compat domain, we + * will typically be the first entity to inform Xen. + */ + if ( info->guest_width != ctx->x86_pv.width ) { - int rc; - struct xen_domctl domctl; - - /* Try to set address size, domain is always created 64 bit. */ - memset(&domctl, 0, sizeof(domctl)); - domctl.domain = ctx->domid; - domctl.cmd = XEN_DOMCTL_set_address_size; - domctl.u.address_size.size = info->guest_width * 8; - rc = do_domctl(xch, &domctl); + struct xen_domctl domctl = { + .domain = ctx->domid, + .cmd = XEN_DOMCTL_set_address_size, + .u.address_size.size = info->guest_width * 8, + }; + int rc = do_domctl(xch, &domctl); + if ( rc != 0 ) { - ERROR("Width of guest in stream (%u" - " bits) differs with existing domain (%u bits)", - info->guest_width * 8, ctx->x86_pv.width * 8); + ERROR("Failed to update d%d address size to %u", + ctx->domid, info->guest_width * 8); return -1; } @@ -636,18 +653,14 @@ static int handle_x86_pv_info(struct xc_sr_context *ctx, return -1; } } - else if ( info->pt_levels != 3 && - info->pt_levels != 4 ) - { - ERROR("Unexpected guest levels %u, Expected 3 or 4", - info->pt_levels); - return -1; - } - else if ( info->pt_levels != ctx->x86_pv.levels ) + + /* Sanity check (possibly new) domain settings. */ + if ( (info->guest_width != ctx->x86_pv.width) || + (info->pt_levels != ctx->x86_pv.levels) ) { - ERROR("Levels of guest in stream (%u" - ") differs with existing domain (%u)", - info->pt_levels, ctx->x86_pv.levels); + ERROR("X86_PV_INFO width/pt_levels settings %u/%u mismatch with d%d %u/%u", + info->guest_width, info->pt_levels, ctx->domid, + ctx->x86_pv.width, ctx->x86_pv.levels); return -1; } From patchwork Thu Dec 19 18:24:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11304259 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63FEB14F6 for ; Thu, 19 Dec 2019 18:26:15 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 33157222C2 for ; Thu, 19 Dec 2019 18:26:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="bCvmuFfA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33157222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ii0U1-0002jF-7B; Thu, 19 Dec 2019 18:25:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ii0U0-0002j9-1Z for xen-devel@lists.xenproject.org; Thu, 19 Dec 2019 18:25:08 +0000 X-Inumbo-ID: dcd6a07a-228c-11ea-88e7-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dcd6a07a-228c-11ea-88e7-bc764e2007e4; Thu, 19 Dec 2019 18:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1576779898; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ybWoKu8my6CNmcAxCb7aCNtJrujasAhyxKL3lD6wVgg=; b=bCvmuFfAGBoASA6PD+7g+aHvByzE6OAlX6Tzv5N//WUObuK4KL+Z/8km ki/VDLr5qcapwjUWOH0aoeZ4WLcoiibK4zUibqiXKv4+xM3RBJ7IA8+3z i8qd9TGS4+QErEGIMaZvuLOy1Q2Kp0ZnELF6ben1t8tGxl7pVwfOQpUtM Q=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Gr1f7jBvOle4n08JrqmSQDjjZWmDPpvl+s72su+LLTmdB4e2KKEXsrmHrRZiP63vJ38fbXYN8y 7IFxuOpCC/MNQ3zlqZt/1jFetknG6cYz8Tay/fRKStRexWcwo0bv0Cx3H9MLzft4UyPyVLEBPS olpC7jbFJIN29QdByhO6HzyphqQmqTAGIG9lyaJ2HEAe2yN8kk5Tr7WrSfy8DW+WFr6gZPef4V 86xH4cm065teB9/7fRSyJ2zgGSELQLCxRaB5xwlK4T+AY+fRfoy75kvSLX65SI+hLFHW2awkUU E48= X-SBRS: 2.7 X-MesageID: 10318047 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,332,1571716800"; d="scan'208";a="10318047" From: Andrew Cooper To: Xen-devel Date: Thu, 19 Dec 2019 18:24:42 +0000 Message-ID: <20191219182442.7232-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191219140656.9906-1-andrew.cooper3@citrix.com> References: <20191219140656.9906-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/1] libxc: Drop other examples of the 'goto x; } else if' antipattern X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" None of these are buggy, but the resulting code is more robust. No functional change. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu --- tools/libxc/xc_dom_core.c | 3 ++- tools/libxc/xc_misc.c | 3 ++- tools/libxc/xc_resource.c | 7 ++++--- tools/libxc/xc_sr_common.c | 3 ++- tools/libxc/xc_sr_restore.c | 18 ++++++++++++------ tools/libxc/xc_sr_restore_x86_hvm.c | 4 +++- tools/libxc/xc_sr_restore_x86_pv.c | 33 ++++++++++++++++++--------------- 7 files changed, 43 insertions(+), 28 deletions(-) diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c index 9bd04cb2d5..73fe09fe18 100644 --- a/tools/libxc/xc_dom_core.c +++ b/tools/libxc/xc_dom_core.c @@ -225,7 +225,8 @@ void *xc_dom_malloc_filemap(struct xc_dom_image *dom, "tried to map file which is too large"); goto err; } - else if ( !*size ) + + if ( !*size ) { xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, "'%s': zero length file", filename); diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c index 8e60b6e9f0..b8eebd91e4 100644 --- a/tools/libxc/xc_misc.c +++ b/tools/libxc/xc_misc.c @@ -794,7 +794,8 @@ int xc_livepatch_list(xc_interface *xch, unsigned int max, unsigned int start, xc_hypercall_bounce_post(xch, len); continue; } - else if ( rc < 0 ) /* For all other errors we bail out. */ + + if ( rc < 0 ) /* For all other errors we bail out. */ break; if ( !version ) diff --git a/tools/libxc/xc_resource.c b/tools/libxc/xc_resource.c index 3abadbdcfc..3394cc1833 100644 --- a/tools/libxc/xc_resource.c +++ b/tools/libxc/xc_resource.c @@ -133,10 +133,11 @@ int xc_resource_op(xc_interface *xch, uint32_t nr_ops, xc_resource_op_t *ops) { if ( nr_ops == 1 ) return xc_resource_op_one(xch, ops); - else if ( nr_ops > 1 ) + + if ( nr_ops > 1 ) return xc_resource_op_multi(xch, nr_ops, ops); - else - return -1; + + return -1; } /* diff --git a/tools/libxc/xc_sr_common.c b/tools/libxc/xc_sr_common.c index 79b9c3e940..6b887b3053 100644 --- a/tools/libxc/xc_sr_common.c +++ b/tools/libxc/xc_sr_common.c @@ -102,7 +102,8 @@ int read_record(struct xc_sr_context *ctx, int fd, struct xc_sr_record *rec) PERROR("Failed to read Record Header from stream"); return -1; } - else if ( rhdr.length > REC_LENGTH_MAX ) + + if ( rhdr.length > REC_LENGTH_MAX ) { ERROR("Record (0x%08x, %s) length %#x exceeds max (%#x)", rhdr.type, rec_type_to_str(rhdr.type), rhdr.length, REC_LENGTH_MAX); diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index 1ac404b97b..98038096c7 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -28,18 +28,21 @@ static int read_headers(struct xc_sr_context *ctx) ERROR("Invalid marker: Got 0x%016"PRIx64, ihdr.marker); return -1; } - else if ( ihdr.id != IHDR_ID ) + + if ( ihdr.id != IHDR_ID ) { ERROR("Invalid ID: Expected 0x%08x, Got 0x%08x", IHDR_ID, ihdr.id); return -1; } - else if ( ihdr.version != IHDR_VERSION ) + + if ( ihdr.version != IHDR_VERSION ) { ERROR("Invalid Version: Expected %d, Got %d", IHDR_VERSION, ihdr.version); return -1; } - else if ( ihdr.options & IHDR_OPT_BIG_ENDIAN ) + + if ( ihdr.options & IHDR_OPT_BIG_ENDIAN ) { ERROR("Unable to handle big endian streams"); return -1; @@ -345,12 +348,14 @@ static int handle_page_data(struct xc_sr_context *ctx, struct xc_sr_record *rec) rec->length, sizeof(*pages)); goto err; } - else if ( pages->count < 1 ) + + if ( pages->count < 1 ) { ERROR("Expected at least 1 pfn in PAGE_DATA record"); goto err; } - else if ( rec->length < sizeof(*pages) + (pages->count * sizeof(uint64_t)) ) + + if ( rec->length < sizeof(*pages) + (pages->count * sizeof(uint64_t)) ) { ERROR("PAGE_DATA record (length %u) too short to contain %u" " pfns worth of information", rec->length, pages->count); @@ -383,7 +388,8 @@ static int handle_page_data(struct xc_sr_context *ctx, struct xc_sr_record *rec) type, pfn, i); goto err; } - else if ( type < XEN_DOMCTL_PFINFO_BROKEN ) + + if ( type < XEN_DOMCTL_PFINFO_BROKEN ) /* NOTAB and all L1 through L4 tables (including pinned) should * have a page worth of data in the record. */ pages_of_data++; diff --git a/tools/libxc/xc_sr_restore_x86_hvm.c b/tools/libxc/xc_sr_restore_x86_hvm.c index 4765a52f33..9763aaa8dc 100644 --- a/tools/libxc/xc_sr_restore_x86_hvm.c +++ b/tools/libxc/xc_sr_restore_x86_hvm.c @@ -142,12 +142,14 @@ static int x86_hvm_setup(struct xc_sr_context *ctx) dhdr_type_to_str(ctx->restore.guest_type)); return -1; } - else if ( ctx->restore.guest_page_size != PAGE_SIZE ) + + if ( ctx->restore.guest_page_size != PAGE_SIZE ) { ERROR("Invalid page size %u for x86_hvm domains", ctx->restore.guest_page_size); return -1; } + #ifdef __i386__ /* Very large domains (> 1TB) will exhaust virtual address space. */ if ( ctx->restore.p2m_size > 0x0fffffff ) diff --git a/tools/libxc/xc_sr_restore_x86_pv.c b/tools/libxc/xc_sr_restore_x86_pv.c index 9e9ff32d47..2367f2a9ed 100644 --- a/tools/libxc/xc_sr_restore_x86_pv.c +++ b/tools/libxc/xc_sr_restore_x86_pv.c @@ -145,7 +145,8 @@ static int process_start_info(struct xc_sr_context *ctx, ERROR("Start Info pfn %#lx out of range", pfn); goto err; } - else if ( ctx->x86_pv.restore.pfn_types[pfn] != XEN_DOMCTL_PFINFO_NOTAB ) + + if ( ctx->x86_pv.restore.pfn_types[pfn] != XEN_DOMCTL_PFINFO_NOTAB ) { ERROR("Start Info pfn %#lx has bad type %u", pfn, (ctx->x86_pv.restore.pfn_types[pfn] >> @@ -275,8 +276,8 @@ static int process_vcpu_basic(struct xc_sr_context *ctx, ERROR("GDT frame %u (pfn %#lx) out of range", i, pfn); goto err; } - else if ( (ctx->x86_pv.restore.pfn_types[pfn] != - XEN_DOMCTL_PFINFO_NOTAB) ) + + if ( (ctx->x86_pv.restore.pfn_types[pfn] != XEN_DOMCTL_PFINFO_NOTAB) ) { ERROR("GDT frame %u (pfn %#lx) has bad type %u", i, pfn, (ctx->x86_pv.restore.pfn_types[pfn] >> @@ -302,10 +303,10 @@ static int process_vcpu_basic(struct xc_sr_context *ctx, ERROR("cr3 (pfn %#lx) out of range", pfn); goto err; } - else if ( (ctx->x86_pv.restore.pfn_types[pfn] & - XEN_DOMCTL_PFINFO_LTABTYPE_MASK) != - (((xen_pfn_t)ctx->x86_pv.levels) << - XEN_DOMCTL_PFINFO_LTAB_SHIFT) ) + + if ( (ctx->x86_pv.restore.pfn_types[pfn] & + XEN_DOMCTL_PFINFO_LTABTYPE_MASK) != + (((xen_pfn_t)ctx->x86_pv.levels) << XEN_DOMCTL_PFINFO_LTAB_SHIFT) ) { ERROR("cr3 (pfn %#lx) has bad type %u, expected %u", pfn, (ctx->x86_pv.restore.pfn_types[pfn] >> @@ -334,10 +335,10 @@ static int process_vcpu_basic(struct xc_sr_context *ctx, ERROR("cr1 (pfn %#lx) out of range", pfn); goto err; } - else if ( (ctx->x86_pv.restore.pfn_types[pfn] & - XEN_DOMCTL_PFINFO_LTABTYPE_MASK) != - (((xen_pfn_t)ctx->x86_pv.levels) << - XEN_DOMCTL_PFINFO_LTAB_SHIFT) ) + + if ( (ctx->x86_pv.restore.pfn_types[pfn] & + XEN_DOMCTL_PFINFO_LTABTYPE_MASK) != + (((xen_pfn_t)ctx->x86_pv.levels) << XEN_DOMCTL_PFINFO_LTAB_SHIFT) ) { ERROR("cr1 (pfn %#lx) has bad type %u, expected %u", pfn, (ctx->x86_pv.restore.pfn_types[pfn] >> @@ -542,8 +543,8 @@ static int update_guest_p2m(struct xc_sr_context *ctx) pfn, i); goto err; } - else if ( (ctx->x86_pv.restore.pfn_types[pfn] != - XEN_DOMCTL_PFINFO_NOTAB) ) + + if ( (ctx->x86_pv.restore.pfn_types[pfn] != XEN_DOMCTL_PFINFO_NOTAB) ) { ERROR("pfn (%#lx) for p2m_frame_list[%u] has bad type %u", pfn, i, (ctx->x86_pv.restore.pfn_types[pfn] >> @@ -692,7 +693,8 @@ static int handle_x86_pv_p2m_frames(struct xc_sr_context *ctx, rec->length, sizeof(*data) + sizeof(uint64_t)); return -1; } - else if ( data->start_pfn > data->end_pfn ) + + if ( data->start_pfn > data->end_pfn ) { ERROR("End pfn in stream (%#x) exceeds Start (%#x)", data->end_pfn, data->start_pfn); @@ -1039,7 +1041,8 @@ static int x86_pv_setup(struct xc_sr_context *ctx) dhdr_type_to_str(ctx->restore.guest_type)); return -1; } - else if ( ctx->restore.guest_page_size != PAGE_SIZE ) + + if ( ctx->restore.guest_page_size != PAGE_SIZE ) { ERROR("Invalid page size %d for x86_pv domains", ctx->restore.guest_page_size);