* [PATCH v2] MIPS: Changed current_thread_info() to an equivalent supported by both clang and GCC
@ 2015-01-10 12:52 ` Daniel Sanders
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Sanders @ 2015-01-10 12:52 UTC (permalink / raw)
To: Ralf Baechle, linux-mips
Cc: Daniel Sanders, Paul Burton, Markos Chandras, James Hogan,
Behan Webster, Sergei Shtylyov, David Daney
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 <daniel.sanders@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: Behan Webster <behanw@converseincode.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: David Daney <ddaney.cavm@gmail.com>
---
This version of the patch preserves the name of the original named register
local following David Daney's request.
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
This is part of a patch series to get Linux for Mips working when compiled with
clang. I've chosen to submit this patch individually since it's my first kernel
patch and I'd like to be sure I'm following your processes correctly before I
submit all of them.
Please CC me on replies since I'm not subscribed to the mailing list.
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 b/arch/mips/include/asm/thread_info.h
index 99eea59..0f239cf 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -58,10 +58,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;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] MIPS: Changed current_thread_info() to an equivalent supported by both clang and GCC
@ 2015-01-10 12:52 ` Daniel Sanders
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Sanders @ 2015-01-10 12:52 UTC (permalink / raw)
To: Ralf Baechle, linux-mips
Cc: Daniel Sanders, Paul Burton, Markos Chandras, James Hogan,
Behan Webster, Sergei Shtylyov, David Daney
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 <daniel.sanders@imgtec.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: Behan Webster <behanw@converseincode.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: David Daney <ddaney.cavm@gmail.com>
---
This version of the patch preserves the name of the original named register
local following David Daney's request.
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
This is part of a patch series to get Linux for Mips working when compiled with
clang. I've chosen to submit this patch individually since it's my first kernel
patch and I'd like to be sure I'm following your processes correctly before I
submit all of them.
Please CC me on replies since I'm not subscribed to the mailing list.
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 b/arch/mips/include/asm/thread_info.h
index 99eea59..0f239cf 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -58,10 +58,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;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] MIPS: Changed current_thread_info() to an equivalent supported by both clang and GCC
2015-01-10 12:52 ` Daniel Sanders
(?)
@ 2015-01-16 14:47 ` Ralf Baechle
2015-01-17 15:52 ` Daniel Sanders
-1 siblings, 1 reply; 4+ messages in thread
From: Ralf Baechle @ 2015-01-16 14:47 UTC (permalink / raw)
To: Daniel Sanders
Cc: linux-mips, Paul Burton, Markos Chandras, James Hogan,
Behan Webster, Sergei Shtylyov, David Daney
On Sat, Jan 10, 2015 at 12:52:40PM +0000, Daniel Sanders wrote:
> 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.
Older versions of <asm/unistd.h> which have been copied into some userland
packages are using some local register variables in syscall wrappers. These
syscall wrappers have historically been a pain because every once in a
while they got broken by a new GCC release or other issues. If you're
lucky that has been resolved by the maintainers of those external software
packages - the only way to be certain is the review ...
At least the kernel does no longer do syscalls.
Ralf
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2] MIPS: Changed current_thread_info() to an equivalent supported by both clang and GCC
2015-01-16 14:47 ` Ralf Baechle
@ 2015-01-17 15:52 ` Daniel Sanders
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Sanders @ 2015-01-17 15:52 UTC (permalink / raw)
To: Ralf Baechle
Cc: linux-mips@linux-mips.org, Paul Burton, Markos Chandras,
James Hogan, Behan Webster, Sergei Shtylyov, David Daney
> -----Original Message-----
> From: Ralf Baechle [mailto:ralf@linux-mips.org]
> Sent: 16 January 2015 14:47
> To: Daniel Sanders
> Cc: linux-mips@linux-mips.org; Paul Burton; Markos Chandras; James
> Hogan; Behan Webster; Sergei Shtylyov; David Daney
> Subject: Re: [PATCH v2] MIPS: Changed current_thread_info() to an
> equivalent supported by both clang and GCC
>
> On Sat, Jan 10, 2015 at 12:52:40PM +0000, Daniel Sanders wrote:
>
> > 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.
>
> Older versions of <asm/unistd.h> which have been copied into some
> userland
> packages are using some local register variables in syscall wrappers. These
> syscall wrappers have historically been a pain because every once in a
> while they got broken by a new GCC release or other issues. If you're
> lucky that has been resolved by the maintainers of those external software
> packages - the only way to be certain is the review ...
>
> At least the kernel does no longer do syscalls.
>
> Ralf
Thanks for warning me. I'll have to keep an eye out for that.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-17 15:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-10 12:52 [PATCH v2] MIPS: Changed current_thread_info() to an equivalent supported by both clang and GCC Daniel Sanders
2015-01-10 12:52 ` Daniel Sanders
2015-01-16 14:47 ` Ralf Baechle
2015-01-17 15:52 ` Daniel Sanders
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.