hv: pae: fix bug when calculate PDPT address

There are two bugs related to PDPT address calculation for PAE mode.

1. Current code doesn't ignore the "Ignored" fileds when load pdpt registers.
Mask the "Ignored" fileds according to SDM Figure 4-7 Vol3.

2. Current code only ignores 4bits instead of 5bits in low "Ignored" filed when
calculate PDPT address in PAE mode for guest memory address translation.

Tracked-On: #2561
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Binbin Wu 2019-02-19 17:05:23 +08:00 committed by wenlingz
parent 21ae3e7451
commit 253852419a
3 changed files with 7 additions and 2 deletions

View File

@ -211,7 +211,7 @@ static int32_t local_gva2gpa_pae(struct acrn_vcpu *vcpu, struct page_walk_info *
uint64_t addr;
int32_t ret = -EFAULT;
addr = pw_info->top_entry & 0xFFFFFFF0U;
addr = get_pae_pdpt_addr(pw_info->top_entry);
base = (uint64_t *)gpa2hva(vcpu->vm, addr);
if (base != NULL) {
index = (gva >> 30U) & 0x3UL;

View File

@ -43,7 +43,7 @@ static void load_pdptrs(const struct acrn_vcpu *vcpu)
{
uint64_t guest_cr3 = exec_vmread(VMX_GUEST_CR3);
/* TODO: check whether guest cr3 is valid */
uint64_t *guest_cr3_hva = (uint64_t *)gpa2hva(vcpu->vm, guest_cr3);
uint64_t *guest_cr3_hva = (uint64_t *)gpa2hva(vcpu->vm, get_pae_pdpt_addr(guest_cr3));
stac();
exec_vmwrite64(VMX_GUEST_PDPTE0_FULL, get_pgentry(guest_cr3_hva + 0UL));

View File

@ -176,6 +176,11 @@ static inline void clflush(volatile void *p)
asm volatile ("clflush (%0)" :: "r"(p));
}
/* get PDPT address from CR3 vaule in PAE mode */
static inline uint64_t get_pae_pdpt_addr(uint64_t cr3)
{
return (cr3 & 0xFFFFFFE0UL);
}
/**
* @}