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).
This commit is contained in:
Norman Feske 2017-05-07 22:03:22 +02:00 committed by Christian Helmuth
parent 1f4f119b1e
commit 4d442bca30
180 changed files with 932 additions and 834 deletions

View File

@ -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();

View File

@ -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();
}
}

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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);

View File

@ -52,7 +52,7 @@ struct Sync_root : public Root_component<Session_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)

View File

@ -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;
}

View File

@ -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);

View File

@ -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();
}
/*

View File

@ -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<Nova::Utcb *>(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<addr_t>(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;

View File

@ -19,6 +19,7 @@
#include <base/object_pool.h>
#include <base/capability.h>
#include <base/session_label.h>
#include <cpu_session/cpu_session.h>
#include <pager/capability.h>
/* NOVA includes */
@ -31,6 +32,8 @@
namespace Genode {
typedef Cpu_session::Thread_creation_failed Invalid_thread;
class Pager_entrypoint;
class Pager_object;

View File

@ -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;

View File

@ -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<addr_t>(_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();
}
}

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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)) { }

View File

@ -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)

View File

@ -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)

View File

@ -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(); }

View File

@ -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<Parent>,
* 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<Parent>,
* 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<Parent>,
*
* \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<Parent>,
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<Parent>,
_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<Parent>,
* 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);

View File

@ -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} });
}
};

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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 { };

View File

@ -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_session> 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<Pd_session>, Name const &, Affinity::Location,
Weight, addr_t);
GENODE_RPC(Rpc_kill_thread, void, kill_thread, Thread_capability);

View File

@ -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),

View File

@ -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
*/

View File

@ -17,6 +17,7 @@
#include <base/exception.h>
#include <base/stdint.h>
#include <base/signal.h>
#include <base/quota_guard.h>
#include <dataspace/capability.h>
#include <thread/capability.h>
@ -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);

View File

@ -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<Region_map> create(size_t size) = 0;
@ -60,7 +51,7 @@ struct Genode::Rm_session : Session
*********************/
GENODE_RPC_THROW(Rpc_create, Capability<Region_map>, 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<Region_map>);
GENODE_RPC_INTERFACE(Rpc_create, Rpc_destroy);

View File

@ -26,7 +26,7 @@ class Genode::Rom_connection : public Connection<Rom_session>,
{
public:
class Rom_connection_failed : public Parent::Service_denied { };
class Rom_connection_failed : public Service_denied { };
enum { RAM_QUOTA = 6*1024UL };

View File

@ -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<Typed_root<SESSION_TYPE> >,
* 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<Typed_root<SESSION_TYPE> >,
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<Typed_root<SESSION_TYPE> >,
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<SESSION_TYPE>::Factory::Denied(); }
catch (...) { throw Service_denied(); }
}
void upgrade(SESSION_TYPE &session,
@ -329,14 +327,14 @@ class Genode::Root_component : public Rpc_object<Typed_root<SESSION_TYPE> >,
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;

View File

@ -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);

View File

@ -34,6 +34,7 @@ namespace Genode {
*/
struct Insufficient_ram_quota : Exception { };
struct Insufficient_cap_quota : Exception { };
struct Service_denied : Exception { };
}

View File

