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

[PATCH v11 13/23] 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.

Sync the tools/ mirror of the header to the UAPI content: the KVM
selftests include path puts tools/arch/x86/include ahead of the
installed kernel headers, so the mirror is what actually gets used.
That makes the struct fields __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      | 27 +++++++++-------
 .../selftests/kvm/x86/xen_shinfo_test.c       | 31 ++++++-------------
 2 files changed, 24 insertions(+), 34 deletions(-)

diff --git a/tools/arch/x86/include/asm/pvclock-abi.h 
b/tools/arch/x86/include/asm/pvclock-abi.h
index b9fece5fc96d..6d70cf640362 100644
--- a/tools/arch/x86/include/asm/pvclock-abi.h
+++ b/tools/arch/x86/include/asm/pvclock-abi.h
@@ -1,6 +1,9 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 #ifndef _ASM_X86_PVCLOCK_ABI_H
 #define _ASM_X86_PVCLOCK_ABI_H
+
+#include <linux/types.h>
+
 #ifndef __ASSEMBLER__
 
 /*
@@ -24,20 +27,20 @@
  */
 
 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];
+       __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;
+       __u32   version;
+       __u32   sec;
+       __u32   nsec;
 } __attribute__((__packed__));
 
 #define PVCLOCK_TSC_STABLE_BIT (1 << 0)
diff --git a/tools/testing/selftests/kvm/x86/xen_shinfo_test.c 
b/tools/testing/selftests/kvm/x86/xen_shinfo_test.c
index aaa414c677ad..c48c0bf44257 100644
--- a/tools/testing/selftests/kvm/x86/xen_shinfo_test.c
+++ b/tools/testing/selftests/kvm/x86/xen_shinfo_test.c
@@ -98,22 +98,7 @@ 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__));
+#include <asm/pvclock-abi.h>
 
 struct vcpu_runstate_info {
        u32 state;
@@ -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 %u 
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 %u 
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®.