Skip to content

Commit dbd9ab0

Browse files
fyin1wenlingz
authored andcommitted
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>
1 parent b1ccde5 commit dbd9ab0

File tree

5 files changed

+0
-95
lines changed

5 files changed

+0
-95
lines changed

hypervisor/arch/x86/guest/guest.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -714,36 +714,3 @@ uint64_t e820_alloc_low_memory(uint32_t size_arg)
714714
pr_fatal("Can't allocate memory under 1M from E820\n");
715715
return ACRN_INVALID_HPA;
716716
}
717-
718-
/*******************************************************************
719-
* GUEST initial GDT table
720-
*
721-
* If guest starts with protected mode, HV needs to prepare Guest GDT.
722-
******************************************************************/
723-
724-
#define GUEST_INIT_GDT_SKIP_SIZE 0x8000UL
725-
#define GUEST_INIT_GDT_START (trampoline_start16_paddr + \
726-
GUEST_INIT_GDT_SKIP_SIZE)
727-
728-
/* The GDT defined below compatible with linux kernel */
729-
#define GUEST_INIT_GDT_DESC_0 (0x0)
730-
#define GUEST_INIT_GDT_DESC_1 (0x0)
731-
#define GUEST_INIT_GDT_DESC_2 (0x00CF9B000000FFFFUL) /* Linear Code */
732-
#define GUEST_INIT_GDT_DESC_3 (0x00CF93000000FFFFUL) /* Linear Data */
733-
734-
static const uint64_t guest_init_gdt[] = {
735-
GUEST_INIT_GDT_DESC_0,
736-
GUEST_INIT_GDT_DESC_1,
737-
GUEST_INIT_GDT_DESC_2,
738-
GUEST_INIT_GDT_DESC_3,
739-
};
740-
741-
uint64_t create_guest_init_gdt(struct vm *vm, uint32_t *limit)
742-
{
743-
void *gtd_addr = gpa2hva(vm, GUEST_INIT_GDT_START);
744-
745-
*limit = sizeof(guest_init_gdt) - 1U;
746-
(void)memcpy_s(gtd_addr, 64U, guest_init_gdt, sizeof(guest_init_gdt));
747-
748-
return GUEST_INIT_GDT_START;
749-
};

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -293,51 +293,6 @@ void set_ap_entry(struct vcpu *vcpu, uint64_t entry)
293293
vcpu_set_rip(vcpu, 0UL);
294294
}
295295

296-
297-
/* NOTE: set_bsp_real_mode_entry & set_bsp_protect_mode_regs is only temporary
298-
* function called by UOS. Once we make UOS to use hypercall to set BSP entry,
299-
* we will remove these two functions.
300-
*/
301-
302-
/*
303-
* @pre reset_vcpu_regs is called in advance
304-
*/
305-
void set_bsp_real_mode_entry(struct vcpu *vcpu)
306-
{
307-
struct ext_context *ectx;
308-
309-
ectx = &(vcpu->arch_vcpu.contexts[vcpu->arch_vcpu.cur_context].ext_ctx);
310-
311-
ectx->cs.selector = REAL_MODE_BSP_INIT_CODE_SEL;
312-
ectx->cs.base = 0x3ff0000UL;
313-
vcpu_set_rip(vcpu, 0xFFF0UL);
314-
}
315-
316-
static struct acrn_vcpu_regs protect_mode_init_regs = {
317-
.cs_ar = PROTECTED_MODE_CODE_SEG_AR,
318-
.cs_sel = 0x10U,
319-
.ss_sel = 0x18U,
320-
.ds_sel = 0x18U,
321-
.es_sel = 0x18U,
322-
.cr0 = CR0_ET | CR0_NE | CR0_PE,
323-
.cr3 = 0UL,
324-
.cr4 = 0UL,
325-
};
326-
327-
void set_bsp_protect_mode_regs(struct vcpu *vcpu)
328-
{
329-
/* if vcpu is in protect mode, we need to set registers
330-
* according to protect_init_regs first.
331-
*/
332-
uint32_t limit;
333-
protect_mode_init_regs.gdt.base = create_guest_init_gdt(vcpu->vm,
334-
&limit);
335-
protect_mode_init_regs.gdt.limit = (uint16_t) (limit & 0xFFFFU);
336-
set_vcpu_regs(vcpu, &protect_mode_init_regs);
337-
338-
vcpu_set_rip(vcpu, (uint64_t)vcpu->entry_addr);
339-
}
340-
341296
/***********************************************************************
342297
*
343298
* @pre vm != NULL && rtn_vcpu_handle != NULL

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ int copy_from_gva(struct vcpu *vcpu, void *h_ptr, uint64_t gva,
160160
uint32_t size, uint32_t *err_code, uint64_t *fault_addr);
161161
int copy_to_gva(struct vcpu *vcpu, void *h_ptr, uint64_t gva,
162162
uint32_t size, uint32_t *err_code, uint64_t *fault_addr);
163-
164-
uint64_t create_guest_init_gdt(struct vm *vm, uint32_t *limit);
165163
extern struct acrn_vcpu_regs vm0_boot_context;
166164

167165
#endif /* !ASSEMBLER */

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ struct vcpu {
209209
uint16_t pcpu_id; /* Physical CPU ID of this VCPU */
210210
uint16_t vcpu_id; /* virtual identifier for VCPU */
211211
struct vm *vm; /* Reference to the VM this VCPU belongs to */
212-
void *entry_addr; /* Entry address for this VCPU when first started */
213212

214213
/* State of this VCPU before suspend */
215214
volatile enum vcpu_state prev_state;
@@ -287,8 +286,6 @@ void vcpu_set_pat_ext(struct vcpu *vcpu, uint64_t val);
287286
void set_vcpu_regs(struct vcpu *vcpu, struct acrn_vcpu_regs *vcpu_regs);
288287
void reset_vcpu_regs(struct vcpu *vcpu);
289288
void set_ap_entry(struct vcpu *vcpu, uint64_t entry);
290-
void set_bsp_real_mode_entry(struct vcpu *vcpu);
291-
void set_bsp_protect_mode_regs(struct vcpu *vcpu);
292289

293290
static inline bool is_long_mode(struct vcpu *vcpu)
294291
{

hypervisor/include/public/acrn_common.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -457,18 +457,6 @@ struct acrn_vm_pci_msix_remap {
457457
uint32_t vector_ctl;
458458
} __aligned(8);
459459

460-
/**
461-
* @brief The guest config pointer offset.
462-
*
463-
* It's designed to support passing DM config data pointer, based on it,
464-
* hypervisor would parse then pass DM defined configuration to GUEST VCPU
465-
* when booting guest VM.
466-
* the address 0xef000 here is designed by DM, as it arranged all memory
467-
* layout below 1M, DM add this address to E280 reserved range to make sure
468-
* there is no overlap for the address 0xef000 usage.
469-
*/
470-
#define GUEST_CFG_OFFSET 0xef000UL
471-
472460
/**
473461
* @brief Info The power state data of a VCPU.
474462
*

0 commit comments

Comments
 (0)