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

[PATCH v13 15/26] KVM: selftests: Use UAPI pvclock-abi.h in xen_shinfo_test



From: David Woodhouse <dwmw@xxxxxxxxxxxx>

Now that pvclock-abi.h is a UAPI header, use it in xen_shinfo_test.c
instead of locally duplicating the struct definitions.

Drop the tools/ mirror of the header: with the kernel copy now UAPI,
the selftests resolve <asm/pvclock-abi.h> from the installed kernel
headers, which they already depend on, and nothing else in tools/
builds against the mirror — keeping it would only be a file for
check-headers.sh to police with no consumer. The UAPI struct fields
are __u64 (unsigned long long), so switch the verbose printfs away
from PRIu64, which is "lu" on 64-bit.

Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
---
 tools/arch/x86/include/asm/pvclock-abi.h      | 48 -------------------
 .../selftests/kvm/x86/xen_shinfo_test.c       | 33 ++++---------
 2 files changed, 10 insertions(+), 71 deletions(-)
 delete mode 100644 tools/arch/x86/include/asm/pvclock-abi.h

diff --git a/tools/arch/x86/include/asm/pvclock-abi.h 
b/tools/arch/x86/include/asm/pvclock-abi.h
deleted file mode 100644
index b9fece5fc96d..000000000000
--- a/tools/arch/x86/include/asm/pvclock-abi.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_X86_PVCLOCK_ABI_H
-#define _ASM_X86_PVCLOCK_ABI_H
-#ifndef __ASSEMBLER__
-
-/*
- * These structs MUST NOT be changed.
- * They are the ABI between hypervisor and guest OS.
- * Both Xen and KVM are using this.
- *
- * pvclock_vcpu_time_info holds the system time and the tsc timestamp
- * of the last update. So the guest can use the tsc delta to get a
- * more precise system time.  There is one per virtual cpu.
- *
- * pvclock_wall_clock references the point in time when the system
- * time was zero (usually boot time), thus the guest calculates the
- * current wall clock by adding the system time.
- *
- * Protocol for the "version" fields is: hypervisor raises it (making
- * it uneven) before it starts updating the fields and raises it again
- * (making it even) when it is done.  Thus the guest can make sure the
- * time values it got are consistent by checking the version before
- * and after reading them.
- */
-
-struct pvclock_vcpu_time_info {
-       u32   version;
-       u32   pad0;
-       u64   tsc_timestamp;
-       u64   system_time;
-       u32   tsc_to_system_mul;
-       s8    tsc_shift;
-       u8    flags;
-       u8    pad[2];
-} __attribute__((__packed__)); /* 32 bytes */
-
-struct pvclock_wall_clock {
-       u32   version;
-       u32   sec;
-       u32   nsec;
-} __attribute__((__packed__));
-
-#define PVCLOCK_TSC_STABLE_BIT (1 << 0)
-#define PVCLOCK_GUEST_STOPPED  (1 << 1)
-/* PVCLOCK_COUNTS_FROM_ZERO broke ABI and can't be used anymore. */
-#define PVCLOCK_COUNTS_FROM_ZERO (1 << 2)
-#endif /* __ASSEMBLER__ */
-#endif /* _ASM_X86_PVCLOCK_ABI_H */
diff --git a/tools/testing/selftests/kvm/x86/xen_shinfo_test.c 
b/tools/testing/selftests/kvm/x86/xen_shinfo_test.c
index aaa414c677ad..9045f03cf2d3 100644
--- a/tools/testing/selftests/kvm/x86/xen_shinfo_test.c
+++ b/tools/testing/selftests/kvm/x86/xen_shinfo_test.c
@@ -15,6 +15,8 @@
 
 #include <sys/eventfd.h>
 
+#include <asm/pvclock-abi.h>
+
 #define SHINFO_REGION_GVA      0xc0000000ULL
 #define SHINFO_REGION_GPA      0xc0000000ULL
 #define SHINFO_REGION_SLOT     10
@@ -98,23 +100,6 @@ struct sched_poll {
        u64 timeout;
 };
 
-struct pvclock_vcpu_time_info {
-       u32   version;
-       u32   pad0;
-       u64   tsc_timestamp;
-       u64   system_time;
-       u32   tsc_to_system_mul;
-       s8    tsc_shift;
-       u8    flags;
-       u8    pad[2];
-} __attribute__((__packed__)); /* 32 bytes */
-
-struct pvclock_wall_clock {
-       u32   version;
-       u32   sec;
-       u32   nsec;
-} __attribute__((__packed__));
-
 struct vcpu_runstate_info {
        u32 state;
        u64 state_entry_time;
@@ -987,12 +972,14 @@ int main(int argc, char *argv[])
 
        if (verbose) {
                printf("Wall clock (v %d) %d.%09d\n", wc->version, wc->sec, 
wc->nsec);
-               printf("Time info 1: v %u tsc %" PRIu64 " time %" PRIu64 " mul 
%u shift %u flags %x\n",
-                      ti->version, ti->tsc_timestamp, ti->system_time, 
ti->tsc_to_system_mul,
-                      ti->tsc_shift, ti->flags);
-               printf("Time info 2: v %u tsc %" PRIu64 " time %" PRIu64 " mul 
%u shift %u flags %x\n",
-                      ti2->version, ti2->tsc_timestamp, ti2->system_time, 
ti2->tsc_to_system_mul,
-                      ti2->tsc_shift, ti2->flags);
+               printf("Time info 1: v %u tsc %llu time %llu mul %u shift %d 
flags %x\n",
+                      ti->version, (unsigned long long)ti->tsc_timestamp,
+                      (unsigned long long)ti->system_time,
+                      ti->tsc_to_system_mul, ti->tsc_shift, ti->flags);
+               printf("Time info 2: v %u tsc %llu time %llu mul %u shift %d 
flags %x\n",
+                      ti2->version, (unsigned long long)ti2->tsc_timestamp,
+                      (unsigned long long)ti2->system_time,
+                      ti2->tsc_to_system_mul, ti2->tsc_shift, ti2->flags);
        }
 
        TEST_ASSERT(wc->version && !(wc->version & 1),
-- 
2.43.0




 


Rackspace

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