Ensure the CPUs are all online. We take cpu_lock, so nobody can go offline

in the meantime.
This commit is contained in:
maxv 2018-02-22 11:57:39 +00:00
parent 5ab8a4e764
commit 53447ceddb

View File

@ -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;