|
7 | 7 | #include <hypervisor.h>
|
8 | 8 | #include <schedule.h>
|
9 | 9 |
|
| 10 | +#ifdef CONFIG_EFI_STUB |
| 11 | +#include <acrn_efi.h> |
| 12 | +extern struct efi_ctx* efi_ctx; |
| 13 | +#endif |
| 14 | + |
10 | 15 | vm_sw_loader_t vm_sw_loader;
|
11 | 16 |
|
12 | 17 | /***********************************************************************
|
@@ -67,14 +72,16 @@ int create_vcpu(int cpu_id, struct vm *vm, struct vcpu **rtn_vcpu_handle)
|
67 | 72 | vcpu->pcpu_id, vcpu->vm->attr.id, vcpu->vcpu_id,
|
68 | 73 | is_vcpu_bsp(vcpu) ? "PRIMARY" : "SECONDARY");
|
69 | 74 |
|
70 |
| - /* Is this VCPU a VM BSP, create page hierarchy for this VM */ |
71 |
| - if (is_vcpu_bsp(vcpu)) { |
| 75 | +#ifdef CONFIG_START_VM0_BSP_64BIT |
| 76 | + /* Is this VCPU a VM0 BSP, create page hierarchy for this VM */ |
| 77 | + if (is_vcpu_bsp(vcpu) && is_vm0(vcpu->vm)) { |
72 | 78 | /* Set up temporary guest page tables */
|
73 | 79 | vm->arch_vm.guest_init_pml4 = create_guest_initial_paging(vm);
|
74 | 80 | pr_info("VM *d VCPU %d CR3: 0x%016llx ",
|
75 | 81 | vm->attr.id, vcpu->vcpu_id,
|
76 | 82 | vm->arch_vm.guest_init_pml4);
|
77 | 83 | }
|
| 84 | +#endif |
78 | 85 |
|
79 | 86 | /* Allocate VMCS region for this VCPU */
|
80 | 87 | vcpu->arch_vcpu.vmcs = alloc_page();
|
@@ -319,8 +326,24 @@ int prepare_vcpu(struct vm *vm, int pcpu_id)
|
319 | 326 | /* Load VM SW */
|
320 | 327 | if (!vm_sw_loader)
|
321 | 328 | vm_sw_loader = general_sw_loader;
|
| 329 | + if (is_vm0(vcpu->vm)) { |
| 330 | + vcpu->arch_vcpu.cpu_mode = CPU_MODE_PROTECTED; |
| 331 | +#ifdef CONFIG_EFI_STUB |
| 332 | + if ((efi_ctx->efer & MSR_IA32_EFER_LMA_BIT) && |
| 333 | + (efi_ctx->cs_ar & 0x2000)) |
| 334 | + vcpu->arch_vcpu.cpu_mode = CPU_MODE_64BIT; |
| 335 | +#elif CONFIG_START_VM0_BSP_64BIT |
| 336 | + vcpu->arch_vcpu.cpu_mode = CPU_MODE_64BIT; |
| 337 | +#endif |
| 338 | + } else { |
| 339 | +#ifdef CONFIG_EFI_STUB |
| 340 | + /* currently non-vm0 will boot kernel directly */ |
| 341 | + vcpu->arch_vcpu.cpu_mode = CPU_MODE_PROTECTED; |
| 342 | +#else |
| 343 | + vcpu->arch_vcpu.cpu_mode = CPU_MODE_REAL; |
| 344 | +#endif |
| 345 | + } |
322 | 346 | vm_sw_loader(vm, vcpu);
|
323 |
| - vcpu->arch_vcpu.cpu_mode = CPU_MODE_64BIT; |
324 | 347 | } else {
|
325 | 348 | vcpu->arch_vcpu.cpu_mode = CPU_MODE_REAL;
|
326 | 349 | }
|
|
0 commit comments