kernel: add syscalls for k_object_access APIs
These modify kernel object metadata and are intended to be callable from user threads, need a privilege elevation for these to work. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
3b5ae804ad
commit
743e4686a0
4 changed files with 65 additions and 27 deletions
|
@ -215,7 +215,33 @@ int _k_object_validate(void *obj, enum k_objects otype, int init);
|
|||
* @param object Address of the kernel object
|
||||
*/
|
||||
void _k_object_init(void *obj);
|
||||
#else
|
||||
static inline int _k_object_validate(void *obj, enum k_objects otype, int init)
|
||||
{
|
||||
ARG_UNUSED(obj);
|
||||
ARG_UNUSED(otype);
|
||||
ARG_UNUSED(init);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void _k_object_init(void *obj)
|
||||
{
|
||||
ARG_UNUSED(obj);
|
||||
}
|
||||
|
||||
static inline void _impl_k_object_access_grant(void *object,
|
||||
struct k_thread *thread)
|
||||
{
|
||||
ARG_UNUSED(object);
|
||||
ARG_UNUSED(thread);
|
||||
}
|
||||
|
||||
static inline void _impl_k_object_access_all_grant(void *object)
|
||||
{
|
||||
ARG_UNUSED(object);
|
||||
}
|
||||
#endif /* !CONFIG_USERSPACE */
|
||||
|
||||
/**
|
||||
* grant a thread access to a kernel object
|
||||
|
@ -227,7 +253,7 @@ void _k_object_init(void *obj);
|
|||
* @param object Address of kernel object
|
||||
* @param thread Thread to grant access to the object
|
||||
*/
|
||||
void k_object_access_grant(void *object, struct k_thread *thread);
|
||||
__syscall void k_object_access_grant(void *object, struct k_thread *thread);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -244,29 +270,7 @@ void k_object_access_grant(void *object, struct k_thread *thread);
|
|||
*
|
||||
* @param object Address of kernel object
|
||||
*/
|
||||
void k_object_access_all_grant(void *object);
|
||||
|
||||
#else
|
||||
static inline int _k_object_validate(void *obj, enum k_objects otype, int init)
|
||||
{
|
||||
ARG_UNUSED(obj);
|
||||
ARG_UNUSED(otype);
|
||||
ARG_UNUSED(init);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void _k_object_init(void *obj)
|
||||
{
|
||||
ARG_UNUSED(obj);
|
||||
}
|
||||
|
||||
static inline void k_object_access_grant(void *object, struct k_thread *thread)
|
||||
{
|
||||
ARG_UNUSED(object);
|
||||
ARG_UNUSED(thread);
|
||||
}
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
__syscall void k_object_access_all_grant(void *object);
|
||||
|
||||
/* timeouts */
|
||||
|
||||
|
|
|
@ -37,4 +37,4 @@ lib-$(CONFIG_SYS_CLOCK_EXISTS) += timer.o
|
|||
lib-$(CONFIG_ATOMIC_OPERATIONS_C) += atomic_c.o
|
||||
lib-$(CONFIG_POLL) += poll.o
|
||||
lib-$(CONFIG_PTHREAD_IPC) += pthread.o
|
||||
lib-$(CONFIG_USERSPACE) += userspace.o mem_domain.o
|
||||
lib-$(CONFIG_USERSPACE) += userspace.o userspace_handler.o mem_domain.o
|
||||
|
|
|
@ -174,7 +174,7 @@ static struct _k_object *access_check(void *object)
|
|||
return ko;
|
||||
}
|
||||
|
||||
void k_object_access_grant(void *object, struct k_thread *thread)
|
||||
void _impl_k_object_access_grant(void *object, struct k_thread *thread)
|
||||
{
|
||||
struct _k_object *ko = access_check(object);
|
||||
|
||||
|
@ -183,7 +183,7 @@ void k_object_access_grant(void *object, struct k_thread *thread)
|
|||
}
|
||||
}
|
||||
|
||||
void k_object_access_all_grant(void *object)
|
||||
void _impl_k_object_access_all_grant(void *object)
|
||||
{
|
||||
struct _k_object *ko = access_check(object);
|
||||
|
||||
|
|
34
kernel/userspace_handler.c
Normal file
34
kernel/userspace_handler.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <syscall_handler.h>
|
||||
|
||||
/* Normally these would be included in userspace.c, but the way
|
||||
* syscall_dispatch.c declares weak handlers results in build errors if these
|
||||
* are located in userspace.c. Just put in a separate file.
|
||||
*/
|
||||
|
||||
u32_t _handler_k_object_access_grant(u32_t object, u32_t thread, u32_t arg3,
|
||||
u32_t arg4, u32_t arg5, u32_t arg6,
|
||||
void *ssf)
|
||||
{
|
||||
_SYSCALL_ARG2;
|
||||
|
||||
_SYSCALL_IS_OBJ(thread, K_OBJ_THREAD, 0, ssf);
|
||||
_impl_k_object_access_grant((void *)object, (struct k_thread *)thread);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32_t _handler_k_object_access_all_grant(u32_t object, u32_t arg2, u32_t arg3,
|
||||
u32_t arg4, u32_t arg5, u32_t arg6,
|
||||
void *ssf)
|
||||
{
|
||||
_SYSCALL_ARG1;
|
||||
|
||||
_impl_k_object_access_all_grant((void *)object);
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue