]> git.karo-electronics.de Git - linux-beck.git/blobdiff - arch/arm64/kernel/process.c
Merge tag 'restart-handler-for-v3.18' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-beck.git] / arch / arm64 / kernel / process.c
index 398ab05081b437438d41fabf6691aee5c76e1361..c3065dbc4fa269bafbb0b93f5a458d0534ae2bc5 100644 (file)
@@ -57,36 +57,10 @@ unsigned long __stack_chk_guard __read_mostly;
 EXPORT_SYMBOL(__stack_chk_guard);
 #endif
 
-static void setup_restart(void)
-{
-       /*
-        * Tell the mm system that we are going to reboot -
-        * we may need it to insert some 1:1 mappings so that
-        * soft boot works.
-        */
-       setup_mm_for_reboot();
-
-       /* Clean and invalidate caches */
-       flush_cache_all();
-
-       /* Turn D-cache off */
-       cpu_cache_off();
-
-       /* Push out any further dirty data, and ensure cache is empty */
-       flush_cache_all();
-}
-
 void soft_restart(unsigned long addr)
 {
-       typedef void (*phys_reset_t)(unsigned long);
-       phys_reset_t phys_reset;
-
-       setup_restart();
-
-       /* Switch to the identity mapping */
-       phys_reset = (phys_reset_t)virt_to_phys(cpu_reset);
-       phys_reset(addr);
-
+       setup_mm_for_reboot();
+       cpu_soft_restart(virt_to_phys(cpu_reset), addr);
        /* Should never get here */
        BUG();
 }
@@ -231,9 +205,27 @@ void exit_thread(void)
 {
 }
 
+static void tls_thread_flush(void)
+{
+       asm ("msr tpidr_el0, xzr");
+
+       if (is_compat_task()) {
+               current->thread.tp_value = 0;
+
+               /*
+                * We need to ensure ordering between the shadow state and the
+                * hardware state, so that we don't corrupt the hardware state
+                * with a stale shadow state during context switch.
+                */
+               barrier();
+               asm ("msr tpidrro_el0, xzr");
+       }
+}
+
 void flush_thread(void)
 {
        fpsimd_flush_thread();
+       tls_thread_flush();
        flush_ptrace_hw_breakpoint(current);
 }