mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-17 10:26:15 +00:00
Use the max guest memory address when creating its iommu domain.
Also, assert that the GPA being mapped in the domain is less than its maxaddr. Reviewed by: grehan Pointed out by: Anish Gupta (akgupt3@gmail.com)
This commit is contained in:
parent
c8c5946a57
commit
477867a0e5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=269962
@ -448,6 +448,11 @@ vtd_update_mapping(void *arg, vm_paddr_t gpa, vm_paddr_t hpa, uint64_t len,
|
||||
ptpindex = 0;
|
||||
ptpshift = 0;
|
||||
|
||||
KASSERT(gpa + len > gpa, ("%s: invalid gpa range %#lx/%#lx", __func__,
|
||||
gpa, len));
|
||||
KASSERT(gpa + len <= dom->maxaddr, ("%s: gpa range %#lx/%#lx beyond "
|
||||
"domain maxaddr %#lx", __func__, gpa, len, dom->maxaddr));
|
||||
|
||||
if (gpa & PAGE_MASK)
|
||||
panic("vtd_create_mapping: unaligned gpa 0x%0lx", gpa);
|
||||
|
||||
|
@ -572,6 +572,21 @@ vm_malloc(struct vm *vm, vm_paddr_t gpa, size_t len)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static vm_paddr_t
|
||||
vm_maxmem(struct vm *vm)
|
||||
{
|
||||
int i;
|
||||
vm_paddr_t gpa, maxmem;
|
||||
|
||||
maxmem = 0;
|
||||
for (i = 0; i < vm->num_mem_segs; i++) {
|
||||
gpa = vm->mem_segs[i].gpa + vm->mem_segs[i].len;
|
||||
if (gpa > maxmem)
|
||||
maxmem = gpa;
|
||||
}
|
||||
return (maxmem);
|
||||
}
|
||||
|
||||
static void
|
||||
vm_gpa_unwire(struct vm *vm)
|
||||
{
|
||||
@ -709,7 +724,7 @@ vm_assign_pptdev(struct vm *vm, int bus, int slot, int func)
|
||||
if (ppt_assigned_devices(vm) == 0) {
|
||||
KASSERT(vm->iommu == NULL,
|
||||
("vm_assign_pptdev: iommu must be NULL"));
|
||||
maxaddr = vmm_mem_maxaddr();
|
||||
maxaddr = vm_maxmem(vm);
|
||||
vm->iommu = iommu_create_domain(maxaddr);
|
||||
|
||||
error = vm_gpa_wire(vm);
|
||||
|
Loading…
Reference in New Issue
Block a user