void vt_ept_updatecr3 (void) { ulong cr3, cr4; u32 tmpl, tmph; u64 tmp64; vt_paging_flush_guest_tlb (); if (!current->u.vt.lma && current->u.vt.vr.pg) { asm_vmread (VMCS_CR4_READ_SHADOW, &cr4); if (cr4 & CR4_PAE_BIT) { asm_vmread (VMCS_GUEST_CR3, &cr3); cr3 &= 0xFFFFFFE0; read_gphys_q (cr3 + 0x0, &tmp64, 0); conv64to32 (tmp64, &tmpl, &tmph); asm_vmwrite (VMCS_GUEST_PDPTE0, tmpl); asm_vmwrite (VMCS_GUEST_PDPTE0_HIGH, tmph); read_gphys_q (cr3 + 0x8, &tmp64, 0); conv64to32 (tmp64, &tmpl, &tmph); asm_vmwrite (VMCS_GUEST_PDPTE1, tmpl); asm_vmwrite (VMCS_GUEST_PDPTE1_HIGH, tmph); read_gphys_q (cr3 + 0x10, &tmp64, 0); conv64to32 (tmp64, &tmpl, &tmph); asm_vmwrite (VMCS_GUEST_PDPTE2, tmpl); asm_vmwrite (VMCS_GUEST_PDPTE2_HIGH, tmph); read_gphys_q (cr3 + 0x18, &tmp64, 0); conv64to32 (tmp64, &tmpl, &tmph); asm_vmwrite (VMCS_GUEST_PDPTE3, tmpl); asm_vmwrite (VMCS_GUEST_PDPTE3_HIGH, tmph); } } }
bool cpu_emul_rdmsr (void) { u32 ic, oa, od; ulong lc; u64 msrdata; bool err; /* FIXME: Privilege check */ current->vmctl.read_general_reg (GENERAL_REG_RCX, &lc); ic = lc; err = current->vmctl.read_msr (ic, &msrdata); conv64to32 (msrdata, &oa, &od); current->vmctl.write_general_reg (GENERAL_REG_RAX, oa); current->vmctl.write_general_reg (GENERAL_REG_RDX, od); return err; }