Rounding Pointers Type Safe Capabilities with C++ Meta Programming

Rounding Pointers Type Safe Capabilities with C++ Meta Programming

Faculty of Computer Science / Institute of Systems Architecture / Operating Systems ROUNDING POINTERS TYPE SAFE CAPABILITIES WITH C++ META PROGRAMMING Alexander Warg, Adam Lackorzynski MOTIVATION Rounding Pointers Type Safe Capabilities with C++ Meta Programming BASICS OBJECT CAPABILITIES Protected / Secure references Local naming for components and services Fine-grained access control Well known security properties C++ Templates as powerful concept Full control over memory management Object oriented Rounding Pointers Type Safe Capabilities with C++ Meta Programming EFFICIENCY CAPABILITIES ARE INTEGERS No dynamically allocated C++ objects Treat capabilities as values (not objects) Use static C++ type checks No extra indirection for operations Rounding Pointers Type Safe Capabilities with C++ Meta Programming INTUITIVITY AND TYPE SYSTEM Interfaces are C++ classes class Remote_iface : public Kobject { ... }; Capabilities are smart pointers Cap<Remote_iface> c = ... c->method(args); Composition of interfaces via C++ inheritance class Specific_iface : public Remote_iface { ... }; Abstract interfaces → dynamic type information desirable Rounding Pointers Type Safe Capabilities with C++ Meta Programming IMPLEMENTATION EDGE OF THE C++ STANDARD Overloaded '->' operator of Cap must return a pointer → 'this' pointer carries the capability (integer) Implicit conversions on 'this' pointer → blurry capabilities → invocations on non-existing objects Rounding Pointers Type Safe Capabilities with C++ Meta Programming DYNAMIC TYPES META PROTOCOL Dynamic type information from objects (IPC) Enables 'cap_dynamic_cast' BLURRY CAPABILITIES ARE USEFUL The blur provides type information for composed objects Dynamic type information provides initial offset Rounding Pointers Type Safe Capabilities with C++ Meta Programming CONCLUSION INTUITIVE, POINTER-LIKE C++ INTEGRATION including explicit and implicit type conversion STATIC AND DYNAMIC C++ TYPE CHECKING EFFICIENT REPRESENTATION template class wrapping a native integer EFFICIENT METHOD INVOCATION capability as 'this' pointer ADHERE TO C++ STANDARD capability as 'this' pointer depends on sane implementation Rounding Pointers Type Safe Capabilities with C++ Meta Programming BLANK Rounding Pointers Type Safe Capabilities with C++ Meta Programming STUB METHODS l4_cap_idx_t Kobject::this_to_cap() const { return reinterpret_cast<l4_cap_idx_t>(this) & BLUR_MASK; } int Remote_iface::method(int arg) { L4::Ipc::Io_stream s(l4_utcb()); s << L4::Opcode(Remote_iface::OP_METHOD) << arg; return s.call(this_to_cap()); } Rounding Pointers Type Safe Capabilities with C++ Meta Programming STATIC TYPE CONVERSION template< typename T, typename S > Cap<T> cap_static_cast(Cap<S> const &s) { // let the compiler check the conversion (void)static_cast<T*>(reinterpret_cast<S*>(0)); return Cap<T>(s.cap_idx()); } Rounding Pointers Type Safe Capabilities with C++ Meta Programming DYNAMIC TYPE CONVERSION template< typename T, typename S > Cap<T> cap_dynamic_cast(Cap<S> const &s) { if (meta_supports(s, T::INTERFACE_ID)) return Cap<T>(s.cap_idx()); else return Cap<T>::INVALID; } Rounding Pointers Type Safe Capabilities with C++ Meta Programming.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us