From nobody Tue Feb 10 04:15:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1602183508; cv=none; d=zohomail.com; s=zohoarc; b=bF3DRZiGTXS/29Ei/Eo4539lqhVSLYqj6ikLmDJeOUgNI8IZ/tSnRT0JjNQceZl8Qp6XhjVoOfxMBtR07IxHGPdW6oRPRWhmmcALmABQ6ogEvFsdM8Pks2CrowPgVtWp8RuGiDzFsB7OPycoj+dNSzNpVwlKDJb0pwRDt/ndaRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602183508; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D58UTgHV8FlNHLsedxEWdVpeTR0XSu26cm7AoQLQNpU=; b=GYSGv7fXQ/t1d7OQtBV+w2r1dvqJyd9tpSbIPU93WU+V++uOr0Fa44qR1OKvoKkdBu/4ma0bfhrFC1x6sW3ptIjTcNTZzMQFpuyY+3BjRkLqkdgCCZMZfhraHXRDaC+znoS8PVnFY/bZr+uDco0972Kf+rWTmLBPJbR/8TuKHO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1602183508291234.36773913826823; Thu, 8 Oct 2020 11:58:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.4566.12026 (Exim 4.92) (envelope-from ) id 1kQb7C-0005ze-1g; Thu, 08 Oct 2020 18:58:10 +0000 Received: by outflank-mailman (output) from mailman id 4566.12026; Thu, 08 Oct 2020 18:58:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kQb7B-0005zU-UL; Thu, 08 Oct 2020 18:58:09 +0000 Received: by outflank-mailman (input) for mailman id 4566; Thu, 08 Oct 2020 18:58:08 +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.92) (envelope-from ) id 1kQb7A-0005RO-PI for xen-devel@lists.xenproject.org; Thu, 08 Oct 2020 18:58:08 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ebdf290f-2615-4289-be82-5b3bb9be3c6f; Thu, 08 Oct 2020 18:57:52 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kQb6t-00042S-7Y; Thu, 08 Oct 2020 18:57:51 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQb6t-0002P9-03; Thu, 08 Oct 2020 18:57:51 +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.92) (envelope-from ) id 1kQb7A-0005RO-PI for xen-devel@lists.xenproject.org; Thu, 08 Oct 2020 18:58:08 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ebdf290f-2615-4289-be82-5b3bb9be3c6f; Thu, 08 Oct 2020 18:57:52 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kQb6t-00042S-7Y; Thu, 08 Oct 2020 18:57:51 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQb6t-0002P9-03; Thu, 08 Oct 2020 18:57:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ebdf290f-2615-4289-be82-5b3bb9be3c6f DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=D58UTgHV8FlNHLsedxEWdVpeTR0XSu26cm7AoQLQNpU=; b=Hi+X0PIXwE3MkDPPVg7LgaUgIy 1IT8qkoisipVVxs5J/J4D+7PangVK3a9UXTSWQucdbxGtyCTx8gRu9OcvjDB3VPqFHmU+ti3VZyN5 FaR26E7S5UZdCNP/drdWiJ7MeGKil7Hu1PmEhpBjbxgscOZeTVqU8ufWNGe7kpH3cC0E=; From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Andrew Cooper , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Ian Jackson , Wei Liu Subject: [PATCH v10 09/11] tools/python: modify libxc.py to verify v4 stream Date: Thu, 8 Oct 2020 19:57:33 +0100 Message-Id: <20201008185735.29875-10-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201008185735.29875-1-paul@xen.org> References: <20201008185735.29875-1-paul@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) From: Paul Durrant This patch adds code to verify the presence of a REC_TYPE_domain_context record in a v4 stream, as well as absence of REC_TYPE_shared_info and REC_TYPE_tsc_info records. Signed-off-by: Paul Durrant --- Cc: Andrew Cooper Cc: "Marek Marczykowski-G=C3=B3recki" Cc: Ian Jackson Cc: Wei Liu v10: - New in v10 --- tools/python/xen/migration/libxc.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/python/xen/migration/libxc.py b/tools/python/xen/migrati= on/libxc.py index 9881f5ced4..24fb50cbda 100644 --- a/tools/python/xen/migration/libxc.py +++ b/tools/python/xen/migration/libxc.py @@ -59,6 +59,7 @@ REC_TYPE_checkpoint_dirty_pfn_list =3D 0x0000000f REC_TYPE_static_data_end =3D 0x00000010 REC_TYPE_x86_cpuid_policy =3D 0x00000011 REC_TYPE_x86_msr_policy =3D 0x00000012 +REC_TYPE_domain_context =3D 0x00000013 =20 rec_type_to_str =3D { REC_TYPE_end : "End", @@ -80,6 +81,7 @@ rec_type_to_str =3D { REC_TYPE_static_data_end : "Static data end", REC_TYPE_x86_cpuid_policy : "x86 CPUID policy", REC_TYPE_x86_msr_policy : "x86 MSR policy", + REC_TYPE_domain_context : "Domain context", } =20 # page_data @@ -156,9 +158,9 @@ class VerifyLibxc(VerifyBase): raise StreamError("Bad image id: Expected 0x%x, got 0x%x" % (IHDR_IDENT, ident)) =20 - if not (2 <=3D version <=3D 3): + if not (2 <=3D version <=3D 4): raise StreamError( - "Unknown image version: Expected 2 <=3D ver <=3D 3, got %d= " % + "Unknown image version: Expected 2 <=3D ver <=3D 4, got %d= " % (version, )) =20 self.version =3D version @@ -362,6 +364,9 @@ class VerifyLibxc(VerifyBase): def verify_record_shared_info(self, content): """ shared info record """ =20 + if self.version >=3D 4: + raise RecordError("Shared info record found in v4 stream") + contentsz =3D len(content) if contentsz !=3D 4096: raise RecordError("Length expected to be 4906 bytes, not %d" % @@ -371,6 +376,9 @@ class VerifyLibxc(VerifyBase): def verify_record_tsc_info(self, content): """ tsc info record """ =20 + if self.version >=3D 4: + raise RecordError("TSC info record found in v4 stream") + sz =3D calcsize(X86_TSC_INFO_FORMAT) =20 if len(content) !=3D sz: @@ -476,6 +484,14 @@ class VerifyLibxc(VerifyBase): raise RecordError("Record length %u, expected multiple of %u" % (contentsz, sz)) =20 + def verify_record_domain_context(self, content): + """ domain context record """ + + if self.version < 4: + raise RecordError("Domain context record found in v3 stream") + + if len(content) =3D=3D 0: + raise RecordError("Zero length domain context") =20 record_verifiers =3D { REC_TYPE_end: @@ -526,4 +542,6 @@ record_verifiers =3D { VerifyLibxc.verify_record_x86_cpuid_policy, REC_TYPE_x86_msr_policy: VerifyLibxc.verify_record_x86_msr_policy, + REC_TYPE_domain_context: + VerifyLibxc.verify_record_domain_context, } --=20 2.20.1