Skip to content
Snippets Groups Projects
Commit 8dd67e0d authored by Nadav Har'El's avatar Nadav Har'El Committed by Avi Kivity
Browse files

Fix bug booting with 64 CPUs


OSv is currently limited to 64 vCPUs, because we use a 64-bit bitmask for
wakeups (see max_cpus in sched.cc). Having exactly 64 CPUs *should* work,
but unfortunately didn't because of a bug:

cpu_set::operator++ first incremented the index, and then called advance()
to find the following one-bit. We had a bug when the index was 63: we then
expect operator++ to return 64 (end(), signaling the end of the iteration),
but what happened was that after it incremented the index to 64, advance()
wrongly handled the case idx=64 (1<<64 returns 1, unexpectedly) and moved
it back to idx=63.

The patch fixes operator++ to not call advance when idx=64 is reached,
so now it works correctly also for idx=63, and booting with 64 CPUs now
works.

Fixes #234.

Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
parent 3a76d481
No related branches found
No related tags found
No related merge requests found
...@@ -119,8 +119,9 @@ public: ...@@ -119,8 +119,9 @@ public:
} }
unsigned operator*() { return _idx; } unsigned operator*() { return _idx; }
iterator& operator++() { iterator& operator++() {
++_idx; if (++_idx < max_cpus) {
advance(); advance();
}
return *this; return *this;
} }
iterator operator++(int) { iterator operator++(int) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment