Skip to content

Commit 93fa2bc

Browse files
ZideChen0wenlingz
authored andcommitted
hv: minor fixes in init_paging()
- change variable name from hpa to hva because in this function we are dealing with hva, not hpa. - can get the address of ld_text_end by directly referring to this symbol, because relative addressing yields the correct hva, not the hva before relocation. Tracked-On: #4441 Signed-off-by: Zide Chen <zide.chen@intel.com>
1 parent 734ad6c commit 93fa2bc

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

hypervisor/arch/x86/mmu.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void hv_access_memory_region_update(uint64_t base, uint64_t size)
211211

212212
void init_paging(void)
213213
{
214-
uint64_t hv_hpa, text_end, size;
214+
uint64_t hv_hva;
215215
uint32_t i;
216216
uint64_t low32_max_ram = 0UL;
217217
uint64_t high64_max_ram;
@@ -265,19 +265,17 @@ void init_paging(void)
265265
* Before the new PML4 take effect in enable_paging(), HPA->HVA is always 1:1 mapping,
266266
* simply treat the return value of get_hv_image_base() as HPA.
267267
*/
268-
hv_hpa = get_hv_image_base();
269-
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, hv_hpa & PDE_MASK,
270-
CONFIG_HV_RAM_SIZE + (((hv_hpa & (PDE_SIZE - 1UL)) != 0UL) ? PDE_SIZE : 0UL),
268+
hv_hva = get_hv_image_base();
269+
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, hv_hva & PDE_MASK,
270+
CONFIG_HV_RAM_SIZE + (((hv_hva & (PDE_SIZE - 1UL)) != 0UL) ? PDE_SIZE : 0UL),
271271
PAGE_CACHE_WB, PAGE_CACHE_MASK | PAGE_USER, &ppt_mem_ops, MR_MODIFY);
272272

273-
size = ((uint64_t)&ld_text_end - hv_hpa);
274-
text_end = hv_hpa + size;
275273
/*
276274
* remove 'NX' bit for pages that contain hv code section, as by default XD bit is set for
277275
* all pages, including pages for guests.
278276
*/
279-
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, round_pde_down(hv_hpa),
280-
round_pde_up(text_end) - round_pde_down(hv_hpa), 0UL,
277+
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, round_pde_down(hv_hva),
278+
round_pde_up((uint64_t)&ld_text_end) - round_pde_down(hv_hva), 0UL,
281279
PAGE_NX, &ppt_mem_ops, MR_MODIFY);
282280

283281
mmu_modify_or_del((uint64_t *)ppt_mmu_pml4_addr, (uint64_t)get_reserve_sworld_memory_base(),

0 commit comments

Comments
 (0)