KVM: sefltests: Add kvm_util_types.h to hold common types, e.g. vm_vaddr_t
authorSean Christopherson <seanjc@google.com>
Thu, 14 Mar 2024 23:26:21 +0000 (16:26 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 29 Apr 2024 19:54:16 +0000 (12:54 -0700)
Move the base types unique to KVM selftests out of kvm_util.h and into a
new header, kvm_util_types.h.  This will allow kvm_util_arch.h, i.e. core
arch headers, to reference common types, e.g. vm_vaddr_t and vm_paddr_t.

No functional change intended.

Reviewed-by: Ackerley Tng <ackerleytng@google.com>
Link: https://lore.kernel.org/r/20240314232637.2538648-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/include/kvm_util.h
tools/testing/selftests/kvm/include/kvm_util_types.h [new file with mode: 0644]

index c51babca552a4d940912a17ad6d73f1f1a47fe84..f5a1eaeaf0c8d3d77131865522125b493793a8a1 100644 (file)
 #include <sys/ioctl.h>
 
 #include "kvm_util_arch.h"
+#include "kvm_util_types.h"
 #include "sparsebit.h"
 
-/*
- * Provide a version of static_assert() that is guaranteed to have an optional
- * message param.  _GNU_SOURCE is defined for all KVM selftests, _GNU_SOURCE
- * implies _ISOC11_SOURCE, and if _ISOC11_SOURCE is defined, glibc #undefs and
- * #defines static_assert() as a direct alias to _Static_assert() (see
- * usr/include/assert.h).  Define a custom macro instead of redefining
- * static_assert() to avoid creating non-deterministic behavior that is
- * dependent on include order.
- */
-#define __kvm_static_assert(expr, msg, ...) _Static_assert(expr, msg)
-#define kvm_static_assert(expr, ...) __kvm_static_assert(expr, ##__VA_ARGS__, #expr)
-
 #define KVM_DEV_PATH "/dev/kvm"
 #define KVM_MAX_VCPUS 512
 
 #define NSEC_PER_SEC 1000000000L
 
-typedef uint64_t vm_paddr_t; /* Virtual Machine (Guest) physical address */
-typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */
-
 struct userspace_mem_region {
        struct kvm_userspace_memory_region2 region;
        struct sparsebit *unused_phy_pages;
diff --git a/tools/testing/selftests/kvm/include/kvm_util_types.h b/tools/testing/selftests/kvm/include/kvm_util_types.h
new file mode 100644 (file)
index 0000000..ec787b9
--- /dev/null
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef SELFTEST_KVM_UTIL_TYPES_H
+#define SELFTEST_KVM_UTIL_TYPES_H
+
+/*
+ * Provide a version of static_assert() that is guaranteed to have an optional
+ * message param.  _GNU_SOURCE is defined for all KVM selftests, _GNU_SOURCE
+ * implies _ISOC11_SOURCE, and if _ISOC11_SOURCE is defined, glibc #undefs and
+ * #defines static_assert() as a direct alias to _Static_assert() (see
+ * usr/include/assert.h).  Define a custom macro instead of redefining
+ * static_assert() to avoid creating non-deterministic behavior that is
+ * dependent on include order.
+ */
+#define __kvm_static_assert(expr, msg, ...) _Static_assert(expr, msg)
+#define kvm_static_assert(expr, ...) __kvm_static_assert(expr, ##__VA_ARGS__, #expr)
+
+typedef uint64_t vm_paddr_t; /* Virtual Machine (Guest) physical address */
+typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */
+
+#endif /* SELFTEST_KVM_UTIL_TYPES_H */