xen: use correct cache attributes for Xen specific memory regions
bus_activate_resource maps memory regions as uncacheable on x86, which is more strict than required for regions allocated using xenmem_alloc, so don't rely on bus_activate_resource and instead map the region using pmap_mapdev_attr and VM_MEMATTR_XEN as the cache attribute. Sponsored by: Citrix Systems R&D
This commit is contained in:
parent
080c6fdc0c
commit
f4c6843ec2
@ -120,10 +120,11 @@ xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size)
|
||||
{
|
||||
struct resource *res;
|
||||
vm_paddr_t phys_addr;
|
||||
void *virt_addr;
|
||||
int error;
|
||||
|
||||
res = bus_alloc_resource(child, SYS_RES_MEMORY, res_id, LOW_MEM_LIMIT,
|
||||
~0, size, RF_ACTIVE);
|
||||
~0, size, RF_ACTIVE | RF_UNMAPPED);
|
||||
if (res == NULL)
|
||||
return (NULL);
|
||||
|
||||
@ -134,6 +135,9 @@ xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size)
|
||||
bus_release_resource(child, SYS_RES_MEMORY, *res_id, res);
|
||||
return (NULL);
|
||||
}
|
||||
virt_addr = pmap_mapdev_attr(phys_addr, size, VM_MEMATTR_XEN);
|
||||
KASSERT(virt_addr != NULL, ("Failed to create linear mappings"));
|
||||
rman_set_virtual(res, virt_addr);
|
||||
|
||||
return (res);
|
||||
}
|
||||
@ -142,11 +146,14 @@ static int
|
||||
xenpv_free_physmem(device_t dev, device_t child, int res_id, struct resource *res)
|
||||
{
|
||||
vm_paddr_t phys_addr;
|
||||
vm_offset_t virt_addr;
|
||||
size_t size;
|
||||
|
||||
phys_addr = rman_get_start(res);
|
||||
size = rman_get_size(res);
|
||||
virt_addr = (vm_offset_t)rman_get_virtual(res);
|
||||
|
||||
pmap_unmapdev(virt_addr, size);
|
||||
vm_phys_fictitious_unreg_range(phys_addr, phys_addr + size);
|
||||
return (bus_release_resource(child, SYS_RES_MEMORY, res_id, res));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user