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:
Li, Fei1
2018-10-17 19:59:36 +08:00
committed by wenlingz
parent 49b476bb56
commit 70ddca3a87
5 changed files with 16 additions and 20 deletions

View File

@@ -134,6 +134,7 @@ static inline void clflush(volatile void *p)
* host physical address width is 52
*/
#define INVALID_HPA (0x1UL << 52U)
#define INVALID_GPA (0x1UL << 52U)
/* External Interfaces */
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
*/
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,
uint64_t gpa, uint64_t size, uint64_t prot_orig);
void ept_mr_modify(struct vm *vm, uint64_t *pml4_page, uint64_t gpa,

View File

@@ -45,7 +45,7 @@ static inline void *gpa2hva(struct vm *vm, uint64_t 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 */