This repository has been archived by the owner on Jan 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 878
Add support for multicore Windows 10 guests #272
Open
nevilad
wants to merge
1
commit into
intel:master
Choose a base branch
from
nevilad:cpuid_4_ids
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2610,6 +2610,16 @@ static void handle_cpuid_virtual(struct vcpu_t *vcpu, uint32_t a, uint32_t c) | |
uint32_t reserved2 : 4; | ||
}; | ||
} cpuid_eax; | ||
struct vm_t *vm = vcpu->vm; | ||
hax_list_head *list; | ||
int vcpu_count = 0; | ||
|
||
hax_mutex_lock(vm->vm_lock); | ||
hax_list_for_each(list, (hax_list_head *)(&vm->vcpu_list)) { | ||
vcpu_count++; | ||
} | ||
hax_mutex_unlock(vm->vm_lock); | ||
|
||
cpuid_eax.raw = state->_eax; | ||
|
||
if (0xF != cpuid_eax.familyID) | ||
|
@@ -2651,6 +2661,9 @@ static void handle_cpuid_virtual(struct vcpu_t *vcpu, uint32_t a, uint32_t c) | |
// (see IA SDM Vol. 3A 3.2, Table 3-14) | ||
0x00; | ||
|
||
if (vcpu_count > 1) | ||
state->_ebx |= (vcpu_count) << 16; | ||
|
||
// Report only the features specified, excluding any features not | ||
// supported by the host CPU, but including "hypervisor", which is | ||
// desirable for VMMs. | ||
|
@@ -2673,8 +2686,23 @@ static void handle_cpuid_virtual(struct vcpu_t *vcpu, uint32_t a, uint32_t c) | |
return; | ||
} | ||
case 4: { // Deterministic Cache Parameters | ||
// [31:26] cores per package - 1 | ||
// Use host cache values. | ||
// Use host cache values, but change maximum number of addresable | ||
// IDs according to the number of virtual CPUs (bits [31:26]). | ||
state->_eax &= ~0xFC000000; | ||
if (state->_eax & 31) { | ||
struct vm_t *vm = vcpu->vm; | ||
hax_list_head *list; | ||
int vcpu_count = 0; | ||
|
||
hax_mutex_lock(vm->vm_lock); | ||
hax_list_for_each(list, (hax_list_head *)(&vm->vcpu_list)) { | ||
vcpu_count++; | ||
} | ||
hax_mutex_unlock(vm->vm_lock); | ||
|
||
if (vcpu_count > 1) | ||
state->_eax |= (vcpu_count - 1) << 26; | ||
} | ||
return; | ||
} | ||
case 5: // MONITOR/MWAIT | ||
|
@@ -2772,13 +2800,26 @@ static void handle_cpuid_virtual(struct vcpu_t *vcpu, uint32_t a, uint32_t c) | |
return; | ||
} | ||
case 0x80000008: { // Virtual/Physical Address Size | ||
struct vm_t *vm = vcpu->vm; | ||
hax_list_head *list; | ||
int vcpu_count = 0; | ||
|
||
hax_mutex_lock(vm->vm_lock); | ||
hax_list_for_each(list, (hax_list_head *)(&vm->vcpu_list)) { | ||
vcpu_count++; | ||
} | ||
hax_mutex_unlock(vm->vm_lock); | ||
|
||
// Bit mask to identify the reserved bits in paging structure high | ||
// order address field | ||
physical_address_size = (uint8_t)state->_eax & 0xff; | ||
pw_reserved_bits_high_mask = | ||
~((1 << (physical_address_size - 32)) - 1); | ||
|
||
state->_ebx = state->_ecx = state->_edx = 0; | ||
|
||
if (vcpu_count > 1) | ||
state->_ecx |= vcpu_count - 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to Intel SDM, when the initial EAX value is 0x80000008, ECX is reserved to 0. Why set state->_ecx here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, SDM says it's reserved to 0. I've done this since qemu does the same:
|
||
return; | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to a function.