summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-10-15 23:23:52 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-10-15 23:23:52 +0000
commit402af595bcaa120a104360ebebeb3d8f5eac8859 (patch)
tree246ce2dffcd538c7674e8ed19b552cbadd811192 /sys/arch/amd64
parent01ed2ea8940e2739cafb585b7d5f8d8db553c397 (diff)
make random(9) return per-cpu values (by saving the seed in the cpuinfo),
which are uniform for the profclock on each cpu in a SMP system (but using a different seed for each cpu). on all cpus, avoid seeding with a value out of the [0, 2^31-1] range (since that is not stable) ok kettenis drahn
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/amd64/cpu.c3
-rw-r--r--sys/arch/amd64/include/cpu.h3
2 files changed, 4 insertions, 2 deletions
diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
index c7222a901d4..ee47764724e 100644
--- a/sys/arch/amd64/amd64/cpu.c
+++ b/sys/arch/amd64/amd64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.20 2008/10/06 20:42:02 chl Exp $ */
+/* $OpenBSD: cpu.c,v 1.21 2008/10/15 23:23:46 deraadt Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
@@ -397,6 +397,7 @@ cpu_boot_secondary_processors(void)
ci = cpu_info[i];
if (ci == NULL)
continue;
+ ci->ci_randseed = random();
if (ci->ci_idle_pcb == NULL)
continue;
if ((ci->ci_flags & CPUF_PRESENT) == 0)
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index 248a9659c6e..8bbe67e6ebc 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.37 2008/07/18 23:43:31 art Exp $ */
+/* $OpenBSD: cpu.h,v 1.38 2008/10/15 23:23:46 deraadt Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -71,6 +71,7 @@ struct cpu_info {
u_int ci_apicid;
u_long ci_spin_locks;
u_long ci_simple_locks;
+ u_int32_t ci_randseed;
u_int64_t ci_scratch;