[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/19] target/i386/hvf: add rdmsr 35H MSR_CORE_THREAD_COUNT
From: |
Paolo Bonzini |
Subject: |
[PULL 18/19] target/i386/hvf: add rdmsr 35H MSR_CORE_THREAD_COUNT |
Date: |
Mon, 15 Feb 2021 14:16:25 +0100 |
From: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
Some guests (ex. Darwin-XNU) can attemp to read this MSR to retrieve and
validate CPU topology comparing it to ACPI MADT content
MSR description from Intel Manual:
35H: MSR_CORE_THREAD_COUNT: Configured State of Enabled Processor Core
Count and Logical Processor Count
Bits 15:0 THREAD_COUNT The number of logical processors that are
currently enabled in the physical package
Bits 31:16 Core_COUNT The number of processor cores that are currently
enabled in the physical package
Bits 63:32 Reserved
Signed-off-by: Vladislav Yaroshchuk <yaroshchuk2000@gmail.com>
Message-Id: <20210113205323.33310-1-yaroshchuk2000@gmail.com>
[RB: reordered MSR definition and dropped u suffix from shift offset]
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/cpu.h | 1 +
target/i386/hvf/x86_emu.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 8d599bb5b8..82c1ac00ef 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -368,6 +368,7 @@ typedef enum X86Seg {
#define MSR_IA32_SMBASE 0x9e
#define MSR_SMI_COUNT 0x34
+#define MSR_CORE_THREAD_COUNT 0x35
#define MSR_MTRRcap 0xfe
#define MSR_MTRRcap_VCNT 8
#define MSR_MTRRcap_FIXRANGE_SUPPORT (1 << 8)
diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c
index da570e352b..e52c39ddb1 100644
--- a/target/i386/hvf/x86_emu.c
+++ b/target/i386/hvf/x86_emu.c
@@ -668,6 +668,7 @@ void simulate_rdmsr(struct CPUState *cpu)
{
X86CPU *x86_cpu = X86_CPU(cpu);
CPUX86State *env = &x86_cpu->env;
+ CPUState *cs = env_cpu(env);
uint32_t msr = ECX(env);
uint64_t val = 0;
@@ -745,6 +746,10 @@ void simulate_rdmsr(struct CPUState *cpu)
case MSR_MTRRdefType:
val = env->mtrr_deftype;
break;
+ case MSR_CORE_THREAD_COUNT:
+ val = cs->nr_threads * cs->nr_cores; /* thread count, bits 15..0 */
+ val |= ((uint32_t)cs->nr_cores << 16); /* core count, bits 31..16 */
+ break;
default:
/* fprintf(stderr, "%s: unknown msr 0x%x\n", __func__, msr); */
val = 0;
--
2.29.2
- [PULL 08/19] sev/i386: Enable an SEV-ES guest based on SEV policy, (continued)
- [PULL 08/19] sev/i386: Enable an SEV-ES guest based on SEV policy, Paolo Bonzini, 2021/02/15
- [PULL 09/19] libqos/qgraph: add qos_node_create_driver_named(), Paolo Bonzini, 2021/02/15
- [PULL 11/19] tests/qtest/qos-test: dump qos graph if verbose, Paolo Bonzini, 2021/02/15
- [PULL 13/19] tests/qtest/qos-test: dump QEMU command if verbose, Paolo Bonzini, 2021/02/15
- [PULL 12/19] tests/qtest/qos-test: dump environment variables if verbose, Paolo Bonzini, 2021/02/15
- [PULL 14/19] util/cutils: Skip "." when looking for next directory component, Paolo Bonzini, 2021/02/15
- [PULL 17/19] hvf: x86: Remove unused definitions, Paolo Bonzini, 2021/02/15
- [PULL 15/19] hvf: Guard xgetbv call, Paolo Bonzini, 2021/02/15
- [PULL 16/19] target/i386/hvf: add vmware-cpuid-freq cpu feature, Paolo Bonzini, 2021/02/15
- [PULL 18/19] target/i386/hvf: add rdmsr 35H MSR_CORE_THREAD_COUNT,
Paolo Bonzini <=
- [PULL 19/19] hvf: Fetch cr4 before evaluating CPUID(1), Paolo Bonzini, 2021/02/15
- Re: [PULL 00/19] i386, qgraph patches for 2020-02-15, Thomas Huth, 2021/02/15
- Re: [PULL 00/19] i386, qgraph patches for 2020-02-15, Philippe Mathieu-Daudé, 2021/02/15
- Re: [PULL 00/19] i386, qgraph patches for 2020-02-15, no-reply, 2021/02/15
- Re: [PULL 00/19] i386, qgraph patches for 2020-02-15, Eric Blake, 2021/02/15