summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-06-17 21:54:15 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-06-17 21:54:15 +0000
commit10f3515340ce9e31762c8d316c04e530eac7ce34 (patch)
tree3fed187d4fdb587508403a39c43cb52a3bd6d8b2
parent75f2a5d3afbf6278dcfc7c3f4fd7dad5fcb48ab1 (diff)
Override cpu_switch() with a faster version if we can use BWX instructions.
From RusticBSD, ok deraadt@
-rw-r--r--sys/arch/alpha/alpha/locore.s22
-rw-r--r--sys/arch/alpha/alpha/machdep.c28
2 files changed, 43 insertions, 7 deletions
diff --git a/sys/arch/alpha/alpha/locore.s b/sys/arch/alpha/alpha/locore.s
index 8ed599af4ff..f517807db3e 100644
--- a/sys/arch/alpha/alpha/locore.s
+++ b/sys/arch/alpha/alpha/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.27 2004/12/24 22:50:27 miod Exp $ */
+/* $OpenBSD: locore.s,v 1.28 2005/06/17 21:54:14 miod Exp $ */
/* $NetBSD: locore.s,v 1.94 2001/04/26 03:10:44 ross Exp $ */
/*-
@@ -891,10 +891,7 @@ cpu_switch_queuescan:
*
* Note: GET_CPUINFO clobbers v0, t0, t8...t11.
*/
-#ifdef __alpha_bwx__
- ldiq t0, SONPROC /* p->p_stat = SONPROC */
- stb t0, P_STAT(s2)
-#else
+EXPORT(__bwx_switch0)
addq s2, P_STAT, t3 /* p->p_stat = SONPROC */
ldq_u t1, 0(t3)
ldiq t0, SONPROC
@@ -902,7 +899,7 @@ cpu_switch_queuescan:
mskbl t1, t3, t1
or t0, t1, t0
stq_u t0, 0(t3)
-#endif /* __alpha_bwx__ */
+EXPORT(__bwx_switch1)
GET_CPUINFO
/* p->p_cpu initialized in fork1() for single-processor */
@@ -935,6 +932,19 @@ cpu_switch_queuescan:
RET
END(cpu_switch)
+#ifndef SMALL_KERNEL
+ /*
+ * BWX-enhanced version of the p->p_stat assignment, to be copied
+ * over the __bwx_switch0 area.
+
+ * Do not put anything between the end of cpu_switch and this!
+ */
+EXPORT(__bwx_switch2)
+ ldiq t0, SONPROC /* p->p_stat = SONPROC */
+ stb t0, P_STAT(s2)
+EXPORT(__bwx_switch3)
+#endif
+
/*
* switch_trampoline()
*
diff --git a/sys/arch/alpha/alpha/machdep.c b/sys/arch/alpha/alpha/machdep.c
index 268ccba2a2c..ed271257d0b 100644
--- a/sys/arch/alpha/alpha/machdep.c
+++ b/sys/arch/alpha/alpha/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.91 2005/04/28 17:19:27 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.92 2005/06/17 21:54:14 miod Exp $ */
/* $NetBSD: machdep.c,v 1.210 2000/06/01 17:12:38 thorpej Exp $ */
/*-
@@ -412,6 +412,32 @@ nobootinfo:
*/
#endif
+#ifndef SMALL_KERNEL
+ /*
+ * If we run on a BWX-capable processor, override cpu_switch
+ * with a faster version.
+ * We do this now because the kernel text might be mapped
+ * read-only eventually (although this is not the case at the moment).
+ */
+ if (alpha_implver() >= ALPHA_IMPLVER_EV5) {
+ if (~alpha_amask(ALPHA_AMASK_BWX) != 0) {
+ extern vaddr_t __bwx_switch0, __bwx_switch1,
+ __bwx_switch2, __bwx_switch3;
+ u_int32_t *dst, *src, *end;
+
+ src = (u_int32_t *)&__bwx_switch2;
+ end = (u_int32_t *)&__bwx_switch3;
+ dst = (u_int32_t *)&__bwx_switch0;
+ while (src != end)
+ *dst++ = *src++;
+ src = (u_int32_t *)&__bwx_switch1;
+ end = (u_int32_t *)&__bwx_switch2;
+ while (src != end)
+ *dst++ = *src++;
+ }
+ }
+#endif
+
/*
* find out this system's page size
*/