@ -64,7 +64,8 @@ struct Genode::Trace::Session_client : Genode::Rpc_client<Genode::Trace::Session
/**
* Retrieve subject directory
*
* \throw Out_of_metadata
* \throw Out_of_ram
* \throw Out_of_caps
*/
size_t subjects(Subject_id *dst, size_t dst_len)
{

View File

@ -31,7 +31,8 @@ struct Genode::Trace::Session : Genode::Session
/**
* Allocate policy-module backing store
*
* \throw Out_of_metadata
* \throw Out_of_ram
* \throw Out_of_caps
*/
virtual Policy_id alloc_policy(size_t size) = 0;
@ -50,7 +51,8 @@ struct Genode::Trace::Session : Genode::Session
/**
* Start tracing of a subject
*
* \throw Out_of_metadata
* \throw Out_of_ram
* \throw Out_of_caps
* \throw Already_traced
* \throw Source_is_dead
* \throw Nonexistent_policy
@ -112,7 +114,7 @@ struct Genode::Trace::Session : Genode::Session
GENODE_RPC(Rpc_dataspace, Dataspace_capability, dataspace);
GENODE_RPC_THROW(Rpc_alloc_policy, Policy_id, alloc_policy,
GENODE_TYPE_LIST(Out_of_metadata),
GENODE_TYPE_LIST(Out_of_ram, Out_of_caps),
size_t);
GENODE_RPC_THROW(Rpc_policy, Dataspace_capability, policy,
GENODE_TYPE_LIST(Nonexistent_policy),
@ -120,12 +122,12 @@ struct Genode::Trace::Session : Genode::Session
GENODE_RPC_THROW(Rpc_unload_policy, void, unload_policy,
GENODE_TYPE_LIST(Nonexistent_policy), Policy_id);
GENODE_RPC_THROW(Rpc_trace, void, trace,
GENODE_TYPE_LIST(Out_of_metadata, Already_traced,
GENODE_TYPE_LIST(Out_of_ram, Out_of_caps, Already_traced,
Source_is_dead, Nonexistent_policy,
Traced_by_other_session),
Subject_id, Policy_id, size_t);
GENODE_RPC_THROW(Rpc_rule, void, rule,
GENODE_TYPE_LIST(Out_of_metadata),
GENODE_TYPE_LIST(Out_of_ram, Out_of_caps),
Session_label const &, Thread_name const &,
Policy_id, size_t);
GENODE_RPC_THROW(Rpc_pause, void, pause,
@ -134,7 +136,7 @@ struct Genode::Trace::Session : Genode::Session
GENODE_TYPE_LIST(Nonexistent_subject, Source_is_dead),
Subject_id);
GENODE_RPC_THROW(Rpc_subjects, size_t, subjects,
GENODE_TYPE_LIST(Out_of_metadata));
GENODE_TYPE_LIST(Out_of_ram, Out_of_caps));
GENODE_RPC_THROW(Rpc_subject_info, Subject_info, subject_info,
GENODE_TYPE_LIST(Nonexistent_subject), Subject_id);
GENODE_RPC_THROW(Rpc_buffer, Dataspace_capability, buffer,

View File

@ -67,8 +67,7 @@ Thread_capability Cpu_session_component::create_thread(Capability<Pd_session> 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);

View File

@ -77,7 +77,7 @@ class Genode::Cpu_thread_component : public Rpc_object<Cpu_thread>,
: 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<Cpu_thread>,
/*
* 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
*/

View File

@ -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);

View File

@ -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();
}
}

View File

@ -21,6 +21,7 @@
#include <base/thread.h>
#include <base/object_pool.h>
#include <pager/capability.h>
#include <cpu_session/cpu_session.h>
#include <ipc_pager.h>
/* 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<Pager_object>::Entry
* Constructor
*
* \param location affinity of paged thread to physical CPU
*
* \throw Invalid_thread
*/
Pager_object(Cpu_session_capability cpu_sesion,
Thread_capability thread,

View File

@ -82,7 +82,7 @@ class Genode::Rm_session_component : public Rpc_object<Rm_session>
return rm->cap();
}
catch (Allocator::Out_of_memory) { throw Out_of_metadata(); }
catch (Allocator::Out_of_memory) { throw Out_of_ram(); }
}
void destroy(Capability<Region_map> cap) override

View File

@ -39,7 +39,7 @@ class Genode::Trace::Root : public Genode::Root_component<Session_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,

View File

@ -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)

View File

@ -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<Io_mem_dataspace>(_ds_ep->manage(&_ds));

View File

@ -178,7 +178,7 @@ class Core_child : public Child_policy
service = &s; });
if (!service)
throw Parent::Service_denied();
throw Service_denied();
return *service;
}

View File

@ -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()) {

View File

@ -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<Rom_dataspace>(_ds_ep->manage(&_ds));
}

View File

