UPSTREAM: arm64: Remove the get_thread_info() function
authorCatalin Marinas <catalin.marinas@arm.com>
Thu, 18 Feb 2016 15:50:04 +0000 (15:50 +0000)
committerJeff Vander Stoep <jeffv@google.com>
Thu, 22 Sep 2016 20:38:22 +0000 (13:38 -0700)
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: Catalin Marinas <catalin.marinas@arm.com>
Bug: 30369029
Patchset: kaslr-arm64-4.4

(cherry picked from commit e950631e84e7e38892ffbeee5e1816b270026b0e)
Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
Change-Id: Ic6e9b6af7314fa83d9b0773ae3fac5a2ff34e67a

arch/arm64/include/asm/thread_info.h
arch/arm64/kernel/process.c
arch/arm64/mm/fault.c

index eba8db6838af6202af7dbc9678d06f43fc8e8a4a..abd64bd1f6d9f0160a3122555cf23be1a30f87eb 100644 (file)
@@ -85,12 +85,6 @@ static inline struct thread_info *current_thread_info(void)
        return (struct thread_info *)sp_el0;
 }
 
-/* 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)   \
index 4431e8364881230f88928e4ce1c1461461a63c6e..6f3fb46170bfdc9a22230e60776a92b629b3a5f2 100644 (file)
@@ -381,15 +381,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));
-       else
-               asm(ALTERNATIVE("nop", SET_PSTATE_UAO(0), 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));
+       }
 }
 
 /*
index d0762a729d01ff62c9f73ee9fb3fcca35bf01ed4..a8eafeceb08a5ac5cb7b16965896dfcd4ca4b933 100644 (file)
@@ -234,7 +234,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))