mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 12:42:54 +00:00
hv: mmu: add pre-assumption for hpa2gpa
They're: (a) only SOS would use hpa2gpa and (b) the GPA and HPA in SOS is identical mapping. Rename hpa2gpa to vm0_hpa2gpa then. Tracked-On: #1124 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
parent
49b476bb56
commit
70ddca3a87
@ -103,19 +103,12 @@ uint64_t gpa2hpa(struct vm *vm, uint64_t gpa)
|
|||||||
return local_gpa2hpa(vm, gpa, NULL);
|
return local_gpa2hpa(vm, gpa, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t hpa2gpa(struct vm *vm, uint64_t hpa)
|
/**
|
||||||
|
* @pre: the gpa and hpa are identical mapping in SOS.
|
||||||
|
*/
|
||||||
|
uint64_t vm0_hpa2gpa(uint64_t hpa)
|
||||||
{
|
{
|
||||||
uint64_t *pgentry, pg_size = 0UL;
|
return hpa;
|
||||||
|
|
||||||
pgentry = lookup_address((uint64_t *)vm->arch_vm.m2p,
|
|
||||||
hpa, &pg_size, PTT_EPT);
|
|
||||||
if (pgentry == NULL) {
|
|
||||||
pr_err("VM %d hpa2gpa: failed for hpa 0x%llx",
|
|
||||||
vm->vm_id, hpa);
|
|
||||||
ASSERT(false, "hpa2gpa not found");
|
|
||||||
}
|
|
||||||
return ((*pgentry & (~(pg_size - 1UL)))
|
|
||||||
| (hpa & (pg_size - 1UL)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ept_violation_vmexit_handler(struct vcpu *vcpu)
|
int ept_violation_vmexit_handler(struct vcpu *vcpu)
|
||||||
|
@ -131,7 +131,8 @@ static void create_secure_world_ept(struct vm *vm, uint64_t gpa_orig,
|
|||||||
hpa, gpa_rebased, size, EPT_RWX | EPT_WB);
|
hpa, gpa_rebased, size, EPT_RWX | EPT_WB);
|
||||||
|
|
||||||
/* Get the gpa address in SOS */
|
/* Get the gpa address in SOS */
|
||||||
gpa = hpa2gpa(vm0, hpa);
|
gpa = vm0_hpa2gpa(hpa);
|
||||||
|
|
||||||
/* Unmap trusty memory space from sos ept mapping*/
|
/* Unmap trusty memory space from sos ept mapping*/
|
||||||
ept_mr_del(vm0, (uint64_t *)vm0->arch_vm.nworld_eptp,
|
ept_mr_del(vm0, (uint64_t *)vm0->arch_vm.nworld_eptp,
|
||||||
gpa, size);
|
gpa, size);
|
||||||
|
@ -140,7 +140,7 @@ bool sbl_seed_parse(struct vm *vm, char *cmdline, char *out_arg, uint32_t out_le
|
|||||||
struct image_boot_params *boot_params;
|
struct image_boot_params *boot_params;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
||||||
if (cmdline == NULL) {
|
if (!is_vm0(vm) || (cmdline == NULL)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,10 +165,8 @@ bool sbl_seed_parse(struct vm *vm, char *cmdline, char *out_arg, uint32_t out_le
|
|||||||
* Convert the addresses to SOS GPA since this structure will
|
* Convert the addresses to SOS GPA since this structure will
|
||||||
* be used in SOS.
|
* be used in SOS.
|
||||||
*/
|
*/
|
||||||
boot_params->p_seed_list =
|
boot_params->p_seed_list = vm0_hpa2gpa(boot_params->p_seed_list);
|
||||||
hpa2gpa(vm, boot_params->p_seed_list);
|
boot_params->p_platform_info = vm0_hpa2gpa(boot_params->p_platform_info);
|
||||||
boot_params->p_platform_info =
|
|
||||||
hpa2gpa(vm, boot_params->p_platform_info);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Replace original arguments with spaces since SOS's GPA is not
|
* Replace original arguments with spaces since SOS's GPA is not
|
||||||
|
@ -134,6 +134,7 @@ static inline void clflush(volatile void *p)
|
|||||||
* host physical address width is 52
|
* host physical address width is 52
|
||||||
*/
|
*/
|
||||||
#define INVALID_HPA (0x1UL << 52U)
|
#define INVALID_HPA (0x1UL << 52U)
|
||||||
|
#define INVALID_GPA (0x1UL << 52U)
|
||||||
/* External Interfaces */
|
/* External Interfaces */
|
||||||
void destroy_ept(struct vm *vm);
|
void destroy_ept(struct vm *vm);
|
||||||
/**
|
/**
|
||||||
@ -146,7 +147,10 @@ uint64_t gpa2hpa(struct vm *vm, uint64_t gpa);
|
|||||||
* @return hpa - the HPA of parameter gpa is hpa
|
* @return hpa - the HPA of parameter gpa is hpa
|
||||||
*/
|
*/
|
||||||
uint64_t local_gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size);
|
uint64_t local_gpa2hpa(struct vm *vm, uint64_t gpa, uint32_t *size);
|
||||||
uint64_t hpa2gpa(struct vm *vm, uint64_t hpa);
|
/**
|
||||||
|
* @pre: the gpa and hpa are identical mapping in SOS.
|
||||||
|
*/
|
||||||
|
uint64_t vm0_hpa2gpa(uint64_t hpa);
|
||||||
void ept_mr_add(struct vm *vm, uint64_t *pml4_page, uint64_t hpa,
|
void ept_mr_add(struct vm *vm, uint64_t *pml4_page, uint64_t hpa,
|
||||||
uint64_t gpa, uint64_t size, uint64_t prot_orig);
|
uint64_t gpa, uint64_t size, uint64_t prot_orig);
|
||||||
void ept_mr_modify(struct vm *vm, uint64_t *pml4_page, uint64_t gpa,
|
void ept_mr_modify(struct vm *vm, uint64_t *pml4_page, uint64_t gpa,
|
||||||
|
@ -45,7 +45,7 @@ static inline void *gpa2hva(struct vm *vm, uint64_t x)
|
|||||||
|
|
||||||
static inline uint64_t hva2gpa(struct vm *vm, void *x)
|
static inline uint64_t hva2gpa(struct vm *vm, void *x)
|
||||||
{
|
{
|
||||||
return hpa2gpa(vm, hva2hpa(x));
|
return (is_vm0(vm)) ? vm0_hpa2gpa(hva2hpa(x)) : INVALID_GPA;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !ASSEMBLER */
|
#endif /* !ASSEMBLER */
|
||||||
|
Loading…
Reference in New Issue
Block a user