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

[PATCH v20210601 05/38] tools: add xc_is_known_page_type to libxenctrl


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Tue, 1 Jun 2021 18:10:45 +0200
  • Arc-authentication-results: i=1; strato.com; dkim=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1622563887; 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=8EOjWvQk239Wp/aWNifZAKC+Sjf+9ZihUrmLiKkJAAc=; b=jQtdKSlb9FH79dzWoVHsq+ujCn1n/8KRNjKaVo8a5JhPySvEmEgswqcmPRAhLxmZnN rPIrQgwycooC1awY+AEii3QeQOGCQaoAgjlLPa0igEwBv9il2BiI/L0vTkxKTFiud2ed Pt+l/YLilb0RC0KipK0/QP7mbBgDd6aVawfYDz7hUUZBXeA8KWdcxjwvix2IuJViwL7O wvfvpHBeJUCbfvEMqAWFAEAiNUQyOikhs95pEN3ZEXOZR3fpBURQphfQy1usoZu22LeI 3jG9+TzBJLiP7K0phGwU8FqYuVIx/RicY4Tlp/3PU77+JXE7EpQmAILFHJd866+JSQg5 NKYg==
  • Arc-seal: i=1; a=rsa-sha256; t=1622563887; cv=none; d=strato.com; s=strato-dkim-0002; b=gISW+Gu/ZVcbfMZyUxvVAXMjU8BS7D4pv8ZvtGeCsbYtzWqCA8j3ayIU4wTvSrvgP3 G4bitN66zGnxrgW8IA+Jwhtao7w/EJbsyGyoD7ZuCTKbKuc0SScyaLIYKI/ZJNsqasaD nMg4BSvuJzosmK80Y6psVd6yRFxEIX0xio6kPTuB/Kr3+m7mhwlOCTPG1+HSKpW+3/KI 1yxeDyy8d9vLXeeiJU3WtpqyxVUFPTE42CefxTWO7yo3QvuiH0HpIeY3GlXqNj3dmuxs aR0cmj7G2aabMfEPmyxz2HuerX+b8IBbuPOnefG3/3wnyO59Jg/1MwAuFoqgEtQz9uh6 GrGA==
  • Authentication-results: strato.com; dkim=none
  • Cc: Olaf Hering <olaf@xxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 01 Jun 2021 16:11:45 +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>
---
 tools/libs/ctrl/xc_private.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/tools/libs/ctrl/xc_private.h b/tools/libs/ctrl/xc_private.h
index 5d2c7274fb..afb08aafe1 100644
--- a/tools/libs/ctrl/xc_private.h
+++ b/tools/libs/ctrl/xc_private.h
@@ -421,6 +421,39 @@ void *xc_map_foreign_ranges(xc_interface *xch, uint32_t 
dom,
 int xc_get_pfn_type_batch(xc_interface *xch, uint32_t dom,
                           unsigned int num, xen_pfn_t *);
 
+/* Sanitiy check for types returned by Xen */
+static inline bool xc_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;
+}
+
 void bitmap_64_to_byte(uint8_t *bp, const uint64_t *lp, int nbits);
 void bitmap_byte_to_64(uint64_t *lp, const uint8_t *bp, int nbits);
 



 


Rackspace

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