Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3084f401 authored by Catalin Marinas's avatar Catalin Marinas Committed by Sami Tolvanen
Browse files

UPSTREAM: arm64: Remove the get_thread_info() function



This function was introduced by previous commits implementing UAO.
However, it can be replaced with task_thread_info() in
uao_thread_switch() or get_fs() in do_page_fault() (the latter being
called only on the current context, so no need for using the saved
pt_regs).

Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>

Bug: 31432001
Change-Id: Ib3c67aadad8dedacc62473ccce45e4c1d61e0ac3
(cherry picked from commit e950631e84e7e38892ffbeee5e1816b270026b0e)
Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
parent 4d6ab70a
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -80,12 +80,6 @@ static inline struct thread_info *current_thread_info(void)
		(current_stack_pointer & ~(THREAD_SIZE - 1));
}

/* Access struct thread_info of another thread */
static inline struct thread_info *get_thread_info(unsigned long thread_stack)
{
	return (struct thread_info *)(thread_stack & ~(THREAD_SIZE - 1));
}

#define thread_saved_pc(tsk)	\
	((unsigned long)(tsk->thread.cpu_context.pc))
#define thread_saved_sp(tsk)	\
+6 −9
Original line number Diff line number Diff line
@@ -387,15 +387,12 @@ static void tls_thread_switch(struct task_struct *next)
/* Restore the UAO state depending on next's addr_limit */
static void uao_thread_switch(struct task_struct *next)
{
	unsigned long next_sp = next->thread.cpu_context.sp;

	if (IS_ENABLED(CONFIG_ARM64_UAO) &&
	    get_thread_info(next_sp)->addr_limit == KERNEL_DS)
		asm(ALTERNATIVE("nop", SET_PSTATE_UAO(1), ARM64_HAS_UAO,
			        CONFIG_ARM64_UAO));
	if (IS_ENABLED(CONFIG_ARM64_UAO)) {
		if (task_thread_info(next)->addr_limit == KERNEL_DS)
			asm(ALTERNATIVE("nop", SET_PSTATE_UAO(1), ARM64_HAS_UAO));
		else
		asm(ALTERNATIVE("nop", SET_PSTATE_UAO(0), ARM64_HAS_UAO,
				CONFIG_ARM64_UAO));
			asm(ALTERNATIVE("nop", SET_PSTATE_UAO(0), ARM64_HAS_UAO));
	}
}

/*
+1 −1
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
	}

	if (permission_fault(esr) && (addr < USER_DS)) {
		if (get_thread_info(regs->sp)->addr_limit == KERNEL_DS)
		if (get_fs() == KERNEL_DS)
			panic("Accessing user space memory with fs=KERNEL_DS");

		if (!search_exception_tables(regs->pc))