Skip to contentSkip to conversation

Arch: x86_32, fix fault_msg nul termination

PATCH In review Jiri Slaby 4 participants 9 messages Mar 12, 2008 – Mar 21, 2008 x86

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 Arch: x86_32, fix fault_msg nul termination

The fault_msg text is not explictly nul terminated now in startup assembly. Do so by converting .ascii to .asciz.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc H. Peter Anvin <[email protected]>
---
 arch/x86/kernel/head_32.S |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/head_32.S +1 -1
index 9e7e015..826988a 100644
@@ -657,7 +657,7 @@ int_msg:
 	.asciz "Unknown interrupt or fault at EIP %p %p %p\n"
 
 fault_msg:
-	.ascii								\
+	.asciz								\
 /* fault info: */	"BUG: Int %d: CR2 %p\n"				\
 /* pusha regs: */	"     EDI %p  ESI %p  EBP %p  ESP %p\n"		\
 			"     EBX %p  EDX %p  ECX %p  EAX %p\n"		\
Signature · 1 line
1.5.4.1
author
#1 lore raw

PATCH 1/1 Mark early_printk as asmlinkage

It's not explicitly marked as asmlinkage, but invoked from x86_32 startup code with parameters on stack.

No other architectures define early_printk and none of them are affected by this change, since defines asmlinkage as empty token.

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc H. Peter Anvin <[email protected]>
---
 arch/x86/kernel/early_printk.c |    2 +-
 include/linux/kernel.h         |    2 +-
 kernel/printk.c                |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/early_printk.c +1 -1
index 643fd86..ff9e735 100644
@@ -196,7 +196,7 @@ static struct console simnow_console = {
 static struct console *early_console = &early_vga_console;
 static int early_console_initialized;
 
-void early_printk(const char *fmt, ...)
+asmlinkage void early_printk(const char *fmt, ...)
 {
 	char buf[512];
 	int n;
include/linux/kernel.h +1 -1
index 7e68c07..c7d61a1 100644
@@ -210,7 +210,7 @@ static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
 		{ return false; }
 #endif
 
-extern void __attribute__((format(printf, 1, 2)))
+extern void asmlinkage __attribute__((format(printf, 1, 2)))
 	early_printk(const char *fmt, ...);
 
 unsigned long int_sqrt(unsigned long);
kernel/printk.c +1 -1
index 3fb257c..951543d 100644
@@ -38,7 +38,7 @@
 /*
  * Architectures can override it:
  */
-void __attribute__((weak)) early_printk(const char *fmt, ...)
+void asmlinkage __attribute__((weak)) early_printk(const char *fmt, ...)
 {
 }
 
Signature · 1 line
1.5.4.1
reviewer NAK
#2 lore raw

Re: [PATCH] Mark early_printk as asmlinkage

Quoted 5 lines · Jiri Slaby

It's not explicitly marked as asmlinkage, but invoked from x86_32 startup code with parameters on stack.

No other architectures define early_printk and none of them are affected by this change, since defines asmlinkage as empty token.

NAK.

The regparm ABI for x86-32 uses parameters on the stack when the function is varadic (as it is here), so this is unnecessary.

-hpa

author
#3 lore raw

Re: [PATCH] Mark early_printk as asmlinkage

Quoted 10 lines · H. Peter Anvin
Quoted 5 lines · Jiri Slaby

It's not explicitly marked as asmlinkage, but invoked from x86_32 startup code with parameters on stack.

No other architectures define early_printk and none of them are affected by this change, since defines asmlinkage as empty token.

NAK.

The regparm ABI for x86-32 uses parameters on the stack when the function is varadic (as it is here), so this is unnecessary.

Makes sense. Why is printk marked as asmlinkage?

#4 lore raw

Re: [PATCH] Mark early_printk as asmlinkage

Quoted 5 lines · Jiri Slaby
Quoted 4 lines · H. Peter Anvin
Quoted 3 lines · Jiri Slaby

It's not explicitly marked as asmlinkage, but invoked from x86_32 startup code with parameters on stack.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

No other architectures define early_printk and none of them are affected by this change, since defines asmlinkage as empty token.

NAK.

The regparm ABI for x86-32 uses parameters on the stack when the function is varadic (as it is here), so this is unnecessary.

Makes sense. Why is printk marked as asmlinkage?

Hm. Don't know if it's historical, stylistic (anything called from assembly should have "asmlinkage"), or just based on a misunderstanding of the regparm ABI.

-hpa

#5 lore raw

Re: [PATCH] Mark early_printk as asmlinkage

In reply to H. Peter Anvin
Quoted 9 lines · H. Peter Anvin
Quoted 7 lines · Jiri Slaby

It's not explicitly marked as asmlinkage, but invoked from x86_32
startup code with parameters on stack.

No other architectures define early_printk and none of them are affected
by this change, since defines asmlinkage as empty token.

Quoted 5 lines

NAK.

The regparm ABI for x86-32 uses parameters on the stack when the function is varadic (as it is here), so this is unnecessary.

I'd call asmlinkage kind of documentation, then. Not everyone is as good with x86 abi as you are...

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw

Re: [PATCH] Mark early_printk as asmlinkage

Quoted 5 lines · Pavel Machek
Quoted 4 lines · H. Peter Anvin
Quoted 3 lines · Jiri Slaby

It's not explicitly marked as asmlinkage, but invoked from x86_32 startup code with parameters on stack.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

No other architectures define early_printk and none of them are affected by this change, since defines asmlinkage as empty token.

NAK.

The regparm ABI for x86-32 uses parameters on the stack when the function is varadic (as it is here), so this is unnecessary.

I'd call asmlinkage kind of documentation, then. Not everyone is as good with x86 abi as you are...

Since it's already only used on x86-32 and we no longer support non-regparm x86, I'd like to at least get to the point where x86-32 doesn't have any function. We can retain it for documentation's sake, but even then it's iffy... is "this is callable from assembly" really something arch-invariant.

-hpa

#7 lore raw

Re: [PATCH] Mark early_printk as asmlinkage

Quoted 8 lines · H. Peter Anvin
Quoted 2 lines

I'd call asmlinkage kind of documentation, then. Not everyone is as good with x86 abi as you are...

Since it's already only used on x86-32 and we no longer support non-regparm x86, I'd like to at least get to the point where x86-32 doesn't have any function. We can retain it for documentation's sake, but even then it's iffy... is "this is callable from assembly" really something arch-invariant.

the kernel still works if we disable regparm, and it makes sense to just have a good list of all functions that are called from assembly. But it's not just about non-regparm or documentation, we have regular trouble with over-eager gcc optimizations that assume that all code is generated by gcc ... Furthermore, code flow is easier to understand if we know what is called from assembly and what not. So documenting all these places makes sense to me and we've applied similar patches in the past.

Ingo

#8 lore raw
In reply to Jiri Slaby
Quoted 2 lines · Jiri Slaby

The fault_msg text is not explictly nul terminated now in startup assembly. Do so by converting .ascii to .asciz.

thanks Jiri, applied.

arch/x86/kernel/head_32.S int_msg: · line 663

Quoted 6 lines

fault_msg:

arch/x86/kernel/head_32.S +1 -1
-	.ascii								\
+	.asciz								\
 /* fault info: */	"BUG: Int %d: CR2 %p\n"				\
 /* pusha regs: */	"     EDI %p  ESI %p  EBP %p  ESP %p\n"		\
 			"     EBX %p  EDX %p  ECX %p  EAX %p\n"		\

i guess in practice we were saved by a NIL following this string, but there's no guarantee indeed.

Ingo