Skip to content
This repository was archived by the owner on Jan 28, 2023. It is now read-only.

Commit 6dbef99

Browse files
committed
Change maximum number of addresable IDs according to the number of
virtual CPUs in cpuid 4 Signed-off-by: Alexey Romko <[email protected]>
1 parent 7f3aaab commit 6dbef99

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

core/vcpu.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,8 +2673,23 @@ static void handle_cpuid_virtual(struct vcpu_t *vcpu, uint32_t a, uint32_t c)
26732673
return;
26742674
}
26752675
case 4: { // Deterministic Cache Parameters
2676-
// [31:26] cores per package - 1
2677-
// Use host cache values.
2676+
// Use host cache values, but change maximum number of addresable
2677+
// IDs according to the number of virtual CPUs (bits [31:26]).
2678+
state->_eax &= ~0xFC000000;
2679+
if (state->_eax & 31) {
2680+
struct vm_t *vm = vcpu->vm;
2681+
hax_list_head *list;
2682+
int count = 0;
2683+
2684+
hax_mutex_lock(vm->vm_lock);
2685+
hax_list_for_each(list, (hax_list_head *)(&vm->vcpu_list)) {
2686+
count++;
2687+
}
2688+
hax_mutex_unlock(vm->vm_lock);
2689+
2690+
if (count > 1)
2691+
state->_eax |= (count - 1) << 26;
2692+
}
26782693
return;
26792694
}
26802695
case 5: // MONITOR/MWAIT

0 commit comments

Comments
 (0)