@ -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<uint16_t>(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;
}

View File

@ -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();
}
}

View File

@ -42,7 +42,7 @@ struct Genode::Expanding_cpu_session_client : Upgradeable_client<Genode::Cpu_ses
create_thread(Pd_session_capability pd, Name const &name,
Affinity::Location location, Weight weight, addr_t utcb) override
{
return retry<Cpu_session::Out_of_metadata>(
return retry<Out_of_ram>(
[&] () {
return Cpu_session_client::create_thread(pd, name, location,
weight, utcb); },

View File

@ -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<Region_map::Out_of_metadata>(
return retry<Out_of_ram>(
[&] () {
return Region_map_client::attach(ds, size, offset,
use_local_addr,
local_addr,
executable); },
return retry<Out_of_caps>(
[&] {
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); });
}
};

View File

@ -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<Session_state>(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();
}

View File

@ -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;
}
}
}

View File

@ -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

View File

@ -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) {

View File

@ -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")) {

View File

@ -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:

View File

@ -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;
}

View File

@ -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<Genode::Region_map::Out_of_metadata>(
return retry<Genode::Out_of_ram>(
[&] () {
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<Genode::Region_map::Out_of_metadata>(
return retry<Genode::Out_of_ram>(
[&] () {
return _rm.attach_executable(ds, local_addr - _base, size, offset);
},

View File

@ -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();
}
}

View File

@ -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"); }
}

View File

@ -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();
}
}

View File

