[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v20210616 07/36] tools: add sr_is_known_page_type to libsaverestore


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Wed, 16 Jun 2021 14:51:00 +0200
  • Arc-authentication-results: i=1; strato.com; dkim=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1623847896; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=ikZ54MUbm6J0+L4XW5ARSvIze4KQJX0wbR+SClf730w=; b=Li9M5NuoXwVzfog2OtC6dmydfnROU2UPs+KqlXq/sizYlcp2z8JA1F1Fa7HPKCTfQF Cdf6ROhmdEJtMN7UeEf/BOI/r6KYbHTTXegtQksvsO/OIHkAisdDcCZ0tiwPqpuxIs10 RrRHP/OMaMfNq47rot0BJL7SU+pSMqi11mCd9W7zZyc8BhS6nSEdtS17beoy3vugwAGF NLEGRJbGP4AkEjtjiuV7PtjA4LPq0lXBRZcGXIRAhxt3zAn/d5vtfdQmU+ggh1AUnJIj x5nM0HhegNmyIaGQENmES70rr4jjGH8tLlPEEjUnN/qTQGzV6unni4r0I3xCKNmFfbNA 4JiA==
  • Arc-seal: i=1; a=rsa-sha256; t=1623847896; cv=none; d=strato.com; s=strato-dkim-0002; b=dxOtudDpDUxA61h6q5gaxkGxLyyUZ0Qhf56ZBw5pvtCPzZyGAT+05ORT39AQQSr2GL cOJ6ZQ+jCQOg6eWlv4mIPMeZwPXlLrUjhw40KsAgIVPchaLrVNwOSsvZ26CanAJ5GDn1 e3lyeeON91UPhwe+gTQpxToQRTj7Tu5bE7Z1CDguN+O3sjVy2cA7OqYNmgp0YIojewEN pXRkAItVbuHNTwsh0MO7jc+G6EnlEJUiFL0TYf+0rFGHHyJ1d60pzWPSjkMrrFRJwAks OqF2ASJoSouRjLhCM4oAeVO3vX123nYGdsINbfyx+CfEUdmh4lb0smVwYK+8JvrcDi3V OMcg==
  • Authentication-results: strato.com; dkim=none
  • Cc: Olaf Hering <olaf@xxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Wed, 16 Jun 2021 12:51:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Users of xc_get_pfn_type_batch may want to sanity check the data
returned by Xen. Add a simple helper for this purpose.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

v02:
- rename xc_is_known_page_type to sr_is_known_page_type
- move from ctrl/xc_private.h to saverestore/common.h (jgross)
---
 tools/libs/saverestore/common.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/tools/libs/saverestore/common.h b/tools/libs/saverestore/common.h
index ca2eb47a4f..c9cc4206e5 100644
--- a/tools/libs/saverestore/common.h
+++ b/tools/libs/saverestore/common.h
@@ -467,6 +467,39 @@ int populate_pfns(struct xc_sr_context *ctx, unsigned int 
count,
 /* Handle a STATIC_DATA_END record. */
 int handle_static_data_end(struct xc_sr_context *ctx);
 
+/* Sanitiy check for types returned by Xen */
+static inline bool sr_is_known_page_type(xen_pfn_t type)
+{
+    bool ret;
+
+    switch (type)
+    {
+    case XEN_DOMCTL_PFINFO_NOTAB:
+
+    case XEN_DOMCTL_PFINFO_L1TAB:
+    case XEN_DOMCTL_PFINFO_L1TAB | XEN_DOMCTL_PFINFO_LPINTAB:
+
+    case XEN_DOMCTL_PFINFO_L2TAB:
+    case XEN_DOMCTL_PFINFO_L2TAB | XEN_DOMCTL_PFINFO_LPINTAB:
+
+    case XEN_DOMCTL_PFINFO_L3TAB:
+    case XEN_DOMCTL_PFINFO_L3TAB | XEN_DOMCTL_PFINFO_LPINTAB:
+
+    case XEN_DOMCTL_PFINFO_L4TAB:
+    case XEN_DOMCTL_PFINFO_L4TAB | XEN_DOMCTL_PFINFO_LPINTAB:
+
+    case XEN_DOMCTL_PFINFO_XTAB:
+    case XEN_DOMCTL_PFINFO_XALLOC:
+    case XEN_DOMCTL_PFINFO_BROKEN:
+        ret = true;
+        break;
+    default:
+        ret = false;
+        break;
+    }
+    return ret;
+}
+
 #endif
 /*
  * Local variables:



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.