From 58e4f6cf9deea0fa2ac1da9632c4875a3e641df2 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 2 Aug 2017 17:30:49 +0200 Subject: [PATCH] core: add map method to pd_session interface The method can be used to trigger the eager insertion of page frames into page tables. Intention: to be used for memory used for DMA. Issue #2209 --- repos/base-fiasco/lib/mk/core-fiasco.inc | 4 ++-- repos/base-foc/lib/mk/core-foc.inc | 4 ++-- repos/base-hw/lib/mk/core-hw.inc | 2 +- repos/base-linux/src/core/linux/target.mk | 4 ++-- repos/base-nova/lib/mk/core-nova.inc | 2 +- ...pd_assign_pci.cc => pd_session_support.cc} | 3 +++ repos/base-okl4/lib/mk/core-okl4.inc | 4 ++-- .../base-pistachio/lib/mk/core-pistachio.inc | 4 ++-- repos/base-sel4/lib/mk/core-sel4.inc | 4 ++-- repos/base/include/pd_session/client.h | 2 ++ repos/base/include/pd_session/pd_session.h | 19 ++++++++++++++++++- .../src/core/include/pd_session_component.h | 1 + ...pd_assign_pci.cc => pd_session_support.cc} | 4 +++- .../app/gdb_monitor/pd_session_component.h | 3 +++ repos/ports/src/noux/pd_session_component.h | 3 +++ 15 files changed, 47 insertions(+), 16 deletions(-) rename repos/base-nova/src/core/{pd_assign_pci.cc => pd_session_support.cc} (94%) rename repos/base/src/core/{pd_assign_pci.cc => pd_session_support.cc} (89%) diff --git a/repos/base-fiasco/lib/mk/core-fiasco.inc b/repos/base-fiasco/lib/mk/core-fiasco.inc index b2bd083af2..b887d67912 100644 --- a/repos/base-fiasco/lib/mk/core-fiasco.inc +++ b/repos/base-fiasco/lib/mk/core-fiasco.inc @@ -23,7 +23,7 @@ SRC_CC += stack_area.cc \ pager_object.cc \ rpc_cap_factory_l4.cc \ ram_dataspace_factory.cc \ - pd_assign_pci.cc \ + pd_session_support.cc \ platform.cc \ platform_pd.cc \ platform_services.cc \ @@ -60,7 +60,7 @@ vpath rpc_cap_factory_l4.cc $(GEN_CORE_DIR) vpath ram_dataspace_factory.cc $(GEN_CORE_DIR) vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR) vpath core_region_map.cc $(GEN_CORE_DIR) -vpath pd_assign_pci.cc $(GEN_CORE_DIR) +vpath pd_session_support.cc $(GEN_CORE_DIR) vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR) vpath region_map_component.cc $(GEN_CORE_DIR) vpath io_mem_session_component.cc $(GEN_CORE_DIR) diff --git a/repos/base-foc/lib/mk/core-foc.inc b/repos/base-foc/lib/mk/core-foc.inc index 371bb832d6..379ab28038 100644 --- a/repos/base-foc/lib/mk/core-foc.inc +++ b/repos/base-foc/lib/mk/core-foc.inc @@ -19,7 +19,7 @@ SRC_CC += stack_area.cc \ main.cc \ pager.cc \ pager_object.cc \ - pd_assign_pci.cc \ + pd_session_support.cc \ native_cpu_component.cc \ rpc_cap_factory.cc \ platform.cc \ @@ -55,7 +55,7 @@ vpath default_log.cc $(GEN_CORE_DIR) vpath io_mem_session_component.cc $(GEN_CORE_DIR) vpath io_mem_session_support.cc $(GEN_CORE_DIR) vpath main.cc $(GEN_CORE_DIR) -vpath pd_assign_pci.cc $(GEN_CORE_DIR) +vpath pd_session_support.cc $(GEN_CORE_DIR) vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR) vpath pd_session_component.cc $(GEN_CORE_DIR) vpath region_map_component.cc $(GEN_CORE_DIR) diff --git a/repos/base-hw/lib/mk/core-hw.inc b/repos/base-hw/lib/mk/core-hw.inc index 23269b1558..36ddfd27c8 100644 --- a/repos/base-hw/lib/mk/core-hw.inc +++ b/repos/base-hw/lib/mk/core-hw.inc @@ -30,7 +30,7 @@ SRC_CC += io_mem_session_support.cc SRC_CC += irq_session_component.cc SRC_CC += main.cc SRC_CC += native_pd_component.cc -SRC_CC += pd_assign_pci.cc +SRC_CC += pd_session_support.cc SRC_CC += platform.cc SRC_CC += platform_pd.cc SRC_CC += platform_thread.cc diff --git a/repos/base-linux/src/core/linux/target.mk b/repos/base-linux/src/core/linux/target.mk index 1e7ed7b2cc..cc6830d661 100644 --- a/repos/base-linux/src/core/linux/target.mk +++ b/repos/base-linux/src/core/linux/target.mk @@ -14,7 +14,7 @@ SRC_CC = main.cc \ cpu_session_component.cc \ cpu_session_support.cc \ cpu_thread_component.cc \ - pd_assign_pci.cc \ + pd_session_support.cc \ dataspace_component.cc \ native_pd_component.cc \ native_cpu_component.cc \ @@ -52,7 +52,7 @@ vpath cpu_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_support.cc $(GEN_CORE_DIR) vpath cpu_thread_component.cc $(GEN_CORE_DIR) vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR) -vpath pd_assign_pci.cc $(GEN_CORE_DIR) +vpath pd_session_support.cc $(GEN_CORE_DIR) vpath capability_space.cc $(GEN_CORE_DIR) vpath rpc_cap_factory_l4.cc $(GEN_CORE_DIR) vpath ram_dataspace_factory.cc $(GEN_CORE_DIR) diff --git a/repos/base-nova/lib/mk/core-nova.inc b/repos/base-nova/lib/mk/core-nova.inc index 989bd28d41..73b70ffdaa 100644 --- a/repos/base-nova/lib/mk/core-nova.inc +++ b/repos/base-nova/lib/mk/core-nova.inc @@ -24,7 +24,7 @@ SRC_CC += stack_area.cc \ pager.cc \ native_cpu_component.cc \ native_pd_component.cc \ - pd_assign_pci.cc \ + pd_session_support.cc \ rpc_cap_factory.cc \ ram_dataspace_factory.cc \ platform.cc \ diff --git a/repos/base-nova/src/core/pd_assign_pci.cc b/repos/base-nova/src/core/pd_session_support.cc similarity index 94% rename from repos/base-nova/src/core/pd_assign_pci.cc rename to repos/base-nova/src/core/pd_session_support.cc index 250b0848b4..fe253c4beb 100644 --- a/repos/base-nova/src/core/pd_assign_pci.cc +++ b/repos/base-nova/src/core/pd_session_support.cc @@ -30,3 +30,6 @@ bool Pd_session_component::assign_pci(addr_t pci_config_memory, uint16_t bdf) return res == Nova::NOVA_OK; } + + +void Pd_session_component::map(addr_t, addr_t) { } diff --git a/repos/base-okl4/lib/mk/core-okl4.inc b/repos/base-okl4/lib/mk/core-okl4.inc index b4e50cab72..f591e69df6 100644 --- a/repos/base-okl4/lib/mk/core-okl4.inc +++ b/repos/base-okl4/lib/mk/core-okl4.inc @@ -24,7 +24,7 @@ SRC_CC += stack_area.cc \ pager.cc \ pager_ep.cc \ pager_object.cc \ - pd_assign_pci.cc \ + pd_session_support.cc \ rpc_cap_factory_l4.cc \ ram_dataspace_factory.cc \ platform.cc \ @@ -57,7 +57,7 @@ vpath capability_space.cc $(GEN_CORE_DIR) vpath rpc_cap_factory_l4.cc $(GEN_CORE_DIR) vpath ram_dataspace_factory.cc $(GEN_CORE_DIR) vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR) -vpath pd_assign_pci.cc $(GEN_CORE_DIR) +vpath pd_session_support.cc $(GEN_CORE_DIR) vpath region_map_component.cc $(GEN_CORE_DIR) vpath io_mem_session_component.cc $(GEN_CORE_DIR) vpath io_mem_session_support.cc $(GEN_CORE_DIR) diff --git a/repos/base-pistachio/lib/mk/core-pistachio.inc b/repos/base-pistachio/lib/mk/core-pistachio.inc index dca36427a5..1d2dc822cb 100644 --- a/repos/base-pistachio/lib/mk/core-pistachio.inc +++ b/repos/base-pistachio/lib/mk/core-pistachio.inc @@ -21,7 +21,7 @@ SRC_CC = stack_area.cc \ main.cc \ rpc_cap_factory_l4.cc \ ram_dataspace_factory.cc \ - pd_assign_pci.cc \ + pd_session_support.cc \ pager.cc \ pager_ep.cc \ pager_object.cc \ @@ -51,7 +51,7 @@ vpath rom_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_support.cc $(GEN_CORE_DIR) vpath cpu_thread_component.cc $(GEN_CORE_DIR) -vpath pd_assign_pci.cc $(GEN_CORE_DIR) +vpath pd_session_support.cc $(GEN_CORE_DIR) vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR) vpath region_map_component.cc $(GEN_CORE_DIR) vpath rpc_cap_factory_l4.cc $(GEN_CORE_DIR) diff --git a/repos/base-sel4/lib/mk/core-sel4.inc b/repos/base-sel4/lib/mk/core-sel4.inc index acf2b1c05a..97f6caef28 100644 --- a/repos/base-sel4/lib/mk/core-sel4.inc +++ b/repos/base-sel4/lib/mk/core-sel4.inc @@ -10,7 +10,7 @@ SRC_CC += \ cpu_thread_component.cc \ rpc_cap_factory.cc \ ram_dataspace_factory.cc \ - pd_assign_pci.cc \ + pd_session_support.cc \ io_mem_session_component.cc \ io_mem_session_support.cc \ thread_start.cc \ @@ -48,7 +48,7 @@ vpath rom_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_component.cc $(GEN_CORE_DIR) vpath cpu_session_support.cc $(GEN_CORE_DIR) vpath cpu_thread_component.cc $(GEN_CORE_DIR) -vpath pd_assign_pci.cc $(GEN_CORE_DIR) +vpath pd_session_support.cc $(GEN_CORE_DIR) vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR) vpath region_map_component.cc $(GEN_CORE_DIR) vpath io_mem_session_component.cc $(GEN_CORE_DIR) diff --git a/repos/base/include/pd_session/client.h b/repos/base/include/pd_session/client.h index 0261c9267a..0b6e27363f 100644 --- a/repos/base/include/pd_session/client.h +++ b/repos/base/include/pd_session/client.h @@ -31,6 +31,8 @@ struct Genode::Pd_session_client : Rpc_client bool assign_pci(addr_t pci_config_memory_address, uint16_t bdf) override { return call(pci_config_memory_address, bdf); } + void map(addr_t virt, addr_t size) override { call(virt, size); } + Signal_source_capability alloc_signal_source() override { return call(); } diff --git a/repos/base/include/pd_session/pd_session.h b/repos/base/include/pd_session/pd_session.h index 9f33feac13..5e4e714d03 100644 --- a/repos/base/include/pd_session/pd_session.h +++ b/repos/base/include/pd_session/pd_session.h @@ -68,6 +68,20 @@ struct Genode::Pd_session : Session, Ram_allocator */ virtual bool assign_pci(addr_t pci_config_memory_address, uint16_t bdf) = 0; + /** + * Trigger eager insertion of page frames to page table within + * specified virtual range. + * + * If the used kernel don't support this feature, the operation will + * silently ignore the request. + * + * \param virt virtual address within the address space to start + * \param size the virtual size of the region + * + * \throw Out_of_ram + * \throw Out_of_caps + */ + virtual void map(addr_t virt, addr_t size) = 0; /******************************** ** Support for the signal API ** @@ -291,6 +305,9 @@ struct Genode::Pd_session : Session, Ram_allocator GENODE_RPC(Rpc_assign_parent, void, assign_parent, Capability); GENODE_RPC(Rpc_assign_pci, bool, assign_pci, addr_t, uint16_t); + GENODE_RPC_THROW(Rpc_map, void, map, + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), + addr_t, addr_t); GENODE_RPC_THROW(Rpc_alloc_signal_source, Signal_source_capability, alloc_signal_source, @@ -331,7 +348,7 @@ struct Genode::Pd_session : Session, Ram_allocator GENODE_RPC(Rpc_native_pd, Capability, native_pd); - GENODE_RPC_INTERFACE(Rpc_assign_parent, Rpc_assign_pci, + GENODE_RPC_INTERFACE(Rpc_assign_parent, Rpc_assign_pci, Rpc_map, Rpc_alloc_signal_source, Rpc_free_signal_source, Rpc_alloc_context, Rpc_free_context, Rpc_submit, Rpc_alloc_rpc_cap, Rpc_free_rpc_cap, Rpc_address_space, diff --git a/repos/base/src/core/include/pd_session_component.h b/repos/base/src/core/include/pd_session_component.h index d699706b1d..975a24e1f1 100644 --- a/repos/base/src/core/include/pd_session_component.h +++ b/repos/base/src/core/include/pd_session_component.h @@ -178,6 +178,7 @@ class Genode::Pd_session_component : public Session_object bool assign_pci(addr_t, uint16_t) override; + void map(addr_t, addr_t) override; /**************** ** Signalling ** diff --git a/repos/base/src/core/pd_assign_pci.cc b/repos/base/src/core/pd_session_support.cc similarity index 89% rename from repos/base/src/core/pd_assign_pci.cc rename to repos/base/src/core/pd_session_support.cc index 4fc2fc0044..16966a8e54 100644 --- a/repos/base/src/core/pd_assign_pci.cc +++ b/repos/base/src/core/pd_session_support.cc @@ -18,5 +18,7 @@ using namespace Genode; -bool Pd_session_component::assign_pci(addr_t, uint16_t) { return false; } +bool Pd_session_component::assign_pci(addr_t, uint16_t) { return true; } + +void Pd_session_component::map(addr_t, addr_t) { } diff --git a/repos/ports/src/app/gdb_monitor/pd_session_component.h b/repos/ports/src/app/gdb_monitor/pd_session_component.h index e06d24412d..fd1fa69e17 100644 --- a/repos/ports/src/app/gdb_monitor/pd_session_component.h +++ b/repos/ports/src/app/gdb_monitor/pd_session_component.h @@ -85,6 +85,9 @@ class Gdb_monitor::Pd_session_component : public Rpc_object bool assign_pci(addr_t addr, uint16_t bdf) override { return _pd.assign_pci(addr, bdf); } + void map(addr_t virt, addr_t size) override { + return _pd.map(virt, size); } + Signal_source_capability alloc_signal_source() override { return _pd.alloc_signal_source(); } diff --git a/repos/ports/src/noux/pd_session_component.h b/repos/ports/src/noux/pd_session_component.h index 347186302a..2663bd755b 100644 --- a/repos/ports/src/noux/pd_session_component.h +++ b/repos/ports/src/noux/pd_session_component.h @@ -216,6 +216,9 @@ class Noux::Pd_session_component : public Rpc_object bool assign_pci(addr_t addr, uint16_t bdf) override { return _pd.assign_pci(addr, bdf); } + void map(addr_t virt, addr_t size) override { + return _pd.map(virt, size); } + Signal_source_capability alloc_signal_source() override { return _with_automatic_cap_upgrade([&] () {