162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _ASM_X86_PVCLOCK_ABI_H 362306a36Sopenharmony_ci#define _ASM_X86_PVCLOCK_ABI_H 462306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci/* 762306a36Sopenharmony_ci * These structs MUST NOT be changed. 862306a36Sopenharmony_ci * They are the ABI between hypervisor and guest OS. 962306a36Sopenharmony_ci * Both Xen and KVM are using this. 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * pvclock_vcpu_time_info holds the system time and the tsc timestamp 1262306a36Sopenharmony_ci * of the last update. So the guest can use the tsc delta to get a 1362306a36Sopenharmony_ci * more precise system time. There is one per virtual cpu. 1462306a36Sopenharmony_ci * 1562306a36Sopenharmony_ci * pvclock_wall_clock references the point in time when the system 1662306a36Sopenharmony_ci * time was zero (usually boot time), thus the guest calculates the 1762306a36Sopenharmony_ci * current wall clock by adding the system time. 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * Protocol for the "version" fields is: hypervisor raises it (making 2062306a36Sopenharmony_ci * it uneven) before it starts updating the fields and raises it again 2162306a36Sopenharmony_ci * (making it even) when it is done. Thus the guest can make sure the 2262306a36Sopenharmony_ci * time values it got are consistent by checking the version before 2362306a36Sopenharmony_ci * and after reading them. 2462306a36Sopenharmony_ci */ 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_cistruct pvclock_vcpu_time_info { 2762306a36Sopenharmony_ci u32 version; 2862306a36Sopenharmony_ci u32 pad0; 2962306a36Sopenharmony_ci u64 tsc_timestamp; 3062306a36Sopenharmony_ci u64 system_time; 3162306a36Sopenharmony_ci u32 tsc_to_system_mul; 3262306a36Sopenharmony_ci s8 tsc_shift; 3362306a36Sopenharmony_ci u8 flags; 3462306a36Sopenharmony_ci u8 pad[2]; 3562306a36Sopenharmony_ci} __attribute__((__packed__)); /* 32 bytes */ 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_cistruct pvclock_wall_clock { 3862306a36Sopenharmony_ci u32 version; 3962306a36Sopenharmony_ci u32 sec; 4062306a36Sopenharmony_ci u32 nsec; 4162306a36Sopenharmony_ci} __attribute__((__packed__)); 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define PVCLOCK_TSC_STABLE_BIT (1 << 0) 4462306a36Sopenharmony_ci#define PVCLOCK_GUEST_STOPPED (1 << 1) 4562306a36Sopenharmony_ci/* PVCLOCK_COUNTS_FROM_ZERO broke ABI and can't be used anymore. */ 4662306a36Sopenharmony_ci#define PVCLOCK_COUNTS_FROM_ZERO (1 << 2) 4762306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */ 4862306a36Sopenharmony_ci#endif /* _ASM_X86_PVCLOCK_ABI_H */ 49