Module Name: src
Committed By: maxv
Date: Thu Feb 22 11:57:39 UTC 2018
Modified Files:
src/sys/arch/x86/x86: svs.c
Log Message:
Ensure the CPUs are all online. We take cpu_lock, so nobody can go offline
in the meantime.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/x86/svs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x86/x86/svs.c
diff -u src/sys/arch/x86/x86/svs.c:1.6 src/sys/arch/x86/x86/svs.c:1.7
--- src/sys/arch/x86/x86/svs.c:1.6 Thu Feb 22 10:42:11 2018
+++ src/sys/arch/x86/x86/svs.c Thu Feb 22 11:57:39 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: svs.c,v 1.6 2018/02/22 10:42:11 maxv Exp $ */
+/* $NetBSD: svs.c,v 1.7 2018/02/22 11:57:39 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.6 2018/02/22 10:42:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.7 2018/02/22 11:57:39 maxv Exp $");
#include "opt_svs.h"
@@ -616,14 +616,28 @@ svs_disable_cpu(void *arg1, void *arg2)
x86_write_psl(psl);
}
-static void
+static int
svs_disable(void)
{
+ struct cpu_info *ci = NULL;
+ CPU_INFO_ITERATOR cii;
uint64_t xc;
+ mutex_enter(&cpu_lock);
+
/*
- * We expect all the CPUs to be online. XXX ensure they are.
+ * We expect all the CPUs to be online.
*/
+ for (CPU_INFO_FOREACH(cii, ci)) {
+ struct schedstate_percpu *spc = &ci->ci_schedstate;
+ if (spc->spc_flags & SPCF_OFFLINE) {
+ printf("[!] cpu%d offline, SVS not disabled\n",
+ cpu_index(ci));
+ mutex_exit(&cpu_lock);
+ return EOPNOTSUPP;
+ }
+ }
+
svs_cpu_barrier1 = ncpu;
svs_cpu_barrier2 = ncpu;
@@ -637,6 +651,10 @@ svs_disable(void)
*/
printf("[+] Done\n");
+
+ mutex_exit(&cpu_lock);
+
+ return 0;
}
int sysctl_machdep_svs_enabled(SYSCTLFN_ARGS);
@@ -659,10 +677,10 @@ sysctl_machdep_svs_enabled(SYSCTLFN_ARGS
if (val == 1) {
error = EINVAL;
} else {
- if (svs_enabled) {
- svs_disable();
- }
- error = 0;
+ if (svs_enabled)
+ error = svs_disable();
+ else
+ error = 0;
}
return error;