Skip to content

Commit f54884f

Browse files
committed
KVM: sefltests: Add kvm_util_types.h to hold common types, e.g. vm_vaddr_t
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>
1 parent 2b7deea commit f54884f

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

tools/testing/selftests/kvm/include/kvm_util.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,14 @@
2121
#include <sys/ioctl.h>
2222

2323
#include "kvm_util_arch.h"
24+
#include "kvm_util_types.h"
2425
#include "sparsebit.h"
2526

26-
/*
27-
* Provide a version of static_assert() that is guaranteed to have an optional
28-
* message param. _GNU_SOURCE is defined for all KVM selftests, _GNU_SOURCE
29-
* implies _ISOC11_SOURCE, and if _ISOC11_SOURCE is defined, glibc #undefs and
30-
* #defines static_assert() as a direct alias to _Static_assert() (see
31-
* usr/include/assert.h). Define a custom macro instead of redefining
32-
* static_assert() to avoid creating non-deterministic behavior that is
33-
* dependent on include order.
34-
*/
35-
#define __kvm_static_assert(expr, msg, ...) _Static_assert(expr, msg)
36-
#define kvm_static_assert(expr, ...) __kvm_static_assert(expr, ##__VA_ARGS__, #expr)
37-
3827
#define KVM_DEV_PATH "/dev/kvm"
3928
#define KVM_MAX_VCPUS 512
4029

4130
#define NSEC_PER_SEC 1000000000L
4231

43-
typedef uint64_t vm_paddr_t; /* Virtual Machine (Guest) physical address */
44-
typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */
45-
4632
struct userspace_mem_region {
4733
struct kvm_userspace_memory_region2 region;
4834
struct sparsebit *unused_phy_pages;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef SELFTEST_KVM_UTIL_TYPES_H
3+
#define SELFTEST_KVM_UTIL_TYPES_H
4+
5+
/*
6+
* Provide a version of static_assert() that is guaranteed to have an optional
7+
* message param. _GNU_SOURCE is defined for all KVM selftests, _GNU_SOURCE
8+
* implies _ISOC11_SOURCE, and if _ISOC11_SOURCE is defined, glibc #undefs and
9+
* #defines static_assert() as a direct alias to _Static_assert() (see
10+
* usr/include/assert.h). Define a custom macro instead of redefining
11+
* static_assert() to avoid creating non-deterministic behavior that is
12+
* dependent on include order.
13+
*/
14+
#define __kvm_static_assert(expr, msg, ...) _Static_assert(expr, msg)
15+
#define kvm_static_assert(expr, ...) __kvm_static_assert(expr, ##__VA_ARGS__, #expr)
16+
17+
typedef uint64_t vm_paddr_t; /* Virtual Machine (Guest) physical address */
18+
typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */
19+
20+
#endif /* SELFTEST_KVM_UTIL_TYPES_H */

0 commit comments

Comments
 (0)