linux-mips
[Top] [All Lists]

Re: Breakage in arch/mips/kernel/traps.c for 64bit

To: tsbogend@alpha.franken.de
Subject: Re: Breakage in arch/mips/kernel/traps.c for 64bit
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Mon, 05 May 2008 23:58:27 +0900 (JST)
Cc: ralf@linux-mips.org, linux-mips@linux-mips.org
In-reply-to: <20080504220804.GA13442@alpha.franken.de>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20080503224849.GA2314@alpha.franken.de> <20080504.223944.41198532.anemo@mba.ocn.ne.jp> <20080504220804.GA13442@alpha.franken.de>
Sender: linux-mips-bounce@linux-mips.org
On Mon, 5 May 2008 00:08:04 +0200, tsbogend@alpha.franken.de (Thomas 
Bogendoerfer) wrote:
> >     while (!kstack_end((void *)(unsigned long)sp)) {
> > 
> > will make this part sparse-free, though it seems a bit ugly.
> 
> hmm, would leaving sp as unsigned long * and casting it for __get_user()
> make sparse happy ?

Well, not as expected...  Here is some warning patterns.

1.      unsigned long __user *sp = (unsigned long __user *)(reg29 & ~3);
        ...
        while (!kstack_end(sp)) {
                if (__get_user(addr, sp++)) {

linux/arch/mips/kernel/traps.c:91:21: warning: incorrect type in argument 1 
(different address spaces)
linux/arch/mips/kernel/traps.c:91:21:    expected void *addr
linux/arch/mips/kernel/traps.c:91:21:    got unsigned long [noderef] <asn:1>*sp

2.      unsigned long *sp = (unsigned long *)(reg29 & ~3);
        ...
        while (!kstack_end(sp)) {
                if (__get_user(addr, (unsigned long __user *)sp++)) {

linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to 
expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to 
expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to 
expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to 
expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to 
expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to 
expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to 
expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to 
expression (<asn:1>)
linux/arch/mips/kernel/traps.c:92:7: warning: cast adds address space to 
expression (<asn:1>)

3.      unsigned long __user *sp = (unsigned long __user *)(reg29 & ~3);
        ...
        while (!kstack_end((void *)(unsigned long)sp)) {
                if (__get_user(addr, sp++)) {

No warnings.

4.      unsigned long *sp = (unsigned long *)(reg29 & ~3);
        ...
        while (!kstack_end(sp)) {
                unsigned long __user *p = (unsigned long __user *)sp++;
                if (__get_user(addr, p)) {

linux/arch/mips/kernel/traps.c:92:30: warning: cast adds address space to 
expression (<asn:1>)

4.      unsigned long *sp = (unsigned long *)(reg29 & ~3);
        ...
        while (!kstack_end(sp)) {
                unsigned long __user *p =
                        (unsigned long __user *)(unsigned long)sp++;
                if (__get_user(addr, p)) {

No warnings.


I think the "cast adds address space to expression" sparse warning is
not worth to handle so seriously.  So I'm OK with any of (2) to (4).

---
Atsushi Nemoto

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