mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
Kernel: Detect and display CPUID Hyper-V data
This commit is contained in:
parent
b22357b17b
commit
528574d958
2 changed files with 33 additions and 0 deletions
|
@ -174,6 +174,7 @@ public:
|
||||||
void initialize(u32 cpu);
|
void initialize(u32 cpu);
|
||||||
|
|
||||||
void detect_hypervisor();
|
void detect_hypervisor();
|
||||||
|
void detect_hypervisor_hyperv(CPUID const& hypervisor_leaf_range);
|
||||||
|
|
||||||
void idle_begin()
|
void idle_begin()
|
||||||
{
|
{
|
||||||
|
|
|
@ -376,6 +376,38 @@ UNMAP_AFTER_INIT void Processor::detect_hypervisor()
|
||||||
StringView hypervisor_signature(hypervisor_signature_buffer);
|
StringView hypervisor_signature(hypervisor_signature_buffer);
|
||||||
|
|
||||||
dmesgln("CPU[{}]: CPUID hypervisor signature '{}' ({:#x} {:#x} {:#x}), max leaf {:#x}", id(), hypervisor_signature, hypervisor_leaf_range.ebx(), hypervisor_leaf_range.ecx(), hypervisor_leaf_range.edx(), hypervisor_leaf_range.eax());
|
dmesgln("CPU[{}]: CPUID hypervisor signature '{}' ({:#x} {:#x} {:#x}), max leaf {:#x}", id(), hypervisor_signature, hypervisor_leaf_range.ebx(), hypervisor_leaf_range.ecx(), hypervisor_leaf_range.edx(), hypervisor_leaf_range.eax());
|
||||||
|
|
||||||
|
if (hypervisor_signature == "Microsoft Hv"sv)
|
||||||
|
detect_hypervisor_hyperv(hypervisor_leaf_range);
|
||||||
|
}
|
||||||
|
|
||||||
|
UNMAP_AFTER_INIT void Processor::detect_hypervisor_hyperv(CPUID const& hypervisor_leaf_range)
|
||||||
|
{
|
||||||
|
if (hypervisor_leaf_range.eax() < 0x40000001)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CPUID hypervisor_interface(0x40000001);
|
||||||
|
|
||||||
|
// Get signature of hypervisor interface.
|
||||||
|
alignas(sizeof(u32)) char interface_signature_buffer[5];
|
||||||
|
*reinterpret_cast<u32*>(interface_signature_buffer) = hypervisor_interface.eax();
|
||||||
|
interface_signature_buffer[4] = '\0';
|
||||||
|
StringView hyperv_interface_signature(interface_signature_buffer);
|
||||||
|
|
||||||
|
dmesgln("CPU[{}]: Hyper-V interface signature '{}' ({:#x})", id(), hyperv_interface_signature, hypervisor_interface.eax());
|
||||||
|
|
||||||
|
if (hypervisor_leaf_range.eax() < 0x40000001)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CPUID hypervisor_sysid(0x40000002);
|
||||||
|
dmesgln("CPU[{}]: Hyper-V system identity {}.{}, build number {}", id(), hypervisor_sysid.ebx() >> 16, hypervisor_sysid.ebx() & 0xFFFF, hypervisor_sysid.eax());
|
||||||
|
|
||||||
|
if (hypervisor_leaf_range.eax() < 0x40000005 || hyperv_interface_signature != "Hv#1"sv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dmesgln("CPU[{}]: Hyper-V hypervisor detected", id());
|
||||||
|
|
||||||
|
// TODO: Actually do something with Hyper-V.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Processor::write_raw_gdt_entry(u16 selector, u32 low, u32 high)
|
void Processor::write_raw_gdt_entry(u16 selector, u32 low, u32 high)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue