mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 13:05:45 +00:00
arch: x86_64: Enable CR4 LA57 feature
In case the host CPU exposes the support for LA57 feature through its cpuid, the CR4.LA57 bit is enabled accordingly. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
09fd325963
commit
5f0b620148
@ -138,6 +138,7 @@ const EFER_LME: u64 = 0x100;
|
|||||||
const X86_CR0_PE: u64 = 0x1;
|
const X86_CR0_PE: u64 = 0x1;
|
||||||
const X86_CR0_PG: u64 = 0x80000000;
|
const X86_CR0_PG: u64 = 0x80000000;
|
||||||
const X86_CR4_PAE: u64 = 0x20;
|
const X86_CR4_PAE: u64 = 0x20;
|
||||||
|
const X86_CR4_LA57: u64 = 0x1000;
|
||||||
|
|
||||||
fn write_gdt_table(table: &[u64], guest_mem: &GuestMemoryMmap) -> Result<()> {
|
fn write_gdt_table(table: &[u64], guest_mem: &GuestMemoryMmap) -> Result<()> {
|
||||||
let boot_gdt_addr = BOOT_GDT_START;
|
let boot_gdt_addr = BOOT_GDT_START;
|
||||||
@ -239,6 +240,11 @@ fn setup_page_tables(mem: &GuestMemoryMmap, sregs: &mut kvm_sregs) -> Result<()>
|
|||||||
sregs.cr3 = PML4_START.raw_value();
|
sregs.cr3 = PML4_START.raw_value();
|
||||||
sregs.cr4 |= X86_CR4_PAE;
|
sregs.cr4 |= X86_CR4_PAE;
|
||||||
sregs.cr0 |= X86_CR0_PG;
|
sregs.cr0 |= X86_CR0_PG;
|
||||||
|
|
||||||
|
if unsafe { std::arch::x86_64::__cpuid(7).ecx } & (1 << 16) != 0 {
|
||||||
|
sregs.cr4 |= X86_CR4_LA57;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user