Commit b5dc70da authored by Charlie Jacobsen's avatar Charlie Jacobsen

private-types: Updates headers and build for private type systems.

This will not build yet (cap_type_system_t not defined yet).

In LCDs (kernel land), there will be multiple threads sharing
this library, but they shouldn't share the same set of types. So,
we need to allow building libcap to preclude this sharing (using
a global type system).

A global type system is allowed by default, and the same interface
will still be there if global types are enabled. There are a few
new functions introduced with this new feature:

      cap_init_cspace_with_type_system
      cap_cspace_get_type_system
      cap_register_private_type

These functions will now always be part of the interface. The old
functions will be available if global types are allowed:

      cap_init_cspace - init cspace and attach global type system to it
      cap_register_type - register a global type

I used some autoconf magic to conditionally include these old
functions in the libcap.h interface.

Implementation not in place yet.
parent d97e0ffd
Pipeline #413 skipped
......@@ -4,4 +4,5 @@ Anton Burtsev aburtsev@flux.utah.edu
Charles Jacobsen charlesj@cs.utah.edu
David M. Johnson johnsond@flux.utah.edu
Pankaj Kumar pankajk@cs.utah.edu
Josh Kunz josh@kunz.xyz
Muktesh Khole mukteshkhole86@gmail.com
\ No newline at end of file
......@@ -90,6 +90,26 @@ AS_CASE([$CSPACE_CNODE_TABLE_BITS],
AC_MSG_NOTICE([CNode table bits = $CAP_CSPACE_CNODE_TABLE_BITS.])
AC_SUBST(CAP_CSPACE_CNODE_TABLE_BITS)
# Allow global capability types?
AC_ARG_ENABLE([global_cap_types],
[AS_HELP_STRING([--enable-global-cap-types],
[(for backward compatability) Allow cspaces to share one global capability type system (default=yes)])],
[],
[enable_global_cap_types="yes"])
AS_IF([test "x$enable_global_cap_types" = "xyes"],
[
AC_DEFINE([CAP_ENABLE_GLOBAL_TYPES], 1,
[Allow cspaces to use one global type system.])
CAP_INCLUDE_GLOBAL_TYPES=$srcdir/src/include/global_cap_types.h
AC_SUBST_FILE([CAP_INCLUDE_GLOBAL_TYPES])
AC_MSG_NOTICE([Allowing global capability type system.])
],
[
CAP_INCLUDE_GLOBAL_TYPES=
AC_SUBST([CAP_INCLUDE_GLOBAL_TYPES])
AC_MSG_NOTICE([Disallowing global capability type system.])
])
# Kernel module build?
AS_IF([test "x$PLATFORM" = "xkernel"],
......@@ -320,7 +340,6 @@ AC_CONFIG_FILES(
src/common/Makefile
src/include/Makefile
src/include/libcap_config.h
src/include/libcap_types.h
src/include/libcap.h
......
/**
* cap.c - capability subsystem
* cap.c - cspaces, cdt's, and operations
*
* Authors:
* Muktesh Khole <mukteshkhole86@gmail.com>
* Anton Burtsev <aburtsev@flux.utah.edu>
* Charles Jacobsen <charlesj@cs.utah.edu>
* Copyright: University of Utah
*/
#include <libcap.h>
......
/* GLOBAL CAPABILITY TYPES ADDENDUM ---------------------------------------- */
/*
* (Added to libcap.h by configure.)
*
* This extends the interface if the build configuration allows for a
* global capability type system. See the --enable-global-cap-types
* configure feature. These are for backward compatability with the
* global type system.
*/
/**
* cap_init_cspace -- Similar to cap_init_cspace_with_type, but defaults
* to use the global type system
* @cspace: the cspace to initialize
*/
int cap_init_cspace(struct cspace *cspace);
/**
* cap_register_type -- Similar to cap_register_private_type, but adds type
* to the default global type system
* @type: integer type index / identifier
* @ops: the cap_type_ops to associate with this type
*/
cap_type_t cap_register_type(cap_type_t type, const struct cap_type_ops *ops);
......@@ -265,14 +265,25 @@ static inline int cap_cspace_slots_in_level(int lvl)
*/
struct cspace * cap_alloc_cspace(void);
/**
* cap_init_cspace -- Sets up cspace - initializes lock, root cnode table, etc.
* cap_init_cspace_with_type_system -- Set up cspace fields
* @cspace: the cspace to initialize
* @ts: the type system to attach
*
* Sets up cspace - initializes lock, root cnode table, etc. Attaches
* type system @ts to it.
*
* Bumps the reference count on @ts. When @cspace is destroyed,
* drops reference on @ts.
*/
int cap_init_cspace(struct cspace *cspace);
int cap_init_cspace_with_type_system(struct cspace *cspace,
struct cap_type_system_t *ts);
/**
* cap_destroy_cspace --
* Equivalent to calling lcd_cap_delete on all cnodes in cspace. Frees up
* all cnode tables, etc.
* cap_destroy_cspace -- Equivalent to calling lcd_cap_delete on all cnodes
* in cspace. Frees up all cnode tables, etc.
*
* Drops reference count on the type system that was attached to
* the cspace when it was created. If the type system reference
* count reaches zero, it will be freed.
*/
void cap_destroy_cspace(struct cspace *cspace);
/**
......@@ -294,7 +305,21 @@ void cap_cspace_setowner(struct cspace *cspace, void * owner);
*/
void* cap_cspace_getowner(struct cspace *cspace);
/**
* cap_register_type -- Register a new capability object type
* cap_cspace_get_type_system -- Returns a pointer to the type system
* that was attached to the cspace when it
* was created (which may be the global
* type system)
* @cspace: the cspace
*
* This function will not bump the reference count on the type system.
* If you plan to use the type system after all other references go away,
* you should bump its reference count (via cap_type_system_get).
*/
cap_type_system_t* cap_cspace_get_type_system(struct cspace *cspace);
/**
* cap_register_private_type -- Register a new capability object type in
* type system
* @ts: the type system to add the new type to
* @type: integer type index / identifier
* @ops: the cap_type_ops to associate with this type
*
......@@ -304,10 +329,11 @@ void* cap_cspace_getowner(struct cspace *cspace);
* this returns -EADDRINUSE. If there are no types remaining or you exceed
* CAP_TYPE_MAX, this returns -ENOMEM.
*
* The built-in types are in libcap_platform.h in the definition of
* cap_type_t.
* Every type system comes with the built-in types that are in
* libcap_platform.h, in the definition of cap_type_t.
*/
cap_type_t cap_register_type(cap_type_t type, const struct cap_type_ops *ops);
cap_type_t cap_register_private_type(cap_type_system_t *ts,
cap_type_t type, const struct cap_type_ops *ops);
/**
* cap_insert -- Inserts object data into cspace at cnode pointed at by c
* @cspace: the cspace to insert the object into
......@@ -449,4 +475,6 @@ struct cspace * cap_cnode_cspace(struct cnode *cnode);
*/
int cap_cnode_verify(struct cspace *cspace, cptr_t cap);
@CAP_INCLUDE_GLOBAL_TYPES@
#endif /* __LIBCAP_H__ */
......@@ -12,6 +12,7 @@
#ifndef __LIBCAP_INTERNAL_H__
#define __LIBCAP_INTERNAL_H__
#include <config.h> /* autogenerated */
#include <libcap.h>
#include <libcap_platform_internal.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment