uefi: restore cr registers according to efi context
@@ -1218,12 +1218,24 @@ static void override_uefi_vmcs(struct vcpu *vcpu)
&vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context];
if (get_vcpu_mode(vcpu) == PAGE_PROTECTED_MODE) {
- cur_context->cr3 = (uint64_t)efi_ctx->cr3 | CR3_PWT;
+ /* Set up guest CR0 field */
+ field = VMX_GUEST_CR0;
+ cur_context->cr0 = efi_ctx->cr0 | CR0_PG | CR0_PE | CR0_NE;
+ exec_vmwrite(field, cur_context->cr0 & 0xFFFFFFFF);
+ pr_dbg("VMX_GUEST_CR0: 0x%016llx ", cur_context->cr0);
+
/* Set up guest CR3 field */
field = VMX_GUEST_CR3;
+ cur_context->cr3 = efi_ctx->cr3;
exec_vmwrite(field, cur_context->cr3 & 0xFFFFFFFF);
pr_dbg("VMX_GUEST_CR3: 0x%016llx ", cur_context->cr3);
+ /* Set up guest CR4 field */
+ field = VMX_GUEST_CR4;
+ cur_context->cr4 = efi_ctx->cr4 | CR4_VMXE;
+ exec_vmwrite(field, cur_context->cr4 & 0xFFFFFFFF);
+ pr_dbg("VMX_GUEST_CR4: 0x%016llx ", cur_context->cr4);
+
/* Selector */
field = VMX_GUEST_CS_SEL;
exec_vmwrite(field, efi_ctx->cs_sel);
