[kvm-unit-tests,2/3] x86: Declare online_cpus based on MAX_TEST_CPUS
diff mbox series

Message ID 20190906163450.30797-3-sean.j.christopherson@intel.com
State New
Headers show
Series
  • x86: Cleanup max test CPUs
Related show

Commit Message

Sean Christopherson Sept. 6, 2019, 4:34 p.m. UTC
Declare online_cpus so that it is properly sized to have MAX_TEST_CPUS
bits.  Currently, online_cpus is hardcoded to a u64, i.e. changing
MAX_TEST_CPUS to be greater than 64 will result in a variety of out of
bounds accesses.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 lib/x86/smp.c  | 2 --
 x86/cstart.S   | 2 +-
 x86/cstart64.S | 2 +-
 3 files changed, 2 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/lib/x86/smp.c b/lib/x86/smp.c
index 30bd1a0..7b1e0e1 100644
--- a/lib/x86/smp.c
+++ b/lib/x86/smp.c
@@ -113,8 +113,6 @@  int cpus_active(void)
     return atomic_read(&active_cpus);
 }
 
-extern unsigned long long online_cpus;
-
 void smp_init(void)
 {
     int i;
diff --git a/x86/cstart.S b/x86/cstart.S
index 575101b..76f6ba5 100644
--- a/x86/cstart.S
+++ b/x86/cstart.S
@@ -208,7 +208,7 @@  smp_init_done:
 	ret
 
 online_cpus:
-	.quad 0
+	.fill max_cpus / 8, 1, 0
 
 cpu_online_count:	.word 1
 
diff --git a/x86/cstart64.S b/x86/cstart64.S
index d4e4652..89ad9f4 100644
--- a/x86/cstart64.S
+++ b/x86/cstart64.S
@@ -282,7 +282,7 @@  idt_descr:
 	.quad boot_idt
 
 online_cpus:
-	.quad 0
+	.fill max_cpus / 8, 1, 0
 
 load_tss:
 	lidtq idt_descr