mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-06 19:30:46 +00:00
hv: Add function to set UOS BSP init state
NOTE: this patch is only workaround patch for UOS BSP state init. Eventually, the DM will call hypercall to init UOS BSP state. We use this workaround patch here to simplify the init_guest_state. Will make the caller of init_guest_state calls init_guest_vmx directly. 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:
@@ -263,6 +263,51 @@ void set_ap_entry(struct vcpu *vcpu, uint64_t entry)
|
||||
vcpu_set_rip(vcpu, 0UL);
|
||||
}
|
||||
|
||||
|
||||
/* NOTE: set_bsp_real_mode_entry & set_bsp_protect_mode_regs is only temporary
|
||||
* function called by UOS. Once we make UOS to use hypercall to set BSP entry,
|
||||
* we will remove these two functions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @pre reset_vcpu_regs is called in advance
|
||||
*/
|
||||
void set_bsp_real_mode_entry(struct vcpu *vcpu)
|
||||
{
|
||||
struct ext_context *ectx;
|
||||
|
||||
ectx = &(vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context].ext_ctx);
|
||||
|
||||
ectx->cs.selector = REAL_MODE_BSP_INIT_CODE_SEL;
|
||||
ectx->cs.base = 0x3ff0000UL;
|
||||
vcpu_set_rip(vcpu, 0xFFF0UL);
|
||||
}
|
||||
|
||||
static struct acrn_vcpu_regs protect_mode_init_regs = {
|
||||
.cs_ar = PROTECTED_MODE_CODE_SEG_AR,
|
||||
.cs_sel = 0x10U,
|
||||
.ss_sel = 0x18U,
|
||||
.ds_sel = 0x18U,
|
||||
.es_sel = 0x18U,
|
||||
.cr0 = CR0_ET | CR0_NE | CR0_PE,
|
||||
.cr3 = 0UL,
|
||||
.cr4 = 0UL,
|
||||
};
|
||||
|
||||
void set_bsp_protect_mode_regs(struct vcpu *vcpu)
|
||||
{
|
||||
/* if vcpu is in protect mode, we need to set registers
|
||||
* according to protect_init_regs first.
|
||||
*/
|
||||
uint32_t limit;
|
||||
protect_mode_init_regs.gdt.base = create_guest_init_gdt(vcpu->vm,
|
||||
&limit);
|
||||
protect_mode_init_regs.gdt.limit = (uint16_t) (limit & 0xFFFFU);
|
||||
set_vcpu_regs(vcpu, &protect_mode_init_regs);
|
||||
|
||||
vcpu_set_rip(vcpu, (uint64_t)vcpu->entry_addr);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @pre vm != NULL && rtn_vcpu_handle != NULL
|
||||
@@ -593,8 +638,7 @@ int prepare_vcpu(struct vm *vm, uint16_t pcpu_id)
|
||||
vcpu->arch_vcpu.cpu_mode = CPU_MODE_PROTECTED;
|
||||
#else
|
||||
if (is_vm0(vcpu->vm)) {
|
||||
struct acrn_vcpu_regs *vm0_init_ctx =
|
||||
(struct acrn_vcpu_regs *)(&vm0_boot_context);
|
||||
struct acrn_vcpu_regs *vm0_init_ctx = &vm0_boot_context;
|
||||
/* VM0 bsp start mode is decided by the boot context
|
||||
* setup by bootloader / bios */
|
||||
if ((vm0_init_ctx->ia32_efer & MSR_IA32_EFER_LMA_BIT) &&
|
||||
|
@@ -304,11 +304,11 @@ int reset_vm(struct vm *vm)
|
||||
|
||||
foreach_vcpu(i, vm, vcpu) {
|
||||
reset_vcpu(vcpu);
|
||||
|
||||
vcpu->arch_vcpu.cpu_mode = CPU_MODE_REAL;
|
||||
if (is_vcpu_bsp(vcpu)) {
|
||||
vm_sw_loader(vm, vcpu);
|
||||
}
|
||||
|
||||
vcpu->arch_vcpu.cpu_mode = CPU_MODE_REAL;
|
||||
}
|
||||
|
||||
vioapic_reset(vm_ioapic(vm));
|
||||
|
@@ -673,8 +673,7 @@ static void init_guest_state(struct vcpu *vcpu)
|
||||
{
|
||||
struct cpu_context *ctx =
|
||||
&vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context];
|
||||
struct acrn_vcpu_regs* init_ctx =
|
||||
(struct acrn_vcpu_regs*)(&vm0_boot_context);
|
||||
struct acrn_vcpu_regs* init_ctx = &vm0_boot_context;
|
||||
enum vm_cpu_mode vcpu_mode = get_vcpu_mode(vcpu);
|
||||
|
||||
vcpu_set_rflags(vcpu, 0x2UL); /* Bit 1 is a active high reserved bit */
|
||||
|
Reference in New Issue
Block a user