From c48e13e1c07331e4999e21920d32550f0270bd9f Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Wed, 25 May 2016 11:19:03 +0200 Subject: [PATCH] platform_drv: return quota when freeing dma memory This is an interim fix for solving the quota leakage problem of the platform driver on x86 platforms. To properly fix that problem one has to track which dataspaces where created by the platform driver, so that freeing the dataspace and reversing the quota transfer is done on correct dataspaces only. Refer #1980 --- .../drivers/platform/spec/x86/pci_session_component.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/repos/os/src/drivers/platform/spec/x86/pci_session_component.h b/repos/os/src/drivers/platform/spec/x86/pci_session_component.h index 78212e0baf..2c0cd2d849 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_session_component.h +++ b/repos/os/src/drivers/platform/spec/x86/pci_session_component.h @@ -842,8 +842,17 @@ namespace Platform { void free_dma_buffer(Ram_capability ram) { - if (ram.valid()) + /* + * FIXME: proof that the ram cap come from us, + * otherwise we get bookkeeping errors + */ + if (ram.valid()) { + Genode::size_t size = Genode::Dataspace_client(ram).size(); _resources.ram().free(ram); + if (_resources.ram().transfer_quota(Genode::env()->ram_session_cap(), size)) + throw Fatal(); + _md_alloc.upgrade(size); + } } Device_capability device(String const &name) override;