mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[kernel] Add capabilities to handles
This change finally adds capabilities to handles. Included changes: - j6_handle_t is now again 64 bits, with the highest 8 bits being a type code, and the next highest 24 bits being the capability mask, so that programs can check type/caps without calling the kernel. - The definitions grammar now includes a `capabilities [ ]` section on objects, to list what capabilities are relevant. - j6/caps.h is auto-generated from object capability lists - init_libj6 again sets __handle_self and __handle_sys, this is a bit of a hack. - A new syscall, j6_handle_list, will return the list of existing handles owned by the calling process. - syscall_verify.cpp.cog now actually checks that the needed capabilities exist on handles before allowing the call.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
/// \file process.h
|
||||
/// Definition of process kobject types
|
||||
|
||||
#include <j6/caps.h>
|
||||
#include <util/map.h>
|
||||
#include <util/vector.h>
|
||||
|
||||
@@ -17,10 +18,10 @@ class process :
|
||||
{
|
||||
public:
|
||||
/// Capabilities on a newly constructed process handle
|
||||
constexpr static j6_cap_t creation_caps = 0;
|
||||
constexpr static j6_cap_t creation_caps = j6_cap_process_all;
|
||||
|
||||
/// Capabilities on a process to itself
|
||||
constexpr static j6_cap_t self_caps = 0;
|
||||
constexpr static j6_cap_t self_caps = j6_cap_process_all;
|
||||
|
||||
/// Top of memory area where thread stacks are allocated
|
||||
constexpr static uintptr_t stacks_top = 0x0000800000000000;
|
||||
@@ -74,13 +75,19 @@ public:
|
||||
/// \returns Pointer to the handle struct, or null if not found
|
||||
handle * lookup_handle(j6_handle_t handle);
|
||||
|
||||
/// Get the list of handle ids this process owns
|
||||
/// \arg handles Pointer to an array of handles to copy into
|
||||
/// \arg len Size of the array
|
||||
/// \returns Total number of handles (may be more than number copied)
|
||||
size_t list_handles(j6_handle_t *handles, size_t len);
|
||||
|
||||
/// Inform the process of an exited thread
|
||||
/// \args th The thread which has exited
|
||||
/// \returns True if this thread ending has ended the process
|
||||
bool thread_exited(thread *th);
|
||||
|
||||
/// Get the handle for this process to refer to itself
|
||||
inline j6_handle_t self_handle() const { return 1; }
|
||||
inline j6_handle_t self_handle() const { return m_self_handle; }
|
||||
|
||||
/// Get the process object that owns kernel threads and the
|
||||
/// kernel address space
|
||||
@@ -95,6 +102,7 @@ private:
|
||||
// This constructor is called by create_kernel_process
|
||||
process(page_table *kpml4);
|
||||
|
||||
j6_handle_t m_self_handle;
|
||||
int32_t m_return_code;
|
||||
|
||||
vm_space m_space;
|
||||
|
||||
Reference in New Issue
Block a user