@ -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<Platform::Session::Out_of_metadata>(
[&] () { 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<Platform::Session::Out_of_metadata>(
[&] () { return _pci.alloc_dma_buffer(size); },
return Genode::retry<Genode::Out_of_ram>(
[&] () {
return Genode::retry<Genode::Out_of_caps>(
[&] () { 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<Platform::Device::Quota_exceeded>(
[&] () { 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;
}

View File

@ -194,20 +194,14 @@ struct Pci_driver
{
Platform::Device_client client(_cap);
Genode::size_t donate = 4096;
Genode::retry<Platform::Device::Quota_exceeded>(
[&] () { 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<Platform::Session::Out_of_metadata>(
[&] () { 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<Platform::Session::Out_of_metadata>(
[&] () { 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<Platform::Session::Out_of_metadata>(
[&] () { return _pci.alloc_dma_buffer(size); },
[&] () {
_pci.upgrade_ram(donate);
donate = donate * 2 > size ? 4096 : donate * 2;
});
Ram_dataspace_capability ram_cap =
retry<Out_of_ram>(
[&] () {
return retry<Out_of_caps>(
[&] () { 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();

View File

@ -184,13 +184,8 @@ class Lx::Pci_dev : public pci_dev, public Lx_kit::List<Pci_dev>::Element
template <typename T>
void config_write(unsigned int devfn, T val)
{
Genode::size_t donate = 4096;
Genode::retry<Platform::Device::Quota_exceeded>(
[&] () { _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<Pci_dev>::Element
template <typename FUNC>
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<Platform::Session::Out_of_metadata>(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<Platform::Session::Out_of_metadata>(attempt, handler);
Platform::Device_capability next_cap =
Lx::pci()->with_upgrade([&] () {
return pci()->next_device(cap); });
Lx::pci()->release_device(cap);
cap = next_cap;
}
}

View File

@ -835,10 +835,11 @@ class Usb::Root : public Genode::Root_component<Session_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();
}
}

View File

@ -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<Platform::Session::Out_of_metadata>(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<Platform::Session::Out_of_metadata>(attempt, handler);
/* try next one. Upgrade session quota on demand.*/
Lx::pci()->with_upgrade([&] () {
cap = Lx::pci()->next_device(cap); });
}
}

View File

@ -190,7 +190,7 @@ class Root : public Genode::Root_component<Wifi_session_component,
tx_buf_size + rx_buf_size > 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())

View File

@ -127,7 +127,7 @@ void *Lx::ioremap(addr_t phys_addr, unsigned long size,
Lx_kit::Mapped_io_mem_range *io_mem = nullptr;
retry<Genode::Region_map::Out_of_metadata>(
retry<Genode::Out_of_ram>(
[&] () {
io_mem = new (&Lx_kit::env().heap())
Lx_kit::Mapped_io_mem_range(Lx_kit::env().env(), *_global_rm,

View File

@ -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<Platform::Session::Out_of_metadata>(
[&] () { return _global_pci->alloc_dma_buffer(size); },
cap = retry<Genode::Out_of_ram>(
[&] () {
return retry<Genode::Out_of_caps>(
[&] () { return _global_pci->alloc_dma_buffer(size); },
[&] () { _global_pci->upgrade_caps(2); });
},
[&] () {
_global_pci->upgrade_ram(donate);
donate = donate * 2 > size ? 4096 : donate * 2;

View File

@ -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;

View File

@ -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();

View File

@ -384,7 +384,7 @@ class File_system::Root : public Root_component<Session_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<Session_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<Session_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();
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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.
*/

View File

@ -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();
}
}

View File

@ -524,13 +524,14 @@ class Terminal::Root_component : public Genode::Root_component<Session_component
policy.attribute("port").value(&tcp_port);
return new (md_alloc())
Session_component(_env, io_buffer_size, tcp_port);
} catch (Xml_node::Nonexistent_attribute) {
}
catch (Xml_node::Nonexistent_attribute) {
error("Missing \"port\" attribute in policy definition");
throw Root::Unavailable();
} catch (Session_policy::No_policy_defined) {
throw Service_denied();
}
catch (Session_policy::No_policy_defined) {
error("Invalid session request, no matching policy");
throw Root::Unavailable();
throw Service_denied();
}
}

View File

@ -1184,7 +1184,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
void upgrade(Genode::Session_capability session_cap, Upgrade_args const &args) override
{
if (!args.valid_string()) throw Root::Invalid_args();
if (!args.valid_string()) return;
auto lambda = [&] (Rpc_object_base *session) {
if (!session) {

View File

@ -1 +1 @@
f430ea6c6057b67970e7e014e07b306904c6467c
e67494f2498577a7810dda61be9061fd004a79a4

View File

@ -163,9 +163,8 @@ int Framebuffer::map_io_mem(addr_t base, size_t size, bool write_combined,
try {
*out_addr = genode_env().rm().attach(io_ds, size, 0, addr != 0, addr);
} catch (Rm_session::Attach_failed) {
return -3;
}
catch (Region_map::Region_conflict) { return -3; }
log("fb mapped to ", *out_addr);

View File

@ -72,16 +72,14 @@ class Pci_card
Platform::Device_capability _first_device()
{
return Genode::retry<Platform::Session::Out_of_metadata>(
[&] () { 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<Platform::Session::Out_of_metadata>(
[&] () { 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()

View File

@ -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: ",

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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();

View File

@ -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;
}

View File

@ -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;
+ }
+

View File

@ -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)

View File

@ -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();
}
/*

View File

@ -441,13 +441,15 @@ class File_system::Root : public Root_component<Session_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<Session_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<Session_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();
}
/*

View File

@ -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

View File

@ -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 <typename FUNC>
auto _retry(FUNC func) -> decltype(func())
{
File_system::Connection_base::upgrade_ram(8*1024);
enum { UPGRADE_ATTEMPTS = 2 };
return Genode::retry<Out_of_ram>(
[&] () {
return Genode::retry<Out_of_caps>(
[&] () { 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<Out_of_metadata>(
[&] () { 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<Out_of_metadata>(
[&] () { 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<Out_of_metadata>(
[&] () { 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<Out_of_metadata>(
[&] () { return Session_client::node(path); },
[&] () { upgrade_ram(); },
UPGRADE_ATTEMPTS);
return _retry([&] () {
return Session_client::node(path); });
}
};

View File

@ -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);

View File

@ -127,7 +127,7 @@ class Gpio::Root : public Genode::Root_component<Gpio::Session_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 "

Some files were not shown because too many files have changed in this diff Show More