The branch main has been updated by royger:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f4c6843ec2b9aa5eff475778fb000ed6278c5b77

commit f4c6843ec2b9aa5eff475778fb000ed6278c5b77
Author:     Roger Pau Monné <[email protected]>
AuthorDate: 2021-04-09 09:31:44 +0000
Commit:     Roger Pau Monné <[email protected]>
CommitDate: 2021-08-12 07:18:32 +0000

    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
---
 sys/dev/xen/bus/xenpv.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/dev/xen/bus/xenpv.c b/sys/dev/xen/bus/xenpv.c
index 42f2c88a2885..91004039a85e 100644
--- a/sys/dev/xen/bus/xenpv.c
+++ b/sys/dev/xen/bus/xenpv.c
@@ -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));
 }
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "[email protected]"

Reply via email to