arm64: implement exception depth count

Add the exception depth count to tpidrro_el0 and make it available
through the arch_exception_depth() accessor.

The IN_EL0 flag is now updated unconditionally even if userspace is
not configured. Doing otherwise made the code rather hairy and
I doubt the overhead is measurable.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
Nicolas Pitre 2021-04-13 00:42:00 -04:00 committed by Carles Cufí
commit a82fff04ff
10 changed files with 53 additions and 13 deletions

View file

@ -18,5 +18,10 @@ static ALWAYS_INLINE _cpu_t *arch_curr_cpu(void)
return (_cpu_t *)(read_tpidrro_el0() & TPIDRROEL0_CURR_CPU);
}
static ALWAYS_INLINE int arch_exception_depth(void)
{
return (read_tpidrro_el0() & TPIDRROEL0_EXC_DEPTH) / TPIDRROEL0_EXC_UNIT;
}
#endif /* !_ASMLANGUAGE */
#endif /* ZEPHYR_INCLUDE_ARCH_ARM64_ARCH_INLINES_H */

View file

@ -36,7 +36,6 @@ struct _callee_saved {
uint64_t x29;
uint64_t sp_el0;
uint64_t sp_elx;
uint64_t xzr;
};
typedef struct _callee_saved _callee_saved_t;
@ -45,6 +44,7 @@ struct _thread_arch {
#ifdef CONFIG_USERSPACE
struct arm_mmu_ptables *ptables;
#endif
uint8_t exception_depth;
};
typedef struct _thread_arch _thread_arch_t;

View file

@ -21,4 +21,8 @@
#define TPIDRROEL0_CURR_CPU 0x0000fffffffffff8
#define TPIDRROEL0_EXC_DEPTH 0xff00000000000000
#define TPIDRROEL0_EXC_UNIT 0x0100000000000000
#define TPIDRROEL0_EXC_SHIFT 56
#endif /* ZEPHYR_INCLUDE_ARCH_ARM64_TPIDRRO_EL0_H_ */