kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Cc: kvm@vger.kernel.org, Evgeny Yakovlev <wrfsh@yandex-team.ru>
Subject: [kvm-unit-tests PATCH 2/3] x86: Declare online_cpus based on MAX_TEST_CPUS
Date: Fri,  6 Sep 2019 09:34:49 -0700	[thread overview]
Message-ID: <20190906163450.30797-3-sean.j.christopherson@intel.com> (raw)
In-Reply-To: <20190906163450.30797-1-sean.j.christopherson@intel.com>

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(-)

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
-- 
2.22.0


  parent reply	other threads:[~2019-09-06 16:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 16:34 [kvm-unit-tests PATCH 0/3] x86: Cleanup max test CPUs Sean Christopherson
2019-09-06 16:34 ` [kvm-unit-tests PATCH 1/3] x86: Fix out of bounds access when processing online_cpus Sean Christopherson
2019-09-06 16:34 ` Sean Christopherson [this message]
2019-09-06 16:34 ` [kvm-unit-tests PATCH 3/3] x86: Bump max number of test CPUs to 255 Sean Christopherson
2019-09-10 14:46   ` Paolo Bonzini
2019-09-10  7:57 ` [kvm-unit-tests PATCH 0/3] x86: Cleanup max test CPUs Peter Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190906163450.30797-3-sean.j.christopherson@intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=wrfsh@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).