[Top] [All Lists]

[PATCH v3] MIPS: Changed current_thread_info() to an equivalent supporte

To: unlisted-recipients:; (no To-header on input)
Subject: [PATCH v3] MIPS: Changed current_thread_info() to an equivalent supported by both clang and GCC
From: Daniel Sanders <>
Date: Tue, 24 Feb 2015 15:02:57 +0000
Cc: Daniel Sanders <>, Ralf Baechle <>, Paul Burton <>, Markos Chandras <>, James Hogan <>, <>, Behan Webster <>, Sergei Shtylyov <>, David Daney <>
List-archive: <>
List-help: <>
List-id: linux-mips <>
List-owner: <>
List-post: <>
List-software: Ecartis version 1.0.0
List-subscribe: <>
List-unsubscribe: <>
Original-recipient: rfc822;
Without this, a 'break' instruction is executed very early in the boot and
the boot hangs.

The problem is that clang doesn't honour named registers on local variables
and silently treats them as normal uninitialized variables. However, it
does honour them on global variables.

Signed-off-by: Daniel Sanders <>
Cc: Ralf Baechle <>
Cc: Paul Burton <>
Cc: Markos Chandras <>
Cc: James Hogan <>
Cc: Behan Webster <>
Cc: Sergei Shtylyov <>
Cc: David Daney <>
v2 of this patch has been updated following David Daney's request to preserve
the name of the original named register local.

v3 of this patch just rebases to master and adds some background discussion from
the previous threads.

For reference, a similar patch for ARM's stack pointer has already been merged:
  0abc08b ARM: 8170/1: Add global named register current_stack_pointer for ARM

LLVM is unlikely to support uninitialized reads of named register locals in the
foreseeable future. There are some significant implementation difficulties and
there were objections based on the future direction of LLVM. The thread is at I've linked
to the bit where the issues started to be discussed rather than the start of
the thread.

Difficulty and objections aside, it's also a very large amount of work to
support a single (as far as I know) user of named register locals, especially
when the kernel has already accepted patches to switch named register locals to
named register globals in the arm and arm64/aarch64 arches.

 arch/mips/include/asm/thread_info.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/thread_info.h 
index 55ed660..2f0dba3 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -55,10 +55,10 @@ struct thread_info {
 #define init_stack             (init_thread_union.stack)
 /* How to get the thread information struct from C.  */
+register struct thread_info *__current_thread_info __asm__("$28");
 static inline struct thread_info *current_thread_info(void)
-       register struct thread_info *__current_thread_info __asm__("$28");
        return __current_thread_info;

<Prev in Thread] Current Thread [Next in Thread>