Skip to content

Commit e63d32a

Browse files
ZideChen0acrnsi
authored andcommitted
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>
1 parent 9e91f14 commit e63d32a

File tree

7 files changed

+6
-28
lines changed

7 files changed

+6
-28
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,6 @@ void init_pcpu_post(uint16_t pcpu_id)
176176
#endif
177177
load_gdtr_and_tr();
178178

179-
enable_smep();
180-
181-
enable_smap();
182-
183179
pcpu_xsave_init();
184180

185181
if (pcpu_id == BOOT_CPU_ID) {
@@ -256,6 +252,10 @@ void init_pcpu_post(uint16_t pcpu_id)
256252
}
257253

258254
setup_clos(pcpu_id);
255+
256+
enable_smep();
257+
258+
enable_smap();
259259
}
260260

261261
static uint16_t get_pcpu_id_from_lapic_id(uint32_t lapic_id)

hypervisor/arch/x86/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ static void init_primary_pcpu_post(void)
6666
{
6767
init_debug_pre();
6868

69-
init_pcpu_post(BOOT_CPU_ID);
70-
7169
init_seed();
7270

71+
init_pcpu_post(BOOT_CPU_ID);
72+
7373
init_debug_post(BOOT_CPU_ID);
7474

7575
enter_guest_mode(BOOT_CPU_ID);

hypervisor/arch/x86/mmu.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,6 @@ void init_paging(void)
288288
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, (uint64_t)get_reserve_sworld_memory_base(),
289289
TRUSTY_RAM_SIZE * (CONFIG_MAX_VM_NUM - 1U), PAGE_USER, 0UL, &ppt_mem_ops, MR_MODIFY);
290290

291-
#ifdef CONFIG_ACPI_PARSE_ENABLED
292-
for (i = 0U; i < entries_count; i++) {
293-
entry = p_e820 + i;
294-
if ((entry->type == E820_TYPE_ACPI_RECLAIM) || (entry->type == E820_TYPE_RESERVED)) {
295-
hv_access_memory_region_update(entry->baseaddr, entry->length);
296-
}
297-
}
298-
#endif
299291
/* Enable paging */
300292
enable_paging();
301293

hypervisor/arch/x86/seed/seed.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ static uint32_t parse_seed_arg(void)
4545
uint32_t i = SEED_ARG_NUM - 1U;
4646
uint32_t len;
4747

48-
stac();
49-
5048
if (boot_regs[0U] == MULTIBOOT_INFO_MAGIC) {
5149
mbi = (struct multiboot_info *)hpa2hva((uint64_t)boot_regs[1U]);
5250
if (mbi != NULL) {
@@ -79,8 +77,6 @@ static uint32_t parse_seed_arg(void)
7977
}
8078
}
8179

82-
clac();
83-
8480
return i;
8581
}
8682

hypervisor/arch/x86/seed/seed_abl.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ bool parse_seed_abl(uint64_t addr, struct physical_seed *phy_seed)
4848
struct abl_svn_seed *abl_seed = (struct abl_svn_seed *)hpa2hva(addr);
4949
bool status = false;
5050

51-
stac();
52-
5351
if ((phy_seed != NULL) && (abl_seed != NULL) &&
5452
(abl_seed->num_seeds >= 2U) && (abl_seed->num_seeds <= ABL_SEED_LIST_MAX)) {
5553

@@ -90,7 +88,5 @@ bool parse_seed_abl(uint64_t addr, struct physical_seed *phy_seed)
9088
status = true;
9189
}
9290

93-
clac();
94-
9591
return status;
9692
}

hypervisor/arch/x86/seed/seed_sbl.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ bool parse_seed_sbl(uint64_t addr, struct physical_seed *phy_seed)
6868
struct seed_info *seed_list = NULL;
6969
bool status = false;
7070

71-
stac();
72-
7371
boot_params = (struct image_boot_params *)hpa2hva(addr);
7472

7573
if (boot_params != NULL) {
@@ -115,7 +113,5 @@ bool parse_seed_sbl(uint64_t addr, struct physical_seed *phy_seed)
115113
}
116114
}
117115

118-
clac();
119-
120116
return status;
121117
}

hypervisor/arch/x86/trampoline.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,13 @@ uint64_t prepare_trampoline(void)
115115
pr_dbg("trampoline code: %llx size %x", dest_pa, size);
116116

117117
/* Copy segment for AP initialization code below 1MB */
118-
stac();
119118
(void)memcpy_s(hpa2hva(dest_pa), (size_t)size, &ld_trampoline_load,
120119
(size_t)size);
121120
update_trampoline_code_refs(dest_pa);
122121

123122
for (i = 0UL; i < size; i = i + CACHE_LINE_SIZE) {
124123
clflush(hpa2hva(dest_pa + i));
125124
}
126-
clac();
127125

128126
trampoline_start16_paddr = dest_pa;
129127

0 commit comments

Comments
 (0)