xref: /openbmc/linux/arch/x86/include/asm/pvclock-abi.h (revision b2441318)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21965aae3SH. Peter Anvin #ifndef _ASM_X86_PVCLOCK_ABI_H
31965aae3SH. Peter Anvin #define _ASM_X86_PVCLOCK_ABI_H
4bb898558SAl Viro #ifndef __ASSEMBLY__
5bb898558SAl Viro 
6bb898558SAl Viro /*
7bb898558SAl Viro  * These structs MUST NOT be changed.
8bb898558SAl Viro  * They are the ABI between hypervisor and guest OS.
9bb898558SAl Viro  * Both Xen and KVM are using this.
10bb898558SAl Viro  *
11bb898558SAl Viro  * pvclock_vcpu_time_info holds the system time and the tsc timestamp
12bb898558SAl Viro  * of the last update. So the guest can use the tsc delta to get a
13bb898558SAl Viro  * more precise system time.  There is one per virtual cpu.
14bb898558SAl Viro  *
15bb898558SAl Viro  * pvclock_wall_clock references the point in time when the system
16bb898558SAl Viro  * time was zero (usually boot time), thus the guest calculates the
17bb898558SAl Viro  * current wall clock by adding the system time.
18bb898558SAl Viro  *
19bb898558SAl Viro  * Protocol for the "version" fields is: hypervisor raises it (making
20bb898558SAl Viro  * it uneven) before it starts updating the fields and raises it again
21bb898558SAl Viro  * (making it even) when it is done.  Thus the guest can make sure the
22bb898558SAl Viro  * time values it got are consistent by checking the version before
23bb898558SAl Viro  * and after reading them.
24bb898558SAl Viro  */
25bb898558SAl Viro 
26bb898558SAl Viro struct pvclock_vcpu_time_info {
27bb898558SAl Viro 	u32   version;
28bb898558SAl Viro 	u32   pad0;
29bb898558SAl Viro 	u64   tsc_timestamp;
30bb898558SAl Viro 	u64   system_time;
31bb898558SAl Viro 	u32   tsc_to_system_mul;
32bb898558SAl Viro 	s8    tsc_shift;
33424c32f1SGlauber Costa 	u8    flags;
34424c32f1SGlauber Costa 	u8    pad[2];
35bb898558SAl Viro } __attribute__((__packed__)); /* 32 bytes */
36bb898558SAl Viro 
37bb898558SAl Viro struct pvclock_wall_clock {
38bb898558SAl Viro 	u32   version;
39bb898558SAl Viro 	u32   sec;
40bb898558SAl Viro 	u32   nsec;
41bb898558SAl Viro } __attribute__((__packed__));
42bb898558SAl Viro 
433a0d7256SGlauber Costa #define PVCLOCK_TSC_STABLE_BIT	(1 << 0)
44eae3ee7dSEric B Munson #define PVCLOCK_GUEST_STOPPED	(1 << 1)
459bac175dSRadim Krčmář /* PVCLOCK_COUNTS_FROM_ZERO broke ABI and can't be used anymore. */
4661191725SMarcelo Tosatti #define PVCLOCK_COUNTS_FROM_ZERO (1 << 2)
47bb898558SAl Viro #endif /* __ASSEMBLY__ */
481965aae3SH. Peter Anvin #endif /* _ASM_X86_PVCLOCK_ABI_H */
49