18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_PVCLOCK_ABI_H 38c2ecf20Sopenharmony_ci#define _ASM_X86_PVCLOCK_ABI_H 48c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci/* 78c2ecf20Sopenharmony_ci * These structs MUST NOT be changed. 88c2ecf20Sopenharmony_ci * They are the ABI between hypervisor and guest OS. 98c2ecf20Sopenharmony_ci * Both Xen and KVM are using this. 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * pvclock_vcpu_time_info holds the system time and the tsc timestamp 128c2ecf20Sopenharmony_ci * of the last update. So the guest can use the tsc delta to get a 138c2ecf20Sopenharmony_ci * more precise system time. There is one per virtual cpu. 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * pvclock_wall_clock references the point in time when the system 168c2ecf20Sopenharmony_ci * time was zero (usually boot time), thus the guest calculates the 178c2ecf20Sopenharmony_ci * current wall clock by adding the system time. 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * Protocol for the "version" fields is: hypervisor raises it (making 208c2ecf20Sopenharmony_ci * it uneven) before it starts updating the fields and raises it again 218c2ecf20Sopenharmony_ci * (making it even) when it is done. Thus the guest can make sure the 228c2ecf20Sopenharmony_ci * time values it got are consistent by checking the version before 238c2ecf20Sopenharmony_ci * and after reading them. 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistruct pvclock_vcpu_time_info { 278c2ecf20Sopenharmony_ci u32 version; 288c2ecf20Sopenharmony_ci u32 pad0; 298c2ecf20Sopenharmony_ci u64 tsc_timestamp; 308c2ecf20Sopenharmony_ci u64 system_time; 318c2ecf20Sopenharmony_ci u32 tsc_to_system_mul; 328c2ecf20Sopenharmony_ci s8 tsc_shift; 338c2ecf20Sopenharmony_ci u8 flags; 348c2ecf20Sopenharmony_ci u8 pad[2]; 358c2ecf20Sopenharmony_ci} __attribute__((__packed__)); /* 32 bytes */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistruct pvclock_wall_clock { 388c2ecf20Sopenharmony_ci u32 version; 398c2ecf20Sopenharmony_ci u32 sec; 408c2ecf20Sopenharmony_ci u32 nsec; 418c2ecf20Sopenharmony_ci} __attribute__((__packed__)); 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define PVCLOCK_TSC_STABLE_BIT (1 << 0) 448c2ecf20Sopenharmony_ci#define PVCLOCK_GUEST_STOPPED (1 << 1) 458c2ecf20Sopenharmony_ci/* PVCLOCK_COUNTS_FROM_ZERO broke ABI and can't be used anymore. */ 468c2ecf20Sopenharmony_ci#define PVCLOCK_COUNTS_FROM_ZERO (1 << 2) 478c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 488c2ecf20Sopenharmony_ci#endif /* _ASM_X86_PVCLOCK_ABI_H */ 49