From 4d442bca305e1c2d5f8313010a3ac2ba7b96f589 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Sun, 7 May 2017 22:03:22 +0200 Subject: [PATCH] Streamline exception types This patch reduces the number of exception types by facilitating globally defined exceptions for common usage patterns shared by most services. In particular, RPC functions that demand a session-resource upgrade not longer reflect this condition via a session-specific exception but via the 'Out_of_ram' or 'Out_of_caps' types. Furthermore, the 'Parent::Service_denied', 'Parent::Unavailable', 'Root::Invalid_args', 'Root::Unavailable', 'Service::Invalid_args', 'Service::Unavailable', and 'Local_service::Factory::Denied' types have been replaced by the single 'Service_denied' exception type defined in 'session/session.h'. This consolidation eases the error handling (there are fewer exceptions to handle), alleviates the need to convert exceptions along the session-creation call chain, and avoids possible aliasing problems (catching the wrong type with the same name but living in a different scope). --- .../src/core/irq_session_component.cc | 6 +- .../src/core/irq_session_component.cc | 4 +- .../base-hw/src/core/irq_session_component.cc | 4 +- repos/base-hw/src/core/platform_pd.cc | 2 +- repos/base-hw/src/core/platform_thread.cc | 4 +- repos/base-hw/src/test/cpu_quota/sync/main.cc | 2 +- .../src/core/dataspace_component.cc | 4 +- .../base-linux/src/lib/base/child_process.cc | 6 +- .../src/lib/base/region_map_mmap.cc | 4 +- repos/base-nova/src/core/core_region_map.cc | 4 +- repos/base-nova/src/core/include/pager.h | 3 + .../src/core/irq_session_component.cc | 10 +- repos/base-nova/src/core/pager.cc | 18 +-- .../src/core/irq_session_component.cc | 4 +- .../src/core/irq_session_component.cc | 4 +- .../src/core/irq_session_component.cc | 10 +- repos/base/include/base/attached_dataspace.h | 13 +-- .../include/base/attached_io_mem_dataspace.h | 6 +- .../include/base/attached_ram_dataspace.h | 11 +- .../include/base/attached_rom_dataspace.h | 5 +- repos/base/include/base/child.h | 29 ++--- repos/base/include/base/connection.h | 5 + repos/base/include/base/local_connection.h | 2 +- repos/base/include/base/service.h | 27 ++--- repos/base/include/base/session_state.h | 4 +- repos/base/include/base/trace/types.h | 1 - repos/base/include/cpu_session/cpu_session.h | 7 +- repos/base/include/parent/parent.h | 15 +-- repos/base/include/ram_session/ram_session.h | 3 - repos/base/include/region_map/region_map.h | 40 +++---- repos/base/include/rm_session/rm_session.h | 15 +-- repos/base/include/rom_session/connection.h | 2 +- repos/base/include/root/component.h | 24 ++-- repos/base/include/root/root.h | 19 +--- repos/base/include/session/session.h | 1 + repos/base/include/trace_session/client.h | 3 +- .../include/trace_session/trace_session.h | 14 ++- repos/base/src/core/cpu_session_component.cc | 3 +- .../src/core/include/cpu_thread_component.h | 4 +- .../core/include/io_port_session_component.h | 2 +- repos/base/src/core/include/irq_args.h | 4 +- repos/base/src/core/include/pager.h | 5 + .../src/core/include/rm_session_component.h | 2 +- repos/base/src/core/include/trace/root.h | 2 +- .../src/core/include/trace/subject_registry.h | 9 +- .../base/src/core/io_mem_session_component.cc | 2 +- repos/base/src/core/main.cc | 2 +- repos/base/src/core/region_map_component.cc | 20 ++-- repos/base/src/core/rom_session_component.cc | 2 +- .../spec/x86/io_port_session_component.cc | 4 +- .../base/src/core/trace_session_component.cc | 17 +-- .../internal/expanding_cpu_session_client.h | 2 +- .../internal/expanding_region_map_client.h | 14 ++- repos/base/src/lib/base/child.cc | 34 +++--- repos/base/src/lib/base/child_process.cc | 32 ++++-- repos/base/src/lib/base/env_deprecated.cc | 4 +- repos/base/src/lib/base/heap.cc | 15 ++- repos/base/src/lib/base/root_proxy.cc | 6 +- repos/base/src/lib/base/session_state.cc | 4 +- repos/base/src/lib/base/sliced_heap.cc | 9 +- repos/base/src/lib/ldso/include/region_map.h | 4 +- repos/base/src/test/rm_fault/main.cc | 4 +- repos/base/src/test/sub_rm/main.cc | 4 +- repos/dde_bsd/src/drivers/audio/main.cc | 8 +- repos/dde_bsd/src/lib/audio/bus.cc | 28 +++-- .../dde_ipxe/src/lib/dde_ipxe/dde_support.cc | 36 +++--- .../src/include/lx_kit/internal/pci_dev.h | 33 ++---- repos/dde_linux/src/lib/usb/raw/raw.cc | 5 +- .../src/lib/usb/spec/x86/pci_driver.cc | 23 ++-- repos/dde_linux/src/lib/wifi/nic.cc | 2 +- .../src/lx_kit/mapped_io_mem_range.cc | 2 +- repos/dde_linux/src/lx_kit/pci.cc | 8 +- repos/dde_rump/include/util/allocator_fap.h | 8 +- .../src/server/rump_cgd/block_driver.h | 2 +- repos/dde_rump/src/server/rump_fs/main.cc | 11 +- repos/dde_rump/src/test/blk_crypt/main.cc | 3 +- repos/demo/include/launchpad/launchpad.h | 2 +- repos/gems/src/app/decorator/main.cc | 9 +- .../gems/src/app/launcher/subsystem_manager.h | 4 +- repos/gems/src/app/themed_decorator/main.cc | 2 +- repos/gems/src/server/file_terminal/main.cc | 11 +- repos/gems/src/server/tcp_terminal/main.cc | 11 +- repos/gems/src/server/wm/nitpicker.h | 2 +- repos/libports/ports/qt5.hash | 2 +- .../drivers/framebuffer/vesa/framebuffer.cc | 3 +- .../src/drivers/framebuffer/vesa/hw_emul.cc | 10 +- .../src/drivers/framebuffer/vesa/main.cc | 2 +- repos/libports/src/lib/acpica/osl.cc | 6 +- repos/libports/src/lib/egl/driver.cc | 3 +- repos/libports/src/lib/libc/libc_mem_alloc.cc | 2 +- .../src/lib/libc_lwip_nic_dhcp/init.cc | 3 +- repos/libports/src/lib/lwip/platform/nic.cc | 3 +- .../src/lib/qt5/patches/qt5_qml.patch | 4 +- .../src/lib/sdl/audio/SDL_genodeaudio.cc | 3 +- repos/libports/src/server/ffat_fs/main.cc | 30 ++--- .../src/server/fuse_fs/fuse_fs_main.cc | 14 ++- .../file_system/node_handle_registry.h | 8 +- .../include/file_system_session/connection.h | 44 +++---- .../file_system_session/file_system_session.h | 24 ++-- repos/os/include/gpio/component.h | 2 +- repos/os/include/input/root.h | 2 +- .../nitpicker_session/nitpicker_session.h | 24 ++-- repos/os/include/os/attached_mmio.h | 4 +- .../os/include/os/child_policy_dynamic_rom.h | 8 +- repos/os/include/os/session_policy.h | 2 +- repos/os/include/os/slave.h | 17 +-- repos/os/include/regulator/component.h | 2 +- repos/os/include/report_rom/report_service.h | 9 +- repos/os/include/report_rom/rom_service.h | 5 +- .../x86/platform_device/platform_device.h | 23 ++-- .../spec/x86/platform_session/connection.h | 14 +++ .../x86/platform_session/platform_session.h | 12 +- repos/os/run/report_rom.run | 2 +- repos/os/src/app/cli_monitor/start_command.h | 2 +- repos/os/src/app/rom_to_file/main.cc | 7 +- repos/os/src/drivers/ahci/main.cc | 8 +- .../src/drivers/ahci/spec/exynos5/platform.cc | 4 +- .../os/src/drivers/ahci/spec/x86/platform.cc | 21 ++-- repos/os/src/drivers/audio/spec/linux/main.cc | 4 +- .../os/src/drivers/input/spec/ps2/x86/main.cc | 5 +- .../src/drivers/platform/spec/arndale/main.cc | 2 +- .../drivers/platform/spec/odroid_x2/main.cc | 5 +- .../platform/spec/x86/device_pd/main.cc | 40 ++++--- repos/os/src/drivers/platform/spec/x86/irq.cc | 4 +- .../platform/spec/x86/nonpci_devices.cc | 6 +- .../drivers/platform/spec/x86/pci_device.cc | 24 ++-- .../platform/spec/x86/pci_device_pd_ipc.h | 6 +- .../platform/spec/x86/pci_session_component.h | 107 +++++++++--------- repos/os/src/drivers/uart/uart_component.h | 11 +- repos/os/src/init/child.cc | 16 +-- repos/os/src/init/child.h | 2 +- repos/os/src/init/main.cc | 7 +- repos/os/src/init/server.cc | 33 +++--- repos/os/src/init/server.h | 2 +- repos/os/src/lib/vfs/fs_file_system.h | 14 ++- repos/os/src/server/dynamic_rom/main.cc | 6 +- repos/os/src/server/fs_log/main.cc | 17 +-- repos/os/src/server/input_filter/main.cc | 2 +- repos/os/src/server/input_merger/main.cc | 2 +- repos/os/src/server/iso9660/main.cc | 6 +- repos/os/src/server/loader/main.cc | 6 +- repos/os/src/server/lx_fs/main.cc | 17 +-- repos/os/src/server/mixer/mixer.cc | 2 +- repos/os/src/server/nic_bridge/component.h | 12 +- repos/os/src/server/nic_bridge/main.cc | 2 +- repos/os/src/server/nic_dump/component.cc | 4 +- repos/os/src/server/nic_router/component.cc | 2 +- repos/os/src/server/nitpicker/main.cc | 17 ++- repos/os/src/server/part_blk/component.h | 8 +- repos/os/src/server/ram_blk/main.cc | 6 +- repos/os/src/server/ram_fs/main.cc | 22 ++-- repos/os/src/server/report_rom/rom_registry.h | 9 +- repos/os/src/server/rom_blk/main.cc | 2 +- repos/os/src/server/tar_rom/main.cc | 4 +- repos/os/src/server/trace_fs/main.cc | 72 +++++++----- repos/os/src/server/vfs/main.cc | 10 +- repos/os/src/server/vfs/node.h | 6 +- repos/os/src/test/blk/cli/main.cc | 6 +- repos/os/src/test/bomb/main.cc | 4 +- repos/os/src/test/fault_detection/main.cc | 2 +- repos/os/src/test/input_filter/main.cc | 2 +- repos/os/src/test/pci/test.cc | 12 +- repos/os/src/test/report_rom/main.cc | 5 +- repos/os/src/test/trace/main.cc | 18 +-- repos/ports/include/vmm/guest_memory.h | 2 +- repos/ports/include/vmm/vcpu_dispatcher.h | 2 +- repos/ports/src/app/gdb_monitor/app_child.h | 2 +- .../ports/src/app/gdb_monitor/child_config.h | 18 +-- .../app/gdb_monitor/gdbserver/genode-low.cc | 9 +- .../app/gdb_monitor/region_map_component.cc | 4 +- .../src/app/seoul/boot_module_provider.h | 7 +- repos/ports/src/app/seoul/main.cc | 5 +- repos/ports/src/noux/child_policy.h | 2 +- repos/ports/src/noux/empty_rom_service.h | 6 +- repos/ports/src/noux/local_rom_service.h | 3 +- repos/ports/src/noux/region_map_component.h | 4 +- repos/ports/src/virtualbox/mm.h | 14 ++- repos/ports/src/virtualbox/pgm.cc | 12 +- repos/ports/src/virtualbox/thread.cc | 8 +- repos/ports/src/virtualbox/vmm_memory.h | 13 ++- 180 files changed, 932 insertions(+), 834 deletions(-) diff --git a/repos/base-fiasco/src/core/irq_session_component.cc b/repos/base-fiasco/src/core/irq_session_component.cc index 1940cb2b1..c0fde4637 100644 --- a/repos/base-fiasco/src/core/irq_session_component.cc +++ b/repos/base-fiasco/src/core/irq_session_component.cc @@ -130,11 +130,11 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, { long msi = Arg_string::find_arg(args, "device_config_phys").long_value(0); if (msi) - throw Root::Unavailable(); + throw Service_denied(); if (!irq_alloc || irq_alloc->alloc_addr(1, _irq_number).error()) { - error("Unavailable IRQ ", _irq_number, " requested"); - throw Root::Unavailable(); + error("unavailable IRQ ", _irq_number, " requested"); + throw Service_denied(); } _irq_object.start(); diff --git a/repos/base-foc/src/core/irq_session_component.cc b/repos/base-foc/src/core/irq_session_component.cc index 426049b2f..a55f22a45 100644 --- a/repos/base-foc/src/core/irq_session_component.cc +++ b/repos/base-foc/src/core/irq_session_component.cc @@ -191,13 +191,13 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, if (msi) { if (msi_alloc.get(irq_args.irq_number(), 1)) { error("unavailable MSI ", irq_args.irq_number(), " requested"); - throw Root::Unavailable(); + throw Service_denied(); } msi_alloc.set(irq_args.irq_number(), 1); } else { if (!irq_alloc || irq_alloc->alloc_addr(1, irq_args.irq_number()).error()) { error("unavailable IRQ ", irq_args.irq_number(), " requested"); - throw Root::Unavailable(); + throw Service_denied(); } } diff --git a/repos/base-hw/src/core/irq_session_component.cc b/repos/base-hw/src/core/irq_session_component.cc index ee0b50278..e8d15a0b7 100644 --- a/repos/base-hw/src/core/irq_session_component.cc +++ b/repos/base-hw/src/core/irq_session_component.cc @@ -81,13 +81,13 @@ Irq_session_component::Irq_session_component(Range_allocator * const irq_alloc, _is_msi = Platform::get_msi_params(mmconf, _address, _value, _irq_number); if (!_is_msi) - throw Root::Unavailable(); + throw Service_denied(); } /* allocate interrupt */ if (_irq_alloc->alloc_addr(1, _irq_number).error()) { error("unavailable interrupt ", _irq_number, " requested"); - throw Root::Invalid_args(); + throw Service_denied(); } Irq_args const irq_args(args); diff --git a/repos/base-hw/src/core/platform_pd.cc b/repos/base-hw/src/core/platform_pd.cc index cd434c251..55d33f751 100644 --- a/repos/base-hw/src/core/platform_pd.cc +++ b/repos/base-hw/src/core/platform_pd.cc @@ -165,7 +165,7 @@ Platform_pd::Platform_pd(Allocator * md_alloc, char const *label) { if (!_cap.valid()) { error("failed to create kernel object"); - throw Root::Unavailable(); + throw Service_denied(); } } diff --git a/repos/base-hw/src/core/platform_thread.cc b/repos/base-hw/src/core/platform_thread.cc index 297cb1afa..9411c99fe 100644 --- a/repos/base-hw/src/core/platform_thread.cc +++ b/repos/base-hw/src/core/platform_thread.cc @@ -69,7 +69,7 @@ Platform_thread::Platform_thread(const char * const label, void *utcb_phys; if (!platform()->ram_alloc()->alloc(sizeof(Native_utcb), &utcb_phys)) { error("failed to allocate UTCB"); - throw Cpu_session::Out_of_metadata(); + throw Out_of_ram(); } map_local((addr_t)utcb_phys, (addr_t)_utcb_core_addr, sizeof(Native_utcb) / get_page_size()); @@ -94,7 +94,7 @@ Platform_thread::Platform_thread(size_t const quota, CACHED); } catch (...) { error("failed to allocate UTCB"); - throw Cpu_session::Out_of_metadata(); + throw Out_of_ram(); } _utcb_core_addr = (Native_utcb *)core_env()->rm_session()->attach(_utcb); affinity(location); diff --git a/repos/base-hw/src/test/cpu_quota/sync/main.cc b/repos/base-hw/src/test/cpu_quota/sync/main.cc index 4d306c090..ce9a6f6f5 100644 --- a/repos/base-hw/src/test/cpu_quota/sync/main.cc +++ b/repos/base-hw/src/test/cpu_quota/sync/main.cc @@ -52,7 +52,7 @@ struct Sync_root : public Root_component Session_component *_create_session(char const *args) override { try { return new (md_alloc()) Session_component(*this); } - catch (...) { throw Root::Invalid_args(); } + catch (...) { throw Service_denied(); } } Sync_root(Entrypoint &ep, Allocator &md_alloc) diff --git a/repos/base-linux/src/core/dataspace_component.cc b/repos/base-linux/src/core/dataspace_component.cc index c7bd07bc9..542e98057 100644 --- a/repos/base-linux/src/core/dataspace_component.cc +++ b/repos/base-linux/src/core/dataspace_component.cc @@ -39,7 +39,7 @@ Linux_dataspace::Filename Dataspace_component::_file_name(const char *args) /* only files inside the current working directory are allowed */ for (const char *c = fname.buf; *c; ++c) - if (*c == '/') throw Root::Invalid_args(); + if (*c == '/') throw Service_denied(); return fname; } @@ -48,7 +48,7 @@ Linux_dataspace::Filename Dataspace_component::_file_name(const char *args) Genode::size_t Dataspace_component::_file_size() { struct stat64 s; - if (lx_stat(_fname.buf, &s) < 0) throw Root::Invalid_args(); + if (lx_stat(_fname.buf, &s) < 0) throw Service_denied(); return s.st_size; } diff --git a/repos/base-linux/src/lib/base/child_process.cc b/repos/base-linux/src/lib/base/child_process.cc index 38ea85fa2..0472e660d 100644 --- a/repos/base-linux/src/lib/base/child_process.cc +++ b/repos/base-linux/src/lib/base/child_process.cc @@ -77,8 +77,10 @@ Child::Process::Process(Dataspace_capability elf_ds, /* attach ELF locally */ addr_t elf_addr; try { elf_addr = local_rm.attach(elf_ds); } - catch (Region_map::Attach_failed) { - error("local attach of ELF executable failed"); throw; } + catch (Region_map::Invalid_dataspace) { + error("local attach of ELF executable failed (Invalid_dataspace)"); throw; } + catch (Region_map::Region_conflict) { + error("local attach of ELF executable failed (Region_conflict)"); throw; } /* setup ELF object and read program entry pointer */ Elf_binary elf(elf_addr); diff --git a/repos/base-linux/src/lib/base/region_map_mmap.cc b/repos/base-linux/src/lib/base/region_map_mmap.cc index 5827df160..01e811b1c 100644 --- a/repos/base-linux/src/lib/base/region_map_mmap.cc +++ b/repos/base-linux/src/lib/base/region_map_mmap.cc @@ -179,7 +179,7 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds, /* only support attach_at for sub RM sessions */ if (_sub_rm && !use_local_addr) { error("Region_map_mmap::attach: attaching w/o local addr not supported"); - throw Out_of_metadata(); + throw Region_conflict(); } if (offset < 0) { @@ -261,7 +261,7 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds, */ if (rm->_base) { error("Region_map_mmap::attach: mapping a sub RM session twice is not supported"); - throw Out_of_metadata(); + throw Region_conflict(); } /* diff --git a/repos/base-nova/src/core/core_region_map.cc b/repos/base-nova/src/core/core_region_map.cc index 156ca47ed..6d395aec3 100644 --- a/repos/base-nova/src/core/core_region_map.cc +++ b/repos/base-nova/src/core/core_region_map.cc @@ -72,7 +72,7 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size, /* allocate the virtual region contiguous for the dataspace */ void * virt_ptr = alloc_region(ds, page_rounded_size); if (!virt_ptr) - throw Out_of_metadata(); + throw Out_of_ram(); /* map it */ Nova::Utcb * const utcb = reinterpret_cast(Thread::myself()->utcb()); @@ -81,7 +81,7 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size, if (map_local(utcb, ds->phys_addr(), reinterpret_cast(virt_ptr), page_rounded_size >> get_page_size_log2(), rights, true)) { platform()->region_alloc()->free(virt_ptr, page_rounded_size); - throw Out_of_metadata(); + throw Out_of_ram(); } return virt_ptr; diff --git a/repos/base-nova/src/core/include/pager.h b/repos/base-nova/src/core/include/pager.h index 0a98ca294..2ba830f99 100644 --- a/repos/base-nova/src/core/include/pager.h +++ b/repos/base-nova/src/core/include/pager.h @@ -19,6 +19,7 @@ #include #include #include +#include #include /* NOVA includes */ @@ -31,6 +32,8 @@ namespace Genode { + typedef Cpu_session::Thread_creation_failed Invalid_thread; + class Pager_entrypoint; class Pager_object; diff --git a/repos/base-nova/src/core/irq_session_component.cc b/repos/base-nova/src/core/irq_session_component.cc index 57a6c02d3..63e6bfb64 100644 --- a/repos/base-nova/src/core/irq_session_component.cc +++ b/repos/base-nova/src/core/irq_session_component.cc @@ -146,7 +146,7 @@ void Irq_object::start(unsigned irq, Genode::addr_t const device_phys) src, dst, MAP_FROM_KERNEL_TO_CORE); if (ret) { error("getting IRQ from kernel failed - ", irq); - throw Root::Unavailable(); + throw Service_denied(); } /* associate GSI or MSI to device belonging to device_phys */ @@ -157,7 +157,7 @@ void Irq_object::start(unsigned irq, Genode::addr_t const device_phys) ok = associate(irq_sel(), _msi_addr, _msi_data, _sigh_cap); if (!ok) - throw Root::Unavailable(); + throw Service_denied(); _device_phys = device_phys; } @@ -208,17 +208,17 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, if (device_phys) { if ((unsigned long)irq_number >= kernel_hip()->sel_gsi) - throw Root::Unavailable(); + throw Service_denied(); irq_number = kernel_hip()->sel_gsi - 1 - irq_number; /* XXX last GSI number unknown - assume 40 GSIs (depends on IO-APIC) */ if (irq_number < 40) - throw Root::Unavailable(); + throw Service_denied(); } if (!irq_alloc || irq_alloc->alloc_addr(1, irq_number).error()) { error("unavailable IRQ ", irq_number, " requested"); - throw Root::Unavailable(); + throw Service_denied(); } _irq_number = irq_number; diff --git a/repos/base-nova/src/core/pager.cc b/repos/base-nova/src/core/pager.cc index 5efa7b89b..37e9d69ea 100644 --- a/repos/base-nova/src/core/pager.cc +++ b/repos/base-nova/src/core/pager.cc @@ -516,7 +516,7 @@ void Exception_handlers::register_handler(Pager_object *obj, Mtd mtd, if (!kernel_hip()->is_cpu_enabled(kernel_cpu_id) || !pager_threads[genode_cpu_id]) { warning("invalid CPU parameter used in pager object"); - throw Region_map::Invalid_thread(); + throw Invalid_thread(); } addr_t const ec_sel = pager_threads[genode_cpu_id]->native_thread().ec_sel; @@ -526,7 +526,7 @@ void Exception_handlers::register_handler(Pager_object *obj, Mtd mtd, uint8_t res = create_portal(obj->exc_pt_sel_client() + EV, platform_specific()->core_pd_sel(), ec_sel, mtd, entry, obj); if (res != Nova::NOVA_OK) - throw Region_map::Invalid_thread(); + throw Invalid_thread(); } @@ -597,12 +597,12 @@ Pager_object::Pager_object(Cpu_session_capability cpu_session_cap, if (Native_thread::INVALID_INDEX == _selectors || Native_thread::INVALID_INDEX == _client_exc_pt_sel) - throw Region_map::Invalid_thread(); + throw Invalid_thread(); /* ypos information not supported by now */ if (location.ypos()) { warning("unsupported location ", location.xpos(), "x", location.ypos()); - throw Region_map::Invalid_thread(); + throw Invalid_thread(); } /* place Pager_object on specified CPU by selecting proper pager thread */ @@ -611,7 +611,7 @@ Pager_object::Pager_object(Cpu_session_capability cpu_session_cap, if (!kernel_hip()->is_cpu_enabled(kernel_cpu_id) || !pager_threads[genode_cpu_id]) { warning("invalid CPU parameter used in pager object"); - throw Region_map::Invalid_thread(); + throw Invalid_thread(); } addr_t ec_sel = pager_threads[genode_cpu_id]->native_thread().ec_sel; @@ -637,7 +637,7 @@ Pager_object::Pager_object(Cpu_session_capability cpu_session_cap, */ res = Nova::create_sm(exc_pt_sel_client() + SM_SEL_EC, pd_sel, 0); if (res != Nova::NOVA_OK) { - throw Region_map::Invalid_thread(); + throw Invalid_thread(); } /* create portal for final cleanup call used during destruction */ @@ -645,19 +645,19 @@ Pager_object::Pager_object(Cpu_session_capability cpu_session_cap, reinterpret_cast(_invoke_handler), this); if (res != Nova::NOVA_OK) { error("could not create pager cleanup portal, error=", res); - throw Region_map::Invalid_thread(); + throw Invalid_thread(); } /* semaphore used to block paged thread during recall */ res = Nova::create_sm(sel_sm_block_pause(), pd_sel, 0); if (res != Nova::NOVA_OK) { - throw Region_map::Invalid_thread(); + throw Invalid_thread(); } /* semaphore used to block paged thread during OOM memory revoke */ res = Nova::create_sm(sel_sm_block_oom(), pd_sel, 0); if (res != Nova::NOVA_OK) { - throw Region_map::Invalid_thread(); + throw Invalid_thread(); } } diff --git a/repos/base-okl4/src/core/irq_session_component.cc b/repos/base-okl4/src/core/irq_session_component.cc index 83218f853..9a7c51318 100644 --- a/repos/base-okl4/src/core/irq_session_component.cc +++ b/repos/base-okl4/src/core/irq_session_component.cc @@ -145,11 +145,11 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, { long msi = Arg_string::find_arg(args, "device_config_phys").long_value(0); if (msi) - throw Root::Unavailable(); + throw Service_denied(); if (!irq_alloc || irq_alloc->alloc_addr(1, _irq_number).error()) { error("unavailable IRQ ", Hex(_irq_number), " requested"); - throw Root::Unavailable(); + throw Service_denied(); } _irq_object.start(); diff --git a/repos/base-pistachio/src/core/irq_session_component.cc b/repos/base-pistachio/src/core/irq_session_component.cc index f00483719..6f2b01142 100644 --- a/repos/base-pistachio/src/core/irq_session_component.cc +++ b/repos/base-pistachio/src/core/irq_session_component.cc @@ -135,11 +135,11 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, { long msi = Arg_string::find_arg(args, "device_config_phys").long_value(0); if (msi) - throw Root::Unavailable(); + throw Service_denied(); if (!irq_alloc || irq_alloc->alloc_addr(1, _irq_number).error()) { error("unavailable IRQ ", Hex(_irq_number), " requested"); - throw Root::Unavailable(); + throw Service_denied(); } _irq_object.start(); diff --git a/repos/base-sel4/src/core/irq_session_component.cc b/repos/base-sel4/src/core/irq_session_component.cc index e99849786..ddf19eeef 100644 --- a/repos/base-sel4/src/core/irq_session_component.cc +++ b/repos/base-sel4/src/core/irq_session_component.cc @@ -122,19 +122,19 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, { long msi = Arg_string::find_arg(args, "device_config_phys").long_value(0); if (msi) - throw Root::Unavailable(); + throw Service_denied(); if (!irq_alloc || irq_alloc->alloc_addr(1, _irq_number).error()) { - Genode::error("Unavailable IRQ ", _irq_number, " requested"); - throw Root::Unavailable(); + Genode::error("unavailable IRQ ", _irq_number, " requested"); + throw Service_denied(); } Irq_args const irq_args(args); if (!_irq_object.associate(irq_args.trigger(), irq_args.polarity())) { - Genode::error("Could not associate with IRQ ", irq_args.irq_number()); - throw Root::Unavailable(); + Genode::error("could not associate with IRQ ", irq_args.irq_number()); + throw Service_denied(); } _irq_object.start(); diff --git a/repos/base/include/base/attached_dataspace.h b/repos/base/include/base/attached_dataspace.h index ca2b48454..10ac0e770 100644 --- a/repos/base/include/base/attached_dataspace.h +++ b/repos/base/include/base/attached_dataspace.h @@ -24,10 +24,7 @@ class Genode::Attached_dataspace : Noncopyable { public: - /** - * Exception type - */ - class Invalid_dataspace { }; + typedef Region_map::Invalid_dataspace Invalid_dataspace; private: @@ -44,7 +41,7 @@ class Genode::Attached_dataspace : Noncopyable if (ds.valid()) return ds; - throw Invalid_dataspace(); + throw Region_map::Invalid_dataspace(); } public: @@ -52,8 +49,10 @@ class Genode::Attached_dataspace : Noncopyable /** * Constructor * - * \throw Rm_session::Attach_failed - * \throw Invalid_dataspace + * \throw Region_map::Region_conflict + * \throw Region_map::Invalid_dataspace + * \throw Out_of_caps + * \throw Out_of_ram */ Attached_dataspace(Region_map &rm, Dataspace_capability ds) : _ds(_check(ds)), _rm(rm), _local_addr(_rm.attach(_ds)) { } diff --git a/repos/base/include/base/attached_io_mem_dataspace.h b/repos/base/include/base/attached_io_mem_dataspace.h index 8f16a45fd..99174d23b 100644 --- a/repos/base/include/base/attached_io_mem_dataspace.h +++ b/repos/base/include/base/attached_io_mem_dataspace.h @@ -45,13 +45,13 @@ class Genode::Attached_io_mem_dataspace * \param size size of resource * \param write_combined enable write combining for the resource * - * \throw Parent::Service_denied + * \throw Service_denied * \throw Insufficient_ram_quota * \throw Insufficient_cap_quota - * \throw Parent::Unavailable * \throw Out_of_ram * \throw Out_of_caps - * \throw Rm_session::Attach_failed + * \throw Region_map::Region_conflict + * \throw Region_map::Invalid_dataspace */ Attached_io_mem_dataspace(Env &env, Genode::addr_t base, Genode::size_t size, bool write_combined = false) diff --git a/repos/base/include/base/attached_ram_dataspace.h b/repos/base/include/base/attached_ram_dataspace.h index d82645eba..f257ef0d9 100644 --- a/repos/base/include/base/attached_ram_dataspace.h +++ b/repos/base/include/base/attached_ram_dataspace.h @@ -60,12 +60,10 @@ class Genode::Attached_ram_dataspace try { _ds = _ram->alloc(_size, _cached); _local_addr = _rm->attach(_ds); - - /* revert allocation if attaching the dataspace failed */ - } catch (Region_map::Attach_failed) { - _ram->free(_ds); - throw; } + /* revert allocation if attaching the dataspace failed */ + catch (Region_map::Region_conflict) { _ram->free(_ds); throw; } + catch (Region_map::Invalid_dataspace) { _ram->free(_ds); throw; } /* * Eagerly map dataspace if used for DMA @@ -92,7 +90,8 @@ class Genode::Attached_ram_dataspace * * \throw Out_of_ram * \throw Out_of_caps - * \throw Rm_session::Attach_failed + * \throw Region_map::Region_conflict + * \throw Region_map::Invalid_dataspace */ Attached_ram_dataspace(Ram_session &ram, Region_map &rm, size_t size, Cache_attribute cached = CACHED) diff --git a/repos/base/include/base/attached_rom_dataspace.h b/repos/base/include/base/attached_rom_dataspace.h index b83f73f24..cbc1145fe 100644 --- a/repos/base/include/base/attached_rom_dataspace.h +++ b/repos/base/include/base/attached_rom_dataspace.h @@ -66,7 +66,10 @@ class Genode::Attached_rom_dataspace * Constructor * * \throw Rom_connection::Rom_connection_failed - * \throw Rm_session::Attach_failed + * \throw Region_map::Region_conflict + * \throw Region_map::Invalid_dataspace + * \throw Out_of_ram + * \throw Out_of_caps */ Attached_rom_dataspace(Env &env, char const *name) : _rm(env.rm()), _rom(env, name) { _try_attach(); } diff --git a/repos/base/include/base/child.h b/repos/base/include/base/child.h index a51f189ba..b0f48255a 100644 --- a/repos/base/include/base/child.h +++ b/repos/base/include/base/child.h @@ -72,12 +72,12 @@ struct Genode::Child_policy * \return service to be contacted for the new session * \deprecated * - * \throw Parent::Service_denied + * \throw Service_denied */ virtual Service &resolve_session_request(Service::Name const &, Session_state::Args const &) { - throw Parent::Service_denied(); + throw Service_denied(); } /** @@ -95,13 +95,13 @@ struct Genode::Child_policy * * \return routing and policy-selection information for the session * - * \throw Parent::Service_denied + * \throw Service_denied */ virtual Route resolve_session_request(Service::Name const &, Session_label const &) { /* \deprecated make pure virtual once the old version is gone */ - throw Parent::Service_denied(); + throw Service_denied(); } /** @@ -297,7 +297,8 @@ class Genode::Child : protected Rpc_object, * Constructor * * \throw Cpu_session::Thread_creation_failed - * \throw Cpu_session::Out_of_metadata + * \throw Out_of_ram + * \throw Out_of_caps */ Initial_thread(Cpu_session &, Pd_session_capability, Name const &); ~Initial_thread(); @@ -377,10 +378,12 @@ class Genode::Child : protected Rpc_object, * the local address space to initialize their * content with the data from the 'elf_ds' * - * \throw Region_map::Attach_failed + * \throw Region_map::Region_conflict + * \throw Region_map::Invalid_dataspace * \throw Invalid_executable * \throw Missing_dynamic_linker - * \throw Ram_session::Alloc_failed + * \throw Out_of_ram + * \throw Out_of_caps */ Loaded_executable(Dataspace_capability elf_ds, Dataspace_capability ldso_ds, @@ -400,7 +403,8 @@ class Genode::Child : protected Rpc_object, * * \throw Missing_dynamic_linker * \throw Invalid_executable - * \throw Region_map::Attach_failed + * \throw Region_map::Region_conflict + * \throw Region_map::Invalid_dataspace * \throw Out_of_ram * \throw Out_of_caps * @@ -466,7 +470,7 @@ class Genode::Child : protected Rpc_object, session.async_client_notify = true; _service.initiate_request(session); - if (session.phase == Session_state::INVALID_ARGS) + if (session.phase == Session_state::SERVICE_DENIED) error(_child._policy.name(), ": environment ", CONNECTION::service_name(), " session denied " "(", session.args(), ")"); @@ -575,7 +579,7 @@ class Genode::Child : protected Rpc_object, _args, _child._policy.filter_session_affinity(Affinity()), route.label, route.diag); } - catch (Parent::Service_denied) { + catch (Service_denied) { error(_child._policy.name(), ": ", _service_name(), " " "environment session denied"); } } @@ -639,9 +643,8 @@ class Genode::Child : protected Rpc_object, * the child * \param policy policy for the child * - * \throw Parent::Service_denied if the initial sessions for the - * child's environment could not be - * opened + * \throw Service_denied the initial sessions for the child's + * environment could not be established */ Child(Region_map &rm, Rpc_entrypoint &entrypoint, Child_policy &policy); diff --git a/repos/base/include/base/connection.h b/repos/base/include/base/connection.h index 27b13b53f..3214121e5 100644 --- a/repos/base/include/base/connection.h +++ b/repos/base/include/base/connection.h @@ -64,6 +64,11 @@ class Genode::Connection_base : public Noncopyable { upgrade(Session::Resources { Ram_quota{bytes}, Cap_quota{0} }); } + + void upgrade_caps(size_t caps) + { + upgrade(Session::Resources { Ram_quota{0}, Cap_quota{caps} }); + } }; diff --git a/repos/base/include/base/local_connection.h b/repos/base/include/base/local_connection.h index 6e925a404..b47f7c3f3 100644 --- a/repos/base/include/base/local_connection.h +++ b/repos/base/include/base/local_connection.h @@ -150,7 +150,7 @@ class Genode::Local_connection : Local_connection_base */ error(SESSION::service_name(), " session (", _session_state->args(), ") " "unavailable"); - throw Parent::Service_denied(); + throw Service_denied(); } SESSION const &session() const diff --git a/repos/base/include/base/service.h b/repos/base/include/base/service.h index 1e1f958f1..cd88f5746 100644 --- a/repos/base/include/base/service.h +++ b/repos/base/include/base/service.h @@ -56,13 +56,6 @@ class Genode::Service : public Ram_transfer::Account, public: - /********************* - ** Exception types ** - *********************/ - - class Invalid_args : Exception { }; - class Unavailable : Exception { }; - /** * Constructor * @@ -121,12 +114,10 @@ class Genode::Local_service : public Service { typedef Session_state::Args Args; - class Denied : Exception { }; - /** * Create session * - * \throw Denied + * \throw Service_denied * \throw Insufficient_ram_quota * \throw Insufficient_cap_quota */ @@ -193,8 +184,8 @@ class Genode::Local_service : public Service session.cap = rpc_obj.cap(); session.phase = Session_state::AVAILABLE; } - catch (typename Factory::Denied) { - session.phase = Session_state::INVALID_ARGS; } + catch (Service_denied) { + session.phase = Session_state::SERVICE_DENIED; } catch (Insufficient_cap_quota) { session.phase = Session_state::INSUFFICIENT_CAP_QUOTA; } catch (Insufficient_ram_quota) { @@ -224,7 +215,7 @@ class Genode::Local_service : public Service } break; - case Session_state::INVALID_ARGS: + case Session_state::SERVICE_DENIED: case Session_state::INSUFFICIENT_RAM_QUOTA: case Session_state::INSUFFICIENT_CAP_QUOTA: case Session_state::AVAILABLE: @@ -285,11 +276,11 @@ class Genode::Parent_service : public Service } catch (Out_of_ram) { session.id_at_parent.destruct(); - session.phase = Session_state::INVALID_ARGS; } + session.phase = Session_state::SERVICE_DENIED; } catch (Out_of_caps) { session.id_at_parent.destruct(); - session.phase = Session_state::INVALID_ARGS; } + session.phase = Session_state::SERVICE_DENIED; } catch (Insufficient_ram_quota) { session.id_at_parent.destruct(); @@ -299,9 +290,9 @@ class Genode::Parent_service : public Service session.id_at_parent.destruct(); session.phase = Session_state::INSUFFICIENT_CAP_QUOTA; } - catch (Parent::Service_denied) { + catch (Service_denied) { session.id_at_parent.destruct(); - session.phase = Session_state::INVALID_ARGS; } + session.phase = Session_state::SERVICE_DENIED; } break; @@ -334,7 +325,7 @@ class Genode::Parent_service : public Service session.phase = Session_state::CLOSED; break; - case Session_state::INVALID_ARGS: + case Session_state::SERVICE_DENIED: case Session_state::INSUFFICIENT_RAM_QUOTA: case Session_state::INSUFFICIENT_CAP_QUOTA: case Session_state::AVAILABLE: diff --git a/repos/base/include/base/session_state.h b/repos/base/include/base/session_state.h index d2f96b5ff..f3cc9a0c1 100644 --- a/repos/base/include/base/session_state.h +++ b/repos/base/include/base/session_state.h @@ -79,7 +79,7 @@ class Genode::Session_state : public Parent::Client, public Parent::Server, Parent::Client parent_client; enum Phase { CREATE_REQUESTED, - INVALID_ARGS, + SERVICE_DENIED, INSUFFICIENT_RAM_QUOTA, INSUFFICIENT_CAP_QUOTA, AVAILABLE, @@ -191,7 +191,7 @@ class Genode::Session_state : public Parent::Client, public Parent::Server, switch (phase) { case CREATE_REQUESTED: - case INVALID_ARGS: + case SERVICE_DENIED: case INSUFFICIENT_RAM_QUOTA: case INSUFFICIENT_CAP_QUOTA: case CLOSED: diff --git a/repos/base/include/base/trace/types.h b/repos/base/include/base/trace/types.h index 26803a0e1..4bbf86bd0 100644 --- a/repos/base/include/base/trace/types.h +++ b/repos/base/include/base/trace/types.h @@ -26,7 +26,6 @@ namespace Genode { namespace Trace { *********************/ struct Policy_too_large : Exception { }; - struct Out_of_metadata : Exception { }; struct Nonexistent_subject : Exception { }; struct Already_traced : Exception { }; struct Source_is_dead : Exception { }; diff --git a/repos/base/include/cpu_session/cpu_session.h b/repos/base/include/cpu_session/cpu_session.h index 60f00835c..79c424d86 100644 --- a/repos/base/include/cpu_session/cpu_session.h +++ b/repos/base/include/cpu_session/cpu_session.h @@ -50,7 +50,6 @@ struct Genode::Cpu_session : Session class Thread_creation_failed : public Exception { }; class Quota_exceeded : public Thread_creation_failed { }; - class Out_of_metadata : public Exception { }; enum { THREAD_NAME_LEN = 32 }; @@ -90,8 +89,8 @@ struct Genode::Cpu_session : Session * \param utcb base of the UTCB that will be used by the thread * \return capability representing the new thread * \throw Thread_creation_failed - * \throw Out_of_metadata - * \throw Quota_exceeded + * \throw Out_of_ram + * \throw Out_of_caps */ virtual Thread_capability create_thread(Capability pd, Name const &name, @@ -230,7 +229,7 @@ struct Genode::Cpu_session : Session *********************/ GENODE_RPC_THROW(Rpc_create_thread, Thread_capability, create_thread, - GENODE_TYPE_LIST(Thread_creation_failed, Out_of_metadata), + GENODE_TYPE_LIST(Thread_creation_failed, Out_of_ram, Out_of_caps), Capability, Name const &, Affinity::Location, Weight, addr_t); GENODE_RPC(Rpc_kill_thread, void, kill_thread, Thread_capability); diff --git a/repos/base/include/parent/parent.h b/repos/base/include/parent/parent.h index f57f0d901..2403de5a2 100644 --- a/repos/base/include/parent/parent.h +++ b/repos/base/include/parent/parent.h @@ -53,13 +53,6 @@ class Genode::Parent public: - /********************* - ** Exception types ** - *********************/ - - struct Service_denied : Exception { }; - struct Unavailable : Exception { }; - typedef Rpc_in_buffer<64> Service_name; typedef Rpc_in_buffer<160> Session_args; typedef Rpc_in_buffer<160> Upgrade_args; @@ -171,8 +164,6 @@ class Genode::Parent * server. The parent delivers a signal to the handler as registered * via 'session_sigh' once the server responded to the request. Now the * session capability can be picked up by calling 'session_cap'. - * - * \throw Unavailable */ virtual Session_capability session(Client::Id id, Service_name const &service_name, @@ -220,7 +211,7 @@ class Genode::Parent * Interface for providing services */ - enum Session_response { SESSION_OK, SESSION_CLOSED, INVALID_ARGS, + enum Session_response { SESSION_OK, SESSION_CLOSED, SERVICE_DENIED, INSUFFICIENT_RAM_QUOTA, INSUFFICIENT_CAP_QUOTA }; /** @@ -301,12 +292,12 @@ class Genode::Parent GENODE_RPC_THROW(Rpc_session, Session_capability, session, GENODE_TYPE_LIST(Service_denied, Out_of_caps, Out_of_ram, Insufficient_cap_quota, - Insufficient_ram_quota, Unavailable), + Insufficient_ram_quota), Client::Id, Service_name const &, Session_args const &, Affinity const &); GENODE_RPC_THROW(Rpc_session_cap, Session_capability, session_cap, GENODE_TYPE_LIST(Service_denied, Insufficient_cap_quota, - Insufficient_ram_quota, Unavailable), + Insufficient_ram_quota), Client::Id); GENODE_RPC_THROW(Rpc_upgrade, Upgrade_result, upgrade, GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), diff --git a/repos/base/include/ram_session/ram_session.h b/repos/base/include/ram_session/ram_session.h index e1aebb7bd..89981e422 100644 --- a/repos/base/include/ram_session/ram_session.h +++ b/repos/base/include/ram_session/ram_session.h @@ -45,9 +45,6 @@ struct Genode::Ram_session : Session, Ram_allocator class Invalid_session : public Exception { }; class Undefined_ref_account : public Exception { }; - /* deprecated */ - typedef Out_of_ram Quota_exceeded; - /** * Destructor */ diff --git a/repos/base/include/region_map/region_map.h b/repos/base/include/region_map/region_map.h index 727ce74ba..370c37fab 100644 --- a/repos/base/include/region_map/region_map.h +++ b/repos/base/include/region_map/region_map.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -87,33 +88,28 @@ struct Genode::Region_map ** Exception types ** *********************/ - class Attach_failed : public Exception { }; - class Invalid_args : public Attach_failed { }; - class Invalid_dataspace : public Attach_failed { }; - class Region_conflict : public Attach_failed { }; - class Out_of_metadata : public Attach_failed { }; - - class Invalid_thread : public Exception { }; - class Unbound_thread : public Exception { }; + class Invalid_dataspace : public Exception { }; + class Region_conflict : public Exception { }; /** - * Map dataspace into local address space + * Map dataspace into region map * - * \param ds capability of dataspace to map - * \param size size of the locally mapped region - * default (0) is the whole dataspace - * \param offset start at offset in dataspace (page-aligned) - * \param use_local_addr if set to true, attach the dataspace at - * the specified 'local_addr' - * \param local_addr local destination address - * \param executable if the mapping should be executable + * \param ds capability of dataspace to map + * \param size size of the locally mapped region + * default (0) is the whole dataspace + * \param offset start at offset in dataspace (page-aligned) + * \param use_local_addr if set to true, attach the dataspace at + * the specified 'local_addr' + * \param local_addr local destination address + * \param executable if the mapping should be executable * - * \throw Attach_failed if dataspace or offset is invalid, - * or on region conflict - * \throw Out_of_metadata if meta-data backing store is exhausted + * \throw Invalid_dataspace + * \throw Region_conflict + * \throw Out_of_ram RAM quota of meta-data backing store is exhausted + * \throw Out_of_caps cap quota of meta-data backing store is exhausted * - * \return local address of mapped dataspace + * \return address of mapped dataspace within region map * */ virtual Local_addr attach(Dataspace_capability ds, @@ -168,7 +164,7 @@ struct Genode::Region_map GENODE_RPC_THROW(Rpc_attach, Local_addr, attach, GENODE_TYPE_LIST(Invalid_dataspace, Region_conflict, - Out_of_metadata, Invalid_args), + Out_of_ram, Out_of_caps), Dataspace_capability, size_t, off_t, bool, Local_addr, bool); GENODE_RPC(Rpc_detach, void, detach, Local_addr); GENODE_RPC(Rpc_fault_handler, void, fault_handler, Signal_context_capability); diff --git a/repos/base/include/rm_session/rm_session.h b/repos/base/include/rm_session/rm_session.h index f01c86774..f6f1e823a 100644 --- a/repos/base/include/rm_session/rm_session.h +++ b/repos/base/include/rm_session/rm_session.h @@ -30,22 +30,13 @@ struct Genode::Rm_session : Session */ enum { CAP_QUOTA = 2 }; - /** - * Exception types - * - * \deprecated The following type definitions will be removed after the - * transition to the 'Region_map' API is completed. - */ - typedef Region_map::Attach_failed Attach_failed; - typedef Region_map::Out_of_metadata Out_of_metadata; - typedef Region_map::Region_conflict Region_conflict; - /** * Create region map * * \param size upper bound of region map * \return region-map capability - * \throw Out_of_metadata + * \throw Out_of_ram + * \throw Out_of_caps */ virtual Capability create(size_t size) = 0; @@ -60,7 +51,7 @@ struct Genode::Rm_session : Session *********************/ GENODE_RPC_THROW(Rpc_create, Capability, create, - GENODE_TYPE_LIST(Out_of_metadata), size_t); + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), size_t); GENODE_RPC(Rpc_destroy, void, destroy, Capability); GENODE_RPC_INTERFACE(Rpc_create, Rpc_destroy); diff --git a/repos/base/include/rom_session/connection.h b/repos/base/include/rom_session/connection.h index 5834d1736..77f9f1ea3 100644 --- a/repos/base/include/rom_session/connection.h +++ b/repos/base/include/rom_session/connection.h @@ -26,7 +26,7 @@ class Genode::Rom_connection : public Connection, { public: - class Rom_connection_failed : public Parent::Service_denied { }; + class Rom_connection_failed : public Service_denied { }; enum { RAM_QUOTA = 6*1024UL }; diff --git a/repos/base/include/root/component.h b/repos/base/include/root/component.h index 060476635..1fbb16f01 100644 --- a/repos/base/include/root/component.h +++ b/repos/base/include/root/component.h @@ -49,7 +49,7 @@ class Genode::Single_client void aquire(const char *) { if (_used) - throw Root::Unavailable(); + throw Service_denied(); _used = true; } @@ -217,10 +217,11 @@ class Genode::Root_component : public Rpc_object >, * affinity, it suffices to override the overload without the * affinity argument. * - * \throw Allocator::Out_of_memory typically caused by the - * meta-data allocator - * \throw Root::Invalid_args typically caused by the - * session-component constructor + * \throw Out_of_ram + * \throw Out_of_caps + * \throw Service_denied + * \throw Insufficient_cap_quota + * \throw Insufficient_ram_quota */ virtual SESSION_TYPE *_create_session(const char *args, Affinity const &) @@ -230,7 +231,7 @@ class Genode::Root_component : public Rpc_object >, virtual SESSION_TYPE *_create_session(const char *args) { - throw Root::Invalid_args(); + throw Service_denied(); } /** @@ -301,13 +302,10 @@ class Genode::Root_component : public Rpc_object >, SESSION_TYPE &create(Session_state::Args const &args, Affinity affinity) override { - try { - return _create(args, affinity); } - + try { return _create(args, affinity); } catch (Insufficient_ram_quota) { throw; } catch (Insufficient_cap_quota) { throw; } - catch (...) { - throw typename Local_service::Factory::Denied(); } + catch (...) { throw Service_denied(); } } void upgrade(SESSION_TYPE &session, @@ -329,14 +327,14 @@ class Genode::Root_component : public Rpc_object >, Session_capability session(Root::Session_args const &args, Affinity const &affinity) override { - if (!args.valid_string()) throw Root::Invalid_args(); + if (!args.valid_string()) throw Service_denied(); SESSION_TYPE &session = _create(args.string(), affinity); return session.cap(); } void upgrade(Session_capability session, Root::Upgrade_args const &args) override { - if (!args.valid_string()) throw Root::Invalid_args(); + if (!args.valid_string()) throw Service_denied(); _ep->apply(session, [&] (SESSION_TYPE *s) { if (!s) return; diff --git a/repos/base/include/root/root.h b/repos/base/include/root/root.h index fd58d42c5..c7e3a0c90 100644 --- a/repos/base/include/root/root.h +++ b/repos/base/include/root/root.h @@ -29,13 +29,6 @@ namespace Genode { struct Genode::Root { - /********************* - ** Exception types ** - *********************/ - - class Unavailable : public Exception { }; - class Invalid_args : public Exception { }; - typedef Rpc_in_buffer<160> Session_args; typedef Rpc_in_buffer<160> Upgrade_args; @@ -44,10 +37,9 @@ struct Genode::Root /** * Create session * - * \throw Unavailable * \throw Insufficient_ram_quota * \throw Insufficient_cap_quota - * \throw Invalid_args + * \throw Service_denied * * \return capability to new session */ @@ -70,12 +62,11 @@ struct Genode::Root *********************/ GENODE_RPC_THROW(Rpc_session, Session_capability, session, - GENODE_TYPE_LIST(Unavailable, Insufficient_ram_quota, - Insufficient_cap_quota, Invalid_args), + GENODE_TYPE_LIST(Service_denied, Insufficient_ram_quota, + Insufficient_cap_quota), Session_args const &, Affinity const &); - GENODE_RPC_THROW(Rpc_upgrade, void, upgrade, - GENODE_TYPE_LIST(Invalid_args), - Session_capability, Upgrade_args const &); + GENODE_RPC(Rpc_upgrade, void, upgrade, + Session_capability, Upgrade_args const &); GENODE_RPC(Rpc_close, void, close, Session_capability); GENODE_RPC_INTERFACE(Rpc_session, Rpc_upgrade, Rpc_close); diff --git a/repos/base/include/session/session.h b/repos/base/include/session/session.h index e69f50a59..2ef1b6104 100644 --- a/repos/base/include/session/session.h +++ b/repos/base/include/session/session.h @@ -34,6 +34,7 @@ namespace Genode { */ struct Insufficient_ram_quota : Exception { }; struct Insufficient_cap_quota : Exception { }; + struct Service_denied : Exception { }; } diff --git a/repos/base/include/trace_session/client.h b/repos/base/include/trace_session/client.h index 88dce1ee4..478632308 100644 --- a/repos/base/include/trace_session/client.h +++ b/repos/base/include/trace_session/client.h @@ -64,7 +64,8 @@ struct Genode::Trace::Session_client : Genode::Rpc_client pd }; try { _thread_ep->apply(pd_cap, create_thread_lambda); } - catch (Region_map::Out_of_metadata) { throw Out_of_metadata(); } - catch (Allocator::Out_of_memory) { throw Out_of_metadata(); } + catch (Allocator::Out_of_memory) { throw Out_of_ram(); } catch (Native_capability::Reference_count_overflow) { throw Thread_creation_failed(); } thread->session_exception_sigh(_exception_sigh); diff --git a/repos/base/src/core/include/cpu_thread_component.h b/repos/base/src/core/include/cpu_thread_component.h index e386f3250..9703f0107 100644 --- a/repos/base/src/core/include/cpu_thread_component.h +++ b/repos/base/src/core/include/cpu_thread_component.h @@ -77,7 +77,7 @@ class Genode::Cpu_thread_component : public Rpc_object, : trace_control_area(trace_control_area) { if (!trace_control_area.alloc(index)) - throw Cpu_session::Out_of_metadata(); + throw Out_of_ram(); } ~Trace_control_slot() @@ -156,7 +156,7 @@ class Genode::Cpu_thread_component : public Rpc_object, /* * Acquaint thread with its pager object, caution on some base platforms - * this may raise an 'Out_of_meta_data' exception, which causes the + * this may raise an 'Out_of_ram' exception, which causes the * destructor of this object to not being called. Catch it and remove this * object from the object pool */ diff --git a/repos/base/src/core/include/io_port_session_component.h b/repos/base/src/core/include/io_port_session_component.h index e25e10e46..fcc4005cf 100644 --- a/repos/base/src/core/include/io_port_session_component.h +++ b/repos/base/src/core/include/io_port_session_component.h @@ -49,7 +49,7 @@ namespace Genode { * \param io_port_alloc IO_PORT region allocator * \param args session construction arguments, in * particular port base and size - * \throw Root::Invalid_args + * \throw Service_denied */ Io_port_session_component(Range_allocator *io_port_alloc, const char *args); diff --git a/repos/base/src/core/include/irq_args.h b/repos/base/src/core/include/irq_args.h index 98c0fd840..e9a1c1183 100644 --- a/repos/base/src/core/include/irq_args.h +++ b/repos/base/src/core/include/irq_args.h @@ -50,7 +50,7 @@ class Genode::Irq_args default: error("invalid trigger mode ", irq_trg, " specified for IRQ ", _irq_number); - throw Root::Unavailable(); + throw Service_denied(); } switch (irq_pol) { @@ -67,7 +67,7 @@ class Genode::Irq_args default: error("invalid polarity ", irq_pol, " specified for IRQ ", _irq_number); - throw Root::Unavailable(); + throw Service_denied(); } } diff --git a/repos/base/src/core/include/pager.h b/repos/base/src/core/include/pager.h index eec35076a..b6a7701c2 100644 --- a/repos/base/src/core/include/pager.h +++ b/repos/base/src/core/include/pager.h @@ -21,6 +21,7 @@ #include #include #include +#include #include /* core-local includes */ @@ -29,6 +30,8 @@ namespace Genode { + typedef Cpu_session::Thread_creation_failed Invalid_thread; + /** * Special server object for paging * @@ -79,6 +82,8 @@ class Genode::Pager_object : public Object_pool::Entry * Constructor * * \param location affinity of paged thread to physical CPU + * + * \throw Invalid_thread */ Pager_object(Cpu_session_capability cpu_sesion, Thread_capability thread, diff --git a/repos/base/src/core/include/rm_session_component.h b/repos/base/src/core/include/rm_session_component.h index c77bd8574..fd595fdf9 100644 --- a/repos/base/src/core/include/rm_session_component.h +++ b/repos/base/src/core/include/rm_session_component.h @@ -82,7 +82,7 @@ class Genode::Rm_session_component : public Rpc_object return rm->cap(); } - catch (Allocator::Out_of_memory) { throw Out_of_metadata(); } + catch (Allocator::Out_of_memory) { throw Out_of_ram(); } } void destroy(Capability cap) override diff --git a/repos/base/src/core/include/trace/root.h b/repos/base/src/core/include/trace/root.h index 9f769d07d..fbf2efdbc 100644 --- a/repos/base/src/core/include/trace/root.h +++ b/repos/base/src/core/include/trace/root.h @@ -39,7 +39,7 @@ class Genode::Trace::Root : public Genode::Root_component unsigned parent_levels = Arg_string::find_arg(args, "parent_levels").ulong_value(0); if (arg_buffer_size > ram_quota) - throw Root::Invalid_args(); + throw Service_denied(); return new (md_alloc()) Session_component(*md_alloc(), ram_quota, arg_buffer_size, diff --git a/repos/base/src/core/include/trace/subject_registry.h b/repos/base/src/core/include/trace/subject_registry.h index 2b636e9b8..1f32c6535 100644 --- a/repos/base/src/core/include/trace/subject_registry.h +++ b/repos/base/src/core/include/trace/subject_registry.h @@ -183,10 +183,11 @@ class Genode::Trace::Subject * * \param size trace buffer size * - * \throw Out_of_metadata - * \throw Already_traced - * \throw Source_is_dead - * \throw Traced_by_other_session + * \throw Out_of_ram + * \throw Out_of_caps + * \throw Already_traced + * \throw Source_is_dead + * \throw Traced_by_other_session */ void trace(Policy_id policy_id, Dataspace_capability policy_ds, size_t policy_size, Ram_session &ram, size_t size) diff --git a/repos/base/src/core/io_mem_session_component.cc b/repos/base/src/core/io_mem_session_component.cc index 246a3c66d..e4b5db237 100644 --- a/repos/base/src/core/io_mem_session_component.cc +++ b/repos/base/src/core/io_mem_session_component.cc @@ -81,7 +81,7 @@ Io_mem_session_component::Io_mem_session_component(Range_allocator *io_mem_alloc error("Local MMIO mapping failed!"); _ds_cap = Io_mem_dataspace_capability(); - throw Root::Invalid_args(); + throw Service_denied(); } _ds_cap = static_cap_cast(_ds_ep->manage(&_ds)); diff --git a/repos/base/src/core/main.cc b/repos/base/src/core/main.cc index bf43cb637..a9d6b8cc4 100644 --- a/repos/base/src/core/main.cc +++ b/repos/base/src/core/main.cc @@ -178,7 +178,7 @@ class Core_child : public Child_policy service = &s; }); if (!service) - throw Parent::Service_denied(); + throw Service_denied(); return *service; } diff --git a/repos/base/src/core/region_map_component.cc b/repos/base/src/core/region_map_component.cc index b02c3e027..49e62924c 100644 --- a/repos/base/src/core/region_map_component.cc +++ b/repos/base/src/core/region_map_component.cc @@ -324,7 +324,7 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size, /* offset must be positive and page-aligned */ if (offset < 0 || align_addr(offset, get_page_size_log2()) != offset) - throw Invalid_args(); + throw Region_conflict(); auto lambda = [&] (Dataspace_component *dsc) { /* check dataspace validity */ @@ -338,7 +338,7 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size, /* deny creation of regions larger then the actual dataspace */ if (dsc->size() < size + offset) - throw Invalid_args(); + throw Region_conflict(); /* allocate region for attachment */ void *r = 0; @@ -346,7 +346,7 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size, switch (_map.alloc_addr(size, local_addr).value) { case Range_allocator::Alloc_return::OUT_OF_METADATA: - throw Out_of_metadata(); + throw Out_of_ram(); case Range_allocator::Alloc_return::RANGE_CONFLICT: throw Region_conflict(); @@ -377,12 +377,18 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size, Range_allocator::Alloc_return alloc_return = _map.alloc_aligned(size, &r, align_log2); - if (alloc_return.ok()) - break; - else if (alloc_return.value == Range_allocator::Alloc_return::OUT_OF_METADATA) { + if (!alloc_return.ok()) _map.free(r); - throw Out_of_metadata(); + + typedef Range_allocator::Alloc_return Alloc_return; + + switch (alloc_return.value) { + case Alloc_return::OK: break; /* switch */ + case Alloc_return::OUT_OF_METADATA: throw Out_of_ram(); + case Alloc_return::RANGE_CONFLICT: throw Region_conflict(); } + + break; /* for loop */ } if (align_log2 < get_page_size_log2()) { diff --git a/repos/base/src/core/rom_session_component.cc b/repos/base/src/core/rom_session_component.cc index 1fdb38ac2..745401467 100644 --- a/repos/base/src/core/rom_session_component.cc +++ b/repos/base/src/core/rom_session_component.cc @@ -29,7 +29,7 @@ Rom_session_component::Rom_session_component(Rom_fs *rom_fs, { /* ROM module not found */ if (!_rom_module) - throw Root::Invalid_args(); + throw Service_denied(); _ds_cap = static_cap_cast(_ds_ep->manage(&_ds)); } diff --git a/repos/base/src/core/spec/x86/io_port_session_component.cc b/repos/base/src/core/spec/x86/io_port_session_component.cc index c807d8993..3c24e647a 100644 --- a/repos/base/src/core/spec/x86/io_port_session_component.cc +++ b/repos/base/src/core/spec/x86/io_port_session_component.cc @@ -39,11 +39,11 @@ Io_port_session_component::Io_port_session_component(Range_allocator *io_port_al case Range_allocator::Alloc_return::RANGE_CONFLICT: error("I/O port ", Hex_range(base, size), " not available"); - throw Root::Invalid_args(); + throw Service_denied(); case Range_allocator::Alloc_return::OUT_OF_METADATA: error("I/O port allocator ran out of meta data"); - throw Root::Invalid_args(); + throw Service_denied(); case Range_allocator::Alloc_return::OK: break; } diff --git a/repos/base/src/core/trace_session_component.cc b/repos/base/src/core/trace_session_component.cc index a845abd16..82d4a0257 100644 --- a/repos/base/src/core/trace_session_component.cc +++ b/repos/base/src/core/trace_session_component.cc @@ -29,14 +29,7 @@ Dataspace_capability Session_component::dataspace() size_t Session_component::subjects() { - try { - _subjects.import_new_sources(_sources); - - } catch (Allocator::Out_of_memory) { - - warning("TRACE session ran out of memory"); - throw Out_of_metadata(); - } + _subjects.import_new_sources(_sources); return _subjects.subjects((Subject_id *)_argument_buffer.base, _argument_buffer.size/sizeof(Subject_id)); @@ -55,7 +48,7 @@ Policy_id Session_component::alloc_policy(size_t size) Policy_id const id(++_policy_cnt); if (!_md_alloc.withdraw(size)) - throw Out_of_metadata(); + throw Out_of_ram(); try { Ram_dataspace_capability ds = _ram.alloc(size); @@ -64,7 +57,7 @@ Policy_id Session_component::alloc_policy(size_t size) } catch (...) { /* revert withdrawal or quota */ _md_alloc.upgrade(size); - throw Out_of_metadata(); + throw Out_of_ram(); } return id; @@ -94,7 +87,7 @@ void Session_component::trace(Subject_id subject_id, Policy_id policy_id, * session. */ if (!_md_alloc.withdraw(required_ram)) - throw Out_of_metadata(); + throw Out_of_ram(); try { Trace::Subject *subject = _subjects.lookup_by_id(subject_id); @@ -103,7 +96,7 @@ void Session_component::trace(Subject_id subject_id, Policy_id policy_id, } catch (...) { /* revert withdrawal or quota */ _md_alloc.upgrade(required_ram); - throw Out_of_metadata(); + throw Out_of_ram(); } } diff --git a/repos/base/src/include/base/internal/expanding_cpu_session_client.h b/repos/base/src/include/base/internal/expanding_cpu_session_client.h index 4595e5dcd..b672f9187 100644 --- a/repos/base/src/include/base/internal/expanding_cpu_session_client.h +++ b/repos/base/src/include/base/internal/expanding_cpu_session_client.h @@ -42,7 +42,7 @@ struct Genode::Expanding_cpu_session_client : Upgradeable_client( + return retry( [&] () { return Cpu_session_client::create_thread(pd, name, location, weight, utcb); }, diff --git a/repos/base/src/include/base/internal/expanding_region_map_client.h b/repos/base/src/include/base/internal/expanding_region_map_client.h index 07dcd682f..f2ed87ad4 100644 --- a/repos/base/src/include/base/internal/expanding_region_map_client.h +++ b/repos/base/src/include/base/internal/expanding_region_map_client.h @@ -37,12 +37,16 @@ struct Genode::Expanding_region_map_client : Region_map_client bool use_local_addr, Local_addr local_addr, bool executable) override { - return retry( + return retry( [&] () { - return Region_map_client::attach(ds, size, offset, - use_local_addr, - local_addr, - executable); }, + return retry( + [&] { + return Region_map_client::attach(ds, size, offset, + use_local_addr, + local_addr, + executable); }, + [&] { _pd_client.upgrade_caps(2); }); + }, [&] () { _pd_client.upgrade_ram(8*1024); }); } }; diff --git a/repos/base/src/lib/base/child.cc b/repos/base/src/lib/base/child.cc index 5db391e00..84bd19877 100644 --- a/repos/base/src/lib/base/child.cc +++ b/repos/base/src/lib/base/child.cc @@ -76,7 +76,7 @@ void Child::session_sigh(Signal_context_capability sigh) if (session.phase == Session_state::AVAILABLE || session.phase == Session_state::INSUFFICIENT_RAM_QUOTA || session.phase == Session_state::INSUFFICIENT_CAP_QUOTA || - session.phase == Session_state::INVALID_ARGS) { + session.phase == Session_state::SERVICE_DENIED) { if (sigh.valid() && session.async_client_notify) Signal_transmitter(sigh).submit(); @@ -89,9 +89,10 @@ void Child::session_sigh(Signal_context_capability sigh) * Create session-state object for a dynamically created session * * \throw Out_of_ram + * \throw Out_of_caps * \throw Insufficient_cap_quota * \throw Insufficient_ram_quota - * \throw Parent::Service_denied + * \throw Service_denied */ Session_state & create_session(Child_policy::Name const &child_name, Service &service, @@ -123,7 +124,7 @@ create_session(Child_policy::Name const &child_name, Service &service, id_space.apply(id, [&] (Session_state &session) { error("existing session: ", session); }); } - throw Parent::Service_denied(); + throw Service_denied(); } @@ -131,7 +132,7 @@ create_session(Child_policy::Name const &child_name, Service &service, * \deprecated Temporary wrapper around 'Child_policy::resolve_session_request' * that tries both overloads. * - * \throw Parent::Service_denied + * \throw Service_denied */ Child_policy::Route Child::_resolve_session_request(Child_policy &policy, Service::Name const &name, @@ -149,7 +150,7 @@ Child_policy::Route Child::_resolve_session_request(Child_policy &policy, return { policy.resolve_session_request(name, args), label, session_diag_from_args(argbuf) }; } - catch (Parent::Service_denied) { } + catch (Service_denied) { } return policy.resolve_session_request(name, label); } @@ -160,7 +161,8 @@ Session_capability Child::session(Parent::Client::Id id, Parent::Session_args const &args, Affinity const &affinity) { - if (!name.valid_string() || !args.valid_string()) throw Unavailable(); + if (!name.valid_string() || !args.valid_string()) + throw Service_denied(); char argbuf[Parent::Session_args::MAX_SIZE]; @@ -192,7 +194,7 @@ Session_capability Child::session(Parent::Client::Id id, /* adjust the session information as presented to the server */ Arg_string::set_arg(argbuf, sizeof(argbuf), "ram_quota", forward_ram_quota.value); - /* may throw a 'Parent::Service_denied' exception */ + /* may throw a 'Service_denied' exception */ Child_policy::Route route = _resolve_session_request(_policy, name.string(), argbuf); Service &service = route.service; @@ -226,7 +228,7 @@ Session_capability Child::session(Parent::Client::Id id, /* try to dispatch session request synchronously */ service.initiate_request(session); - if (session.phase == Session_state::INVALID_ARGS) { + if (session.phase == Session_state::SERVICE_DENIED) { _revert_quota_and_destroy(session); throw Service_denied(); } @@ -284,7 +286,7 @@ Session_capability Child::session_cap(Client::Id id) auto lamda = [&] (Session_state &session) { - if (session.phase == Session_state::INVALID_ARGS + if (session.phase == Session_state::SERVICE_DENIED || session.phase == Session_state::INSUFFICIENT_RAM_QUOTA || session.phase == Session_state::INSUFFICIENT_CAP_QUOTA) { @@ -298,7 +300,7 @@ Session_capability Child::session_cap(Client::Id id) _revert_quota_and_destroy(session); switch (phase) { - case Session_state::INVALID_ARGS: throw Parent::Service_denied(); + case Session_state::SERVICE_DENIED: throw Service_denied(); case Session_state::INSUFFICIENT_RAM_QUOTA: throw Insufficient_ram_quota(); case Session_state::INSUFFICIENT_CAP_QUOTA: throw Insufficient_cap_quota(); default: break; @@ -449,7 +451,7 @@ Child::Close_result Child::_close(Session_state &session) * If session could not be established, destruct session immediately * without involving the server */ - if (session.phase == Session_state::INVALID_ARGS + if (session.phase == Session_state::SERVICE_DENIED || session.phase == Session_state::INSUFFICIENT_RAM_QUOTA || session.phase == Session_state::INSUFFICIENT_CAP_QUOTA) { _revert_quota_and_destroy(session); @@ -544,8 +546,8 @@ void Child::session_response(Server::Id id, Session_response response) _revert_quota_and_destroy(session); break; - case Parent::INVALID_ARGS: - session.phase = Session_state::INVALID_ARGS; + case Parent::SERVICE_DENIED: + session.phase = Session_state::SERVICE_DENIED; if (session.ready_callback) session.ready_callback->session_ready(session); break; @@ -710,10 +712,10 @@ void Child::_try_construct_env_dependent_members() catch (Out_of_ram) { _error("out of RAM during ELF loading"); } catch (Out_of_caps) { _error("out of caps during ELF loading"); } catch (Cpu_session::Thread_creation_failed) { _error("unable to create initial thread"); } - catch (Cpu_session::Out_of_metadata) { _error("CPU session quota exhausted"); } catch (Process::Missing_dynamic_linker) { _error("dynamic linker unavailable"); } catch (Process::Invalid_executable) { _error("invalid ELF executable"); } - catch (Region_map::Attach_failed) { _error("ELF loading failed"); } + catch (Region_map::Invalid_dataspace) { _error("ELF loading failed (Invalid_dataspace)"); } + catch (Region_map::Region_conflict) { _error("ELF loading failed (Region_conflict)"); } } @@ -745,7 +747,7 @@ void Child::initiate_env_sessions() _linker.construct(*this, Parent::Env::linker(), _policy.linker_name()); _linker->initiate(); } - catch (Parent::Service_denied) { } + catch (Service_denied) { } _try_construct_env_dependent_members(); } diff --git a/repos/base/src/lib/base/child_process.cc b/repos/base/src/lib/base/child_process.cc index dfe1c34d9..0329996cc 100644 --- a/repos/base/src/lib/base/child_process.cc +++ b/repos/base/src/lib/base/child_process.cc @@ -38,8 +38,10 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds /* attach ELF locally */ addr_t elf_addr; try { elf_addr = local_rm.attach(elf_ds); } - catch (Region_map::Attach_failed) { - error("local attach of ELF executable failed"); throw; } + catch (Region_map::Invalid_dataspace) { + error("local attach of ELF executable failed (invalid dataspace)"); throw; } + catch (Region_map::Region_conflict) { + error("local attach of ELF executable failed (region conflict)"); throw; } /* setup ELF object and read program entry pointer */ Elf_binary elf(elf_addr); @@ -60,8 +62,10 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds } try { elf_addr = local_rm.attach(ldso_ds); } - catch (Region_map::Attach_failed) { - error("local attach of dynamic linker failed"); throw; } + catch (Region_map::Invalid_dataspace) { + error("dynamic linker is an invalid dataspace"); throw; } + catch (Region_map::Region_conflict) { + error("region conflict while attaching dynamic linker"); throw; } elf_ds = ldso_ds; elf = Elf_binary(elf_addr); @@ -108,8 +112,10 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds /* attach dataspace */ void *base; try { base = local_rm.attach(ds_cap); } - catch (Region_map::Attach_failed) { - error("local attach of segment dataspace failed"); throw; } + catch (Region_map::Invalid_dataspace) { + error("attempt to attach invalid segment dataspace"); throw; } + catch (Region_map::Region_conflict) { + error("region conflict while locally attaching ELF segment"); throw; } void * const ptr = base; addr_t const laddr = elf_addr + seg.file_offset(); @@ -134,8 +140,8 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds off_t const offset = 0; try { remote_rm.attach_at(ds_cap, addr, size, offset); } - catch (Region_map::Attach_failed) { - error("remote attach of read-write segment failed"); throw; } + catch (Region_map::Region_conflict) { + error("region conflict while remotely attaching ELF segment"); throw; } } else { @@ -151,8 +157,14 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds else remote_rm.attach_at(elf_ds, addr, size, offset); } - catch (Region_map::Attach_failed) { - error("remote attach of read-only segment failed"); throw; } + catch (Region_map::Region_conflict) { + error("region conflict while remotely attaching read-only ELF segment"); + throw; + } + catch (Region_map::Invalid_dataspace) { + error("attempt to attach invalid read-only segment dataspace"); + throw; + } } } diff --git a/repos/base/src/lib/base/env_deprecated.cc b/repos/base/src/lib/base/env_deprecated.cc index b3ec32a44..6c7ba9480 100644 --- a/repos/base/src/lib/base/env_deprecated.cc +++ b/repos/base/src/lib/base/env_deprecated.cc @@ -52,8 +52,8 @@ Genode::Expanding_parent_client::_fallback_sig_cap() /* * Because the 'manage' function consumes meta data of the signal - * session, calling it may result in an 'Out_of_metadata' error. The - * 'manage' function handles this error by upgrading the session quota + * session, calling it may result in an 'Out_of_ram' or 'Out_of_caps' error. + * The 'manage' function handles this error by upgrading the session quota * accordingly. However, this upgrade, in turn, may result in the * depletion of the process' RAM quota. In this case, the process would * issue a resource request to the parent. But in order to do so, the diff --git a/repos/base/src/lib/base/heap.cc b/repos/base/src/lib/base/heap.cc index aa0a1d760..2c71fdde6 100644 --- a/repos/base/src/lib/base/heap.cc +++ b/repos/base/src/lib/base/heap.cc @@ -90,11 +90,18 @@ Heap::Dataspace *Heap::_allocate_dataspace(size_t size, bool enforce_separate_me new_ds_cap = _ds_pool.ram_alloc->alloc(size); ds_addr = _ds_pool.region_map->attach(new_ds_cap); } - catch (Out_of_ram) { return nullptr; } - catch (Region_map::Attach_failed) { - warning("could not attach dataspace"); + catch (Out_of_ram) { + return nullptr; + } + catch (Region_map::Invalid_dataspace) { + warning("heap: attempt to attach invalid dataspace"); _ds_pool.ram_alloc->free(new_ds_cap); - return 0; + return nullptr; + } + catch (Region_map::Region_conflict) { + warning("heap: region conflict while allocating dataspace"); + _ds_pool.ram_alloc->free(new_ds_cap); + return nullptr; } if (enforce_separate_metadata) { diff --git a/repos/base/src/lib/base/root_proxy.cc b/repos/base/src/lib/base/root_proxy.cc index cba0c442a..dd5be6cc2 100644 --- a/repos/base/src/lib/base/root_proxy.cc +++ b/repos/base/src/lib/base/root_proxy.cc @@ -183,14 +183,12 @@ void Root_proxy::_handle_session_request(Xml_node request) _env.parent().deliver_session_cap(id, cap); }); } - catch (Root::Invalid_args) { - _env.parent().session_response(id, Parent::INVALID_ARGS); } catch (Insufficient_ram_quota) { _env.parent().session_response(id, Parent::INSUFFICIENT_RAM_QUOTA); } catch (Insufficient_cap_quota) { _env.parent().session_response(id, Parent::INSUFFICIENT_CAP_QUOTA); } - catch (Root::Unavailable) { - _env.parent().session_response(id, Parent::INVALID_ARGS); } + catch (Service_denied) { + _env.parent().session_response(id, Parent::SERVICE_DENIED); } } if (request.has_type("upgrade")) { diff --git a/repos/base/src/lib/base/session_state.cc b/repos/base/src/lib/base/session_state.cc index 8f3c3e70c..f1268a9f9 100644 --- a/repos/base/src/lib/base/session_state.cc +++ b/repos/base/src/lib/base/session_state.cc @@ -31,7 +31,7 @@ struct Formatted_phase switch (_phase) { case State::CREATE_REQUESTED: print(output, "CREATE_REQUESTED"); break; - case State::INVALID_ARGS: print(output, "INVALID_ARGS"); break; + case State::SERVICE_DENIED: print(output, "SERVICE_DENIED"); break; case State::INSUFFICIENT_RAM_QUOTA: print(output, "INSUFFICIENT_RAM_QUOTA"); break; case State::INSUFFICIENT_CAP_QUOTA: print(output, "INSUFFICIENT_CAP_QUOTA"); break; case State::AVAILABLE: print(output, "AVAILABLE"); break; @@ -88,7 +88,7 @@ void Session_state::generate_session_request(Xml_generator &xml) const xml.attribute("id", id_at_server->id().value); }); break; - case INVALID_ARGS: + case SERVICE_DENIED: case INSUFFICIENT_RAM_QUOTA: case INSUFFICIENT_CAP_QUOTA: case AVAILABLE: diff --git a/repos/base/src/lib/base/sliced_heap.cc b/repos/base/src/lib/base/sliced_heap.cc index d48b88c26..2f9b0bdde 100644 --- a/repos/base/src/lib/base/sliced_heap.cc +++ b/repos/base/src/lib/base/sliced_heap.cc @@ -50,8 +50,13 @@ bool Sliced_heap::alloc(size_t size, void **out_addr) ds_cap = _ram_alloc.alloc(size); block = _region_map.attach(ds_cap); } - catch (Region_map::Attach_failed) { - error("could not attach dataspace to local address space"); + catch (Region_map::Region_conflict) { + error("sliced_heap: region conflict while attaching dataspace"); + _ram_alloc.free(ds_cap); + return false; + } + catch (Region_map::Invalid_dataspace) { + error("sliced_heap: attempt to attach invalid dataspace"); _ram_alloc.free(ds_cap); return false; } diff --git a/repos/base/src/lib/ldso/include/region_map.h b/repos/base/src/lib/ldso/include/region_map.h index a403550b2..5982aded9 100644 --- a/repos/base/src/lib/ldso/include/region_map.h +++ b/repos/base/src/lib/ldso/include/region_map.h @@ -92,7 +92,7 @@ class Linker::Region_map Local_addr attach_at(Dataspace_capability ds, addr_t local_addr, size_t size = 0, off_t offset = 0) { - return retry( + return retry( [&] () { return _rm.attach_at(ds, local_addr - _base, size, offset); }, @@ -105,7 +105,7 @@ class Linker::Region_map Local_addr attach_executable(Dataspace_capability ds, addr_t local_addr, size_t size = 0, off_t offset = 0) { - return retry( + return retry( [&] () { return _rm.attach_executable(ds, local_addr - _base, size, offset); }, diff --git a/repos/base/src/test/rm_fault/main.cc b/repos/base/src/test/rm_fault/main.cc index 0d3df446e..4d4b92fe4 100644 --- a/repos/base/src/test/rm_fault/main.cc +++ b/repos/base/src/test/rm_fault/main.cc @@ -129,7 +129,7 @@ class Test_child_policy : public Child_policy service = &s; }); if (!service) - throw Parent::Service_denied(); + throw Service_denied(); return *service; } @@ -237,7 +237,7 @@ void Component::construct(Env &env) static Main_parent parent(env); log("-- parent role started --"); } - catch (Parent::Service_denied) { + catch (Service_denied) { main_child(); } } diff --git a/repos/base/src/test/sub_rm/main.cc b/repos/base/src/test/sub_rm/main.cc index 4ba588dab..7fe5eb7ec 100644 --- a/repos/base/src/test/sub_rm/main.cc +++ b/repos/base/src/test/sub_rm/main.cc @@ -95,7 +95,7 @@ void Component::construct(Env &env) sub_rm.attach(ds, 0, 0, false, (addr_t)0); fail("sub rm attach_any unexpectedly did not fail"); } - catch (Region_map::Out_of_metadata) { + catch (Region_map::Region_conflict) { log("attach failed as expected"); } } @@ -166,7 +166,7 @@ void Component::construct(Env &env) env.rm().attach(sub_rm.dataspace()); fail("double attachment of sub RM session went undetected\n"); } - catch (Region_map::Out_of_metadata) { + catch (Region_map::Region_conflict) { log("doubly attaching sub RM session failed as expected"); } } diff --git a/repos/dde_bsd/src/drivers/audio/main.cc b/repos/dde_bsd/src/drivers/audio/main.cc index 76216c7b8..289ee1529 100644 --- a/repos/dde_bsd/src/drivers/audio/main.cc +++ b/repos/dde_bsd/src/drivers/audio/main.cc @@ -237,12 +237,12 @@ struct Audio_out::Root_policy if (!Out::channel_number(channel_name, &channel_number)) { Genode::error("invalid output channel '",(char const *)channel_name,"' requested, " "denying '",Genode::label_from_args(args),"'"); - throw ::Root::Invalid_args(); + throw Genode::Service_denied(); } if (Audio_out::channel_acquired[channel_number]) { Genode::error("output channel '",(char const *)channel_name,"' is unavailable, " "denying '",Genode::label_from_args(args),"'"); - throw ::Root::Unavailable(); + throw Genode::Service_denied(); } } @@ -428,12 +428,12 @@ struct Audio_in::Root_policy if (!In::channel_number(channel_name, &channel_number)) { Genode::error("invalid input channel '",(char const *)channel_name,"' requested, " "denying '",Genode::label_from_args(args),"'"); - throw ::Root::Invalid_args(); + throw Genode::Service_denied(); } if (Audio_in::channel_acquired) { Genode::error("input channel '",(char const *)channel_name,"' is unavailable, " "denying '",Genode::label_from_args(args),"'"); - throw Genode::Root::Unavailable(); + throw Genode::Service_denied(); } } diff --git a/repos/dde_bsd/src/lib/audio/bus.cc b/repos/dde_bsd/src/lib/audio/bus.cc index b31eb3cf0..4d5c795ae 100644 --- a/repos/dde_bsd/src/lib/audio/bus.cc +++ b/repos/dde_bsd/src/lib/audio/bus.cc @@ -118,11 +118,10 @@ class Pci_driver : public Bsd::Bus_driver { Platform::Device_capability cap; /* shift values for Pci interface used by Genode */ - cap = Genode::retry( - [&] () { return _pci.next_device(prev, - PCI_CLASS_MULTIMEDIA << 16, - PCI_CLASS_MASK << 16); }, - [&] () { _pci.upgrade_ram(4096); }); + cap = _pci.with_upgrade([&] () { + return _pci.next_device(prev, + PCI_CLASS_MULTIMEDIA << 16, + PCI_CLASS_MASK << 16); }); if (prev.valid()) _pci.release_device(prev); @@ -136,8 +135,12 @@ class Pci_driver : public Bsd::Bus_driver { size_t donate = size; - return Genode::retry( - [&] () { return _pci.alloc_dma_buffer(size); }, + return Genode::retry( + [&] () { + return Genode::retry( + [&] () { return _pci.alloc_dma_buffer(size); }, + [&] () { _pci.upgrade_caps(2); }); + }, [&] () { _pci.upgrade_ram(donate); donate = donate * 2 > size ? 4096 : donate * 2; @@ -398,14 +401,9 @@ extern "C" int pci_mapreg_map(struct pci_attach_args *pa, cmd |= Pci_driver::CMD_MASTER; - Genode::size_t donate = 4096; - Genode::retry( - [&] () { device.config_write(Pci_driver::CMD, cmd, - Platform::Device::ACCESS_16BIT); }, - [&] () { - drv->pci().upgrade_ram(donate); - donate *= 2; - }); + drv->pci().with_upgrade([&] () { + device.config_write(Pci_driver::CMD, cmd, Platform::Device::ACCESS_16BIT); + }); return 0; } diff --git a/repos/dde_ipxe/src/lib/dde_ipxe/dde_support.cc b/repos/dde_ipxe/src/lib/dde_ipxe/dde_support.cc index b3f0fcf19..c7fbe57f8 100644 --- a/repos/dde_ipxe/src/lib/dde_ipxe/dde_support.cc +++ b/repos/dde_ipxe/src/lib/dde_ipxe/dde_support.cc @@ -194,20 +194,14 @@ struct Pci_driver { Platform::Device_client client(_cap); - Genode::size_t donate = 4096; - Genode::retry( - [&] () { client.config_write(devfn, val, _access_size(val)); }, - [&] () { - _pci.upgrade_ram(donate); - donate *= 2; - }); + _pci.with_upgrade([&] () { + client.config_write(devfn, val, _access_size(val)); }); } int first_device(int *bus, int *dev, int *fun) { - _cap = Genode::retry( - [&] () { return _pci.first_device(CLASS_NETWORK, CLASS_MASK); }, - [&] () { _pci.upgrade_ram(4096); }); + _cap = _pci.with_upgrade([&] () { + return _pci.first_device(CLASS_NETWORK, CLASS_MASK); }); if (!_cap.valid()) return -1; @@ -221,9 +215,8 @@ struct Pci_driver int result = -1; _last_cap = _cap; - _cap = Genode::retry( - [&] () { return _pci.next_device(_cap, CLASS_NETWORK, CLASS_MASK); }, - [&] () { _pci.upgrade_ram(4096); }); + _cap = _pci.with_upgrade([&] () { + return _pci.next_device(_cap, CLASS_NETWORK, CLASS_MASK); }); if (_cap.valid()) { _bus_address(bus, dev, fun); @@ -243,12 +236,17 @@ struct Pci_driver size_t donate = size; - Ram_dataspace_capability ram_cap = Genode::retry( - [&] () { return _pci.alloc_dma_buffer(size); }, - [&] () { - _pci.upgrade_ram(donate); - donate = donate * 2 > size ? 4096 : donate * 2; - }); + Ram_dataspace_capability ram_cap = + retry( + [&] () { + return retry( + [&] () { return _pci.alloc_dma_buffer(size); }, + [&] () { _pci.upgrade_caps(2); }); + }, + [&] () { + _pci.upgrade_ram(donate); + donate = donate * 2 > size ? 4096 : donate * 2; + }); _region.mapped_base = _rm.attach(ram_cap); _region.base = Dataspace_client(ram_cap).phys_addr(); diff --git a/repos/dde_linux/src/include/lx_kit/internal/pci_dev.h b/repos/dde_linux/src/include/lx_kit/internal/pci_dev.h index 0967f4e99..5fc78eea4 100644 --- a/repos/dde_linux/src/include/lx_kit/internal/pci_dev.h +++ b/repos/dde_linux/src/include/lx_kit/internal/pci_dev.h @@ -184,13 +184,8 @@ class Lx::Pci_dev : public pci_dev, public Lx_kit::List::Element template void config_write(unsigned int devfn, T val) { - Genode::size_t donate = 4096; - Genode::retry( - [&] () { _client.config_write(devfn, val, _access_size(val)); }, - [&] () { - pci()->upgrade_ram(donate); - donate *= 2; - }); + pci()->with_upgrade([&] () { + _client.config_write(devfn, val, _access_size(val)); }); } Platform::Device &client() { return _client; } @@ -223,19 +218,13 @@ class Lx::Pci_dev : public pci_dev, public Lx_kit::List::Element template void Lx::for_each_pci_device(FUNC const &func) { - /* - * Functor that is called if the platform driver throws a - * 'Out_of_metadata' exception. - */ - auto handler = [&] () { Lx::pci()->upgrade_ram(4096); }; - /* * Obtain first device, the operation may exceed the session quota. * So we use the 'retry' mechanism. */ - Platform::Device_capability cap; - auto attempt = [&] () { cap = Lx::pci()->first_device(); }; - Genode::retry(attempt, handler); + Platform::Device_capability cap = + Lx::pci()->with_upgrade([&] () { + return Lx::pci()->first_device(); }); /* * Iterate over the devices of the platform session. @@ -252,12 +241,12 @@ void Lx::for_each_pci_device(FUNC const &func) * Release current device and try next one. Upgrade session * quota on demand. */ - auto attempt = [&] () { - Platform::Device_capability next_cap = pci()->next_device(cap); - Lx::pci()->release_device(cap); - cap = next_cap; - }; - Genode::retry(attempt, handler); + Platform::Device_capability next_cap = + Lx::pci()->with_upgrade([&] () { + return pci()->next_device(cap); }); + + Lx::pci()->release_device(cap); + cap = next_cap; } } diff --git a/repos/dde_linux/src/lib/usb/raw/raw.cc b/repos/dde_linux/src/lib/usb/raw/raw.cc index 54460d0e6..5396ec59e 100644 --- a/repos/dde_linux/src/lib/usb/raw/raw.cc +++ b/repos/dde_linux/src/lib/usb/raw/raw.cc @@ -835,10 +835,11 @@ class Usb::Root : public Genode::Root_component Session_component(tx_ds, _env.ep(), _env.rm(), vendor, product, bus, dev); ::Session::list()->insert(session); return session; - } catch (Genode::Session_policy::No_policy_defined) { + } + catch (Genode::Session_policy::No_policy_defined) { error("Invalid session request, no matching policy for '", label.string(), "'"); - throw Genode::Root::Unavailable(); + throw Genode::Service_denied(); } } diff --git a/repos/dde_linux/src/lib/usb/spec/x86/pci_driver.cc b/repos/dde_linux/src/lib/usb/spec/x86/pci_driver.cc index 5cad393e8..d982eaec1 100644 --- a/repos/dde_linux/src/lib/usb/spec/x86/pci_driver.cc +++ b/repos/dde_linux/src/lib/usb/spec/x86/pci_driver.cc @@ -56,19 +56,13 @@ class Pci_dev_list Pci_dev_list() { - /* - * Functor that is called if the platform driver throws a - * 'Out_of_metadata' exception. - */ - auto handler = [&] () { Lx::pci()->upgrade_ram(4096); }; - /* * Obtain first device, the operation may exceed the session quota. - * So we use the 'retry' mechanism. + * So we use the 'with_upgrade' mechanism. */ - Platform::Device_capability cap; - auto attempt = [&] () { cap = Lx::pci()->first_device(); }; - Genode::retry(attempt, handler); + Platform::Device_capability cap = + Lx::pci()->with_upgrade([&] () { + return Lx::pci()->first_device(); }); /* * Iterate over the devices of the platform session. @@ -77,12 +71,9 @@ class Pci_dev_list _pci_caps.insert(new (Lx::Malloc::mem()) Element(cap)); - /* try next one. Upgrade session * quota on demand.*/ - auto attempt = [&] () { - cap = Lx::pci()->next_device(cap); - }; - - Genode::retry(attempt, handler); + /* try next one. Upgrade session quota on demand.*/ + Lx::pci()->with_upgrade([&] () { + cap = Lx::pci()->next_device(cap); }); } } diff --git a/repos/dde_linux/src/lib/wifi/nic.cc b/repos/dde_linux/src/lib/wifi/nic.cc index 8cf865f8f..3d0d5326d 100644 --- a/repos/dde_linux/src/lib/wifi/nic.cc +++ b/repos/dde_linux/src/lib/wifi/nic.cc @@ -190,7 +190,7 @@ class Root : public Genode::Root_component ram_quota - session_size) { Genode::error("insufficient 'ram_quota', got ", ram_quota, " need ", tx_buf_size + rx_buf_size + session_size); - throw Genode::Root::Quota_exceeded(); + throw Genode::Insufficient_ram_quota(); } session = new (md_alloc()) diff --git a/repos/dde_linux/src/lx_kit/mapped_io_mem_range.cc b/repos/dde_linux/src/lx_kit/mapped_io_mem_range.cc index d76306a39..78f9c24e7 100644 --- a/repos/dde_linux/src/lx_kit/mapped_io_mem_range.cc +++ b/repos/dde_linux/src/lx_kit/mapped_io_mem_range.cc @@ -127,7 +127,7 @@ void *Lx::ioremap(addr_t phys_addr, unsigned long size, Lx_kit::Mapped_io_mem_range *io_mem = nullptr; - retry( + retry( [&] () { io_mem = new (&Lx_kit::env().heap()) Lx_kit::Mapped_io_mem_range(Lx_kit::env().env(), *_global_rm, diff --git a/repos/dde_linux/src/lx_kit/pci.cc b/repos/dde_linux/src/lx_kit/pci.cc index 38828b693..dab6cf3b2 100644 --- a/repos/dde_linux/src/lx_kit/pci.cc +++ b/repos/dde_linux/src/lx_kit/pci.cc @@ -123,8 +123,12 @@ Lx::backend_alloc(Genode::addr_t size, Genode::Cache_attribute cached) obj = new (_global_md_alloc) Ram_object(*_global_ram, cap); } else { Genode::size_t donate = size; - cap = retry( - [&] () { return _global_pci->alloc_dma_buffer(size); }, + cap = retry( + [&] () { + return retry( + [&] () { return _global_pci->alloc_dma_buffer(size); }, + [&] () { _global_pci->upgrade_caps(2); }); + }, [&] () { _global_pci->upgrade_ram(donate); donate = donate * 2 > size ? 4096 : donate * 2; diff --git a/repos/dde_rump/include/util/allocator_fap.h b/repos/dde_rump/include/util/allocator_fap.h index 333a2dea6..ba559add5 100644 --- a/repos/dde_rump/include/util/allocator_fap.h +++ b/repos/dde_rump/include/util/allocator_fap.h @@ -91,10 +91,14 @@ namespace Allocator { /* lookup phys. address */ _ds_phys[_index] = Genode::Dataspace_client(_ds_cap[_index]).phys_addr(); } catch (Genode::Out_of_ram) { - warning("backend allocator exhausted"); + warning("backend allocator exhausted (out of RAM)"); _quota_exceeded = true; return false; - } catch (Genode::Region_map::Attach_failed) { + } catch (Genode::Out_of_caps) { + warning("backend allocator exhausted (out of caps)"); + _quota_exceeded = true; + return false; + } catch (Genode::Region_map::Region_conflict) { warning("backend VM region exhausted"); _quota_exceeded = true; return false; diff --git a/repos/dde_rump/src/server/rump_cgd/block_driver.h b/repos/dde_rump/src/server/rump_cgd/block_driver.h index b78b19d24..c4641f102 100644 --- a/repos/dde_rump/src/server/rump_cgd/block_driver.h +++ b/repos/dde_rump/src/server/rump_cgd/block_driver.h @@ -46,7 +46,7 @@ class Driver : public Block::Driver _cgd_device = Cgd::init(Genode::env()->heap(), ep); } catch (...) { Genode::error("could not initialize cgd device."); - throw Genode::Root::Unavailable(); + throw Genode::Service_denied(); } _blk_cnt = _cgd_device->block_count(); diff --git a/repos/dde_rump/src/server/rump_fs/main.cc b/repos/dde_rump/src/server/rump_fs/main.cc index 8eaa3a7b3..ca9b94d9d 100644 --- a/repos/dde_rump/src/server/rump_fs/main.cc +++ b/repos/dde_rump/src/server/rump_fs/main.cc @@ -384,7 +384,7 @@ class File_system::Root : public Root_component Arg_string::find_arg(args, "tx_buf_size").aligned_size(); if (!tx_buf_size) - throw Root::Invalid_args(); + throw Service_denied(); /* * Check if donated ram quota suffices for session data, @@ -417,10 +417,8 @@ class File_system::Root : public Root_component */ if (policy.attribute_value("writeable", false)) writeable = Arg_string::find_arg(args, "writeable").bool_value(false); - } catch (Session_policy::No_policy_defined) { - /* missing policy - deny request */ - throw Root::Unavailable(); } + catch (Session_policy::No_policy_defined) { throw Service_denied(); } /* apply client's root offset */ Arg_string::find_arg(args, "root").string(tmp, sizeof(tmp), "/"); @@ -435,9 +433,10 @@ class File_system::Root : public Root_component try { return new (md_alloc()) Session_component(_env, tx_buf_size, root_dir, writeable, *md_alloc()); - } catch (Lookup_failed) { + } + catch (Lookup_failed) { Genode::error("File system root directory \"", root_dir, "\" does not exist"); - throw Root::Unavailable(); + throw Service_denied(); } } diff --git a/repos/dde_rump/src/test/blk_crypt/main.cc b/repos/dde_rump/src/test/blk_crypt/main.cc index 1eeb9f26b..08ccbddbd 100644 --- a/repos/dde_rump/src/test/blk_crypt/main.cc +++ b/repos/dde_rump/src/test/blk_crypt/main.cc @@ -37,7 +37,8 @@ int main(int argc, char *argv[]) Genode::memcpy(buffer, blk.tx()->packet_content(p), blk_sz); /* XXX compare content */ - } catch(Genode::Parent::Service_denied) { + } + catch(Genode::Service_denied) { Genode::error("opening block session was denied"); return -1; } diff --git a/repos/demo/include/launchpad/launchpad.h b/repos/demo/include/launchpad/launchpad.h index e540b3fdc..305df4c05 100644 --- a/repos/demo/include/launchpad/launchpad.h +++ b/repos/demo/include/launchpad/launchpad.h @@ -199,7 +199,7 @@ class Launchpad_child : public Genode::Child_policy, return *service; Genode::warning(name(), ": service ", service_name, " not available"); - throw Genode::Parent::Service_denied(); + throw Genode::Service_denied(); } void announce_service(Genode::Service::Name const &service_name) override diff --git a/repos/gems/src/app/decorator/main.cc b/repos/gems/src/app/decorator/main.cc index 6313cfcf0..9a70dcb58 100644 --- a/repos/gems/src/app/decorator/main.cc +++ b/repos/gems/src/app/decorator/main.cc @@ -161,10 +161,15 @@ struct Decorator::Main : Window_factory_base return new (_heap) Window(attribute(window_node, "id", 0UL), _nitpicker, _animator, _decorator_config); - } catch (Nitpicker::Session::Out_of_metadata) { - Genode::log("Handle Out_of_metadata of nitpicker session - upgrade by 8K"); + } + catch (Genode::Out_of_ram) { + Genode::log("Handle Out_of_ram of nitpicker session - upgrade by 8K"); _nitpicker.upgrade_ram(8192); } + catch (Genode::Out_of_caps) { + Genode::log("Handle Out_of_caps of nitpicker session - upgrade by 2"); + _nitpicker.upgrade_ram(2); + } } return nullptr; } diff --git a/repos/gems/src/app/launcher/subsystem_manager.h b/repos/gems/src/app/launcher/subsystem_manager.h index c82f91220..8e4e2a425 100644 --- a/repos/gems/src/app/launcher/subsystem_manager.h +++ b/repos/gems/src/app/launcher/subsystem_manager.h @@ -206,8 +206,8 @@ class Launcher::Subsystem_manager _children.insert(child); child->start(); - - } catch (Parent::Service_denied) { + } + catch (Service_denied) { Genode::error("failed to start ", binary_name); throw Invalid_config(); } diff --git a/repos/gems/src/app/themed_decorator/main.cc b/repos/gems/src/app/themed_decorator/main.cc index fda0ad379..8e97afafc 100644 --- a/repos/gems/src/app/themed_decorator/main.cc +++ b/repos/gems/src/app/themed_decorator/main.cc @@ -118,7 +118,7 @@ struct Decorator::Main : Window_factory_base * high amount of view handles. * * XXX Consider upgrading the session quota on demand by responding - * to Out_of_metadata exceptions raised by the create_view + * to Out_of_ram or Out_of_caps exceptions raised by the create_view * and view_handle operations. Currently, these exceptions will * abort the decorator. */ diff --git a/repos/gems/src/server/file_terminal/main.cc b/repos/gems/src/server/file_terminal/main.cc index 02ae698c6..04d4f371e 100644 --- a/repos/gems/src/server/file_terminal/main.cc +++ b/repos/gems/src/server/file_terminal/main.cc @@ -246,13 +246,14 @@ namespace Terminal { return new (md_alloc()) Session_component(_env, io_buffer_size, filename); - - } catch (Genode::Xml_node::Nonexistent_attribute) { + } + catch (Genode::Xml_node::Nonexistent_attribute) { Genode::error("missing \"filename\" attribute in policy definition"); - throw Genode::Root::Unavailable(); - } catch (Genode::Session_policy::No_policy_defined) { + throw Genode::Service_denied(); + } + catch (Genode::Session_policy::No_policy_defined) { Genode::error("invalid session request, no matching policy"); - throw Genode::Root::Unavailable(); + throw Genode::Service_denied(); } } diff --git a/repos/gems/src/server/tcp_terminal/main.cc b/repos/gems/src/server/tcp_terminal/main.cc index 3d42548c6..cff946608 100644 --- a/repos/gems/src/server/tcp_terminal/main.cc +++ b/repos/gems/src/server/tcp_terminal/main.cc @@ -524,13 +524,14 @@ class Terminal::Root_component : public Genode::Root_component( - [&] () { return _pci_drv.first_device(); }, - [&] () { _pci_drv.upgrade_ram(4096); }); + return _pci_drv.with_upgrade([&] () { + return _pci_drv.first_device(); }); } Platform::Device_capability _next_device(Platform::Device_capability prev) { - return Genode::retry( - [&] () { return _pci_drv.next_device(prev); }, - [&] () { _pci_drv.upgrade_ram(4096); }); + return _pci_drv.with_upgrade([&] () { + return _pci_drv.next_device(prev); }); } Platform::Device_capability _find_vga_card() diff --git a/repos/libports/src/drivers/framebuffer/vesa/main.cc b/repos/libports/src/drivers/framebuffer/vesa/main.cc index 9c4c22415..505a5f0f8 100644 --- a/repos/libports/src/drivers/framebuffer/vesa/main.cc +++ b/repos/libports/src/drivers/framebuffer/vesa/main.cc @@ -198,7 +198,7 @@ class Framebuffer::Root : public Root_component if (Framebuffer::set_mode(scr_width, scr_height, scr_depth) != 0) { Genode::warning("Could not set vesa mode ", scr_width, "x", scr_height, "@", scr_depth); - throw Root::Invalid_args(); + throw Genode::Service_denied(); } Genode::log("using video mode: ", diff --git a/repos/libports/src/lib/acpica/osl.cc b/repos/libports/src/lib/acpica/osl.cc index 0629b1de0..910c83db4 100644 --- a/repos/libports/src/lib/acpica/osl.cc +++ b/repos/libports/src/lib/acpica/osl.cc @@ -166,9 +166,8 @@ ACPI_STATUS AcpiOsReadPort (ACPI_IO_ADDRESS port, UINT32 *value, UINT32 width) default: FAIL(AE_BAD_PARAMETER) } - } catch (Genode::Parent::Service_denied) { - return AE_BAD_PARAMETER; } + catch (Genode::Service_denied) { return AE_BAD_PARAMETER; } return AE_OK; } @@ -196,9 +195,8 @@ ACPI_STATUS AcpiOsWritePort (ACPI_IO_ADDRESS port, UINT32 value, UINT32 width) default: FAIL(AE_BAD_PARAMETER) } - } catch (Genode::Parent::Service_denied) { - return AE_BAD_PARAMETER; } + catch (Genode::Service_denied) { return AE_BAD_PARAMETER; } return AE_OK; } diff --git a/repos/libports/src/lib/egl/driver.cc b/repos/libports/src/lib/egl/driver.cc index 4b3e55a0f..d293706fe 100644 --- a/repos/libports/src/lib/egl/driver.cc +++ b/repos/libports/src/lib/egl/driver.cc @@ -647,7 +647,8 @@ class Display : public native_display try { _mode.width = genode_framebuffer()->width(); _mode.height = genode_framebuffer()->height(); - } catch (Genode::Parent::Service_denied) { + } + catch (Genode::Service_denied) { Genode::warning("EGL driver: could not create a Framebuffer session. " "Screen surfaces cannot be used."); _mode.width = 1; diff --git a/repos/libports/src/lib/libc/libc_mem_alloc.cc b/repos/libports/src/lib/libc/libc_mem_alloc.cc index f817be715..264663cd5 100644 --- a/repos/libports/src/lib/libc/libc_mem_alloc.cc +++ b/repos/libports/src/lib/libc/libc_mem_alloc.cc @@ -58,7 +58,7 @@ int Libc::Mem_alloc_impl::Dataspace_pool::expand(size_t size, Range_allocator *a } catch (Out_of_ram) { return -2; } catch (Out_of_caps) { return -4; } - catch (Region_map::Attach_failed) { + catch (Region_map::Region_conflict) { _ram_session->free(new_ds_cap); return -3; } diff --git a/repos/libports/src/lib/libc_lwip_nic_dhcp/init.cc b/repos/libports/src/lib/libc_lwip_nic_dhcp/init.cc index f37bafca2..5d90de777 100644 --- a/repos/libports/src/lib/libc_lwip_nic_dhcp/init.cc +++ b/repos/libports/src/lib/libc_lwip_nic_dhcp/init.cc @@ -121,9 +121,8 @@ void __attribute__((constructor)) init_nic_dhcp(void) try { lwip_nic_init(ip_addr, netmask, gateway, (Genode::size_t)tx_buf_size, (Genode::size_t)rx_buf_size); - } catch (Genode::Parent::Service_denied) { - /* ignore for now */ } + catch (Genode::Service_denied) { /* ignore for now */ } if (provide_etc_resolv_conf) create_etc_resolv_conf_plugin(); diff --git a/repos/libports/src/lib/lwip/platform/nic.cc b/repos/libports/src/lib/lwip/platform/nic.cc index 1b49adec0..936cde902 100644 --- a/repos/libports/src/lib/lwip/platform/nic.cc +++ b/repos/libports/src/lib/lwip/platform/nic.cc @@ -288,7 +288,8 @@ extern "C" { nic = new (env()->heap()) Nic::Connection(tx_block_alloc, nbs->tx_buf_size, nbs->rx_buf_size); - } catch (Parent::Service_denied) { + } + catch (Service_denied) { destroy(env()->heap(), tx_block_alloc); return ERR_IF; } diff --git a/repos/libports/src/lib/qt5/patches/qt5_qml.patch b/repos/libports/src/lib/qt5/patches/qt5_qml.patch index dc6c91773..faa8c3db9 100644 --- a/repos/libports/src/lib/qt5/patches/qt5_qml.patch +++ b/repos/libports/src/lib/qt5/patches/qt5_qml.patch @@ -90,7 +90,7 @@ index 5702c59..3d616b5 100644 QT_BEGIN_NAMESPACE diff --git a/qtjsbackend/src/3rdparty/v8/src/platform-genode.cc b/qtjsbackend/src/3rdparty/v8/src/platform-genode.cc new file mode 100644 -index 0000000..25bdfc7 +index 0000000..705b371 --- /dev/null +++ b/qtjsbackend/src/3rdparty/v8/src/platform-genode.cc @@ -0,0 +1,686 @@ @@ -483,7 +483,7 @@ index 0000000..25bdfc7 + + try { + rm->attach(ds_cap, (Genode::addr_t)base, is_executable); -+ } catch (Genode::Rm_session::Region_conflict) { ++ } catch (Genode::Region_map::Region_conflict) { + return false; + } + diff --git a/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc b/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc index 393e65858..1bd544e0c 100644 --- a/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc +++ b/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc @@ -152,7 +152,8 @@ static SDL_AudioDevice *GENODEAUD_CreateDevice(int devindex) Audio_out::Connection(channel_names[channel], false, channel == 0 ? true : false); _this->hidden->audio[channel]->start(); - } catch(Genode::Parent::Service_denied) { + } + catch(Genode::Service_denied) { Genode::error("could not connect to 'Audio_out' service"); while(--channel > 0) diff --git a/repos/libports/src/server/ffat_fs/main.cc b/repos/libports/src/server/ffat_fs/main.cc index 8908bb037..5f1311589 100644 --- a/repos/libports/src/server/ffat_fs/main.cc +++ b/repos/libports/src/server/ffat_fs/main.cc @@ -887,43 +887,45 @@ namespace File_system { throw Lookup_failed(); case FR_NOT_READY: error("f_chdir() failed with error code FR_NOT_READY"); - throw Root::Unavailable(); + throw Service_denied(); case FR_DISK_ERR: error("f_chdir() failed with error code FR_DISK_ERR"); - throw Root::Unavailable(); + throw Service_denied(); case FR_INT_ERR: error("f_chdir() failed with error code FR_INT_ERR"); - throw Root::Unavailable(); + throw Service_denied(); case FR_NOT_ENABLED: error("f_chdir() failed with error code FR_NOT_ENABLED"); - throw Root::Unavailable(); + throw Service_denied(); case FR_NO_FILESYSTEM: error("f_chdir() failed with error code FR_NO_FILESYSTEM"); - throw Root::Unavailable(); + throw Service_denied(); default: /* not supposed to occur according to the libffat documentation */ error("f_chdir() returned an unexpected error code"); - throw Root::Unavailable(); + throw Service_denied(); } session_root_dir = new (&_md_alloc) Directory(root); } - } catch (Xml_node::Nonexistent_attribute) { + } + catch (Xml_node::Nonexistent_attribute) { error("missing \"root\" attribute in policy definition"); - throw Root::Unavailable(); - } catch (Lookup_failed) { + throw Service_denied(); + } + catch (Lookup_failed) { error("session root directory \"", Cstring(root), "\" does not exist"); - throw Root::Unavailable(); + throw Service_denied(); } /* * Determine if write access is permitted for the session. */ writeable = policy.attribute_value("writeable", false); - - } catch (Session_policy::No_policy_defined) { + } + catch (Session_policy::No_policy_defined) { error("Invalid session request, no matching policy"); - throw Root::Unavailable(); + throw Service_denied(); } size_t ram_quota = @@ -933,7 +935,7 @@ namespace File_system { if (!tx_buf_size) { error(label, " requested a session with a zero length transmission buffer"); - throw Root::Invalid_args(); + throw Service_denied(); } /* diff --git a/repos/libports/src/server/fuse_fs/fuse_fs_main.cc b/repos/libports/src/server/fuse_fs/fuse_fs_main.cc index 450597e40..24b41f164 100644 --- a/repos/libports/src/server/fuse_fs/fuse_fs_main.cc +++ b/repos/libports/src/server/fuse_fs/fuse_fs_main.cc @@ -441,13 +441,15 @@ class File_system::Root : public Root_component throw Lookup_failed(); root_dir = root; - } catch (Xml_node::Nonexistent_attribute) { + } + catch (Xml_node::Nonexistent_attribute) { Genode::error("missing \"root\" attribute in policy definition"); - throw Root::Unavailable(); - } catch (Lookup_failed) { + throw Service_denied(); + } + catch (Lookup_failed) { Genode::error("session root directory \"", Genode::Cstring(root), "\" does not exist"); - throw Root::Unavailable(); + throw Service_denied(); } /* @@ -459,7 +461,7 @@ class File_system::Root : public Root_component } catch (Session_policy::No_policy_defined) { Genode::error("Invalid session request, no matching policy"); - throw Root::Unavailable(); + throw Genode::Service_denied(); } size_t ram_quota = @@ -469,7 +471,7 @@ class File_system::Root : public Root_component if (!tx_buf_size) { Genode::error(label, " requested a session with a zero length transmission buffer"); - throw Root::Invalid_args(); + throw Genode::Service_denied(); } /* diff --git a/repos/os/include/file_system/node_handle_registry.h b/repos/os/include/file_system/node_handle_registry.h index c79f584a5..cb8ceb26d 100644 --- a/repos/os/include/file_system/node_handle_registry.h +++ b/repos/os/include/file_system/node_handle_registry.h @@ -38,6 +38,10 @@ namespace File_system { class Node_handle_registry { + public: + + class Out_of_node_handles : public Exception { }; + private: /* maximum number of open nodes per session */ @@ -56,7 +60,7 @@ namespace File_system { /** * Allocate node handle * - * \throw Out_of_metadata + * \throw Out_of_node_handles */ int _alloc(Node_base *node) { @@ -68,7 +72,7 @@ namespace File_system { return i; } - throw Out_of_metadata(); + throw Out_of_node_handles(); } bool _in_range(int handle) const diff --git a/repos/os/include/file_system_session/connection.h b/repos/os/include/file_system_session/connection.h index b7d511387..3dfdfc93f 100644 --- a/repos/os/include/file_system_session/connection.h +++ b/repos/os/include/file_system_session/connection.h @@ -110,45 +110,47 @@ struct File_system::Connection : File_system::Connection_base using Connection_base::Connection_base; /** - * Upgrade the session quota in response to Out_of_metadata + * Extend session quota on demand while calling an RPC function + * + * \noapi */ - void upgrade_ram() + template + auto _retry(FUNC func) -> decltype(func()) { - File_system::Connection_base::upgrade_ram(8*1024); + enum { UPGRADE_ATTEMPTS = 2 }; + return Genode::retry( + [&] () { + return Genode::retry( + [&] () { return func(); }, + [&] () { File_system::Connection_base::upgrade_caps(2); }, + UPGRADE_ATTEMPTS); + }, + [&] () { File_system::Connection_base::upgrade_ram(8*1024); }, + UPGRADE_ATTEMPTS); } - enum { UPGRADE_ATTEMPTS = 2 }; - Dir_handle dir(Path const &path, bool create) override { - return Genode::retry( - [&] () { return Session_client::dir(path, create); }, - [&] () { upgrade_ram(); }, - UPGRADE_ATTEMPTS); + return _retry([&] () { + return Session_client::dir(path, create); }); } File_handle file(Dir_handle dir, Name const &name, Mode mode, bool create) override { - return Genode::retry( - [&] () { return Session_client::file(dir, name, mode, create); }, - [&] () { upgrade_ram(); }, - UPGRADE_ATTEMPTS); + return _retry([&] () { + return Session_client::file(dir, name, mode, create); }); } Symlink_handle symlink(Dir_handle dir, Name const &name, bool create) override { - return Genode::retry( - [&] () { return Session_client::symlink(dir, name, create); }, - [&] () { upgrade_ram(); }, - UPGRADE_ATTEMPTS); + return _retry([&] () { + return Session_client::symlink(dir, name, create); }); } Node_handle node(Path const &path) override { - return Genode::retry( - [&] () { return Session_client::node(path); }, - [&] () { upgrade_ram(); }, - UPGRADE_ATTEMPTS); + return _retry([&] () { + return Session_client::node(path); }); } }; diff --git a/repos/os/include/file_system_session/file_system_session.h b/repos/os/include/file_system_session/file_system_session.h index 97e037f88..75180318e 100644 --- a/repos/os/include/file_system_session/file_system_session.h +++ b/repos/os/include/file_system_session/file_system_session.h @@ -33,6 +33,9 @@ namespace File_system { typedef Genode::uint64_t seek_off_t; typedef Genode::uint64_t file_size_t; + typedef Genode::Out_of_ram Out_of_ram; + typedef Genode::Out_of_caps Out_of_caps; + class Packet_descriptor; /** @@ -72,7 +75,6 @@ namespace File_system { class Node_already_exists : Exception { }; class No_space : Exception { }; class Not_empty : Exception { }; - class Out_of_metadata : Exception { }; class Permission_denied : Exception { }; struct Session; @@ -274,7 +276,8 @@ struct File_system::Session : public Genode::Session * \throw Node_already_exists file cannot be created because a node with * the same name already exists * \throw No_space storage exhausted - * \throw Out_of_metadata server cannot allocate metadata + * \throw Out_of_ram server cannot allocate metadata + * \throw Out_of_caps * \throw Permission_denied */ virtual File_handle file(Dir_handle, Name const &name, Mode, bool create) = 0; @@ -288,7 +291,8 @@ struct File_system::Session : public Genode::Session * \throw Node_already_exists symlink cannot be created because a node with * the same name already exists * \throw No_space storage exhausted - * \throw Out_of_metadata server cannot allocate metadata + * \throw Out_of_ram server cannot allocate metadata + * \throw Out_of_caps * \throw Permission_denied */ virtual Symlink_handle symlink(Dir_handle, Name const &name, bool create) = 0; @@ -302,7 +306,8 @@ struct File_system::Session : public Genode::Session * \throw Node_already_exists directory cannot be created because a * node with the same name already exists * \throw No_space storage exhausted - * \throw Out_of_metadata server cannot allocate metadata + * \throw Out_of_ram server cannot allocate metadata + * \throw Out_of_caps * \throw Permission_denied */ virtual Dir_handle dir(Path const &path, bool create) = 0; @@ -315,7 +320,8 @@ struct File_system::Session : public Genode::Session * * \throw Lookup_failed path lookup failed because one element * of 'path' does not exist - * \throw Out_of_metadata server cannot allocate metadata + * \throw Out_of_ram server cannot allocate metadata + * \throw Out_of_caps */ virtual Node_handle node(Path const &path) = 0; @@ -383,22 +389,22 @@ struct File_system::Session : public Genode::Session GENODE_RPC_THROW(Rpc_file, File_handle, file, GENODE_TYPE_LIST(Invalid_handle, Invalid_name, Lookup_failed, Node_already_exists, - No_space, Out_of_metadata, + No_space, Out_of_ram, Out_of_caps, Permission_denied), Dir_handle, Name const &, Mode, bool); GENODE_RPC_THROW(Rpc_symlink, Symlink_handle, symlink, GENODE_TYPE_LIST(Invalid_handle, Invalid_name, Lookup_failed, Node_already_exists, - No_space, Out_of_metadata, + No_space, Out_of_ram, Out_of_caps, Permission_denied), Dir_handle, Name const &, bool); GENODE_RPC_THROW(Rpc_dir, Dir_handle, dir, GENODE_TYPE_LIST(Lookup_failed, Name_too_long, Node_already_exists, No_space, - Out_of_metadata, Permission_denied), + Out_of_ram, Out_of_caps, Permission_denied), Path const &, bool); GENODE_RPC_THROW(Rpc_node, Node_handle, node, - GENODE_TYPE_LIST(Lookup_failed, Out_of_metadata), + GENODE_TYPE_LIST(Lookup_failed, Out_of_ram, Out_of_caps), Path const &); GENODE_RPC(Rpc_close, void, close, Node_handle); GENODE_RPC(Rpc_status, Status, status, Node_handle); diff --git a/repos/os/include/gpio/component.h b/repos/os/include/gpio/component.h index bea177d80..61cad005b 100644 --- a/repos/os/include/gpio/component.h +++ b/repos/os/include/gpio/component.h @@ -127,7 +127,7 @@ class Gpio::Root : public Genode::Root_component Genode::Arg_string::find_arg(args, "ram_quota").ulong_value(0); if (!_driver.gpio_valid(pin)) - throw Invalid_args(); + throw Genode::Service_denied(); if (ram_quota < sizeof(Session_component)) { Genode::warning("insufficient dontated ram_quota " diff --git a/repos/os/include/input/root.h b/repos/os/include/input/root.h index 4d5f08631..97d575a3b 100644 --- a/repos/os/include/input/root.h +++ b/repos/os/include/input/root.h @@ -54,7 +54,7 @@ class Input::Root_component : public Genode::Static_root Genode::Affinity const &affinity) override { if (_session.event_queue().enabled()) - throw Root::Unavailable(); + throw Genode::Service_denied(); _session.event_queue().enabled(true); diff --git a/repos/os/include/nitpicker_session/nitpicker_session.h b/repos/os/include/nitpicker_session/nitpicker_session.h index 207b2724b..73b9e9673 100644 --- a/repos/os/include/nitpicker_session/nitpicker_session.h +++ b/repos/os/include/nitpicker_session/nitpicker_session.h @@ -23,14 +23,21 @@ #include namespace Nitpicker { + using Genode::size_t; + struct Session_client; struct View; - typedef Genode::Capability View_capability; struct Session; + + typedef Genode::Capability View_capability; + typedef Genode::Surface_base::Rect Rect; typedef Genode::Surface_base::Point Point; typedef Genode::Surface_base::Area Area; + + typedef Genode::Out_of_ram Out_of_ram; + typedef Genode::Out_of_caps Out_of_caps; } @@ -194,7 +201,6 @@ struct Nitpicker::Session : Genode::Session /** * Exception types */ - struct Out_of_metadata : Genode::Exception { }; struct Invalid_handle : Genode::Exception { }; virtual ~Session() { } @@ -238,7 +244,8 @@ struct Nitpicker::Session : Genode::Session * \param handle designated view handle to be assigned to the imported * view. By default, a new handle will be allocated. * - * \throw Out_of_metadata + * \throw Out_of_ram + * \throw Out_of_caps */ virtual View_handle view_handle(View_capability, View_handle handle = View_handle()) = 0; @@ -279,8 +286,9 @@ struct Nitpicker::Session : Genode::Session /** * Define dimensions of virtual framebuffer * - * \throw Out_of_metadata session quota does not suffice for specified - * buffer dimensions + * \throw Out_of_ram session quota does not suffice for specified + * buffer dimensions + * \throw Out_of_caps */ virtual void buffer(Framebuffer::Mode mode, bool use_alpha) = 0; @@ -335,10 +343,10 @@ struct Nitpicker::Session : Genode::Session GENODE_RPC(Rpc_framebuffer_session, Framebuffer::Session_capability, framebuffer_session); GENODE_RPC(Rpc_input_session, Input::Session_capability, input_session); GENODE_RPC_THROW(Rpc_create_view, View_handle, create_view, - GENODE_TYPE_LIST(Out_of_metadata, Invalid_handle), View_handle); + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps, Invalid_handle), View_handle); GENODE_RPC(Rpc_destroy_view, void, destroy_view, View_handle); GENODE_RPC_THROW(Rpc_view_handle, View_handle, view_handle, - GENODE_TYPE_LIST(Out_of_metadata), View_capability, View_handle); + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), View_capability, View_handle); GENODE_RPC(Rpc_view_capability, View_capability, view_capability, View_handle); GENODE_RPC(Rpc_release_view_handle, void, release_view_handle, View_handle); GENODE_RPC(Rpc_command_dataspace, Genode::Dataspace_capability, command_dataspace); @@ -348,7 +356,7 @@ struct Nitpicker::Session : Genode::Session GENODE_RPC(Rpc_mode_sigh, void, mode_sigh, Genode::Signal_context_capability); GENODE_RPC(Rpc_focus, void, focus, Genode::Capability); GENODE_RPC(Rpc_session_control, void, session_control, Label, Session_control); - GENODE_RPC_THROW(Rpc_buffer, void, buffer, GENODE_TYPE_LIST(Out_of_metadata), + GENODE_RPC_THROW(Rpc_buffer, void, buffer, GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), Framebuffer::Mode, bool); GENODE_RPC_INTERFACE(Rpc_framebuffer_session, Rpc_input_session, diff --git a/repos/os/include/os/attached_mmio.h b/repos/os/include/os/attached_mmio.h index ccf6fbbe9..1eb930fc8 100644 --- a/repos/os/include/os/attached_mmio.h +++ b/repos/os/include/os/attached_mmio.h @@ -42,12 +42,12 @@ class Genode::Attached_mmio : public Attached_io_mem_dataspace, * \param size size of resource * \param write_combined enable write combining for the resource * - * \throw Parent::Service_denied + * \throw Service_denied * \throw Insufficient_ram_quota * \throw Insufficient_cap_quota * \throw Out_of_ram * \throw Out_of_caps - * \throw Rm_session::Attach_failed + * \throw Region_map::Region_conflict */ Attached_mmio(Env &env, addr_t base, size_t size, bool write_combined = false) diff --git a/repos/os/include/os/child_policy_dynamic_rom.h b/repos/os/include/os/child_policy_dynamic_rom.h index a53ae5138..e595ed316 100644 --- a/repos/os/include/os/child_policy_dynamic_rom.h +++ b/repos/os/include/os/child_policy_dynamic_rom.h @@ -121,8 +121,10 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object, /** * Load new content into ROM module * - * \throw Ram_session::Alloc_failed - * \throw Rm_session::Attach_failed + * \throw Out_of_ram + * \throw Out_of_caps + * \throw Region_map::Region_conflict + * \throw Region_map::Invalid_dataspace */ void load(void const *data, size_t data_len) { @@ -196,7 +198,7 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object, session.phase = Session_state::CLOSED; break; - case Session_state::INVALID_ARGS: + case Session_state::SERVICE_DENIED: case Session_state::INSUFFICIENT_RAM_QUOTA: case Session_state::INSUFFICIENT_CAP_QUOTA: case Session_state::AVAILABLE: diff --git a/repos/os/include/os/session_policy.h b/repos/os/include/os/session_policy.h index 8c5bd02f7..e53767c8e 100644 --- a/repos/os/include/os/session_policy.h +++ b/repos/os/include/os/session_policy.h @@ -167,7 +167,7 @@ class Genode::Session_policy : public Xml_node /** * Exception type */ - class No_policy_defined { }; + class No_policy_defined : public Service_denied { }; private: diff --git a/repos/os/include/os/slave.h b/repos/os/include/os/slave.h index 90d49e442..ad5849371 100644 --- a/repos/os/include/os/slave.h +++ b/repos/os/include/os/slave.h @@ -78,8 +78,8 @@ class Genode::Slave::Policy : public Child_policy * \param local_rm local address space, needed to populate dataspaces * provided to the child (config, session_requests) * - * \throw Ram_session::Alloc_failed by 'Child_policy_dynamic_rom_file' - * \throw Rm_session::Attach_failed by 'Child_policy_dynamic_rom_file' + * \throw Out_of_ram by 'Child_policy_dynamic_rom_file' + * \throw Out_of_caps by 'Child_policy_dynamic_rom_file' */ Policy(Label const &label, Name const &binary_name, @@ -174,7 +174,7 @@ class Genode::Slave::Policy : public Child_policy if (!service) { error(name(), ": illegal session request of " "service \"", service_name, "\" (", args, ")"); - throw Parent::Service_denied(); + throw Service_denied(); } return *service; @@ -231,7 +231,7 @@ class Genode::Slave::Connection_base session.phase = Session_state::CLOSED; break; - case Session_state::INVALID_ARGS: + case Session_state::SERVICE_DENIED: case Session_state::INSUFFICIENT_RAM_QUOTA: case Session_state::INSUFFICIENT_CAP_QUOTA: case Session_state::AVAILABLE: @@ -301,7 +301,7 @@ class Genode::Slave::Connection_base _policy.trigger_session_requests(); _service._lock.lock(); if (!_service._alive) - throw Parent::Service_denied(); + throw Service_denied(); } ~Connection_base() @@ -323,9 +323,10 @@ struct Genode::Slave::Connection : private Connection_base, /** * Constructor * - * \throw Parent::Service_denied parent denies session request - * \throw Out_of_ram our own quota does not suffice for - * the creation of the new session + * \throw Service_denied parent denies session request + * \throw Out_of_ram our own quota does not suffice for + * the creation of the new session + * \throw Out_of_caps */ Connection(Slave::Policy &policy, Args const &args, Affinity const &affinity = Affinity()) diff --git a/repos/os/include/regulator/component.h b/repos/os/include/regulator/component.h index 08202992e..684228154 100644 --- a/repos/os/include/regulator/component.h +++ b/repos/os/include/regulator/component.h @@ -84,7 +84,7 @@ class Regulator::Root : throw Insufficient_ram_quota(); if (!strlen(reg_name)) - throw Root::Invalid_args(); + throw Service_denied(); return new (md_alloc()) Session_component(regulator_id_by_name(reg_name), diff --git a/repos/os/include/report_rom/report_service.h b/repos/os/include/report_rom/report_service.h index e5507e6f9..a66b50cf6 100644 --- a/repos/os/include/report_rom/report_service.h +++ b/repos/os/include/report_rom/report_service.h @@ -45,11 +45,8 @@ struct Report::Session_component : Genode::Rpc_object, Rom::Writer Rom::Module &_create_module(Rom::Module::Name const &name) { - try { - return _registry.lookup(*this, name); - } catch (...) { - throw Genode::Root::Invalid_args(); - } + try { return _registry.lookup(*this, name); } + catch (...) { throw Genode::Service_denied(); } } static void _log_lines(char const *string, size_t len) @@ -134,7 +131,7 @@ struct Report::Root : Genode::Root_component if (buffer_size == 0) { Genode::error("zero-length report requested by ", label.string()); - throw Root::Invalid_args(); + throw Service_denied(); } return new (md_alloc()) diff --git a/repos/os/include/report_rom/rom_service.h b/repos/os/include/report_rom/rom_service.h index 44f9d828b..29135c3fb 100644 --- a/repos/os/include/report_rom/rom_service.h +++ b/repos/os/include/report_rom/rom_service.h @@ -46,10 +46,9 @@ class Rom::Session_component : public Genode::Rpc_object, Readable_module &_init_module(Genode::Session_label const &label) { - try { - return _registry.lookup(*this, label.string()); } + try { return _registry.lookup(*this, label.string()); } catch (Registry_for_reader::Lookup_failed) { - throw Genode::Root::Invalid_args(); } + throw Genode::Service_denied(); } } Constructible _ds; diff --git a/repos/os/include/spec/x86/platform_device/platform_device.h b/repos/os/include/spec/x86/platform_device/platform_device.h index cbdc76434..a8887d01d 100644 --- a/repos/os/include/spec/x86/platform_device/platform_device.h +++ b/repos/os/include/spec/x86/platform_device/platform_device.h @@ -24,8 +24,13 @@ /* os includes */ #include +namespace Platform { -namespace Platform { struct Device; } + struct Device; + + using Genode::Out_of_caps; + using Genode::Out_of_ram; +} struct Platform::Device : Platform::Abstract_device @@ -34,10 +39,6 @@ struct Platform::Device : Platform::Abstract_device ** Exception types ** *********************/ - class Alloc_failed : public Genode::Exception { }; - class Quota_exceeded : public Alloc_failed { }; - - class Resource { private: @@ -161,6 +162,9 @@ struct Platform::Device : Platform::Abstract_device /** * Write configuration space + * + * \throw Out_of_ram + * \throw Out_of_caps */ virtual void config_write(unsigned char address, unsigned value, Access_size size) = 0; @@ -169,6 +173,9 @@ struct Platform::Device : Platform::Abstract_device * Query Io_port of specified bar * * \param id index of according PCI resource of the device + * + * \throw Out_of_ram + * \throw Out_of_caps */ virtual Genode::Io_port_session_capability io_port(Genode::uint8_t id) = 0; @@ -235,14 +242,14 @@ struct Platform::Device : Platform::Abstract_device GENODE_RPC(Rpc_config_read, unsigned, config_read, unsigned char, Access_size); GENODE_RPC_THROW(Rpc_config_write, void, config_write, - GENODE_TYPE_LIST(Quota_exceeded), + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), unsigned char, unsigned, Access_size); GENODE_RPC(Rpc_irq, Genode::Irq_session_capability, irq, Genode::uint8_t); GENODE_RPC_THROW(Rpc_io_port, Genode::Io_port_session_capability, io_port, - GENODE_TYPE_LIST(Quota_exceeded), + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), Genode::uint8_t); GENODE_RPC_THROW(Rpc_io_mem, Genode::Io_mem_session_capability, io_mem, - GENODE_TYPE_LIST(Quota_exceeded), + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), Genode::uint8_t, Genode::Cache_attribute, Genode::addr_t, Genode::size_t); diff --git a/repos/os/include/spec/x86/platform_session/connection.h b/repos/os/include/spec/x86/platform_session/connection.h index 4eb9eb450..0583ae1a3 100644 --- a/repos/os/include/spec/x86/platform_session/connection.h +++ b/repos/os/include/spec/x86/platform_session/connection.h @@ -13,6 +13,7 @@ #pragma once +#include #include #include @@ -44,4 +45,17 @@ struct Platform::Connection : Genode::Connection, Client CAP_QUOTA)), Client(cap()) { } + + template + auto with_upgrade(FUNC func) -> decltype(func()) + { + return Genode::retry( + [&] () { + return Genode::retry( + [&] () { return func(); }, + [&] () { this->upgrade_caps(2); }); + }, + [&] () { this->upgrade_ram(4096); } + ); + } }; diff --git a/repos/os/include/spec/x86/platform_session/platform_session.h b/repos/os/include/spec/x86/platform_session/platform_session.h index 210a467fa..dc2dfd075 100644 --- a/repos/os/include/spec/x86/platform_session/platform_session.h +++ b/repos/os/include/spec/x86/platform_session/platform_session.h @@ -30,9 +30,7 @@ struct Platform::Session : Genode::Session ** Exception types ** *********************/ - class Alloc_failed : public Genode::Exception { }; - class Out_of_metadata : public Alloc_failed { }; - class Fatal : public Alloc_failed { }; + class Fatal : public Genode::Out_of_ram { }; static const char *service_name() { return "Platform"; } @@ -86,20 +84,20 @@ struct Platform::Session : Genode::Session *********************/ GENODE_RPC_THROW(Rpc_first_device, Device_capability, first_device, - GENODE_TYPE_LIST(Out_of_metadata), + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), unsigned, unsigned); GENODE_RPC_THROW(Rpc_next_device, Device_capability, next_device, - GENODE_TYPE_LIST(Out_of_metadata), + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), Device_capability, unsigned, unsigned); GENODE_RPC(Rpc_release_device, void, release_device, Device_capability); GENODE_RPC_THROW(Rpc_alloc_dma_buffer, Genode::Ram_dataspace_capability, alloc_dma_buffer, - GENODE_TYPE_LIST(Out_of_metadata, Fatal), + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps, Fatal), Genode::size_t); GENODE_RPC(Rpc_free_dma_buffer, void, free_dma_buffer, Genode::Ram_dataspace_capability); GENODE_RPC_THROW(Rpc_device, Device_capability, device, - GENODE_TYPE_LIST(Out_of_metadata), + GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), String const &); GENODE_RPC_INTERFACE(Rpc_first_device, Rpc_next_device, diff --git a/repos/os/run/report_rom.run b/repos/os/run/report_rom.run index 5c057b13d..8ddf6fc4b 100644 --- a/repos/os/run/report_rom.run +++ b/repos/os/run/report_rom.run @@ -72,6 +72,6 @@ compare_output_to { [init -> test-report_rom] ROM client: wait for update notification [init -> test-report_rom] ROM client: try to open the same report again [init -> test-report_rom] Error: Report-session creation failed (label="brightness", ram_quota=14336, cap_quota=3, buffer_size=4096) - [init -> test-report_rom] ROM client: catched Parent::Service_denied - OK + [init -> test-report_rom] ROM client: caught Service_denied - OK [init -> test-report_rom] --- test-report_rom finished --- } diff --git a/repos/os/src/app/cli_monitor/start_command.h b/repos/os/src/app/cli_monitor/start_command.h index aaf750e37..b607a5c3c 100644 --- a/repos/os/src/app/cli_monitor/start_command.h +++ b/repos/os/src/app/cli_monitor/start_command.h @@ -121,7 +121,7 @@ class Cli_monitor::Start_command : public Command Genode::Cap_quota{caps}, ram, ram_limit, _yield_response_sigh_cap, _exit_sig_cap); } - catch (Genode::Parent::Service_denied) { + catch (Genode::Service_denied) { tprintf(terminal, "Error: could not start child \"%s\"\n", binary_name); return; diff --git a/repos/os/src/app/rom_to_file/main.cc b/repos/os/src/app/rom_to_file/main.cc index 542a45433..b1f8db2f6 100644 --- a/repos/os/src/app/rom_to_file/main.cc +++ b/repos/os/src/app/rom_to_file/main.cc @@ -147,8 +147,11 @@ void Rom_to_file::Main::_handle_update() } catch (No_space) { error("file system out of space"); - } catch (Out_of_metadata) { - error("server ran out of memory"); + } catch (Out_of_ram) { + error("server ran out of RAM"); + + } catch (Out_of_caps) { + error("server ran out of caps"); } catch (Invalid_name) { error(Cstring(dir_path), file_name, ": invalid path"); diff --git a/repos/os/src/drivers/ahci/main.cc b/repos/os/src/drivers/ahci/main.cc index 04693d63b..ed15b1a03 100644 --- a/repos/os/src/drivers/ahci/main.cc +++ b/repos/os/src/drivers/ahci/main.cc @@ -105,7 +105,7 @@ class Block::Root_multiple_clients : public Root_component< ::Session_component> Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); if (!tx_buf_size) - throw Invalid_args(); + throw Service_denied(); size_t session_size = sizeof(::Session_component) + sizeof(Factory) + tx_buf_size; @@ -128,12 +128,12 @@ class Block::Root_multiple_clients : public Root_component< ::Session_component> error("rejecting session request, no matching policy for '", label, "'", model_buf[0] == 0 ? "" : " (model=", Cstring(model_buf), " serial=", Cstring(sn_buf), ")"); - throw Root::Invalid_args(); + throw Service_denied(); } if (!Ahci_driver::avail(num)) { error("Device ", num, " not available"); - throw Root::Unavailable(); + throw Service_denied(); } Block::Factory *factory = new (&_alloc) Block::Factory(num); @@ -188,7 +188,7 @@ struct Block::Main Genode::error("no AHCI controller found"); env.parent().exit(~0); } - catch (Genode::Parent::Service_denied) { + catch (Genode::Service_denied) { Genode::error("hardware access denied"); env.parent().exit(~0); } diff --git a/repos/os/src/drivers/ahci/spec/exynos5/platform.cc b/repos/os/src/drivers/ahci/spec/exynos5/platform.cc index b713b6ee7..fce602654 100644 --- a/repos/os/src/drivers/ahci/spec/exynos5/platform.cc +++ b/repos/os/src/drivers/ahci/spec/exynos5/platform.cc @@ -339,7 +339,7 @@ struct Exynos5_hba : Platform::Hba Sata_phy_ctrl phy(env, delayer); if (phy.init()) - throw Root::Unavailable(); + throw Service_denied(); /* additionally perform some generic initializations */ ::Hba hba(env, *this, delayer); @@ -354,7 +354,7 @@ struct Exynos5_hba : Platform::Hba hba.delayer(), ::Hba::Ghc::Hr::Equal(0)); } catch (::Hba::Polling_timeout) { Genode::error("HBA reset failed"); - throw Root::Unavailable(); + throw Service_denied(); } hba.write< ::Hba::Cap>(cap); diff --git a/repos/os/src/drivers/ahci/spec/x86/platform.cc b/repos/os/src/drivers/ahci/spec/x86/platform.cc index 18d0607dd..25cec42c9 100644 --- a/repos/os/src/drivers/ahci/spec/x86/platform.cc +++ b/repos/os/src/drivers/ahci/spec/x86/platform.cc @@ -43,10 +43,9 @@ struct X86_hba : Platform::Hba X86_hba(Genode::Env &env) : env(env) { - pci_device_cap = retry( + pci_device_cap = pci.with_upgrade( [&] () { return pci.next_device(pci_device_cap, AHCI_DEVICE, - CLASS_MASK); }, - [&] () { pci.upgrade_ram(4096); }); + CLASS_MASK); }); if (!pci_device_cap.valid()) { throw Ahci_driver::Missing_controller(); @@ -98,8 +97,12 @@ struct X86_hba : Platform::Hba Platform::Device::Access_size width) { Genode::size_t donate = 4096; - Genode::retry( - [&] () { pci_device->config_write(op, cmd, width); }, + Genode::retry( + [&] () { + Genode::retry( + [&] () { pci_device->config_write(op, cmd, width); }, + [&] () { pci.upgrade_caps(2); }); + }, [&] () { pci.upgrade_ram(donate); donate *= 2; @@ -127,8 +130,12 @@ struct X86_hba : Platform::Hba { size_t donate = size; - return retry( - [&] () { return pci.alloc_dma_buffer(size); }, + return retry( + [&] () { + return retry( + [&] () { return pci.alloc_dma_buffer(size); }, + [&] () { pci.upgrade_caps(2); }); + }, [&] () { pci.upgrade_ram(donate); donate = donate * 2 > size ? 4096 : donate * 2; diff --git a/repos/os/src/drivers/audio/spec/linux/main.cc b/repos/os/src/drivers/audio/spec/linux/main.cc index 5a288ba93..d7fce170f 100644 --- a/repos/os/src/drivers/audio/spec/linux/main.cc +++ b/repos/os/src/drivers/audio/spec/linux/main.cc @@ -221,9 +221,9 @@ struct Audio_out::Root_policy sizeof(channel_name), "left"); if (!channel_number_from_string(channel_name, &channel_number)) - throw ::Root::Invalid_args(); + throw Genode::Service_denied(); if (Audio_out::channel_acquired[channel_number]) - throw ::Root::Unavailable(); + throw Genode::Service_denied(); } void release() { } diff --git a/repos/os/src/drivers/input/spec/ps2/x86/main.cc b/repos/os/src/drivers/input/spec/ps2/x86/main.cc index 84b53da79..8ce76ba71 100644 --- a/repos/os/src/drivers/input/spec/ps2/x86/main.cc +++ b/repos/os/src/drivers/input/spec/ps2/x86/main.cc @@ -42,9 +42,8 @@ struct Ps2::Main Platform::Device_capability _ps2_device_cap() { - return Genode::retry( - [&] () { return _platform.device("PS2"); }, - [&] () { _platform.upgrade_ram(4096); }); + return _platform.with_upgrade([&] () { + return _platform.device("PS2"); }); } Platform::Device_client _device_ps2 { _ps2_device_cap() }; diff --git a/repos/os/src/drivers/platform/spec/arndale/main.cc b/repos/os/src/drivers/platform/spec/arndale/main.cc index fe8ccaef2..ea1acf89f 100644 --- a/repos/os/src/drivers/platform/spec/arndale/main.cc +++ b/repos/os/src/drivers/platform/spec/arndale/main.cc @@ -43,7 +43,7 @@ struct Driver_factory : Regulator::Driver_factory case Regulator::PWR_HDMI: return _pmu; default: - throw Root::Invalid_args(); /* invalid regulator */ + throw Genode::Service_denied(); /* invalid regulator */ }; } diff --git a/repos/os/src/drivers/platform/spec/odroid_x2/main.cc b/repos/os/src/drivers/platform/spec/odroid_x2/main.cc index d5770f82a..d45a35ae0 100644 --- a/repos/os/src/drivers/platform/spec/odroid_x2/main.cc +++ b/repos/os/src/drivers/platform/spec/odroid_x2/main.cc @@ -42,10 +42,9 @@ struct Driver_factory : Regulator::Driver_factory case Regulator::PWR_HDMI: return _pmu; - default: - throw Root::Invalid_args(); /* invalid regulator */ - }; + throw Genode::Service_denied(); /* invalid regulator */ + } } void destroy(Regulator::Driver &driver) { } diff --git a/repos/os/src/drivers/platform/spec/x86/device_pd/main.cc b/repos/os/src/drivers/platform/spec/x86/device_pd/main.cc index 27bb4ccd1..486ffcb94 100644 --- a/repos/os/src/drivers/platform/spec/x86/device_pd/main.cc +++ b/repos/os/src/drivers/platform/spec/x86/device_pd/main.cc @@ -50,19 +50,30 @@ struct Expanding_region_map_client : Genode::Region_map_client Local_addr local_addr, bool executable) override { - return Genode::retry( + return Genode::retry( [&] () { - return Region_map_client::attach(ds, size, offset, - use_local_addr, - local_addr, - executable); }, - [&] () { - enum { UPGRADE_QUOTA = 4096 }; + return Genode::retry( + [&] () { + return Region_map_client::attach(ds, size, offset, + use_local_addr, + local_addr, + executable); }, + [&] () { + enum { UPGRADE_CAP_QUOTA = 2 }; + if (_env.pd().avail_caps().value < UPGRADE_CAP_QUOTA) + throw; - if (_env.ram().avail_ram().value < UPGRADE_QUOTA) + Genode::String<32> arg("cap_quota=", (unsigned)UPGRADE_CAP_QUOTA); + _env.upgrade(Genode::Parent::Env::pd(), arg.string()); + } + ); + }, + [&] () { + enum { UPGRADE_RAM_QUOTA = 4096 }; + if (_env.ram().avail_ram().value < UPGRADE_RAM_QUOTA) throw; - Genode::String<32> arg("ram_quota=", (unsigned)UPGRADE_QUOTA); + Genode::String<32> arg("ram_quota=", (unsigned)UPGRADE_RAM_QUOTA); _env.upgrade(Genode::Parent::Env::pd(), arg.string()); } ); @@ -109,11 +120,10 @@ void Platform::Device_pd_component::attach_dma_mem(Genode::Dataspace_capability addr_t page = ~0UL; - try { - page = _address_space.attach_at(ds_cap, phys); - } catch (Rm_session::Out_of_metadata) { - throw; - } catch (Rm_session::Region_conflict) { + try { page = _address_space.attach_at(ds_cap, phys); } + catch (Out_of_ram) { throw; } + catch (Out_of_caps) { throw; } + catch (Region_map::Region_conflict) { /* * DMA memory already attached before or collision with normal * device_pd memory (text, data, etc). @@ -155,7 +165,7 @@ void Platform::Device_pd_component::assign_pci(Genode::Io_mem_dataspace_capabili addr_t page = _address_space.attach(io_mem_cap); /* sanity check */ if (!page) - throw Rm_session::Region_conflict(); + throw Region_map::Region_conflict(); /* trigger mapping of whole memory area */ if (!map_eager(page, 12)) diff --git a/repos/os/src/drivers/platform/spec/x86/irq.cc b/repos/os/src/drivers/platform/spec/x86/irq.cc index 09fdc9507..97093ed6d 100644 --- a/repos/os/src/drivers/platform/spec/x86/irq.cc +++ b/repos/os/src/drivers/platform/spec/x86/irq.cc @@ -213,7 +213,7 @@ Platform::Irq_session_component::Irq_session_component(unsigned irq, _gsi = msi; return; } - } catch (Genode::Parent::Service_denied) { } + } catch (Genode::Service_denied) { } irq_alloc.free_msi(msi); } @@ -235,7 +235,7 @@ Platform::Irq_session_component::Irq_session_component(unsigned irq, if (Irq_component::get_irq_proxy(_gsi, &irq_alloc, trigger, polarity, &env, &heap)) return; - } catch (Genode::Parent::Service_denied) { } + } catch (Genode::Service_denied) { } Genode::error("unavailable IRQ ", Genode::Hex(_gsi), " requested"); } diff --git a/repos/os/src/drivers/platform/spec/x86/nonpci_devices.cc b/repos/os/src/drivers/platform/spec/x86/nonpci_devices.cc index f8f450421..432b84f93 100644 --- a/repos/os/src/drivers/platform/spec/x86/nonpci_devices.cc +++ b/repos/os/src/drivers/platform/spec/x86/nonpci_devices.cc @@ -161,9 +161,7 @@ Platform::Device_capability Platform::Session_component::device(String const &na _device_list.insert(dev); return _env.ep().rpc_ep().manage(dev); - } catch (Genode::Allocator::Out_of_memory) { - throw Out_of_metadata(); - } catch (Genode::Parent::Service_denied) { - return Device_capability(); } + catch (Genode::Out_of_ram) { throw; } + catch (Genode::Service_denied) { return Device_capability(); } } diff --git a/repos/os/src/drivers/platform/spec/x86/pci_device.cc b/repos/os/src/drivers/platform/spec/x86/pci_device.cc index e658cea5a..2fed491fa 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_device.cc +++ b/repos/os/src/drivers/platform/spec/x86/pci_device.cc @@ -73,10 +73,17 @@ Genode::Io_mem_session_capability Platform::Device_component::io_mem(Genode::uin res_size, wc); _io_mem[i].insert(io_mem); return io_mem->cap(); - } catch (Genode::Allocator::Out_of_memory) { - Genode::error("Quota_exceeded in Device_component::io_mem"); - throw Quota_exceeded(); - } catch (...) { + } + catch (Genode::Out_of_caps) { + Genode::warning("Out_of_caps in Device_component::io_mem"); + throw; + } + catch (Genode::Out_of_ram) { + Genode::warning("Out_of_ram in Device_component::io_mem"); + throw; + } + catch (...) { + Genode::warning("unhandled exception in 'Device_component::io_mem'"); return Genode::Io_mem_session_capability(); } } @@ -119,11 +126,10 @@ void Platform::Device_component::config_write(unsigned char address, /* assign device to device_pd */ if (address == PCI_CMD_REG && value & PCI_CMD_DMA) { - try { - _session.assign_device(this); - } catch (Platform::Session::Out_of_metadata) { - throw Quota_exceeded(); - } catch (...) { + try { _session.assign_device(this); } + catch (Out_of_ram) { throw; } + catch (Out_of_caps) { throw; } + catch (...) { Genode::error("assignment to device failed"); } } diff --git a/repos/os/src/drivers/platform/spec/x86/pci_device_pd_ipc.h b/repos/os/src/drivers/platform/spec/x86/pci_device_pd_ipc.h index 003df7d7d..8e863ce4c 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_device_pd_ipc.h +++ b/repos/os/src/drivers/platform/spec/x86/pci_device_pd_ipc.h @@ -35,11 +35,11 @@ struct Platform::Device_pd : Genode::Session typedef Device_pd_client Client; GENODE_RPC_THROW(Rpc_attach_dma_mem, void, attach_dma_mem, - GENODE_TYPE_LIST(Genode::Rm_session::Out_of_metadata), + GENODE_TYPE_LIST(Genode::Out_of_ram, Genode::Out_of_caps), Genode::Dataspace_capability); GENODE_RPC_THROW(Rpc_assign_pci, void, assign_pci, - GENODE_TYPE_LIST(Genode::Rm_session::Out_of_metadata, - Genode::Rm_session::Region_conflict), + GENODE_TYPE_LIST(Genode::Out_of_ram, Genode::Out_of_caps, + Genode::Region_map::Region_conflict), Genode::Io_mem_dataspace_capability, Genode::uint16_t); GENODE_RPC_INTERFACE(Rpc_attach_dma_mem, Rpc_assign_pci); 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 c5a725bd3..c74a05045 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 @@ -269,7 +269,7 @@ class Platform::Session_component : public Genode::Rpc_object /** * Deduce specified amount of quota from an allocator guard, or throw - * an 'Out_of_metadata' exception if the guard's quota is depleted. + * an 'Out_of_ram' exception if the guard's quota is depleted. */ struct Quota_reservation { @@ -282,7 +282,7 @@ class Platform::Session_component : public Genode::Rpc_object : guard(guard), amount(amount) { if (!guard.withdraw(amount)) - throw Out_of_metadata(); + throw Out_of_ram(); } ~Quota_reservation() noexcept(false) @@ -319,10 +319,10 @@ class Platform::Session_component : public Genode::Rpc_object /** * Constructor * - * \throw Out_of_metadata session RAM does not suffice - * for creating device PD - * \throw Startup_failed child could not be started - * \throw Parent::Service_denied by 'Slave::Connection' + * \throw Out_of_ram + * \throw Out_of_caps + * \throw Startup_failed child could not be started + * \throw Service_denied by 'Slave::Connection' */ Device_pd(Genode::Region_map &local_rm, Genode::Rpc_entrypoint &ep, @@ -340,22 +340,22 @@ class Platform::Session_component : public Genode::Rpc_object _child(local_rm, ep, _policy), _connection(_policy, Genode::Slave::Args()) { } - /* thrown by 'Quota_reservation' */ - catch (Out_of_metadata) { throw; } - /* thrown by 'Device_pd_policy' or 'Child' */ - catch (Genode::Out_of_ram) { throw Out_of_metadata(); } + /* thrown by 'Quota_reservation', 'Device_pd_policy' or 'Child' */ + catch (Genode::Out_of_ram) { + throw; } + catch (Genode::Out_of_caps) { - /* XXX reflect 'Out_of_caps' exception to client */ - Genode::error("Out_of_caps during device-pd creation"); - throw Out_of_metadata(); - } + Genode::warning("Out_of_caps during device-pd creation"); + throw; } + /* thrown by 'Slave::Connection' */ - catch (Genode::Insufficient_ram_quota) { throw Out_of_metadata(); } + catch (Genode::Insufficient_ram_quota) { + throw Genode::Out_of_ram(); } + /* thrown by 'Slave::Connection' */ catch (Genode::Insufficient_cap_quota) { - Genode::error("Insufficient_cap_quota during device-pd creation"); - throw Out_of_metadata(); - } + Genode::warning("Insufficient_cap_quota during device-pd creation"); + throw Genode::Out_of_caps(); } Device_pd_client &session() { return _connection; } @@ -381,8 +381,9 @@ class Platform::Session_component : public Genode::Rpc_object /** * Attempt to initialize device PD * - * \throw Out_of_metadata session quota does not suffice to spawn the - * device PD + * \throw Out_of_ram session quota does not suffice to spawn the + * device PD + * \throw Out_of_caps */ void _try_init_device_pd() { @@ -394,19 +395,11 @@ class Platform::Session_component : public Genode::Rpc_object Device_pd(_local_rm, _device_pd_ep, _env_ram, _env_ram_cap, _env_pd, _env_pd_cap, _label); } - - /* thrown by '_md_alloc' */ - catch (Genode::Out_of_ram) { throw Out_of_metadata(); } - + catch (Genode::Out_of_ram) { /* thrown by '_md_alloc', 'Device_pd' */ + throw; } catch (Genode::Out_of_caps) { - /* XXX reflect exception to client */ - Genode::error("Out_of_caps during Device_pd construction"); - throw Out_of_metadata(); - } - - /* thrown by 'Device_pd' */ - catch (Out_of_metadata) { throw; } - + Genode::warning("Out_of_caps during Device_pd construction"); + throw; } catch (...) { Genode::warning("PCI device protection domain for IOMMU support " "is not available"); @@ -659,11 +652,12 @@ class Platform::Session_component : public Genode::Rpc_object Genode::error("'", _label, "' - device " "'", Genode::Cstring(policy_device), "' " "is part of more than one policy"); - } catch (Genode::Xml_node::Nonexistent_attribute) { + } + catch (Genode::Xml_node::Nonexistent_attribute) { Genode::error("'", _label, "' - device node " "misses a 'name' attribute"); } - throw Genode::Root::Unavailable(); + throw Genode::Service_denied(); }); /* pci devices */ @@ -687,7 +681,7 @@ class Platform::Session_component : public Genode::Rpc_object if (class_sub_prog >= INVALID_CLASS) { Genode::error("'", _label, "' - invalid 'class' ", "attribute '", Genode::Cstring(alias_class), "'"); - throw Genode::Root::Unavailable(); + throw Genode::Service_denied(); } } catch (Xml_attribute::Nonexistent_attribute) { } @@ -697,8 +691,9 @@ class Platform::Session_component : public Genode::Rpc_object try { node.attribute(1); Genode::error("'", _label, "' - attributes beside 'class' detected"); - throw Genode::Root::Unavailable(); - } catch (Xml_attribute::Nonexistent_attribute) { } + throw Genode::Service_denied(); + } + catch (Xml_attribute::Nonexistent_attribute) { } /* we have a class and it is the only attribute */ return; @@ -709,7 +704,8 @@ class Platform::Session_component : public Genode::Rpc_object node.attribute(3); Genode::error("'", _label, "' - " "invalid number of pci node attributes"); - throw Genode::Root::Unavailable(); + throw Genode::Service_denied(); + } catch (Xml_attribute::Nonexistent_attribute) { } try { @@ -737,7 +733,7 @@ class Platform::Session_component : public Genode::Rpc_object Genode::error("'", _label, "' - " "invalid pci node attributes for bdf"); } - throw Genode::Root::Unavailable(); + throw Genode::Service_denied(); }); } @@ -875,12 +871,13 @@ class Platform::Session_component : public Genode::Rpc_object _device_list.insert(dev); return _env.ep().rpc_ep().manage(dev); - } catch (Genode::Allocator::Out_of_memory) { - throw Out_of_metadata(); - } catch (Genode::Out_of_caps) { - /* XXX reflect exception to client */ - Genode::error("Out_of_caps during Device_component construction"); - throw Out_of_metadata(); + } + catch (Genode::Out_of_ram) { + throw; + } + catch (Genode::Out_of_caps) { + Genode::warning("Out_of_caps during Device_component construction"); + throw; } }; return _env.ep().rpc_ep().apply(prev_device, lambda); @@ -965,7 +962,7 @@ class Platform::Session_component : public Genode::Rpc_object throw Fatal(); if (throw_oom) - throw Out_of_metadata(); + throw Genode::Out_of_ram(); } Genode::Ram_dataspace_capability alloc_dma_buffer(Genode::size_t const size) override @@ -979,10 +976,10 @@ class Platform::Session_component : public Genode::Rpc_object /* transfer ram quota to session specific ram session */ try { _env_ram.transfer_quota(_ram, Genode::Ram_quota{size}); } - catch (Genode::Out_of_ram) { throw Out_of_metadata(); } + catch (Genode::Out_of_ram) { throw; } catch (Genode::Out_of_caps) { - Genode::error("Out_of_caps during alloc_dma_buffer (transfer_quota)"); - throw Fatal(); + Genode::warning("Out_of_caps during alloc_dma_buffer"); + throw; } catch (...) { } @@ -1019,14 +1016,14 @@ class Platform::Session_component : public Genode::Rpc_object * UPGRADE_QUOTA steps. */ try { _env_ram.transfer_quota(_ram, Genode::Ram_quota{UPGRADE_QUOTA}); } - catch (Genode::Out_of_ram) { throw Out_of_metadata(); } + catch (Genode::Out_of_ram) { throw; } }); if (!ram_cap.valid()) return ram_cap; if (_device_pd) { - Genode::retry( + Genode::retry( [&] () { _device_pd->session().attach_dma_mem(ram_cap); }, [&] () { if (!_env_ram.withdraw(UPGRADE_QUOTA)) @@ -1044,8 +1041,10 @@ class Platform::Session_component : public Genode::Rpc_object } try { _insert(ram_cap); } - catch (Genode::Allocator::Out_of_memory) { - _rollback(size, ram_cap); } + catch (Genode::Out_of_ram) { + _rollback(size, ram_cap); + throw; + } return ram_cap; } @@ -1234,7 +1233,7 @@ class Platform::Root : public Genode::Root_component catch (Genode::Session_policy::No_policy_defined) { Genode::error("Invalid session request, no matching policy for ", "'", Genode::label_from_args(args).string(), "'"); - throw Genode::Root::Unavailable(); + throw Genode::Service_denied(); } } diff --git a/repos/os/src/drivers/uart/uart_component.h b/repos/os/src/drivers/uart/uart_component.h index ef39e9219..4552f83c7 100644 --- a/repos/os/src/drivers/uart/uart_component.h +++ b/repos/os/src/drivers/uart/uart_component.h @@ -234,13 +234,14 @@ class Uart::Root : public Uart::Root_component return new (md_alloc()) Session_component(_env, _driver_factory, index, baudrate, detect_size); - - } catch (Xml_node::Nonexistent_attribute) { + } + catch (Xml_node::Nonexistent_attribute) { Genode::error("Missing \"uart\" attribute in policy definition"); - throw Root::Unavailable(); - } catch (Session_policy::No_policy_defined) { + throw Genode::Service_denied(); + } + catch (Session_policy::No_policy_defined) { Genode::error("Invalid session request, no matching policy"); - throw Root::Unavailable(); + throw Genode::Service_denied(); } } diff --git a/repos/os/src/init/child.cc b/repos/os/src/init/child.cc index bb00983be..4b9287a2d 100644 --- a/repos/os/src/init/child.cc +++ b/repos/os/src/init/child.cc @@ -402,7 +402,7 @@ Init::Child::Route Init::Child::resolve_session_request(Service::Name const &ser /* prevent infinite recursion */ if (rom == "config") { error("configfile must not be named 'config'"); - throw Parent::Service_denied(); + throw Service_denied(); } return resolve_session_request(service_name, @@ -475,12 +475,12 @@ Init::Child::Route Init::Child::resolve_session_request(Service::Name const &ser return Route { *service, target_label, target_diag }; if (service && service->abandoned()) - throw Parent::Service_denied(); + throw Service_denied(); if (!service_wildcard) { warning(name(), ": service lookup for " "\"", service_name, "\" at parent failed"); - throw Parent::Service_denied(); + throw Service_denied(); } } @@ -498,7 +498,7 @@ Init::Child::Route Init::Child::resolve_session_request(Service::Name const &ser service = &s; }); if (service && service->abandoned()) - throw Parent::Service_denied(); + throw Service_denied(); if (service) return Route { *service, target_label, target_diag }; @@ -506,7 +506,7 @@ Init::Child::Route Init::Child::resolve_session_request(Service::Name const &ser if (!service_wildcard) { warning(name(), ": lookup to child " "server \"", server_name, "\" failed"); - throw Parent::Service_denied(); + throw Service_denied(); } } @@ -515,7 +515,7 @@ Init::Child::Route Init::Child::resolve_session_request(Service::Name const &ser if (is_ambiguous(_child_services, service_name)) { error(name(), ": ambiguous routes to " "service \"", service_name, "\""); - throw Parent::Service_denied(); + throw Service_denied(); } Routed_service *service = nullptr; @@ -526,7 +526,7 @@ Init::Child::Route Init::Child::resolve_session_request(Service::Name const &ser if (!service_wildcard) { warning(name(), ": lookup for service " "\"", service_name, "\" failed"); - throw Parent::Service_denied(); + throw Service_denied(); } } @@ -537,7 +537,7 @@ Init::Child::Route Init::Child::resolve_session_request(Service::Name const &ser } catch (Xml_node::Nonexistent_sub_node) { } warning(name(), ": no route to service \"", service_name, "\""); - throw Parent::Service_denied(); + throw Service_denied(); } diff --git a/repos/os/src/init/child.h b/repos/os/src/init/child.h index ae2096597..1b83ffce3 100644 --- a/repos/os/src/init/child.h +++ b/repos/os/src/init/child.h @@ -357,7 +357,7 @@ class Init::Child : Child_policy, Routed_service::Wakeup return (session.service() == route.service) && (route.label == session.label()); } - catch (Parent::Service_denied) { return false; } + catch (Service_denied) { return false; } } static Xml_node _provides_sub_node(Xml_node start_node) diff --git a/repos/os/src/init/main.cc b/repos/os/src/init/main.cc index b193d10a7..89d5ac9a8 100644 --- a/repos/os/src/init/main.cc +++ b/repos/os/src/init/main.cc @@ -383,10 +383,13 @@ void Init::Main::_handle_config() warning("local capabilities exhausted during child creation"); } catch (Child::Missing_name_attribute) { warning("skipped startup of nameless child"); } - catch (Region_map::Attach_failed) { + catch (Region_map::Region_conflict) { warning("failed to attach dataspace to local address space " "during child construction"); } - catch (Parent::Service_denied) { + catch (Region_map::Invalid_dataspace) { + warning("attempt to attach invalid dataspace to local address space " + "during child construction"); } + catch (Service_denied) { warning("failed to create session during child construction"); } }); } diff --git a/repos/os/src/init/server.cc b/repos/os/src/init/server.cc index b6e8664be..7a321a326 100644 --- a/repos/os/src/init/server.cc +++ b/repos/os/src/init/server.cc @@ -54,7 +54,7 @@ struct Init::Server::Service * Determine route to child service for a given label according * to the node policy * - * \throw Parent::Service_denied + * \throw Service_denied */ Route resolve_session_request(Session_label const &); @@ -69,7 +69,7 @@ Init::Server::Service::resolve_session_request(Session_label const &label) Session_policy policy(label, _service_node.xml()); if (!policy.has_sub_node("child")) - throw Parent::Service_denied(); + throw Service_denied(); Xml_node target_node = policy.sub_node("child"); @@ -86,12 +86,12 @@ Init::Server::Service::resolve_session_request(Session_label const &label) match = &service; }); if (!match || match->abandoned()) - throw Parent::Service_denied(); + throw Service_denied(); return Route { *match, target_label }; } catch (Session_policy::No_policy_defined) { - throw Parent::Service_denied(); } + throw Service_denied(); } } @@ -109,7 +109,7 @@ Init::Server::_resolve_session_request(Service::Name const &service_name, matching_service = &service; }); if (!matching_service) - throw Parent::Service_denied(); + throw Service_denied(); return matching_service->resolve_session_request(label); } @@ -226,7 +226,7 @@ void Init::Server::_handle_create_session_request(Xml_node request, "(", ram_quota, " bytes, ", cap_quota, " caps) " "of forwarded ", name, " session"); session.destroy(); - throw Parent::Service_denied(); + throw Service_denied(); } session.ready_callback = this; @@ -239,22 +239,22 @@ void Init::Server::_handle_create_session_request(Xml_node request, if (session.phase == Session_state::CREATE_REQUESTED) route.service.wakeup(); - if (session.phase == Session_state::INVALID_ARGS) - throw Parent::Service_denied(); + if (session.phase == Session_state::SERVICE_DENIED) + throw Service_denied(); if (session.phase == Session_state::INSUFFICIENT_RAM_QUOTA) - throw Genode::Insufficient_ram_quota(); + throw Insufficient_ram_quota(); if (session.phase == Session_state::INSUFFICIENT_CAP_QUOTA) - throw Genode::Insufficient_cap_quota(); + throw Insufficient_cap_quota(); } - catch (Parent::Service_denied) { + catch (Service_denied) { _env.parent().session_response(Parent::Server::Id { id.value }, - Parent::INVALID_ARGS); } - catch (Genode::Insufficient_ram_quota) { + Parent::SERVICE_DENIED); } + catch (Insufficient_ram_quota) { _env.parent().session_response(Parent::Server::Id { id.value }, Parent::INSUFFICIENT_RAM_QUOTA); } - catch (Genode::Insufficient_cap_quota) { + catch (Insufficient_cap_quota) { _env.parent().session_response(Parent::Server::Id { id.value }, Parent::INSUFFICIENT_CAP_QUOTA); } } @@ -373,9 +373,8 @@ void Init::Server::apply_config(Xml_node config) bool const route_unchanged = (route.service == session.service()) && (route.label == session.label()); if (!route_unchanged) - throw Parent::Service_denied(); + throw Service_denied(); } - catch (Parent::Service_denied) { - close_session(session); } + catch (Service_denied) { close_session(session); } }); } diff --git a/repos/os/src/init/server.h b/repos/os/src/init/server.h index b458bb5fc..ef908bdc5 100644 --- a/repos/os/src/init/server.h +++ b/repos/os/src/init/server.h @@ -69,7 +69,7 @@ class Init::Server : Session_state::Ready_callback, Constructible > _session_request_handler; /** - * \throw Parent::Service_denied + * \throw Service_denied */ Route _resolve_session_request(Genode::Service::Name const &, Session_label const &); diff --git a/repos/os/src/lib/vfs/fs_file_system.h b/repos/os/src/lib/vfs/fs_file_system.h index 69d82e1e0..6fa57296d 100644 --- a/repos/os/src/lib/vfs/fs_file_system.h +++ b/repos/os/src/lib/vfs/fs_file_system.h @@ -369,8 +369,9 @@ class Vfs::Fs_file_system : public File_system Fs_handle_guard node_guard(*this, _fs, node, _handle_space); status = _fs.status(node); } - catch (::File_system::Lookup_failed) { return STAT_ERR_NO_ENTRY; } - catch (::File_system::Out_of_metadata) { return STAT_ERR_NO_PERM; } + catch (::File_system::Lookup_failed) { return STAT_ERR_NO_ENTRY; } + catch (Genode::Out_of_ram) { return STAT_ERR_NO_PERM; } + catch (Genode::Out_of_caps) { return STAT_ERR_NO_PERM; } out = Stat(); @@ -532,7 +533,8 @@ class Vfs::Fs_file_system : public File_system catch (::File_system::Lookup_failed) { return MKDIR_ERR_NO_ENTRY; } catch (::File_system::Name_too_long) { return MKDIR_ERR_NAME_TOO_LONG; } catch (::File_system::No_space) { return MKDIR_ERR_NO_SPACE; } - catch (::File_system::Out_of_metadata) { return MKDIR_ERR_NO_ENTRY; } + catch (::File_system::Out_of_ram) { return MKDIR_ERR_NO_ENTRY; } + catch (::File_system::Out_of_caps) { return MKDIR_ERR_NO_ENTRY; } return MKDIR_OK; } @@ -570,7 +572,8 @@ class Vfs::Fs_file_system : public File_system catch (::File_system::Lookup_failed) { return SYMLINK_ERR_NO_ENTRY; } catch (::File_system::Permission_denied) { return SYMLINK_ERR_NO_PERM; } catch (::File_system::No_space) { return SYMLINK_ERR_NO_SPACE; } - catch (::File_system::Out_of_metadata) { return SYMLINK_ERR_NO_ENTRY; } + catch (::File_system::Out_of_ram) { return SYMLINK_ERR_NO_ENTRY; } + catch (::File_system::Out_of_caps) { return SYMLINK_ERR_NO_ENTRY; } return SYMLINK_OK; } @@ -653,7 +656,8 @@ class Vfs::Fs_file_system : public File_system catch (::File_system::Invalid_name) { return OPEN_ERR_NAME_TOO_LONG; } catch (::File_system::Name_too_long) { return OPEN_ERR_NAME_TOO_LONG; } catch (::File_system::No_space) { return OPEN_ERR_NO_SPACE; } - catch (::File_system::Out_of_metadata) { return OPEN_ERR_NO_PERM; } + catch (::File_system::Out_of_ram) { return OPEN_ERR_NO_PERM; } + catch (::File_system::Out_of_caps) { return OPEN_ERR_NO_PERM; } return OPEN_OK; } diff --git a/repos/os/src/server/dynamic_rom/main.cc b/repos/os/src/server/dynamic_rom/main.cc index ba855d434..1bc0e58c8 100644 --- a/repos/os/src/server/dynamic_rom/main.cc +++ b/repos/os/src/server/dynamic_rom/main.cc @@ -228,10 +228,10 @@ class Dynamic_rom::Root : public Genode::Root_component Session_component(_env, _lookup_rom_node_in_config(module_name), _verbose); - - } catch (Nonexistent_rom_module) { + } + catch (Nonexistent_rom_module) { error("ROM module lookup of '", label.string(), "' failed"); - throw Root::Invalid_args(); + throw Service_denied(); } } diff --git a/repos/os/src/server/fs_log/main.cc b/repos/os/src/server/fs_log/main.cc index 74af65fa8..012064fef 100644 --- a/repos/os/src/server/fs_log/main.cc +++ b/repos/os/src/server/fs_log/main.cc @@ -114,9 +114,9 @@ class Fs_log::Root_component : dir_path = path_from_label(label_str); } - } catch (Session_policy::No_policy_defined) { - dir_path = path_from_label(label_str); } + catch (Session_policy::No_policy_defined) { + dir_path = path_from_label(label_str); } if (dir_path == "/") { strncpy(file_name, "log", sizeof(file_name)); @@ -142,21 +142,22 @@ class Fs_log::Root_component : /* don't truncate at every new child session */ if (truncate && (strcmp(label_prefix, "") == 0)) _fs.truncate(handle, 0); - - } catch (File_system::Lookup_failed) { + } + catch (File_system::Lookup_failed) { handle = _fs.file(dir_handle, file_name, File_system::WRITE_ONLY, true); } return new (md_alloc()) Session_component(_fs, handle, label_prefix); } - catch (Permission_denied) { errstr = "permission denied"; } catch (No_space) { errstr = "file system out of space"; } - catch (Out_of_metadata) { - errstr = "file system server out of metadata"; } + catch (Out_of_ram) { + errstr = "file system server out of RAM"; } + catch (Out_of_caps) { + errstr = "file system server out of caps"; } catch (Invalid_name) { errstr = "invalid path"; } catch (Name_too_long) { @@ -167,7 +168,7 @@ class Fs_log::Root_component : Genode::error("cannot open log file ", (char const *)dir_path.base(), ", ", errstr); - throw Root::Unavailable(); + throw Service_denied(); } public: diff --git a/repos/os/src/server/input_filter/main.cc b/repos/os/src/server/input_filter/main.cc index 991bb4841..f42dc4105 100644 --- a/repos/os/src/server/input_filter/main.cc +++ b/repos/os/src/server/input_filter/main.cc @@ -386,7 +386,7 @@ struct Input_filter::Main : Input_connection::Avail_handler, Registered(_input_connections, _env, label, *this, _heap); - } catch (Genode::Parent::Service_denied) { + } catch (Genode::Service_denied) { error("parent denied input source '", label, "'"); } } catch (Xml_node::Nonexistent_attribute) { diff --git a/repos/os/src/server/input_merger/main.cc b/repos/os/src/server/input_merger/main.cc index a349aae38..408a14833 100644 --- a/repos/os/src/server/input_merger/main.cc +++ b/repos/os/src/server/input_merger/main.cc @@ -101,7 +101,7 @@ struct Input_merger::Main input_source_list.insert(input_source); - } catch (Genode::Parent::Service_denied) { + } catch (Genode::Service_denied) { error("parent denied input source '", label, "'"); } } catch (Xml_node::Nonexistent_attribute) { diff --git a/repos/os/src/server/iso9660/main.cc b/repos/os/src/server/iso9660/main.cc index fa988bf25..ce2b355a1 100644 --- a/repos/os/src/server/iso9660/main.cc +++ b/repos/os/src/server/iso9660/main.cc @@ -153,9 +153,9 @@ class Iso::Root : public Iso::Root_component try { return new (_alloc) Rom_component(_env, _alloc, _cache, _block, _path); } - catch (Io_error) { throw Root::Unavailable(); } - catch (Non_data_disc) { throw Root::Unavailable(); } - catch (File_not_found) { throw Root::Invalid_args(); } + catch (Io_error) { throw Service_denied(); } + catch (Non_data_disc) { throw Service_denied(); } + catch (File_not_found) { throw Service_denied(); } } public: diff --git a/repos/os/src/server/loader/main.cc b/repos/os/src/server/loader/main.cc index 1fe5df3e8..f08be9e84 100644 --- a/repos/os/src/server/loader/main.cc +++ b/repos/os/src/server/loader/main.cc @@ -88,7 +88,7 @@ class Loader::Session_component : public Rpc_object } catch (...) { } - throw Denied(); + throw Service_denied(); } void upgrade(Rom_session_component &, Args const &) override { } @@ -184,7 +184,7 @@ class Loader::Session_component : public Rpc_object { if (session.constructed()) { warning("attempt to open more than one nitpicker session"); - throw Parent::Service_denied(); + throw Service_denied(); } session.construct(_ep, _env, _rm, _ram, _max_size, @@ -357,7 +357,7 @@ class Loader::Session_component : public Rpc_object _cpu_service, _pd_service, _nitpicker_service, _fault_sigh); } - catch (Genode::Parent::Service_denied) { + catch (Genode::Service_denied) { throw Rom_module_does_not_exist(); } } diff --git a/repos/os/src/server/lx_fs/main.cc b/repos/os/src/server/lx_fs/main.cc index 87db045f7..9da9c7d66 100644 --- a/repos/os/src/server/lx_fs/main.cc +++ b/repos/os/src/server/lx_fs/main.cc @@ -354,7 +354,7 @@ class File_system::Root : public Root_component if (root[0] != '/') { Genode::error("Root directory must start with / but is \"", Genode::Cstring(root), "\""); - throw Root::Unavailable(); + throw Service_denied(); } for (root_dir = root; *root_dir == '/'; ++root_dir) ; @@ -364,17 +364,17 @@ class File_system::Root : public Root_component root_dir = "."; } catch (Xml_node::Nonexistent_attribute) { Genode::error("missing \"root\" attribute in policy definition"); - throw Root::Unavailable(); + throw Service_denied(); } /* * Determine if write access is permitted for the session. */ writeable = policy.attribute_value("writeable", false); - - } catch (Session_policy::No_policy_defined) { + } + catch (Session_policy::No_policy_defined) { Genode::error("invalid session request, no matching policy"); - throw Root::Unavailable(); + throw Genode::Service_denied(); } size_t ram_quota = @@ -384,7 +384,7 @@ class File_system::Root : public Root_component if (!tx_buf_size) { Genode::error(label, " requested a session with a zero length transmission buffer"); - throw Root::Invalid_args(); + throw Genode::Service_denied(); } /* @@ -401,10 +401,11 @@ class File_system::Root : public Root_component try { return new (md_alloc()) Session_component(tx_buf_size, _env, root_dir, writeable, *md_alloc()); - } catch (Lookup_failed) { + } + catch (Lookup_failed) { Genode::error("session root directory \"", Genode::Cstring(root), "\" " "does not exist"); - throw Root::Unavailable(); + throw Service_denied(); } } diff --git a/repos/os/src/server/mixer/mixer.cc b/repos/os/src/server/mixer/mixer.cc index 75ff99fde..8e9527693 100644 --- a/repos/os/src/server/mixer/mixer.cc +++ b/repos/os/src/server/mixer/mixer.cc @@ -681,7 +681,7 @@ class Audio_out::Root : public Audio_out::Root_component Channel::Number ch = number_from_string(channel_name); if (ch == Channel::Number::INVALID) - throw Root::Invalid_args(); + throw Genode::Service_denied(); Session_component *session = new (md_alloc()) Session_component(_env, label, (Channel::Number)ch, _mixer); diff --git a/repos/os/src/server/nic_bridge/component.h b/repos/os/src/server/nic_bridge/component.h index 0141c8320..c7698f94b 100644 --- a/repos/os/src/server/nic_bridge/component.h +++ b/repos/os/src/server/nic_bridge/component.h @@ -217,13 +217,19 @@ class Net::Root : public Genode::Root_component Session_component(_env.ram(), _env.rm(), _env.ep(), ram_quota, tx_buf_size, rx_buf_size, _mac_alloc.alloc(), _nic, ip_addr); - } catch (Mac_allocator::Alloc_failed) { + } + catch (Mac_allocator::Alloc_failed) { Genode::warning("Mac address allocation failed!"); - throw Root::Unavailable(); - } catch (Out_of_ram) { + throw Service_denied(); + } + catch (Out_of_ram) { Genode::warning("insufficient 'ram_quota'"); throw Insufficient_ram_quota(); } + catch (Out_of_caps) { + Genode::warning("insufficient 'cap_quota'"); + throw Insufficient_cap_quota(); + } } public: diff --git a/repos/os/src/server/nic_bridge/main.cc b/repos/os/src/server/nic_bridge/main.cc index fff39e7a7..494aea114 100644 --- a/repos/os/src/server/nic_bridge/main.cc +++ b/repos/os/src/server/nic_bridge/main.cc @@ -58,7 +58,7 @@ struct Main /* announce at parent */ env.parent().announce(ep.manage(root)); - } catch (Genode::Parent::Service_denied) { + } catch (Genode::Service_denied) { Genode::error("Could not connect to uplink NIC"); } } diff --git a/repos/os/src/server/nic_dump/component.cc b/repos/os/src/server/nic_dump/component.cc index c091e8223..4a6af43e2 100644 --- a/repos/os/src/server/nic_dump/component.cc +++ b/repos/os/src/server/nic_dump/component.cc @@ -145,6 +145,6 @@ Session_component *Net::Root::_create_session(char const *args) Session_component(*md_alloc(), ram_quota - session_size, _buf_ram, tx_buf_size, rx_buf_size, _region_map, _uplink, _config, _timer, _curr_time, _ep); - } catch (...) { - throw Root::Unavailable(); } + } + catch (...) { throw Service_denied(); } } diff --git a/repos/os/src/server/nic_router/component.cc b/repos/os/src/server/nic_router/component.cc index fee54da11..a8bd64c87 100644 --- a/repos/os/src/server/nic_router/component.cc +++ b/repos/os/src/server/nic_router/component.cc @@ -160,5 +160,5 @@ Session_component *Net::Root::_create_session(char const *args) catch (Pointer::Valid) { error("one session per domain only"); } - throw Root::Unavailable(); + throw Service_denied(); } diff --git a/repos/os/src/server/nitpicker/main.cc b/repos/os/src/server/nitpicker/main.cc index c76905f56..e0f7dbfc7 100644 --- a/repos/os/src/server/nitpicker/main.cc +++ b/repos/os/src/server/nitpicker/main.cc @@ -129,8 +129,9 @@ class Buffer /** * Constructor - allocate and map dataspace for virtual frame buffer * - * \throw Ram_session::Alloc_failed - * \throw Rm_session::Attach_failed + * \throw Out_of_ram + * \throw Out_of_caps + * \throw Region_map::Region_conflict */ Buffer(Genode::Ram_session &ram, Genode::Region_map &rm, Area size, Framebuffer::Mode::Format format, Genode::size_t bytes) @@ -787,9 +788,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object, catch (View_handle_registry::Lookup_failed) { return View_handle(); } catch (View_handle_registry::Out_of_memory) { - throw Nitpicker::Session::Out_of_metadata(); } - catch (Genode::Allocator::Out_of_memory) { - throw Nitpicker::Session::Out_of_metadata(); } + throw Genode::Out_of_ram(); } } /* @@ -803,7 +802,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object, nullptr); } catch (Genode::Allocator::Out_of_memory) { - throw Nitpicker::Session::Out_of_metadata(); } + throw Genode::Out_of_ram(); } } view->apply_origin_policy(_pointer_origin); @@ -813,7 +812,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object, try { return _view_handle_registry.alloc(*view); } catch (View_handle_registry::Out_of_memory) { - throw Nitpicker::Session::Out_of_metadata(); } + throw Genode::Out_of_ram(); } } void destroy_view(View_handle handle) override @@ -852,7 +851,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object, try { return _env.ep().rpc_ep().apply(view_cap, lambda); } catch (View_handle_registry::Out_of_memory) { - throw Nitpicker::Session::Out_of_metadata(); } + throw Genode::Out_of_ram(); } } View_capability view_capability(View_handle handle) override @@ -912,7 +911,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object, { /* check if the session quota suffices for the specified mode */ if (_session_alloc.quota() < ram_quota(mode, use_alpha)) - throw Nitpicker::Session::Out_of_metadata(); + throw Genode::Out_of_ram(); _framebuffer_session_component.notify_mode_change(mode, use_alpha); } diff --git a/repos/os/src/server/part_blk/component.h b/repos/os/src/server/part_blk/component.h index 72934c4cc..aca372ad4 100644 --- a/repos/os/src/server/part_blk/component.h +++ b/repos/os/src/server/part_blk/component.h @@ -241,16 +241,16 @@ class Block::Root : } catch (Xml_node::Nonexistent_attribute) { error("policy does not define partition number for for '", label_str, "'"); - throw Root::Unavailable(); + throw Service_denied(); } catch (Session_policy::No_policy_defined) { error("rejecting session request, no matching policy for '", label_str, "'"); - throw Root::Unavailable(); + throw Service_denied(); } if (!_table.partition(num)) { error("Partition ", num, " unavailable for '", label_str, "'"); - throw Root::Unavailable(); + throw Service_denied(); } size_t ram_quota = @@ -259,7 +259,7 @@ class Block::Root : Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); if (!tx_buf_size) - throw Root::Invalid_args(); + throw Service_denied(); /* delete ram quota by the memory needed for the session */ size_t session_size = max((size_t)4096, diff --git a/repos/os/src/server/ram_blk/main.cc b/repos/os/src/server/ram_blk/main.cc index 4cb5d2cb1..5ef56308f 100644 --- a/repos/os/src/server/ram_blk/main.cc +++ b/repos/os/src/server/ram_blk/main.cc @@ -164,7 +164,8 @@ struct Main Genode::Number_of_bytes bytes; config.attribute("size").value(&bytes); size = bytes; - } catch (...) { + } + catch (...) { error("neither file nor size attribute specified"); throw Exception(); } @@ -185,9 +186,8 @@ struct Main size, " and block size ", block_size); return new (&alloc) Ram_blk(env, size, block_size); } - } catch (...) { - throw Root::Unavailable(); } + catch (...) { throw Service_denied(); } } void destroy(Block::Driver *driver) { diff --git a/repos/os/src/server/ram_fs/main.cc b/repos/os/src/server/ram_fs/main.cc index 63cecf13e..08a4ca4df 100644 --- a/repos/os/src/server/ram_fs/main.cc +++ b/repos/os/src/server/ram_fs/main.cc @@ -459,7 +459,7 @@ class File_system::Root : public Root_component session_root.import(tmp, "/"); } catch (Xml_node::Nonexistent_attribute) { Genode::error("missing \"root\" attribute in policy definition"); - throw Root::Unavailable(); + throw Service_denied(); } /* @@ -471,7 +471,7 @@ class File_system::Root : public Root_component } catch (Session_policy::No_policy_defined) { Genode::error("invalid session request, no matching policy"); - throw Root::Unavailable(); + throw Service_denied(); } /* apply client's root offset */ @@ -493,9 +493,8 @@ class File_system::Root : public Root_component session_root_dir = _root_dir.lookup_and_lock_dir( session_root.base() + 1); session_root_dir->unlock(); - } catch (Lookup_failed) { - throw Root::Unavailable(); } + catch (Lookup_failed) { throw Service_denied(); } } size_t ram_quota = @@ -505,7 +504,7 @@ class File_system::Root : public Root_component if (!tx_buf_size) { Genode::error(label, " requested a session with a zero length transmission buffer"); - throw Root::Invalid_args(); + throw Service_denied(); } /* @@ -562,9 +561,8 @@ struct Attribute_string */ Attribute_string(Genode::Xml_node node, char const *attr, char *fallback = 0) { - try { - node.attribute(attr).value(buf, sizeof(buf)); - } catch (Genode::Xml_node::Nonexistent_attribute) { + try { node.attribute(attr).value(buf, sizeof(buf)); } + catch (Genode::Xml_node::Nonexistent_attribute) { if (fallback) { Genode::strncpy(buf, fallback, sizeof(buf)); @@ -624,17 +622,15 @@ static void preload_content(Genode::Env &env, /* read file content from ROM module */ try { Attached_rom_dataspace rom(env, name); - if (!rom.valid()) - throw Rm_session::Attach_failed(); File *file = new (&alloc) File(alloc, as); file->write(rom.local_addr(), rom.size(), 0); dir.adopt_unsynchronized(file); } catch (Rom_connection::Rom_connection_failed) { - Genode::warning("failed to open ROM file \"", name, "\""); } - catch (Rm_session::Attach_failed) { - Genode::warning("Could not locally attach ROM file \"", name, "\""); } + Genode::warning("failed to open ROM module \"", name, "\""); } + catch (Region_map::Region_conflict) { + Genode::warning("Could not locally attach ROM module \"", name, "\""); } } /* diff --git a/repos/os/src/server/report_rom/rom_registry.h b/repos/os/src/server/report_rom/rom_registry.h index b7e5f17c2..92eb9c6ac 100644 --- a/repos/os/src/server/report_rom/rom_registry.h +++ b/repos/os/src/server/report_rom/rom_registry.h @@ -135,12 +135,13 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy Session_policy policy(rom_label, rom_node); policy.attribute("report").value(&report); return Rom::Module::Name(report.string()); - } catch (Xml_node::Nonexistent_sub_node) { /* no node */ } - catch (Session_policy::No_policy_defined) { } + } + catch (Xml_node::Nonexistent_sub_node) { /* no node */ } + catch (Session_policy::No_policy_defined) { } } warning("no valid policy for ROM request '", rom_label, "'"); - throw Root::Invalid_args(); + throw Service_denied(); } public: @@ -162,7 +163,7 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy */ if (module._num_writers() > 1) { release(writer, module); - throw Root::Invalid_args(); + throw Genode::Service_denied(); } return module; diff --git a/repos/os/src/server/rom_blk/main.cc b/repos/os/src/server/rom_blk/main.cc index 8ace3aedc..d6e9802aa 100644 --- a/repos/os/src/server/rom_blk/main.cc +++ b/repos/os/src/server/rom_blk/main.cc @@ -110,7 +110,7 @@ struct Main } catch(Rom_connection::Rom_connection_failed) { error("cannot open file ", file); } - throw Root::Unavailable(); + throw Service_denied(); } void destroy(Block::Driver *driver) { diff --git a/repos/os/src/server/tar_rom/main.cc b/repos/os/src/server/tar_rom/main.cc index 4bc2ea9be..f2e06c44f 100755 --- a/repos/os/src/server/tar_rom/main.cc +++ b/repos/os/src/server/tar_rom/main.cc @@ -142,6 +142,8 @@ class Tar_rom::Rom_session_component : public Rpc_object * \param tar_addr local address to tar archive * \param tar_size size of tar archive in bytes * \param label name of the requested ROM module + * + * \throw Service_denied */ Rom_session_component(Ram_session &ram, Region_map &rm, char const *tar_addr, unsigned tar_size, @@ -151,7 +153,7 @@ class Tar_rom::Rom_session_component : public Rpc_object _file_ds(_init_file_ds(ram, rm, label)) { if (!_file_ds.valid()) - throw Root::Invalid_args(); + throw Service_denied(); } /** diff --git a/repos/os/src/server/trace_fs/main.cc b/repos/os/src/server/trace_fs/main.cc index 2de492781..54cd71228 100644 --- a/repos/os/src/server/trace_fs/main.cc +++ b/repos/os/src/server/trace_fs/main.cc @@ -306,7 +306,8 @@ class Trace_file_system catch (...) { Genode::error("trace buffer is already managed"); } subject->active_file.set_active(); - } catch (...) { Genode::error("could not enable tracing"); } + } + catch (...) { Genode::error("could not enable tracing"); } } /** @@ -330,7 +331,8 @@ class Trace_file_system try { child = new (&_alloc) Directory(walker.element()); parent.adopt_unsynchronized(child); - } catch (...) { + } + catch (...) { Genode::error("could not create '", walker.element(), "'"); return 0; } @@ -449,12 +451,13 @@ class Trace_file_system _rm.detach(ram); } - } catch (...) { Genode::error("could not allocate policy"); } + } + catch (...) { Genode::error("could not allocate policy"); } } policy_changed = true; - - } catch (Trace_fs::Followed_subject_registry::Invalid_subject) { } + } + catch (Trace_fs::Followed_subject_registry::Invalid_subject) { } } Enable_file *enable_file = dynamic_cast(node); @@ -558,6 +561,7 @@ class Trace_file_system continue; } } catch (Trace_fs::Followed_subject_registry::Invalid_subject) { + /* ignore unknown but already dead subject */ if (state == Subject_info::State::DEAD) continue; @@ -689,10 +693,15 @@ class File_system::Session_component : public Session_rpc_object try { Node *node = _handle_registry.lookup(packet.handle()); - _process_packet_op(packet, *node); } - catch (Invalid_handle) { Genode::error("Invalid_handle"); } + catch (Invalid_handle) { Genode::error("Invalid_handle"); } + + /* + * The 'acknowledge_packet' function cannot block because we + * checked for 'ready_to_ack' in '_process_packets'. + */ + tx_sink()->acknowledge_packet(packet); } /** @@ -898,7 +907,8 @@ class File_system::Session_component : public Session_rpc_object File *file = dynamic_cast(node); if (file) { file->truncate(size); } - } catch (Invalid_handle) { } + } + catch (Invalid_handle) { } } void move(Dir_handle, Name const &, Dir_handle, Name const &) { } @@ -949,20 +959,20 @@ class File_system::Root : public Root_component * Override default settings with specific session settings by * evaluating the policy. */ - try { policy.attribute("interval").value(&interval); - } catch (...) { } - try { policy.attribute("subject_limit").value(&subject_limit); - } catch (...) { } - try { policy.attribute("trace_quota").value(&trace_quota); - } catch (...) { } - try { policy.attribute("trace_meta_quota").value(&trace_meta_quota); - } catch (...) { } - try { policy.attribute("parent_levels").value(&trace_parent_levels); - } catch (...) { } - try { policy.attribute("buffer_size").value(&buffer_size); - } catch (...) { } - try { policy.attribute("buffer_size_max").value(&buffer_size_max); - } catch (...) { } + try { policy.attribute("interval").value(&interval); } + catch (...) { } + try { policy.attribute("subject_limit").value(&subject_limit); } + catch (...) { } + try { policy.attribute("trace_quota").value(&trace_quota); } + catch (...) { } + try { policy.attribute("trace_meta_quota").value(&trace_meta_quota); } + catch (...) { } + try { policy.attribute("parent_levels").value(&trace_parent_levels); } + catch (...) { } + try { policy.attribute("buffer_size").value(&buffer_size); } + catch (...) { } + try { policy.attribute("buffer_size_max").value(&buffer_size_max); } + catch (...) { } /* * Determine directory that is used as root directory of @@ -978,18 +988,20 @@ class File_system::Root : public Root_component */ if (root[0] != '/') throw Lookup_failed(); - } catch (Xml_node::Nonexistent_attribute) { + } + catch (Xml_node::Nonexistent_attribute) { Genode::error("Missing \"root\" attribute in policy definition"); - throw Root::Unavailable(); - } catch (Lookup_failed) { + throw Service_denied(); + } + catch (Lookup_failed) { Genode::error("session root directory " "\"", Genode::Cstring(root), "\" does not exist"); - throw Root::Unavailable(); + throw Service_denied(); } - - } catch (Session_policy::No_policy_defined) { + } + catch (Session_policy::No_policy_defined) { Genode::error("Invalid session request, no matching policy"); - throw Root::Unavailable(); + throw Service_denied(); } size_t ram_quota = @@ -999,7 +1011,7 @@ class File_system::Root : public Root_component if (!tx_buf_size) { Genode::error(label, " requested a session with a zero length transmission buffer"); - throw Root::Invalid_args(); + throw Genode::Service_denied(); } /* diff --git a/repos/os/src/server/vfs/main.cc b/repos/os/src/server/vfs/main.cc index 6e4b0d702..8b31749d2 100644 --- a/repos/os/src/server/vfs/main.cc +++ b/repos/os/src/server/vfs/main.cc @@ -420,7 +420,7 @@ class Vfs_server::Session_component : public File_system::Session_rpc_object, Directory *dir; try { dir = new (_alloc) Directory(_node_space, _vfs, path_str, create); } - catch (Out_of_memory) { throw Out_of_metadata(); } + catch (Out_of_memory) { throw Out_of_ram(); } return Dir_handle(dir->id().value); } @@ -478,7 +478,7 @@ class Vfs_server::Session_component : public File_system::Session_rpc_object, Node *node; try { node = new (_alloc) Node(_node_space, path_str, STAT_ONLY); } - catch (Out_of_memory) { throw Out_of_metadata(); } + catch (Out_of_memory) { throw Out_of_ram(); } return Node_handle(node->id().value); } @@ -662,7 +662,7 @@ class Vfs_server::Root : Arg_string::find_arg(args, "tx_buf_size").aligned_size(); if (!tx_buf_size) - throw Root::Invalid_args(); + throw Service_denied(); size_t session_size = max((size_t)4096, sizeof(Session_component)) + @@ -702,7 +702,7 @@ class Vfs_server::Root : } catch (Session_policy::No_policy_defined) { /* missing policy - deny request */ - throw Root::Unavailable(); + throw Service_denied(); } /* apply client's root offset. */ @@ -715,7 +715,7 @@ class Vfs_server::Root : /* check if the session root exists */ if (!((session_root == "/") || _vfs.directory(session_root.base()))) { error("session root '", session_root, "' not found for '", label, "'"); - throw Root::Unavailable(); + throw Service_denied(); } Session_component *session = new (md_alloc()) diff --git a/repos/os/src/server/vfs/node.h b/repos/os/src/server/vfs/node.h index 4acbab752..8768e5357 100644 --- a/repos/os/src/server/vfs/node.h +++ b/repos/os/src/server/vfs/node.h @@ -77,7 +77,7 @@ namespace Vfs_server { /* * Note that the file objects are created at the * VFS in the local node constructors, this is to - * ensure that Out_of_metadata is thrown before + * ensure that Out_of_ram is thrown before * the VFS is modified. */ } @@ -336,7 +336,7 @@ struct Vfs_server::Directory : Node try { file = new (alloc) File(space, vfs, alloc, file_io_handler, path_str, mode, create); - } catch (Out_of_memory) { throw Out_of_metadata(); } + } catch (Out_of_memory) { throw Out_of_ram(); } if (create) mark_as_updated(); @@ -360,7 +360,7 @@ struct Vfs_server::Directory : Node Symlink *link; try { link = new (alloc) Symlink(space, vfs, path_str, mode, create); } - catch (Out_of_memory) { throw Out_of_metadata(); } + catch (Out_of_memory) { throw Out_of_ram(); } if (create) mark_as_updated(); return link->id(); diff --git a/repos/os/src/test/blk/cli/main.cc b/repos/os/src/test/blk/cli/main.cc index 05909281a..fa63c549c 100644 --- a/repos/os/src/test/blk/cli/main.cc +++ b/repos/os/src/test/blk/cli/main.cc @@ -426,9 +426,11 @@ void Component::construct(Genode::Env &env) perform(env, heap, 1000); log("Tests finished successfully!"); - } catch(Genode::Parent::Service_denied) { + } + catch (Genode::Service_denied) { error("opening block session was denied!"); - } catch(Test::Exception &e) { + } + catch (Test::Exception &e) { error("test failed!"); e.print_error(); } diff --git a/repos/os/src/test/bomb/main.cc b/repos/os/src/test/bomb/main.cc index f600da3b2..54ada8f23 100644 --- a/repos/os/src/test/bomb/main.cc +++ b/repos/os/src/test/bomb/main.cc @@ -104,7 +104,7 @@ class Bomb_child : public Child_policy service = &s; }); if (!service) - throw Parent::Service_denied(); + throw Service_denied(); return *service; } @@ -260,7 +260,7 @@ struct Bomb log("--- bomb started ---"); /* try to create timer session, if it fails, bomb is our parent */ - try { timer.construct(env); } catch (Parent::Service_denied) { } + try { timer.construct(env); } catch (Service_denied) { } if (timer.constructed()) { timer->sigh(signal_timeout); diff --git a/repos/os/src/test/fault_detection/main.cc b/repos/os/src/test/fault_detection/main.cc index 12df2ae81..35cf5511f 100644 --- a/repos/os/src/test/fault_detection/main.cc +++ b/repos/os/src/test/fault_detection/main.cc @@ -139,7 +139,7 @@ class Test_child : public Genode::Child_policy if (service == Log_session::service_name()) return _log_service; if (service == Rom_session::service_name()) return _rom_service; - throw Parent::Service_denied(); + throw Service_denied(); } }; diff --git a/repos/os/src/test/input_filter/main.cc b/repos/os/src/test/input_filter/main.cc index 853d02013..bdaf85629 100644 --- a/repos/os/src/test/input_filter/main.cc +++ b/repos/os/src/test/input_filter/main.cc @@ -140,7 +140,7 @@ class Test::Input_root : public Root_component if (label.last_element() == "ps2") return &_ps2_input; error("no matching policy for session label ", label); - throw Root::Invalid_args(); + throw Service_denied(); } /* diff --git a/repos/os/src/test/pci/test.cc b/repos/os/src/test/pci/test.cc index e946f3015..c6d9e2012 100644 --- a/repos/os/src/test/pci/test.cc +++ b/repos/os/src/test/pci/test.cc @@ -71,16 +71,9 @@ void Component::construct(Genode::Env &env) /* open session to pci service */ static Platform::Connection pci(env); - /* - * Functor that is called if the platform driver throws a - * 'Out_of_metadata' exception. - */ - auto handler = [&] () { pci.upgrade_ram(4096); }; - Platform::Device_capability prev_device_cap, device_cap; - auto attempt = [&] () { device_cap = pci.first_device(); }; - retry(attempt, handler); + pci.with_upgrade([&] () { device_cap = pci.first_device(); }); /* * Iterate through all installed devices @@ -92,8 +85,7 @@ void Component::construct(Genode::Env &env) pci.release_device(prev_device_cap); prev_device_cap = device_cap; - auto attempt = [&] () { device_cap = pci.next_device(device_cap); }; - retry(attempt, handler); + pci.with_upgrade([&] () { device_cap = pci.next_device(device_cap); }); } /* release last device */ diff --git a/repos/os/src/test/report_rom/main.cc b/repos/os/src/test/report_rom/main.cc index 5bc8b0874..0faf0c0a7 100644 --- a/repos/os/src/test/report_rom/main.cc +++ b/repos/os/src/test/report_rom/main.cc @@ -75,9 +75,10 @@ struct Test::Main again.enabled(true); error("expected Service_denied"); throw -3; - } catch (Genode::Parent::Service_denied) { - log("ROM client: catched Parent::Service_denied - OK"); } + catch (Service_denied) { + log("ROM client: caught Service_denied - OK"); } + log("--- test-report_rom finished ---"); _env.parent().exit(0); return; diff --git a/repos/os/src/test/trace/main.cc b/repos/os/src/test/trace/main.cc index 200558c65..23523dbd5 100644 --- a/repos/os/src/test/trace/main.cc +++ b/repos/os/src/test/trace/main.cc @@ -122,14 +122,14 @@ struct Test_out_of_metadata Test_out_of_metadata(Env &env) : env(env) { - log("test Out_of_metadata exception of Trace::Session::subjects call"); + log("test Out_of_ram exception of Trace::Session::subjects call"); /* * The call of 'subjects' will prompt core's TRACE service to import those * threads as trace subjects into the TRACE session. This step should fail * because we dimensioned the TRACE session with a very low amount of * session quota. The allocation failure is propagated to the TRACE client - * by the 'Out_of_metadata' exception. The test validates this + * by the 'Out_of_ram' exception. The test validates this * error-handling procedure. */ @@ -143,14 +143,14 @@ struct Test_out_of_metadata /* we should never arrive here */ struct Unexpectedly_got_no_exception{}; throw Unexpectedly_got_no_exception(); - - } catch (Parent::Service_denied) { - log("got Parent::Service_denied exception as expected"); } + } + catch (Service_denied) { + log("got Service_denied exception as expected"); } try { /* * Create multiple threads because on some platforms there - * are not enough available subjects to trigger the Out_of_metadata + * are not enough available subjects to trigger the Out_of_ram * exception. */ Test_thread thread1 { env, "test-thread1" }; @@ -167,10 +167,10 @@ struct Test_out_of_metadata struct Unexpectedly_got_no_exception{}; throw Unexpectedly_got_no_exception(); - } catch (Trace::Out_of_metadata) { - log("got Trace::Out_of_metadata exception as expected"); } + } catch (Out_of_ram) { + log("got Trace::Out_of_ram exception as expected"); } - log("passed Out_of_metadata test"); + log("passed Out_of_ram test"); } }; diff --git a/repos/ports/include/vmm/guest_memory.h b/repos/ports/include/vmm/guest_memory.h index c543ff044..2a692a047 100644 --- a/repos/ports/include/vmm/guest_memory.h +++ b/repos/ports/include/vmm/guest_memory.h @@ -66,7 +66,7 @@ struct Vmm::Virtual_reservation : private Rm_connection, Region_map_client env.rm().attach_at(Region_map_client::dataspace(), PAGE_SIZE, 0, PAGE_SIZE); - } catch (Rm_session::Region_conflict) { + } catch (Region_map::Region_conflict) { error("region conflict while attaching guest-physical memory"); } } diff --git a/repos/ports/include/vmm/vcpu_dispatcher.h b/repos/ports/include/vmm/vcpu_dispatcher.h index 5393a7839..78104a913 100644 --- a/repos/ports/include/vmm/vcpu_dispatcher.h +++ b/repos/ports/include/vmm/vcpu_dispatcher.h @@ -116,7 +116,7 @@ class Vmm::Vcpu_dispatcher : public T Capability_space::import(T::native_thread().ec_sel); Untyped_capability handler = - retry( + retry( [&] () { /* manually define selector used for RPC result */ Thread::myself()->native_thread().client_rcv_sel = exc_base + EV; diff --git a/repos/ports/src/app/gdb_monitor/app_child.h b/repos/ports/src/app/gdb_monitor/app_child.h index 865ad9605..157ed8acd 100644 --- a/repos/ports/src/app/gdb_monitor/app_child.h +++ b/repos/ports/src/app/gdb_monitor/app_child.h @@ -205,7 +205,7 @@ class Gdb_monitor::App_child : public Child_policy service = new (_alloc) Parent_service(_parent_services, _env, service_name); if (!service) - throw Parent::Service_denied(); + throw Service_denied(); return *service; } diff --git a/repos/ports/src/app/gdb_monitor/child_config.h b/repos/ports/src/app/gdb_monitor/child_config.h index 41c3bfa2b..73cc9e3c9 100644 --- a/repos/ports/src/app/gdb_monitor/child_config.h +++ b/repos/ports/src/app/gdb_monitor/child_config.h @@ -45,8 +45,9 @@ class Init::Child_config /** * Buffer '' sub node in a dedicated RAM dataspace * - * \throw Ram_session::Alloc_failed - * \throw Rm_session::Attach_failed + * \throw Out_of_ram + * \throw Out_of_caps + * \throw Region_map::Region_conflict */ Genode::Ram_dataspace_capability _ram_ds_from_start_node(Genode::Xml_node start, @@ -81,7 +82,7 @@ class Init::Child_config return ram_ds; } - catch (Genode::Region_map::Attach_failed) { ram.free(ram_ds); throw; } + catch (Genode::Region_map::Region_conflict) { ram.free(ram_ds); throw; } } public: @@ -93,12 +94,13 @@ class Init::Child_config * holding the copy of the child's configuration data unless the * configuration is supplied via a config ROM module. * - * \throw Ram_session::Alloc_failed failed to allocate the backing - * store for holding config data + * \throw Out_of_ram failed to allocate the backing + * store for holding config data + * \throw Out_of_caps * - * \throw Region_map::Attach_failed failed to temporarily attach the - * config dataspace to the local - * address space + * \throw Region_map::Region_conflict failed to temporarily attach the + * config dataspace to the local + * address space * * If the start node contains a 'filename' entry, we only keep the * information about the ROM module name. diff --git a/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc b/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc index 79ac2e357..19d1dfb8a 100644 --- a/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc +++ b/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc @@ -104,9 +104,14 @@ class Memory_model _region = region; _local_base = rm.attach(_region->ds_cap(), 0, _region->offset()); - } catch (Region_map::Attach_failed) { + } + catch (Region_map::Region_conflict) { flush(rm); - error(__func__, ": RM attach failed"); + error(__func__, ": RM attach failed (region conflict)"); + } + catch (Region_map::Invalid_dataspace) { + flush(rm); + error(__func__, ": RM attach failed (invalid dataspace)"); } } diff --git a/repos/ports/src/app/gdb_monitor/region_map_component.cc b/repos/ports/src/app/gdb_monitor/region_map_component.cc index a292a2752..d956746dd 100644 --- a/repos/ports/src/app/gdb_monitor/region_map_component.cc +++ b/repos/ports/src/app/gdb_monitor/region_map_component.cc @@ -60,14 +60,14 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size, if (offset < 0 || (size_t)offset >= ds_size) { PWRN("offset outside of dataspace"); - throw Invalid_args(); + throw Region_conflict(); } if (size == 0) size = ds_size - offset; else if (size > ds_size - offset) { PWRN("size bigger than remainder of dataspace"); - throw Invalid_args(); + throw Region_conflict(); } void *addr = _parent_region_map.attach(ds_cap, size, offset, diff --git a/repos/ports/src/app/seoul/boot_module_provider.h b/repos/ports/src/app/seoul/boot_module_provider.h index 7396a9232..116c073d6 100644 --- a/repos/ports/src/app/seoul/boot_module_provider.h +++ b/repos/ports/src/app/seoul/boot_module_provider.h @@ -141,8 +141,11 @@ class Boot_module_provider catch (Xml_node::Nonexistent_attribute) { } catch (Destination_buffer_too_small) { error("Boot_module_provider: destination buffer too small"); } - catch (Region_map::Attach_failed) { - error("Boot_module_provider: Region_map::Attach_failed"); + catch (Region_map::Region_conflict) { + error("Boot_module_provider: Region_map::Region_conflict"); + throw Module_loading_failed(); } + catch (Region_map::Invalid_dataspace) { + error("Boot_module_provider: Region_map::Invalid_dataspace"); throw Module_loading_failed(); } catch (Rom_connection::Rom_connection_failed) { error("Boot_module_provider: Rom_connection_failed"); } diff --git a/repos/ports/src/app/seoul/main.cc b/repos/ports/src/app/seoul/main.cc index ef88ccf08..61c06f436 100644 --- a/repos/ports/src/app/seoul/main.cc +++ b/repos/ports/src/app/seoul/main.cc @@ -228,10 +228,9 @@ class Guest_memory _local_addr = env.rm().attach(_ds); _fb_addr = env.rm().attach_at(_fb_ds, ((Genode::addr_t) _local_addr)+backing_store_size-fb_size); - - } catch (Genode::Rm_session::Region_conflict) { - Genode::error("region conflict"); } + catch (Genode::Region_map::Region_conflict) { + Genode::error("region conflict"); } } ~Guest_memory() diff --git a/repos/ports/src/noux/child_policy.h b/repos/ports/src/noux/child_policy.h index 7615d2812..eedab135d 100644 --- a/repos/ports/src/noux/child_policy.h +++ b/repos/ports/src/noux/child_policy.h @@ -172,7 +172,7 @@ class Noux::Child_policy : public Genode::Child_policy if ((service = _find_service(_parent_services, service_name))) return *service; - throw Parent::Service_denied(); + throw Service_denied(); } void exit(int exit_value) override diff --git a/repos/ports/src/noux/empty_rom_service.h b/repos/ports/src/noux/empty_rom_service.h index 59ab74e96..5eef383aa 100644 --- a/repos/ports/src/noux/empty_rom_service.h +++ b/repos/ports/src/noux/empty_rom_service.h @@ -45,9 +45,9 @@ class Noux::Empty_rom_factory : public Empty_rom_service::Factory Empty_rom_session_component &create(Args const &args, Affinity) override { try { - return *new (_alloc) Empty_rom_session_component(_ep); - } - catch (Rom_connection::Rom_connection_failed) { throw Denied(); } + return *new (_alloc) Empty_rom_session_component(_ep); } + catch (Rom_connection::Rom_connection_failed) { + throw Service_denied(); } } void upgrade(Empty_rom_session_component &, Args const &) override { } diff --git a/repos/ports/src/noux/local_rom_service.h b/repos/ports/src/noux/local_rom_service.h index 538ee5174..c6ae9df31 100644 --- a/repos/ports/src/noux/local_rom_service.h +++ b/repos/ports/src/noux/local_rom_service.h @@ -60,7 +60,8 @@ class Noux::Local_rom_factory : public Local_rom_service::Factory return *new (_alloc) Rom_session_component(_alloc, _env, _ep, _root_dir, _registry, rom_name); } - catch (Rom_connection::Rom_connection_failed) { throw Denied(); } + catch (Rom_connection::Rom_connection_failed) { + throw Service_denied(); } } void upgrade(Rom_session_component &, Args const &) override { } diff --git a/repos/ports/src/noux/region_map_component.h b/repos/ports/src/noux/region_map_component.h index 71662cb87..4d1c25325 100644 --- a/repos/ports/src/noux/region_map_component.h +++ b/repos/ports/src/noux/region_map_component.h @@ -241,9 +241,9 @@ class Noux::Region_map_component : public Rpc_object, local_addr = _rm.attach(ds, size, offset, use_local_addr, local_addr, executable); break; - } catch (Region_map::Out_of_metadata) { - _pd.upgrade_ram(8*1024); } + catch (Out_of_ram) { _pd.upgrade_ram(8*1024); } + catch (Out_of_caps) { _pd.upgrade_caps(2); } } Region * region = new (_alloc) diff --git a/repos/ports/src/virtualbox/mm.h b/repos/ports/src/virtualbox/mm.h index f29137b87..508d5e04a 100644 --- a/repos/ports/src/virtualbox/mm.h +++ b/repos/ports/src/virtualbox/mm.h @@ -49,12 +49,16 @@ class Sub_rm_connection : private Genode::Rm_connection, Local_addr local_addr = (void *)0, bool executable = false) override { - Local_addr addr = Genode::retry( + Local_addr addr = Genode::retry( [&] () { - return Region_map_client::attach(ds, size, offset, - use_local_addr, - local_addr, - executable); }, + return Genode::retry( + [&] () { + return Region_map_client::attach(ds, size, offset, + use_local_addr, + local_addr, + executable); }, + [&] () { upgrade_caps(2); }); + }, [&] () { upgrade_ram(8192); }); Genode::addr_t new_addr = addr; diff --git a/repos/ports/src/virtualbox/pgm.cc b/repos/ports/src/virtualbox/pgm.cc index 2ec8c8993..ae8f15f81 100644 --- a/repos/ports/src/virtualbox/pgm.cc +++ b/repos/ports/src/virtualbox/pgm.cc @@ -95,8 +95,8 @@ int PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, } catch (Guest_memory::Region_conflict) { return VERR_PGM_MAPPING_CONFLICT; } - catch (Ram_session::Alloc_failed) { return VERR_PGM_MAPPING_CONFLICT; } - catch (Rm_session::Attach_failed) { return VERR_PGM_MAPPING_CONFLICT; } + catch (Genode::Out_of_ram) { return VERR_PGM_MAPPING_CONFLICT; } + catch (Genode::Out_of_caps) { return VERR_PGM_MAPPING_CONFLICT; } return VINF_SUCCESS; } @@ -315,9 +315,13 @@ int PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, } catch (Guest_memory::Region_conflict) { return VERR_PGM_MAPPING_CONFLICT; } - catch (Ram_session::Alloc_failed) { + catch (Genode::Out_of_ram) { return VERR_PGM_MAPPING_CONFLICT; /* XXX use a better error code? */ } - catch (Rm_session::Attach_failed) { + catch (Genode::Out_of_caps) { + Genode::warning("Out_of_caps during 'add_ram_mapping'"); + return VERR_PGM_MAPPING_CONFLICT; /* XXX use a better error code? */ } + catch (Genode::Region_map::Region_conflict) { + Genode::warning("Region_conflict during 'add_ram_mapping'"); return VERR_PGM_MAPPING_CONFLICT; /* XXX use a better error code? */ } return VINF_SUCCESS; diff --git a/repos/ports/src/virtualbox/thread.cc b/repos/ports/src/virtualbox/thread.cc index 6aa8eb944..d810c9f46 100644 --- a/repos/ports/src/virtualbox/thread.cc +++ b/repos/ports/src/virtualbox/thread.cc @@ -126,13 +126,13 @@ extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr, for (unsigned i = 0; i < 2; i++) { using namespace Genode; - try { - return create_thread(thread, attr, start_routine, arg); - } catch (Cpu_session::Out_of_metadata) { + try { return create_thread(thread, attr, start_routine, arg); } + catch (Out_of_ram) { log("Upgrading memory for creation of " "thread '", Cstring(rtthread->szName), "'"); cpu_connection(rtthread->enmType)->upgrade_ram(4096); - } catch (...) { break; } + } + catch (...) { break; } } Genode::error("could not create vbox pthread - halt"); diff --git a/repos/ports/src/virtualbox/vmm_memory.h b/repos/ports/src/virtualbox/vmm_memory.h index 5c8e7d55d..32c5ddc5b 100644 --- a/repos/ports/src/virtualbox/vmm_memory.h +++ b/repos/ports/src/virtualbox/vmm_memory.h @@ -67,8 +67,9 @@ class Vmm_memory Vmm_memory(Genode::Env &env) : _env(env) { } /** - * \throw Ram_session::Alloc_failed - * \throw Region_map::Attach_failed + * \throw Out_of_ram + * \throw Out_of_caps + * \throw Region_map::Region_conflict */ void *alloc(size_t cb, PPDMDEVINS pDevIns, unsigned iRegion) { @@ -81,11 +82,15 @@ class Vmm_memory return r->local_addr(); - } catch (Genode::Ram_session::Alloc_failed) { + } catch (Genode::Out_of_ram) { Genode::error("Vmm_memory::alloc(", Genode::Hex(cb), "): " "RAM allocation failed"); throw; - } catch (Genode::Region_map::Attach_failed) { + } catch (Genode::Out_of_caps) { + Genode::error("Vmm_memory::alloc(", Genode::Hex(cb), "): " + "RAM allocation failed (out of caps)"); + throw; + } catch (Genode::Region_map::Region_conflict) { Genode::error("Vmm_memory::alloc(", Genode::Hex(cb), "): " "RM attach failed"); throw;