pvclock-abi.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_PVCLOCK_ABI_H
  3. #define _ASM_X86_PVCLOCK_ABI_H
  4. #ifndef __ASSEMBLY__
  5. /*
  6. * These structs MUST NOT be changed.
  7. * They are the ABI between hypervisor and guest OS.
  8. * Both Xen and KVM are using this.
  9. *
  10. * pvclock_vcpu_time_info holds the system time and the tsc timestamp
  11. * of the last update. So the guest can use the tsc delta to get a
  12. * more precise system time. There is one per virtual cpu.
  13. *
  14. * pvclock_wall_clock references the point in time when the system
  15. * time was zero (usually boot time), thus the guest calculates the
  16. * current wall clock by adding the system time.
  17. *
  18. * Protocol for the "version" fields is: hypervisor raises it (making
  19. * it uneven) before it starts updating the fields and raises it again
  20. * (making it even) when it is done. Thus the guest can make sure the
  21. * time values it got are consistent by checking the version before
  22. * and after reading them.
  23. */
  24. struct pvclock_vcpu_time_info {
  25. u32 version;
  26. u32 pad0;
  27. u64 tsc_timestamp;
  28. u64 system_time;
  29. u32 tsc_to_system_mul;
  30. s8 tsc_shift;
  31. u8 flags;
  32. u8 pad[2];
  33. } __attribute__((__packed__)); /* 32 bytes */
  34. struct pvclock_wall_clock {
  35. u32 version;
  36. u32 sec;
  37. u32 nsec;
  38. } __attribute__((__packed__));
  39. #define PVCLOCK_TSC_STABLE_BIT (1 << 0)
  40. #define PVCLOCK_GUEST_STOPPED (1 << 1)
  41. /* PVCLOCK_COUNTS_FROM_ZERO broke ABI and can't be used anymore. */
  42. #define PVCLOCK_COUNTS_FROM_ZERO (1 << 2)
  43. #endif /* __ASSEMBLY__ */
  44. #endif /* _ASM_X86_PVCLOCK_ABI_H */