hv: Update SOS BSP to use new API to init BSP state

We move the SOS BSP state init to vm loader and drop
function init_guest_context_vm0_bsp.

Update the definition of vm0_boot_context to fix code
violations.

Tracked-On: #1231
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yin Fengwei
2018-09-29 21:14:44 +08:00
committed by wenlingz
parent 26627bd1fc
commit 08c13a9ea8
3 changed files with 18 additions and 44 deletions

View File

@@ -39,8 +39,8 @@ void efi_spurious_handler(int vector)
int uefi_sw_loader(struct vm *vm, struct vcpu *vcpu)
{
int ret = 0;
struct run_context *cur_context =
&vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context].run_ctx;
struct acrn_vcpu_regs *vcpu_regs =
(struct acrn_vcpu_regs *)&vm0_boot_context;
ASSERT(vm != NULL, "Incorrect argument");
@@ -51,9 +51,17 @@ int uefi_sw_loader(struct vm *vm, struct vcpu *vcpu)
vlapic_restore(vcpu_vlapic(vcpu), &uefi_lapic_regs);
vcpu->entry_addr = (void *)efi_ctx->vcpu_regs.rip;
memcpy_s(&cur_context->guest_cpu_regs, sizeof(struct acrn_gp_regs),
&efi_ctx->vcpu_regs.gprs, sizeof(struct acrn_gp_regs));
/* For UEFI platform, the bsp init regs come from two places:
* 1. saved in efi_boot: gpregs, rip
* 2. saved when HV started: other registers
* We copy the info saved in efi_boot to vm0_boot_context and
* init bsp with vm0_boot_context.
*/
memcpy_s(&(vcpu_regs->gprs), sizeof(struct acrn_gp_regs),
&(efi_ctx->vcpu_regs.gprs), sizeof(struct acrn_gp_regs));
vcpu_regs->rip = efi_ctx->vcpu_regs.rip;
set_vcpu_regs(vcpu, vcpu_regs);
/* defer irq enabling till vlapic is ready */
CPU_IRQ_ENABLE();