diff mbox series

[XTF,1/4] lib: Add XEN_MAJOR() and XEN_MINOR() macros

Message ID 20200416094141.65120-2-wipawel@amazon.de (mailing list archive)
State Superseded
Headers show
Series Small fixes and improvements | expand

Commit Message

Wieczorkiewicz, Pawel April 16, 2020, 9:41 a.m. UTC
These are just a simple macros obtaining major, minor values as
returned by xen_version hypercall.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
---
 include/xtf/lib.h    | 3 +++
 tests/xsa-213/main.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/include/xtf/lib.h b/include/xtf/lib.h
index 3348464..40e5731 100644
--- a/include/xtf/lib.h
+++ b/include/xtf/lib.h
@@ -20,6 +20,9 @@ 
 
 #define ACCESS_ONCE(x)   (*(volatile typeof(x) *)&(x))
 
+#define XEN_MAJOR(v) (((v) >> 16) & 0xFFFF)
+#define XEN_MINOR(v) ((v) & 0xFFFF)
+
 void __noreturn panic(const char *fmt, ...) __printf(1, 2);
 
 #define ASSERT(cond)                                    \
diff --git a/tests/xsa-213/main.c b/tests/xsa-213/main.c
index 64e7065..0353168 100644
--- a/tests/xsa-213/main.c
+++ b/tests/xsa-213/main.c
@@ -121,8 +121,8 @@  void test_main(void)
 {
     long rc, xen_version = hypercall_xen_version(XENVER_version, NULL);
 
-    printk("Found Xen %ld.%ld\n",
-           (xen_version >> 16) & 0xffff, xen_version & 0xffff);
+    printk("Found Xen %ld.%ld\n", XEN_MAJOR(xen_version),
+           XEN_MINOR(xen_version));
 
     xtf_set_idte(X86_VEC_AVAIL, &idte);