@@ -6496,15 +6496,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
6496
6496
CPUState * cs = env_cpu (env );
6497
6497
uint32_t limit ;
6498
6498
uint32_t signature [3 ];
6499
- X86CPUTopoInfo topo_info ;
6499
+ X86CPUTopoInfo * topo_info = & env -> topo_info ;
6500
6500
uint32_t threads_per_pkg ;
6501
6501
6502
- topo_info .dies_per_pkg = env -> nr_dies ;
6503
- topo_info .modules_per_die = env -> nr_modules ;
6504
- topo_info .cores_per_module = cs -> nr_cores / env -> nr_dies / env -> nr_modules ;
6505
- topo_info .threads_per_core = cs -> nr_threads ;
6506
-
6507
- threads_per_pkg = x86_threads_per_pkg (& topo_info );
6502
+ threads_per_pkg = x86_threads_per_pkg (topo_info );
6508
6503
6509
6504
/* Calculate & apply limits for different index ranges */
6510
6505
if (index >= 0xC0000000 ) {
@@ -6581,12 +6576,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
6581
6576
int host_vcpus_per_cache = 1 + ((* eax & 0x3FFC000 ) >> 14 );
6582
6577
6583
6578
* eax &= ~0xFC000000 ;
6584
- * eax |= max_core_ids_in_package (& topo_info ) << 26 ;
6579
+ * eax |= max_core_ids_in_package (topo_info ) << 26 ;
6585
6580
if (host_vcpus_per_cache > threads_per_pkg ) {
6586
6581
* eax &= ~0x3FFC000 ;
6587
6582
6588
6583
/* Share the cache at package level. */
6589
- * eax |= max_thread_ids_for_cache (& topo_info ,
6584
+ * eax |= max_thread_ids_for_cache (topo_info ,
6590
6585
CPU_TOPOLOGY_LEVEL_SOCKET ) << 14 ;
6591
6586
}
6592
6587
}
@@ -6598,29 +6593,29 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
6598
6593
switch (count ) {
6599
6594
case 0 : /* L1 dcache info */
6600
6595
encode_cache_cpuid4 (env -> cache_info_cpuid4 .l1d_cache ,
6601
- & topo_info ,
6596
+ topo_info ,
6602
6597
eax , ebx , ecx , edx );
6603
6598
if (!cpu -> l1_cache_per_core ) {
6604
6599
* eax &= ~MAKE_64BIT_MASK (14 , 12 );
6605
6600
}
6606
6601
break ;
6607
6602
case 1 : /* L1 icache info */
6608
6603
encode_cache_cpuid4 (env -> cache_info_cpuid4 .l1i_cache ,
6609
- & topo_info ,
6604
+ topo_info ,
6610
6605
eax , ebx , ecx , edx );
6611
6606
if (!cpu -> l1_cache_per_core ) {
6612
6607
* eax &= ~MAKE_64BIT_MASK (14 , 12 );
6613
6608
}
6614
6609
break ;
6615
6610
case 2 : /* L2 cache info */
6616
6611
encode_cache_cpuid4 (env -> cache_info_cpuid4 .l2_cache ,
6617
- & topo_info ,
6612
+ topo_info ,
6618
6613
eax , ebx , ecx , edx );
6619
6614
break ;
6620
6615
case 3 : /* L3 cache info */
6621
6616
if (cpu -> enable_l3_cache ) {
6622
6617
encode_cache_cpuid4 (env -> cache_info_cpuid4 .l3_cache ,
6623
- & topo_info ,
6618
+ topo_info ,
6624
6619
eax , ebx , ecx , edx );
6625
6620
break ;
6626
6621
}
@@ -6703,12 +6698,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
6703
6698
6704
6699
switch (count ) {
6705
6700
case 0 :
6706
- * eax = apicid_core_offset (& topo_info );
6707
- * ebx = topo_info . threads_per_core ;
6701
+ * eax = apicid_core_offset (topo_info );
6702
+ * ebx = topo_info -> threads_per_core ;
6708
6703
* ecx |= CPUID_B_ECX_TOPO_LEVEL_SMT << 8 ;
6709
6704
break ;
6710
6705
case 1 :
6711
- * eax = apicid_pkg_offset (& topo_info );
6706
+ * eax = apicid_pkg_offset (topo_info );
6712
6707
* ebx = threads_per_pkg ;
6713
6708
* ecx |= CPUID_B_ECX_TOPO_LEVEL_CORE << 8 ;
6714
6709
break ;
@@ -6734,7 +6729,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
6734
6729
break ;
6735
6730
}
6736
6731
6737
- encode_topo_cpuid1f (env , count , & topo_info , eax , ebx , ecx , edx );
6732
+ encode_topo_cpuid1f (env , count , topo_info , eax , ebx , ecx , edx );
6738
6733
break ;
6739
6734
case 0xD : {
6740
6735
/* Processor Extended State */
@@ -7037,7 +7032,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
7037
7032
* thread ID within a package".
7038
7033
* Bits 7:0 is "The number of threads in the package is NC+1"
7039
7034
*/
7040
- * ecx = (apicid_pkg_offset (& topo_info ) << 12 ) |
7035
+ * ecx = (apicid_pkg_offset (topo_info ) << 12 ) |
7041
7036
(threads_per_pkg - 1 );
7042
7037
} else {
7043
7038
* ecx = 0 ;
@@ -7066,19 +7061,19 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
7066
7061
switch (count ) {
7067
7062
case 0 : /* L1 dcache info */
7068
7063
encode_cache_cpuid8000001d (env -> cache_info_amd .l1d_cache ,
7069
- & topo_info , eax , ebx , ecx , edx );
7064
+ topo_info , eax , ebx , ecx , edx );
7070
7065
break ;
7071
7066
case 1 : /* L1 icache info */
7072
7067
encode_cache_cpuid8000001d (env -> cache_info_amd .l1i_cache ,
7073
- & topo_info , eax , ebx , ecx , edx );
7068
+ topo_info , eax , ebx , ecx , edx );
7074
7069
break ;
7075
7070
case 2 : /* L2 cache info */
7076
7071
encode_cache_cpuid8000001d (env -> cache_info_amd .l2_cache ,
7077
- & topo_info , eax , ebx , ecx , edx );
7072
+ topo_info , eax , ebx , ecx , edx );
7078
7073
break ;
7079
7074
case 3 : /* L3 cache info */
7080
7075
encode_cache_cpuid8000001d (env -> cache_info_amd .l3_cache ,
7081
- & topo_info , eax , ebx , ecx , edx );
7076
+ topo_info , eax , ebx , ecx , edx );
7082
7077
break ;
7083
7078
default : /* end of info */
7084
7079
* eax = * ebx = * ecx = * edx = 0 ;
@@ -7090,7 +7085,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
7090
7085
break ;
7091
7086
case 0x8000001E :
7092
7087
if (cpu -> core_id <= 255 ) {
7093
- encode_topo_cpuid8000001e (cpu , & topo_info , eax , ebx , ecx , edx );
7088
+ encode_topo_cpuid8000001e (cpu , topo_info , eax , ebx , ecx , edx );
7094
7089
} else {
7095
7090
* eax = 0 ;
7096
7091
* ebx = 0 ;
@@ -7997,17 +7992,14 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
7997
7992
* fixes this issue by adjusting CPUID_0000_0001_EBX and CPUID_8000_0008_ECX
7998
7993
* based on inputs (sockets,cores,threads), it is still better to give
7999
7994
* users a warning.
8000
- *
8001
- * NOTE: the following code has to follow qemu_init_vcpu(). Otherwise
8002
- * cs->nr_threads hasn't be populated yet and the checking is incorrect.
8003
7995
*/
8004
7996
if (IS_AMD_CPU (env ) &&
8005
7997
!(env -> features [FEAT_8000_0001_ECX ] & CPUID_EXT3_TOPOEXT ) &&
8006
- cs -> nr_threads > 1 ) {
7998
+ env -> topo_info . threads_per_core > 1 ) {
8007
7999
warn_report_once ("This family of AMD CPU doesn't support "
8008
8000
"hyperthreading(%d). Please configure -smp "
8009
8001
"options properly or try enabling topoext "
8010
- "feature." , cs -> nr_threads );
8002
+ "feature." , env -> topo_info . threads_per_core );
8011
8003
}
8012
8004
8013
8005
#ifndef CONFIG_USER_ONLY
@@ -8168,8 +8160,7 @@ static void x86_cpu_init_default_topo(X86CPU *cpu)
8168
8160
{
8169
8161
CPUX86State * env = & cpu -> env ;
8170
8162
8171
- env -> nr_modules = 1 ;
8172
- env -> nr_dies = 1 ;
8163
+ env -> topo_info = (X86CPUTopoInfo ) {1 , 1 , 1 , 1 };
8173
8164
8174
8165
/* thread, core and socket levels are set by default. */
8175
8166
set_bit (CPU_TOPOLOGY_LEVEL_THREAD , env -> avail_cpu_topo );
0 commit comments