diff options
author | neel <neel@FreeBSD.org> | 2012-10-03 01:18:51 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2012-10-03 01:18:51 +0000 |
commit | 77ab4804ac42198ff996def6bc2d7acc841626a5 (patch) | |
tree | d29d281e1e26f6804bb0ef51c890f15893e3d79d /sys/amd64 | |
parent | 3e50e0220bcda77b0a8e06a5f6095a206368e01b (diff) | |
download | FreeBSD-src-77ab4804ac42198ff996def6bc2d7acc841626a5.zip FreeBSD-src-77ab4804ac42198ff996def6bc2d7acc841626a5.tar.gz |
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.
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/vmm/vmm.c | 5 | ||||
-rw-r--r-- | sys/amd64/vmm/vmm_instruction_emul.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index 62bb753..3dabbd6 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -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)); } diff --git a/sys/amd64/vmm/vmm_instruction_emul.c b/sys/amd64/vmm/vmm_instruction_emul.c index 66af72c..7ef4dbb 100644 --- a/sys/amd64/vmm/vmm_instruction_emul.c +++ b/sys/amd64/vmm/vmm_instruction_emul.c @@ -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) |