@@ -501,6 +501,28 @@ void x86_gsbase_write_task(struct task_struct *task, unsigned long gsbase)
task->thread.gsbase = gsbase;
}
+#ifdef CONFIG_UNIKERNEL_LINUX
+/*
+ * 0 = Non UKL thread
+ * 1 = UKL thread - in kernel code
+ * 2 = UKL thread - in application code
+ */
+int is_ukl_thread(void)
+{
+ return current->ukl_thread;
+}
+
+void enter_ukl_user(void)
+{
+ current->ukl_thread = UKL_APPLICATION;
+}
+
+void enter_ukl_kernel(void)
+{
+ current->ukl_thread = UKL_KERNEL;
+}
+#endif
+
static void
start_thread_common(struct pt_regs *regs, unsigned long new_ip,
unsigned long new_sp,
@@ -746,6 +746,13 @@ struct task_struct {
randomized_struct_fields_start
void *stack;
+#ifdef CONFIG_UNIKERNEL_LINUX
+ /*
+ * Indicator used for threads in a UKL application, 0 means non-UKL thread, 1 is UKL thread
+ * in kernel text, 2 is UKL thread in application text
+ */
+ int ukl_thread;
+#endif
refcount_t usage;
/* Per task flags (PF_*), defined further below: */
unsigned int flags;
@@ -1529,6 +1536,25 @@ struct task_struct {
*/
};
+/*
+ * 0 = Non UKL thread
+ * 1 = UKL thread - in kernel code
+ * 2 = UKL thread - in application code
+ */
+#define NON_UKL_THREAD 0
+#define UKL_KERNEL 1
+#define UKL_APPLICATION 2
+
+#ifdef CONFIG_UNIKERNEL_LINUX
+int is_ukl_thread(void);
+void enter_ukl_user(void);
+void enter_ukl_kernel(void);
+#else
+static inline int is_ukl_thread(void) { return NON_UKL_THREAD; }
+static inline void enter_ukl_user(void) {}
+static inline void enter_ukl_kernel(void) {}
+#endif
+
static inline struct pid *task_pid(struct task_struct *task)
{
return task->thread_pid;