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

write to reserved register 'R7' #1732

Closed
nickdesaulniers opened this issue Oct 10, 2022 · 5 comments
Closed

write to reserved register 'R7' #1732

nickdesaulniers opened this issue Oct 10, 2022 · 5 comments
Assignees
Labels
[ARCH] arm32 This bug impacts ARCH=arm [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 6.2 This bug was fixed in Linux 6.2 [Reported-by] kbuild test robot Reported-by: kbuild test robot <lkp@intel.com>

Comments

@nickdesaulniers
Copy link
Member

From this 0day report:

$ wget https://lore.kernel.org/llvm/202210072120.V1O2SuKY-lkp@intel.com/2-config -O .config
$ make ARCH=arm LLVM=1 -j128 crypto/xor.o
In file included from crypto/xor.c:17:
./arch/arm/include/asm/xor.h:61:3: error: write to reserved register 'R7'
                GET_BLOCK_4(p1);
                ^
./arch/arm/include/asm/xor.h:20:10: note: expanded from macro 'GET_BLOCK_4'
        __asm__("ldmia  %0, {%1, %2, %3, %4}" \
                ^
./arch/arm/include/asm/xor.h:63:3: error: write to reserved register 'R7'
                PUT_BLOCK_4(p1);
                ^
./arch/arm/include/asm/xor.h:42:23: note: expanded from macro 'PUT_BLOCK_4'
        __asm__ __volatile__("stmia     %0!, {%2, %3, %4, %5}" \
                             ^
./arch/arm/include/asm/xor.h:83:3: error: write to reserved register 'R7'
                GET_BLOCK_4(p1);
                ^
./arch/arm/include/asm/xor.h:20:10: note: expanded from macro 'GET_BLOCK_4'
        __asm__("ldmia  %0, {%1, %2, %3, %4}" \
                ^
./arch/arm/include/asm/xor.h:86:3: error: write to reserved register 'R7'
                PUT_BLOCK_4(p1);
                ^
./arch/arm/include/asm/xor.h:42:23: note: expanded from macro 'PUT_BLOCK_4'
        __asm__ __volatile__("stmia     %0!, {%2, %3, %4, %5}" \
                             ^

cc @ardbiesheuvel
Looks like CONFIG_THUMB2 was not set in the .config. Reminds me of #701.
CONFIG_FTRACE=y is set, this patch references -pg w/ clang.

@nickdesaulniers nickdesaulniers added [BUG] Untriaged Something isn't working [ARCH] arm32 This bug impacts ARCH=arm [Reported-by] kbuild test robot Reported-by: kbuild test robot <lkp@intel.com> labels Oct 10, 2022
@ardbiesheuvel
Copy link

CONFIG_THUMB2_KERNEL is set, which makes R7 a reserved register when using -pg. In this case, we could just switch to R10 instead.

@nickdesaulniers
Copy link
Member Author

Oops, I grepped something other than .config...

diff --git a/arch/arm/include/asm/xor.h b/arch/arm/include/asm/xor.h
index 669cad5194d3..934b549905f5 100644
--- a/arch/arm/include/asm/xor.h
+++ b/arch/arm/include/asm/xor.h
@@ -51,7 +51,7 @@ xor_arm4regs_2(unsigned long bytes, unsigned long * __restrict p1,
        register unsigned int a1 __asm__("r4");
        register unsigned int a2 __asm__("r5");
        register unsigned int a3 __asm__("r6");
-       register unsigned int a4 __asm__("r7");
+       register unsigned int a4 __asm__("r10");
        register unsigned int b1 __asm__("r8");
        register unsigned int b2 __asm__("r9");
        register unsigned int b3 __asm__("ip");
@@ -73,7 +73,7 @@ xor_arm4regs_3(unsigned long bytes, unsigned long * __restrict p1,
        register unsigned int a1 __asm__("r4");
        register unsigned int a2 __asm__("r5");
        register unsigned int a3 __asm__("r6");
-       register unsigned int a4 __asm__("r7");
+       register unsigned int a4 __asm__("r10");
        register unsigned int b1 __asm__("r8");
        register unsigned int b2 __asm__("r9");
        register unsigned int b3 __asm__("ip");

?

@nickdesaulniers nickdesaulniers added [PATCH] Exists There is a patch that fixes this issue [BUG] linux A bug that should be fixed in the mainline kernel. and removed [BUG] Untriaged Something isn't working labels Oct 10, 2022
@nickdesaulniers nickdesaulniers self-assigned this Oct 10, 2022
@nickdesaulniers
Copy link
Member Author

@nickdesaulniers nickdesaulniers added [PATCH] Submitted A patch has been submitted for review and removed [PATCH] Exists There is a patch that fixes this issue labels Oct 10, 2022
@nickdesaulniers
Copy link
Member Author

@nickdesaulniers nickdesaulniers added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Nov 7, 2022
jonhunter pushed a commit to jonhunter/linux that referenced this issue Nov 8, 2022
kbuild test robot reports:
In file included from crypto/xor.c:17:
./arch/arm/include/asm/xor.h:61:3: error: write to reserved register 'R7'
                GET_BLOCK_4(p1);
                ^
./arch/arm/include/asm/xor.h:20:10: note: expanded from macro 'GET_BLOCK_4'
        __asm__("ldmia  %0, {%1, %2, %3, %4}"
                ^
./arch/arm/include/asm/xor.h:63:3: error: write to reserved register 'R7'
                PUT_BLOCK_4(p1);
                ^
./arch/arm/include/asm/xor.h:42:23: note: expanded from macro 'PUT_BLOCK_4'
        __asm__ __volatile__("stmia     %0!, {%2, %3, %4, %5}"
                             ^
./arch/arm/include/asm/xor.h:83:3: error: write to reserved register 'R7'
                GET_BLOCK_4(p1);
                ^
./arch/arm/include/asm/xor.h:20:10: note: expanded from macro 'GET_BLOCK_4'
        __asm__("ldmia  %0, {%1, %2, %3, %4}"
                ^
./arch/arm/include/asm/xor.h:86:3: error: write to reserved register 'R7'
                PUT_BLOCK_4(p1);
                ^
./arch/arm/include/asm/xor.h:42:23: note: expanded from macro 'PUT_BLOCK_4'
        __asm__ __volatile__("stmia     %0!, {%2, %3, %4, %5}"
                             ^
Thumb2 uses r7 rather than r11 as the frame pointer. Let's use r10
rather than r7 for these temporaries.

Link: ClangBuiltLinux#1732
Link: https://lore.kernel.org/llvm/202210072120.V1O2SuKY-lkp@intel.com/

Reported-by: kernel test robot <lkp@intel.com>
Suggested-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
@nathanchance
Copy link
Member

@nathanchance nathanchance added [FIXED][LINUX] 6.2 This bug was fixed in Linux 6.2 and removed [PATCH] Accepted A submitted patch has been accepted upstream labels Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] arm32 This bug impacts ARCH=arm [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 6.2 This bug was fixed in Linux 6.2 [Reported-by] kbuild test robot Reported-by: kbuild test robot <lkp@intel.com>
Projects
None yet
Development

No branches or pull requests

3 participants