Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wuninitialized in arch/mips/lib/uncached.c #606

Closed
nathanchance opened this issue Jul 17, 2019 · 11 comments
Closed

-Wuninitialized in arch/mips/lib/uncached.c #606

nathanchance opened this issue Jul 17, 2019 · 11 comments
Labels
-Wuninitialized [ARCH] mips This bug impacts ARCH=mips [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.11 This bug was fixed in Linux 5.11

Comments

@nathanchance
Copy link
Member

arch/mips/lib/uncached.c:45:6: warning: variable 'sp' is uninitialized when used here [-Wuninitialized]
        if (sp >= (long)CKSEG0 && sp < (long)CKSEG2)
            ^~
arch/mips/lib/uncached.c:40:18: note: initialize the variable 'sp' to silence this warning
        register long sp __asm__("$sp");
                        ^
                         = 0
1 warning generated.

Not really sure how to solve this one.

Full code: https://github.com/torvalds/linux/blob/3b2663ca844648c1b511f4dc8b1d5918174da58b/arch/mips/lib/uncached.c#L38-L80

@nathanchance nathanchance added [BUG] linux A bug that should be fixed in the mainline kernel. -Wuninitialized [ARCH] mips This bug impacts ARCH=mips labels Jul 17, 2019
@nathanchance nathanchance self-assigned this Jul 17, 2019
@nickdesaulniers
Copy link
Member

I'm guessing $sp is the stack pointer on mips? I'm not sure that the register qualifier initializes the variable sp to the contents of $sp, but rather uses $sp for storage. I wonder if there's a more C-like way of accessing the stack pointer? Also, not sure that ret needs to be register.

@bwendling
Copy link

The __asm__("$sp") bit is what causes it to be the stack pointer. It doesn't initialize it with the stack pointer. It is the stack pointer. And there isn't a C way of getting it, unfortunately. :-/

@nathanchance
Copy link
Member Author

Is there a problem with initializing it to zero then?

@nathanchance
Copy link
Member Author

Although I guess that would change the value in it?

@bwendling
Copy link

Yeah. :-) The other option is write it as inline assembly instead of ... the name for that code, which I forget at the moment.

@nathanchance
Copy link
Member Author

If it is the stack pointer, is it uninitialized then? Should clang even be warning about this?

@bwendling
Copy link

Probably not. I have a vague memory that this cropped up before. But that could just be a false memory.

@nathanchance
Copy link
Member Author

Interestingly enough, there was a patch that commented on this a while ago: https://git.kernel.org/linus/fe92da0f355e9f664a56702c36c50e20e84c51cd

Looks like this is actually pointing out there is a problem: https://lore.kernel.org/linux-mips/20200102030229.GA4478@ubuntu-m2-xlarge-x86/

krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Jan 28, 2020
Link: ClangBuiltLinux/linux#606
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
RealAkito pushed a commit to HarukaNetwork/haruka-workstation-kernel that referenced this issue Mar 23, 2020
Link: ClangBuiltLinux/linux#606
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
Signed-off-by: Akito Mizukito <akito@evolution-x.org>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Apr 2, 2020
Link: ClangBuiltLinux/linux#606
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Jun 19, 2020
Link: ClangBuiltLinux/linux#606
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Jun 22, 2020
Link: ClangBuiltLinux/linux#606
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Albert I <kras@raphielgang.org>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Aug 23, 2020
Link: ClangBuiltLinux/linux#606
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
krasCGQ pushed a commit to krasCGQ/linux that referenced this issue Aug 24, 2020
Link: ClangBuiltLinux/linux#606
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
@nickdesaulniers nickdesaulniers added the [PATCH] Submitted A patch has been submitted for review label Dec 11, 2020
@nickdesaulniers nickdesaulniers added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Dec 14, 2020
@nathanchance
Copy link
Member Author

@nathanchance nathanchance removed the [PATCH] Accepted A submitted patch has been accepted upstream label Jan 4, 2021
@nathanchance nathanchance added the [FIXED][LINUX] 5.11 This bug was fixed in Linux 5.11 label Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Wuninitialized [ARCH] mips This bug impacts ARCH=mips [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.11 This bug was fixed in Linux 5.11
Projects
None yet
Development

No branches or pull requests

3 participants