fix(linux): unmap rx/tx buffers from PVM
linux tests sometimes show instabilities at module unload:
[ 7.403546] Preparing to unload Hafnium
[ 7.422392] NET: Unregistered protocol family 19
WARNING: Stage-2 page fault: pc=0xffffdfc6d6ea4e30, vmid=0x1, vcpu=1,
vaddr=0xffff363cc121d040, ipaddr=0x4121d040, mode=0x2 0x3078305b00000061
NOTICE: Injecting Data Abort exception into VM 0x1.
[ 7.444236] Unable to handle kernel write to read-only memory at virtual
address ffff363cc121d040
[...]
[ 7.485983] Call trace:
[ 7.486921] allocate_slab+0x1d4/0x4b8
[ 7.487685] ___slab_alloc+0x1b0/0x34c
[ 7.488389] __kmalloc+0x298/0x30c
[ 7.489052] kzalloc+0x14/0x20
[ 7.489834] kobject_get_path+0x54/0xc0
[ 7.491293] kobject_uevent_env+0x108/0x428
[ 7.492150] kobject_uevent+0x14/0x20
[ 7.492851] device_release_driver_internal+0x20c/0x254
[ 7.493757] driver_detach+0x80/0xc0
[ 7.494534] bus_remove_driver+0x78/0xac
[ 7.495278] driver_unregister+0x30/0x54
[ 7.496000] platform_driver_unregister+0x14/0x20
Suspecting a stale access to RX/TX buffers after the pages are freed
from linux. Unmap the RX/TX buffers from hypervisor when module is
unloaded.
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I5c3ed88c7864fbc6ce40cc1e6a4f564ff25e7248
diff --git a/main.c b/main.c
index ed5a9e6..5cb1142 100644
--- a/main.c
+++ b/main.c
@@ -836,6 +836,7 @@
kfree(hf_vms);
ffa_rx_release();
+ ffa_rxtx_unmap();
if (hf_send_page) {
__free_page(hf_send_page);
hf_send_page = NULL;
@@ -1006,9 +1007,7 @@
}
/*
- * Configure both addresses. Once configured, we cannot free these pages
- * because the hypervisor will use them, even if the module is
- * unloaded.
+ * Map RX/TX buffers to hypervisor.
*/
ffa_ret = ffa_rxtx_map(page_to_phys(hf_send_page),
page_to_phys(hf_recv_page));