Skip to content

Commit b454a06

Browse files
fyin1wenlingz
authored andcommitted
hv: remove the vm loader for UOS in hv.
Now, we make UOS to set BSP init state by using hypercall. We could drop the old UOS loader in HV and make vm loader in HV only for SOS. Tracked-On: #1231 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent fc57546 commit b454a06

File tree

5 files changed

+11
-55
lines changed

5 files changed

+11
-55
lines changed

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ int prepare_vcpu(struct vm *vm, uint16_t pcpu_id)
661661
} else {
662662
return -EINVAL;
663663
}
664+
vm_sw_loader(vm);
664665
} else {
665666
#ifdef CONFIG_EFI_STUB
666667
/* currently non-vm0 will boot kernel directly */
@@ -670,7 +671,6 @@ int prepare_vcpu(struct vm *vm, uint16_t pcpu_id)
670671
#endif
671672
}
672673
#endif //CONFIG_PARTITION_MODE
673-
vm_sw_loader(vm, vcpu);
674674
} else {
675675
vcpu->arch_vcpu.cpu_mode = CPU_MODE_REAL;
676676
}

hypervisor/arch/x86/guest/vm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,11 @@ int reset_vm(struct vm *vm)
304304

305305
foreach_vcpu(i, vm, vcpu) {
306306
reset_vcpu(vcpu);
307-
308307
vcpu->arch_vcpu.cpu_mode = CPU_MODE_REAL;
309-
if (is_vcpu_bsp(vcpu)) {
310-
vm_sw_loader(vm, vcpu);
311-
}
308+
}
309+
310+
if (is_vm0(vm)) {
311+
vm_sw_loader(vm);
312312
}
313313

314314
vioapic_reset(vm_ioapic(vm));

hypervisor/bsp/uefi/uefi.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,16 @@ void efi_spurious_handler(int vector)
3636
return;
3737
}
3838

39-
int uefi_sw_loader(struct vm *vm, struct vcpu *vcpu)
39+
int uefi_sw_loader(struct vm *vm)
4040
{
4141
int ret = 0;
42+
struct vcpu *vcpu = get_primary_vcpu(vm);
4243
struct acrn_vcpu_regs *vcpu_regs = &vm0_boot_context;
4344

4445
ASSERT(vm != NULL, "Incorrect argument");
4546

4647
pr_dbg("Loading guest to run-time location");
4748

48-
if (!is_vm0(vm))
49-
return load_guest(vm, vcpu);
50-
5149
vlapic_restore(vcpu_vlapic(vcpu), &uefi_lapic_regs);
5250

5351
/* For UEFI platform, the bsp init regs come from two places:

hypervisor/common/vm_load.c

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -85,41 +85,7 @@ static uint64_t create_zero_page(struct vm *vm)
8585
return gpa;
8686
}
8787

88-
int load_guest(struct vm *vm, struct vcpu *vcpu)
89-
{
90-
int32_t ret = 0;
91-
void *hva;
92-
uint64_t lowmem_gpa_top;
93-
94-
hva = gpa2hva(vm, GUEST_CFG_OFFSET);
95-
lowmem_gpa_top = *(uint64_t *)hva;
96-
97-
hva = gpa2hva(vm, lowmem_gpa_top -
98-
MEM_4K - MEM_2K);
99-
vcpu->entry_addr = (void *)(*((uint64_t *)hva));
100-
101-
if (get_vcpu_mode(vcpu) == CPU_MODE_REAL) {
102-
set_bsp_real_mode_entry(vcpu);
103-
} else {
104-
set_bsp_protect_mode_regs(vcpu);
105-
}
106-
107-
vcpu_set_gpreg(vcpu, CPU_REG_RSI, lowmem_gpa_top - MEM_4K);
108-
109-
pr_info("%s, Set config according to predefined offset:",
110-
__func__);
111-
pr_info("VCPU%hu Entry: 0x%llx, RSI: 0x%016llx, cr3: 0x%016llx",
112-
vcpu->vcpu_id, vcpu->entry_addr,
113-
vcpu_get_gpreg(vcpu, CPU_REG_RSI),
114-
vm->arch_vm.guest_init_pml4);
115-
116-
return ret;
117-
}
118-
119-
/*
120-
* @pre vm != NULL
121-
*/
122-
int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
88+
int general_sw_loader(struct vm *vm)
12389
{
12490
int32_t ret = 0;
12591
void *hva;
@@ -128,17 +94,10 @@ int general_sw_loader(struct vm *vm, struct vcpu *vcpu)
12894
struct zero_page *zeropage;
12995
struct sw_linux *sw_linux = &(vm->sw.linux_info);
13096
struct sw_kernel_info *sw_kernel = &(vm->sw.kernel_info);
97+
struct vcpu *vcpu = get_primary_vcpu(vm);
13198

13299
pr_dbg("Loading guest to run-time location");
133100

134-
/* ACRN in partiton mode boots all VMs without devicemodel */
135-
#ifndef CONFIG_PARTITION_MODE
136-
/* FIXME: set config according to predefined offset */
137-
if (!is_vm0(vm)) {
138-
return load_guest(vm, vcpu);
139-
}
140-
#endif
141-
142101
set_vcpu_regs(vcpu, &vm0_boot_context);
143102

144103
/* calculate the kernel entry point */

hypervisor/include/arch/x86/guest/guest.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,9 @@ void init_msr_emulation(struct vcpu *vcpu);
135135
struct run_context;
136136
int vmx_vmrun(struct run_context *context, int ops, int ibrs);
137137

138-
int load_guest(struct vm *vm, struct vcpu *vcpu);
139-
int general_sw_loader(struct vm *vm, struct vcpu *vcpu);
138+
int general_sw_loader(struct vm *vm);
140139

141-
typedef int (*vm_sw_loader_t)(struct vm *vm, struct vcpu *vcpu);
140+
typedef int (*vm_sw_loader_t)(struct vm *vm);
142141
extern vm_sw_loader_t vm_sw_loader;
143142

144143
/* @pre Caller(Guest) should make sure gpa is continuous.

0 commit comments

Comments
 (0)