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

Commit acce9c7

Browse files
committed
Add support for cpuid 4
Signed-off-by: Alexey Romko <[email protected]>
1 parent 69d5462 commit acce9c7

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

core/vcpu.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2715,7 +2715,43 @@ static void handle_cpuid_virtual(struct vcpu_t *vcpu, uint32_t a, uint32_t c)
27152715
case 3: // Reserved
27162716
case 4: { // Deterministic Cache Parameters
27172717
// [31:26] cores per package - 1
2718-
state->_eax = state->_ebx = state->_ecx = state->_edx = 0;
2718+
// Using QEMU's values
2719+
if( 0 == c )
2720+
{
2721+
//1 0 01 00001 data cache, level 1, fully associative cache
2722+
state->_eax = 0x121;
2723+
state->_ebx = 0x1C0003F;
2724+
state->_ecx = 0x3F;
2725+
state->_edx = 0x1;
2726+
}
2727+
else if( 1 == c )
2728+
{
2729+
//1 0 01 00010 instr cache, level 1, fully associative cache
2730+
state->_eax = 0x122;
2731+
state->_ebx = 0x1C0003F;
2732+
state->_ecx = 0x3F;
2733+
state->_edx = 0x1;
2734+
}
2735+
else if( 2 == c )
2736+
{
2737+
//1 0 10 00011 unified cache, level 2, fully associative cache
2738+
state->_eax = 0x143;
2739+
state->_ebx = 0x3C0003F;
2740+
state->_ecx = 0xFFF;
2741+
state->_edx = 0x1;
2742+
}
2743+
else if( 3 == c )
2744+
{
2745+
//1 0 11 00011 unified cache, level 3, fully associative cache
2746+
state->_eax = 0x163;
2747+
state->_ebx = 0x3C0003F;
2748+
state->_ecx = 0x3FFF;
2749+
state->_edx = 0x6;
2750+
}
2751+
else
2752+
{
2753+
state->_eax = state->_ebx = state->_ecx = state->_edx = 0;
2754+
}
27192755
return;
27202756
}
27212757
case 5: // MONITOR/MWAIT

0 commit comments

Comments
 (0)