hv: Cleanup: Remove dead code.

Now, UOS will use hypercall to init BSP state, we could remove
set_bsp_real_mode_entry() and set_bsp_protect_mode_regs().

For SOS, GDT will inherit from SBL or UEFI. For UOS, DM will
prepare GDT. We don't need hypervisor to prepare GDT for guest.

The entry_addr of vcpu struct could be removed. The guest entry
is set through BSP rip register.

GUEST_CFG_OFFSET is not needed any more after this patchset.

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-10-08 19:54:49 +08:00 committed by wenlingz
parent b1ccde55a8
commit dbd9ab07e1
5 changed files with 0 additions and 95 deletions

View File

@ -714,36 +714,3 @@ uint64_t e820_alloc_low_memory(uint32_t size_arg)
pr_fatal("Can't allocate memory under 1M from E820\n");
return ACRN_INVALID_HPA;
}
/*******************************************************************
* GUEST initial GDT table
*
* If guest starts with protected mode, HV needs to prepare Guest GDT.
******************************************************************/
#define GUEST_INIT_GDT_SKIP_SIZE 0x8000UL
#define GUEST_INIT_GDT_START (trampoline_start16_paddr + \
GUEST_INIT_GDT_SKIP_SIZE)
/* The GDT defined below compatible with linux kernel */
#define GUEST_INIT_GDT_DESC_0 (0x0)
#define GUEST_INIT_GDT_DESC_1 (0x0)
#define GUEST_INIT_GDT_DESC_2 (0x00CF9B000000FFFFUL) /* Linear Code */
#define GUEST_INIT_GDT_DESC_3 (0x00CF93000000FFFFUL) /* Linear Data */
static const uint64_t guest_init_gdt[] = {
GUEST_INIT_GDT_DESC_0,
GUEST_INIT_GDT_DESC_1,
GUEST_INIT_GDT_DESC_2,
GUEST_INIT_GDT_DESC_3,
};
uint64_t create_guest_init_gdt(struct vm *vm, uint32_t *limit)
{
void *gtd_addr = gpa2hva(vm, GUEST_INIT_GDT_START);
*limit = sizeof(guest_init_gdt) - 1U;
(void)memcpy_s(gtd_addr, 64U, guest_init_gdt, sizeof(guest_init_gdt));
return GUEST_INIT_GDT_START;
};

View File

@ -293,51 +293,6 @@ 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

View File

@ -160,8 +160,6 @@ int copy_from_gva(struct vcpu *vcpu, void *h_ptr, uint64_t gva,
uint32_t size, uint32_t *err_code, uint64_t *fault_addr);
int copy_to_gva(struct vcpu *vcpu, void *h_ptr, uint64_t gva,
uint32_t size, uint32_t *err_code, uint64_t *fault_addr);
uint64_t create_guest_init_gdt(struct vm *vm, uint32_t *limit);
extern struct acrn_vcpu_regs vm0_boot_context;
#endif /* !ASSEMBLER */

View File

@ -209,7 +209,6 @@ struct vcpu {
uint16_t pcpu_id; /* Physical CPU ID of this VCPU */
uint16_t vcpu_id; /* virtual identifier for VCPU */
struct vm *vm; /* Reference to the VM this VCPU belongs to */
void *entry_addr; /* Entry address for this VCPU when first started */
/* State of this VCPU before suspend */
volatile enum vcpu_state prev_state;
@ -287,8 +286,6 @@ void vcpu_set_pat_ext(struct vcpu *vcpu, uint64_t val);
void set_vcpu_regs(struct vcpu *vcpu, struct acrn_vcpu_regs *vcpu_regs);
void reset_vcpu_regs(struct vcpu *vcpu);
void set_ap_entry(struct vcpu *vcpu, uint64_t entry);
void set_bsp_real_mode_entry(struct vcpu *vcpu);
void set_bsp_protect_mode_regs(struct vcpu *vcpu);
static inline bool is_long_mode(struct vcpu *vcpu)
{

View File

@ -457,18 +457,6 @@ struct acrn_vm_pci_msix_remap {
uint32_t vector_ctl;
} __aligned(8);
/**
* @brief The guest config pointer offset.
*
* It's designed to support passing DM config data pointer, based on it,
* hypervisor would parse then pass DM defined configuration to GUEST VCPU
* when booting guest VM.
* the address 0xef000 here is designed by DM, as it arranged all memory
* layout below 1M, DM add this address to E280 reserved range to make sure
* there is no overlap for the address 0xef000 usage.
*/
#define GUEST_CFG_OFFSET 0xef000UL
/**
* @brief Info The power state data of a VCPU.
*