The code assumes that ci_index is also the Xen's cpunum, and that trunk
authorbouyer <bouyer@NetBSD.org>
Sat, 25 Feb 2012 18:57:50 +0000
branchtrunk
changeset 209476 0e38b8f1bcec
parent 209475 cc4fca63b559
child 209477 eaf3b8aa2f2a
The code assumes that ci_index is also the Xen's cpunum, and that cpunum is less than XEN_LEGACY_MAX_VCPUS. KASSERT both.
sys/arch/xen/x86/cpu.c
--- a/sys/arch/xen/x86/cpu.c	Sat Feb 25 18:11:05 2012 +0000
+++ b/sys/arch/xen/x86/cpu.c	Sat Feb 25 18:57:50 2012 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.88 2012/02/24 11:43:06 bouyer Exp $	*/
+/*	$NetBSD: cpu.c,v 1.89 2012/02/25 18:57:50 bouyer Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.88 2012/02/24 11:43:06 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.89 2012/02/25 18:57:50 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -409,6 +409,7 @@
 	ci->ci_cpuid = cpunum;
 
 	KASSERT(HYPERVISOR_shared_info != NULL);
+	KASSERT(cpunum < XEN_LEGACY_MAX_VCPUS);
 	ci->ci_vcpu = &HYPERVISOR_shared_info->vcpu_info[cpunum];
 
 	KASSERT(ci->ci_func == 0);
@@ -434,6 +435,7 @@
 		KASSERT(ci->ci_data.cpu_idlelwp != NULL);
 	}
 
+	KASSERT(ci->ci_cpuid == ci->ci_index);
 	ci->ci_cpumask = (1 << cpu_index(ci));
 	pmap_reference(pmap_kernel());
 	ci->ci_pmap = pmap_kernel();