aarch64: userspace: Introduce arch_is_user_context
The arch_is_user_context() function is relying on the content of the tpidrro_el0 register to determine whether we are in user context or not. This register is set to '1' when in EL1 and set back to '0' when user threads are running in userspace. Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
parent
6cf0d000e8
commit
6978160427
6 changed files with 57 additions and 2 deletions
|
@ -47,6 +47,9 @@ struct __esf {
|
|||
uint64_t x30;
|
||||
uint64_t spsr;
|
||||
uint64_t elr;
|
||||
#ifdef CONFIG_USERSPACE
|
||||
uint64_t tpidrro_el0;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct __esf z_arch_esf_t;
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* @brief ARM specific syscall header
|
||||
* @brief ARM64 specific syscall header
|
||||
*
|
||||
* This header contains the ARM specific syscall interface. It is
|
||||
* This header contains the ARM64 specific syscall interface. It is
|
||||
* included by the syscall interface architecture-abstraction header
|
||||
* (include/arch/aarch64/syscall.h)
|
||||
*/
|
||||
|
@ -20,4 +20,31 @@
|
|||
#define _SVC_CALL_IRQ_OFFLOAD 1
|
||||
#define _SVC_CALL_RUNTIME_EXCEPT 2
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
#ifndef _ASMLANGUAGE
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <stdbool.h>
|
||||
#include <arch/arm/aarch64/cpu.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline bool arch_is_user_context(void)
|
||||
{
|
||||
uint64_t tpidrro_el0;
|
||||
|
||||
__asm__ volatile("mrs %0, tpidrro_el0" : "=r" (tpidrro_el0));
|
||||
|
||||
return (tpidrro_el0 != 0x0);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ASMLANGUAGE */
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_ARCH_ARM_AARCH64_SYSCALL_H_ */
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#else
|
||||
#include <arch/x86/ia32/syscall.h>
|
||||
#endif
|
||||
#elif defined(CONFIG_ARM64)
|
||||
#include <arch/arm/aarch64/syscall.h>
|
||||
#elif defined(CONFIG_ARM)
|
||||
#include <arch/arm/aarch32/syscall.h>
|
||||
#elif defined(CONFIG_ARC)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue