Get rid of assumptions in the hypervisor that the host physical memory
associated with guest physical memory is contiguous. Add check to vm_gpa2hpa() that the range indicated by [gpa,gpa+len) is all contained within a single 4KB page.
This commit is contained in:
parent
3e50e0220b
commit
77ab4804ac
@ -404,6 +404,11 @@ vm_malloc(struct vm *vm, vm_paddr_t gpa, size_t len)
|
||||
vm_paddr_t
|
||||
vm_gpa2hpa(struct vm *vm, vm_paddr_t gpa, size_t len)
|
||||
{
|
||||
vm_paddr_t nextpage;
|
||||
|
||||
nextpage = rounddown(gpa + PAGE_SIZE, PAGE_SIZE);
|
||||
if (len > nextpage - gpa)
|
||||
panic("vm_gpa2hpa: invalid gpa/len: 0x%016lx/%lu", gpa, len);
|
||||
|
||||
return (VMMMAP_GET(vm->cookie, gpa));
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ vmm_fetch_instruction(struct vm *vm, uint64_t rip, int inst_length,
|
||||
uint64_t cr3, struct vie *vie)
|
||||
{
|
||||
int n, err;
|
||||
uint64_t hpa, gpa, gpaend;
|
||||
uint64_t hpa, gpa, gpaend, off;
|
||||
|
||||
/*
|
||||
* XXX cache previously fetched instructions using 'rip' as the tag
|
||||
@ -150,7 +150,8 @@ vmm_fetch_instruction(struct vm *vm, uint64_t rip, int inst_length,
|
||||
if (err)
|
||||
break;
|
||||
|
||||
n = min(inst_length - vie->num_valid, gpaend - gpa);
|
||||
off = gpa & PAGE_MASK;
|
||||
n = min(inst_length - vie->num_valid, PAGE_SIZE - off);
|
||||
|
||||
hpa = vm_gpa2hpa(vm, gpa, n);
|
||||
if (hpa == -1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user