summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/include/cpu.h
diff options
context:
space:
mode:
authorPaul Irofti <pirofti@cvs.openbsd.org>2019-08-09 15:20:06 +0000
committerPaul Irofti <pirofti@cvs.openbsd.org>2019-08-09 15:20:06 +0000
commitf3cd69e685aca9d61ae3176dd23e55d44a4fbef4 (patch)
tree8845ed61560fe5182016534af9c2102c88785956 /sys/arch/amd64/include/cpu.h
parent8876eb727da619d444f5dd33e54fa3d43eaabf60 (diff)
Add TSC synchronization for multiprocessor machines.
CPU0 is the reference clock and all others are skewed. During CPU initialization the clocks synchronize by keeping a registry of each CPU clock skewness and adapting the TSC read routine accordingly. This commit also re-enables TSC as the default time source. Future work includes MSR-based synchronization via IA32_TSC_ADJUST and perhaps adding a task that is executed periodically to keep the clocks in sync in case they drift apart. Inspired from NetBSD. Tested by many and thoroughly reviewed by kettenis@, thank you! OK kettenis@, deraadt@
Diffstat (limited to 'sys/arch/amd64/include/cpu.h')
-rw-r--r--sys/arch/amd64/include/cpu.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index 161aa6e465b..dd41b80fd3a 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.131 2019/05/17 19:07:16 guenther Exp $ */
+/* $OpenBSD: cpu.h,v 1.132 2019/08/09 15:20:05 pirofti Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -206,6 +206,8 @@ struct cpu_info {
union vmm_cpu_cap ci_vmm_cap;
paddr_t ci_vmxon_region_pa;
struct vmxon_region *ci_vmxon_region;
+
+ int64_t ci_tsc_skew; /* counter skew vs cpu0 */
};
#define CPUF_BSP 0x0001 /* CPU is the original BSP */
@@ -221,6 +223,7 @@ struct cpu_info {
#define CPUF_INVAR_TSC 0x0100 /* CPU has invariant TSC */
#define CPUF_USERXSTATE 0x0200 /* CPU has curproc's xsave state */
+#define CPUF_SYNCTSC 0x0800 /* Synchronize TSC */
#define CPUF_PRESENT 0x1000 /* CPU is present */
#define CPUF_RUNNING 0x2000 /* CPU is running */
#define CPUF_PAUSE 0x4000 /* CPU is paused in DDB */