mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 14:07:42 +00:00
hv: delay enabling SMEP/SMAP until the end of PCPU initialization
Host ACPI parsing is needed during initialization only, not in run time. Hence we don't need to clear U flag for memory in reserved or ACPI type E820 entries. - move enable_smep() and enable_smap() to the end of init_pcpu_post(), so stac()/clac() can be removed from any init code before this point. - call init_seed() before init_pcpu_post(), and rmeove stac()/clac() from init_seed(). Tracked-On: #3194 Signed-off-by: Zide Chen <zide.chen@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
parent
9e91f14bec
commit
e63d32ac02
@ -176,10 +176,6 @@ void init_pcpu_post(uint16_t pcpu_id)
|
|||||||
#endif
|
#endif
|
||||||
load_gdtr_and_tr();
|
load_gdtr_and_tr();
|
||||||
|
|
||||||
enable_smep();
|
|
||||||
|
|
||||||
enable_smap();
|
|
||||||
|
|
||||||
pcpu_xsave_init();
|
pcpu_xsave_init();
|
||||||
|
|
||||||
if (pcpu_id == BOOT_CPU_ID) {
|
if (pcpu_id == BOOT_CPU_ID) {
|
||||||
@ -256,6 +252,10 @@ void init_pcpu_post(uint16_t pcpu_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
setup_clos(pcpu_id);
|
setup_clos(pcpu_id);
|
||||||
|
|
||||||
|
enable_smep();
|
||||||
|
|
||||||
|
enable_smap();
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t get_pcpu_id_from_lapic_id(uint32_t lapic_id)
|
static uint16_t get_pcpu_id_from_lapic_id(uint32_t lapic_id)
|
||||||
|
@ -66,10 +66,10 @@ static void init_primary_pcpu_post(void)
|
|||||||
{
|
{
|
||||||
init_debug_pre();
|
init_debug_pre();
|
||||||
|
|
||||||
init_pcpu_post(BOOT_CPU_ID);
|
|
||||||
|
|
||||||
init_seed();
|
init_seed();
|
||||||
|
|
||||||
|
init_pcpu_post(BOOT_CPU_ID);
|
||||||
|
|
||||||
init_debug_post(BOOT_CPU_ID);
|
init_debug_post(BOOT_CPU_ID);
|
||||||
|
|
||||||
enter_guest_mode(BOOT_CPU_ID);
|
enter_guest_mode(BOOT_CPU_ID);
|
||||||
|
@ -288,14 +288,6 @@ void init_paging(void)
|
|||||||
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, (uint64_t)get_reserve_sworld_memory_base(),
|
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, (uint64_t)get_reserve_sworld_memory_base(),
|
||||||
TRUSTY_RAM_SIZE * (CONFIG_MAX_VM_NUM - 1U), PAGE_USER, 0UL, &ppt_mem_ops, MR_MODIFY);
|
TRUSTY_RAM_SIZE * (CONFIG_MAX_VM_NUM - 1U), PAGE_USER, 0UL, &ppt_mem_ops, MR_MODIFY);
|
||||||
|
|
||||||
#ifdef CONFIG_ACPI_PARSE_ENABLED
|
|
||||||
for (i = 0U; i < entries_count; i++) {
|
|
||||||
entry = p_e820 + i;
|
|
||||||
if ((entry->type == E820_TYPE_ACPI_RECLAIM) || (entry->type == E820_TYPE_RESERVED)) {
|
|
||||||
hv_access_memory_region_update(entry->baseaddr, entry->length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* Enable paging */
|
/* Enable paging */
|
||||||
enable_paging();
|
enable_paging();
|
||||||
|
|
||||||
|
@ -45,8 +45,6 @@ static uint32_t parse_seed_arg(void)
|
|||||||
uint32_t i = SEED_ARG_NUM - 1U;
|
uint32_t i = SEED_ARG_NUM - 1U;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
||||||
stac();
|
|
||||||
|
|
||||||
if (boot_regs[0U] == MULTIBOOT_INFO_MAGIC) {
|
if (boot_regs[0U] == MULTIBOOT_INFO_MAGIC) {
|
||||||
mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1U]);
|
mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1U]);
|
||||||
if (mbi != NULL) {
|
if (mbi != NULL) {
|
||||||
@ -79,8 +77,6 @@ static uint32_t parse_seed_arg(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clac();
|
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,6 @@ bool parse_seed_abl(uint64_t addr, struct physical_seed *phy_seed)
|
|||||||
struct abl_svn_seed *abl_seed = (struct abl_svn_seed *)hpa2hva(addr);
|
struct abl_svn_seed *abl_seed = (struct abl_svn_seed *)hpa2hva(addr);
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
stac();
|
|
||||||
|
|
||||||
if ((phy_seed != NULL) && (abl_seed != NULL) &&
|
if ((phy_seed != NULL) && (abl_seed != NULL) &&
|
||||||
(abl_seed->num_seeds >= 2U) && (abl_seed->num_seeds <= ABL_SEED_LIST_MAX)) {
|
(abl_seed->num_seeds >= 2U) && (abl_seed->num_seeds <= ABL_SEED_LIST_MAX)) {
|
||||||
|
|
||||||
@ -90,7 +88,5 @@ bool parse_seed_abl(uint64_t addr, struct physical_seed *phy_seed)
|
|||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
clac();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,6 @@ bool parse_seed_sbl(uint64_t addr, struct physical_seed *phy_seed)
|
|||||||
struct seed_info *seed_list = NULL;
|
struct seed_info *seed_list = NULL;
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
stac();
|
|
||||||
|
|
||||||
boot_params = (struct image_boot_params *)hpa2hva(addr);
|
boot_params = (struct image_boot_params *)hpa2hva(addr);
|
||||||
|
|
||||||
if (boot_params != NULL) {
|
if (boot_params != NULL) {
|
||||||
@ -115,7 +113,5 @@ bool parse_seed_sbl(uint64_t addr, struct physical_seed *phy_seed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clac();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,6 @@ uint64_t prepare_trampoline(void)
|
|||||||
pr_dbg("trampoline code: %llx size %x", dest_pa, size);
|
pr_dbg("trampoline code: %llx size %x", dest_pa, size);
|
||||||
|
|
||||||
/* Copy segment for AP initialization code below 1MB */
|
/* Copy segment for AP initialization code below 1MB */
|
||||||
stac();
|
|
||||||
(void)memcpy_s(hpa2hva(dest_pa), (size_t)size, &ld_trampoline_load,
|
(void)memcpy_s(hpa2hva(dest_pa), (size_t)size, &ld_trampoline_load,
|
||||||
(size_t)size);
|
(size_t)size);
|
||||||
update_trampoline_code_refs(dest_pa);
|
update_trampoline_code_refs(dest_pa);
|
||||||
@ -123,7 +122,6 @@ uint64_t prepare_trampoline(void)
|
|||||||
for (i = 0UL; i < size; i = i + CACHE_LINE_SIZE) {
|
for (i = 0UL; i < size; i = i + CACHE_LINE_SIZE) {
|
||||||
clflush(hpa2hva(dest_pa + i));
|
clflush(hpa2hva(dest_pa + i));
|
||||||
}
|
}
|
||||||
clac();
|
|
||||||
|
|
||||||
trampoline_start16_paddr = dest_pa;
|
trampoline_start16_paddr = dest_pa;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user