mirror of
				https://github.com/projectacrn/acrn-hypervisor.git
				synced 2025-11-04 11:48:50 +00:00 
			
		
		
		
	cleanup arch folder, only include some necessary, doesn't include hypervisor.h Tracked-On: #1842 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com> modified: arch/x86/configs/apl-mrb/pt_dev.c modified: arch/x86/configs/apl-mrb/ve820.c modified: arch/x86/configs/dnv-cb2/pt_dev.c modified: arch/x86/configs/dnv-cb2/ve820.c modified: arch/x86/configs/partition_config.c modified: arch/x86/configs/sharing_config.c modified: arch/x86/cpu.c modified: arch/x86/cpu_state_tbl.c modified: arch/x86/e820.c modified: arch/x86/gdt.c modified: arch/x86/init.c modified: arch/x86/ioapic.c modified: arch/x86/irq.c modified: arch/x86/lapic.c modified: arch/x86/mmu.c modified: arch/x86/notify.c modified: arch/x86/page.c modified: arch/x86/pagetable.c modified: arch/x86/static_checks.c modified: arch/x86/timer.c modified: arch/x86/trampoline.c modified: arch/x86/vmx.c modified: arch/x86/vtd.c modified: boot/include/acpi.h modified: include/arch/x86/e820.h modified: include/arch/x86/ioapic.h
		
			
				
	
	
		
			62 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * Copyright (C) 2018 Intel Corporation. All rights reserved.
 | 
						|
 *
 | 
						|
 * SPDX-License-Identifier: BSD-3-Clause
 | 
						|
 */
 | 
						|
 | 
						|
#include <types.h>
 | 
						|
#include <gdt.h>
 | 
						|
#include <per_cpu.h>
 | 
						|
 | 
						|
static void set_tss_desc(struct tss_64_descriptor *desc,
 | 
						|
		uint64_t tss, size_t tss_limit, uint32_t type)
 | 
						|
{
 | 
						|
	uint32_t u1, u2, u3;
 | 
						|
	uint32_t tss_hi_32 = (uint32_t)(tss >> 32U);
 | 
						|
	uint32_t tss_lo_32 = (uint32_t)tss;
 | 
						|
 | 
						|
	u1 = tss_lo_32 << 16U;
 | 
						|
	u2 = tss_lo_32 & 0xFF000000U;
 | 
						|
	u3 = (tss_lo_32 & 0x00FF0000U) >> 16U;
 | 
						|
 | 
						|
 | 
						|
	desc->low32_value = u1 | (tss_limit & 0xFFFFU);
 | 
						|
	desc->base_addr_63_32 = tss_hi_32;
 | 
						|
	desc->high32_value = u2 | (type << 8U) | 0x8000U | u3;
 | 
						|
}
 | 
						|
 | 
						|
static inline void load_gdt(struct host_gdt_descriptor *gdtr)
 | 
						|
{
 | 
						|
	asm volatile ("lgdt %0" ::"m"(*gdtr));
 | 
						|
}
 | 
						|
 | 
						|
void load_gdtr_and_tr(void)
 | 
						|
{
 | 
						|
	struct host_gdt *gdt = &get_cpu_var(gdt);
 | 
						|
	struct host_gdt_descriptor gdtr;
 | 
						|
	struct tss_64 *tss = &get_cpu_var(tss);
 | 
						|
 | 
						|
	/* first entry is not used */
 | 
						|
	gdt->rsvd = 0xAAAAAAAAAAAAAAAAUL;
 | 
						|
	/* ring 0 code sel descriptor */
 | 
						|
	gdt->code_segment_descriptor = 0x00Af9b000000ffffUL;
 | 
						|
	/* ring 0 data sel descriptor */
 | 
						|
	gdt->data_segment_descriptor = 0x00cf93000000ffffUL;
 | 
						|
 | 
						|
	tss->ist1 = (uint64_t)get_cpu_var(mc_stack) + CONFIG_STACK_SIZE;
 | 
						|
	tss->ist2 = (uint64_t)get_cpu_var(df_stack) + CONFIG_STACK_SIZE;
 | 
						|
	tss->ist3 = (uint64_t)get_cpu_var(sf_stack) + CONFIG_STACK_SIZE;
 | 
						|
	tss->ist4 = 0UL;
 | 
						|
 | 
						|
	/* tss descriptor */
 | 
						|
	set_tss_desc(&gdt->host_gdt_tss_descriptors,
 | 
						|
		(uint64_t)tss, sizeof(struct tss_64), TSS_AVAIL);
 | 
						|
 | 
						|
	gdtr.len = sizeof(struct host_gdt) - 1U;
 | 
						|
	gdtr.gdt = gdt;
 | 
						|
 | 
						|
	load_gdt(&gdtr);
 | 
						|
 | 
						|
	CPU_LTR_EXECUTE(HOST_GDT_RING0_CPU_TSS_SEL);
 | 
						|
}
 |