Google luky.org euqset.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH-RFC] arch/i386/kernel/: kill some sparse warnings


When running
make C=2 arch/i386/kernel/
sparse complains about access past end of variable ''

The following patch silence these sparse warnings.
RELOC_HIDE uses an asm("") trick to hide the size of the variable for
sparse. I've cheched the generated code and with -O2 the code does not
change with or without RELOC_HIDE.

loadsegment take the pointer to second argument and cast it to unsigned
int *. Using a properly sized variable as argument to loadsegment kills
this warning.
For this fix I wonder what happened to the upper bits in the old
implmentation - they were undefined per definition.

This is the relevant code smippet from system.h:
		".align 4\n\t"			\
		".long 1b,3b\n"			\
		".previous"			\
		: :"m" (*(unsigned int *)&(value)))

'value' is the variable passed as second argument to loadsegment.

Signed-off-by: Sam Ravnborg <sam@xxxxxxxxxxxx>
---

===== arch/i386/kernel/ioport.c 1.14 vs edited =====
--- 1.14/arch/i386/kernel/ioport.c	2004-09-17 08:58:37 +02:00
+++ edited/arch/i386/kernel/ioport.c	2005-01-16 20:24:09 +01:00
@@ -129,7 +129,7 @@
 
 asmlinkage long sys_iopl(unsigned long unused)
 {
-	volatile struct pt_regs * regs = (struct pt_regs *) &unused;
+	volatile struct pt_regs * regs = (struct pt_regs *) RELOC_HIDE(&unused, 0);
 	unsigned int level = regs->ebx;
 	unsigned int old = (regs->eflags >> 12) & 3;
 
===== arch/i386/kernel/signal.c 1.51 vs edited =====
--- 1.51/arch/i386/kernel/signal.c	2005-01-12 01:42:47 +01:00
+++ edited/arch/i386/kernel/signal.c	2005-01-16 21:16:43 +01:00
@@ -120,7 +120,7 @@
 sys_sigaltstack(unsigned long ebx)
 {
 	/* This is needed to make gcc realize it doesn't own the "struct pt_regs" */
-	struct pt_regs *regs = (struct pt_regs *)&ebx;
+	struct pt_regs *regs = (struct pt_regs *) RELOC_HIDE(&ebx, 0);
 	const stack_t __user *uss = (const stack_t __user *)ebx;
 	stack_t __user *uoss = (stack_t __user *)regs->ecx;
 
@@ -154,8 +154,10 @@
 
 #define GET_SEG(seg)							\
 	{ unsigned short tmp;						\
+	  unsigned int tmp2;						\
 	  err |= __get_user(tmp, &sc->seg);				\
-	  loadsegment(seg,tmp); }
+	  tmp2 = tmp;							\
+	  loadsegment(seg,tmp2); }
 
 #define	FIX_EFLAGS	(X86_EFLAGS_AC | X86_EFLAGS_OF | X86_EFLAGS_DF | \
 			 X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \
@@ -208,7 +210,7 @@
 
 asmlinkage int sys_sigreturn(unsigned long __unused)
 {
-	struct pt_regs *regs = (struct pt_regs *) &__unused;
+	struct pt_regs *regs = (struct pt_regs *) RELOC_HIDE(&__unused, 0);
 	struct sigframe __user *frame = (struct sigframe __user *)(regs->esp - 8);
 	sigset_t set;
 	int eax;
@@ -238,7 +240,7 @@
 
 asmlinkage int sys_rt_sigreturn(unsigned long __unused)
 {
-	struct pt_regs *regs = (struct pt_regs *) &__unused;
+	struct pt_regs *regs = (struct pt_regs *) RELOC_HIDE(&__unused, 0);
 	struct rt_sigframe __user *frame = (struct rt_sigframe __user *)(regs->esp - 4);
 	sigset_t set;
 	int eax;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


$B$3$N>pJs$,$"$J$?$NC5$7$F$$?$b$N$+$I$&$+A*Br$7$F$/$@$5$!#(B
yes/$B$^$5$K$3$l$@!*(B   no/$B0c$&$J$!(B   part/$B0lIt8+$D$+$C$?(B   try/$B$3$l$G;n$7$F$_$k(B

$B$"$J$?$,C5$7$F$$?>pJs$O$I$N$h$&$J$3$H$+!"$4<+M3$K5-F~2<$5$!#FC$K!V$^$5$K$3$l$@!*!W$H8@$&>l9g$O5-F~$r$*4j$$7$^$9!#(B
$BNc(B:$B!VJ#?t$N%^%7%s$+$i(BCATV$B7PM3$G(Bipmasquerade$B$rMxMQ$7$F(BWeb$B$r;2>H$7$?$>l9g$N@_Dj$K$D$$F!W(B
Follow-Ups: