summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2020-09-13 11:53:16 +0000
committerjsg <jsg@openbsd.org>2020-09-13 11:53:16 +0000
commit3fb0e55cb6c56eb3839177cd25680436c7474f6c (patch)
tree52a7819dad111478151b7ca8366b1fdd74a80091
parentMore tests for policy matching via dstid. (diff)
downloadwireguard-openbsd-3fb0e55cb6c56eb3839177cd25680436c7474f6c.tar.xz
wireguard-openbsd-3fb0e55cb6c56eb3839177cd25680436c7474f6c.zip
add an ipi for wbinvd and a linux style wbinvd_on_all_cpus() function
ok kettenis@ deraadt@
-rw-r--r--sys/arch/amd64/amd64/cpu.c11
-rw-r--r--sys/arch/amd64/amd64/ipifuncs.c10
-rw-r--r--sys/arch/amd64/include/cpufunc.h13
-rw-r--r--sys/arch/amd64/include/intrdefs.h5
-rw-r--r--sys/arch/i386/i386/cpu.c11
-rw-r--r--sys/arch/i386/i386/ipifuncs.c10
-rw-r--r--sys/arch/i386/include/cpufunc.h13
-rw-r--r--sys/arch/i386/include/intrdefs.h7
-rw-r--r--sys/dev/pci/drm/i915/gt/agp_intel_gtt.c2
-rw-r--r--sys/dev/pci/drm/include/asm/smp.h12
10 files changed, 71 insertions, 23 deletions
diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
index e1b4557f450..cf7b5c6dfd7 100644
--- a/sys/arch/amd64/amd64/cpu.c
+++ b/sys/arch/amd64/amd64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.149 2020/05/29 04:42:23 deraadt Exp $ */
+/* $OpenBSD: cpu.c,v 1.150 2020/09/13 11:53:16 jsg Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
@@ -1322,3 +1322,12 @@ cpu_enter_pages(struct cpu_info_full *cif)
/* an empty iomap, by setting its offset to the TSS limit */
cif->cif_tss.tss_iobase = sizeof(cif->cif_tss);
}
+
+#ifdef MULTIPROCESSOR
+int
+wbinvd_on_all_cpus(void)
+{
+ x86_broadcast_ipi(X86_IPI_WBINVD);
+ return 0;
+}
+#endif
diff --git a/sys/arch/amd64/amd64/ipifuncs.c b/sys/arch/amd64/amd64/ipifuncs.c
index 12152e5e3b6..13c94ec81e3 100644
--- a/sys/arch/amd64/amd64/ipifuncs.c
+++ b/sys/arch/amd64/amd64/ipifuncs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipifuncs.c,v 1.34 2020/01/21 02:59:37 mlarkin Exp $ */
+/* $OpenBSD: ipifuncs.c,v 1.35 2020/09/13 11:53:16 jsg Exp $ */
/* $NetBSD: ipifuncs.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*-
@@ -60,6 +60,7 @@
void x86_64_ipi_nop(struct cpu_info *);
void x86_64_ipi_halt(struct cpu_info *);
+void x86_64_ipi_wbinvd(struct cpu_info *);
#if NVMM > 0
void x86_64_ipi_start_vmm(struct cpu_info *);
@@ -101,6 +102,7 @@ void (*ipifunc[X86_NIPI])(struct cpu_info *) =
NULL,
NULL,
#endif
+ x86_64_ipi_wbinvd,
};
void
@@ -147,3 +149,9 @@ x86_64_ipi_stop_vmm(struct cpu_info *ci)
stop_vmm_on_cpu(ci);
}
#endif /* NVMM > 0 */
+
+void
+x86_64_ipi_wbinvd(struct cpu_info *ci)
+{
+ wbinvd();
+}
diff --git a/sys/arch/amd64/include/cpufunc.h b/sys/arch/amd64/include/cpufunc.h
index b563854e225..7ca9130db77 100644
--- a/sys/arch/amd64/include/cpufunc.h
+++ b/sys/arch/amd64/include/cpufunc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpufunc.h,v 1.35 2020/07/03 17:54:27 kettenis Exp $ */
+/* $OpenBSD: cpufunc.h,v 1.36 2020/09/13 11:53:16 jsg Exp $ */
/* $NetBSD: cpufunc.h,v 1.3 2003/05/08 10:27:43 fvdl Exp $ */
/*-
@@ -270,6 +270,17 @@ wbinvd(void)
__asm volatile("wbinvd" : : : "memory");
}
+#ifdef MULTIPROCESSOR
+int wbinvd_on_all_cpus(void);
+#else
+static inline int
+wbinvd_on_all_cpus(void)
+{
+ wbinvd();
+ return 0;
+}
+#endif
+
static __inline void
clflush(u_int64_t addr)
{
diff --git a/sys/arch/amd64/include/intrdefs.h b/sys/arch/amd64/include/intrdefs.h
index 93c30ebd59c..135b0f8d0dd 100644
--- a/sys/arch/amd64/include/intrdefs.h
+++ b/sys/arch/amd64/include/intrdefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intrdefs.h,v 1.20 2019/03/25 18:48:12 guenther Exp $ */
+/* $OpenBSD: intrdefs.h,v 1.21 2020/09/13 11:53:16 jsg Exp $ */
/* $NetBSD: intrdefs.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */
#ifndef _AMD64_INTRDEFS_H
@@ -82,8 +82,9 @@
#define X86_IPI_DDB 0x00000080
#define X86_IPI_START_VMM 0x00000100
#define X86_IPI_STOP_VMM 0x00000200
+#define X86_IPI_WBINVD 0x00000400
-#define X86_NIPI 10
+#define X86_NIPI 11
#define IREENT_MAGIC 0x18041969
diff --git a/sys/arch/i386/i386/cpu.c b/sys/arch/i386/i386/cpu.c
index 3d39111b0be..592eeb1862a 100644
--- a/sys/arch/i386/i386/cpu.c
+++ b/sys/arch/i386/i386/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.104 2020/05/29 04:42:23 deraadt Exp $ */
+/* $OpenBSD: cpu.c,v 1.105 2020/09/13 11:53:16 jsg Exp $ */
/* $NetBSD: cpu.c,v 1.1.2.7 2000/06/26 02:04:05 sommerfeld Exp $ */
/*-
@@ -920,3 +920,12 @@ cpu_update_nmi_cr3(vaddr_t cr3)
CPU_INFO_FOREACH(cii, ci)
ci->ci_nmi_tss->tss_cr3 = cr3;
}
+
+#ifdef MULTIPROCESSOR
+int
+wbinvd_on_all_cpus(void)
+{
+ i386_broadcast_ipi(I386_IPI_WBINVD);
+ return 0;
+}
+#endif
diff --git a/sys/arch/i386/i386/ipifuncs.c b/sys/arch/i386/i386/ipifuncs.c
index 6b705741d37..aada9fb54d1 100644
--- a/sys/arch/i386/i386/ipifuncs.c
+++ b/sys/arch/i386/i386/ipifuncs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipifuncs.c,v 1.32 2019/01/18 01:34:50 pd Exp $ */
+/* $OpenBSD: ipifuncs.c,v 1.33 2020/09/13 11:53:16 jsg Exp $ */
/* $NetBSD: ipifuncs.c,v 1.1.2.3 2000/06/26 02:04:06 sommerfeld Exp $ */
/*-
@@ -56,6 +56,7 @@
void i386_ipi_nop(struct cpu_info *);
void i386_ipi_halt(struct cpu_info *);
+void i386_ipi_wbinvd(struct cpu_info *);
#if NNPX > 0
void i386_ipi_synch_fpu(struct cpu_info *);
@@ -89,6 +90,7 @@ void (*ipifunc[I386_NIPI])(struct cpu_info *) =
NULL,
#endif
i386_setperf_ipi,
+ i386_ipi_wbinvd,
};
void
@@ -140,6 +142,12 @@ i386_ipi_reload_mtrr(struct cpu_info *ci)
#endif
void
+i386_ipi_wbinvd(struct cpu_info *ci)
+{
+ wbinvd();
+}
+
+void
i386_spurious(void)
{
printf("spurious intr\n");
diff --git a/sys/arch/i386/include/cpufunc.h b/sys/arch/i386/include/cpufunc.h
index 6346bbce32a..098b5982d20 100644
--- a/sys/arch/i386/include/cpufunc.h
+++ b/sys/arch/i386/include/cpufunc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpufunc.h,v 1.32 2019/06/28 21:54:05 bluhm Exp $ */
+/* $OpenBSD: cpufunc.h,v 1.33 2020/09/13 11:53:16 jsg Exp $ */
/* $NetBSD: cpufunc.h,v 1.8 1994/10/27 04:15:59 cgd Exp $ */
/*
@@ -197,6 +197,17 @@ wbinvd(void)
__asm volatile("wbinvd" : : : "memory");
}
+#ifdef MULTIPROCESSOR
+int wbinvd_on_all_cpus(void);
+#else
+static inline int
+wbinvd_on_all_cpus(void)
+{
+ wbinvd();
+ return 0;
+}
+#endif
+
static __inline void
clflush(u_int32_t addr)
{
diff --git a/sys/arch/i386/include/intrdefs.h b/sys/arch/i386/include/intrdefs.h
index 26dac01251e..8a271605015 100644
--- a/sys/arch/i386/include/intrdefs.h
+++ b/sys/arch/i386/include/intrdefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intrdefs.h,v 1.17 2019/01/18 01:34:50 pd Exp $ */
+/* $OpenBSD: intrdefs.h,v 1.18 2020/09/13 11:53:16 jsg Exp $ */
/* $NetBSD: intrdefs.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */
#ifndef _I386_INTRDEFS_H
@@ -116,13 +116,14 @@
#define I386_IPI_GDT 0x00000020
#define I386_IPI_DDB 0x00000040 /* synchronize while in ddb */
#define I386_IPI_SETPERF 0x00000080
+#define I386_IPI_WBINVD 0x00000100
-#define I386_NIPI 8
+#define I386_NIPI 9
#define I386_IPI_NAMES { "halt IPI", "nop IPI", "FPU flush IPI", \
"FPU synch IPI", \
"MTRR update IPI", "GDT update IPI", \
- "DDB IPI", "setperf IPI" }
+ "DDB IPI", "setperf IPI", "wbinvd IPI" }
#define IREENT_MAGIC 0x18041969
diff --git a/sys/dev/pci/drm/i915/gt/agp_intel_gtt.c b/sys/dev/pci/drm/i915/gt/agp_intel_gtt.c
index 92aa77fedae..0e02d264eff 100644
--- a/sys/dev/pci/drm/i915/gt/agp_intel_gtt.c
+++ b/sys/dev/pci/drm/i915/gt/agp_intel_gtt.c
@@ -201,7 +201,7 @@ intel_gtt_chipset_flush(void)
#define I830_HIC 0x70
i915_reg_t hic = _MMIO(I830_HIC);
- wbinvd();
+ wbinvd_on_all_cpus();
I915_WRITE(hic, (I915_READ(hic) | (1<<31)));
for (i = 1000; i; i--) {
diff --git a/sys/dev/pci/drm/include/asm/smp.h b/sys/dev/pci/drm/include/asm/smp.h
index a50485db7f5..cfed96723c7 100644
--- a/sys/dev/pci/drm/include/asm/smp.h
+++ b/sys/dev/pci/drm/include/asm/smp.h
@@ -4,17 +4,7 @@
#define _ASM_SMP_H
#if defined(__i386__) || defined(__amd64__)
-
-#include <machine/cpu.h>
-
-static inline int
-wbinvd_on_all_cpus(void)
-{
- /* XXX single cpu only */
- wbinvd();
- return 0;
-}
-
+#include <machine/cpu.h> /* for wbinvd_on_all_cpus() */
#endif
#endif