An easy way to find out how the kernel uses it is to simply build the kernel ( CROSS_COMPILE=... ARCH=arm make vmlinux ) and then parse it all,
${CROSS_COMPILE}objdump -d vmlinux.o | grep 'sb|r9'
to check (using the names r9 and sb , since it depends on your objdump, which is exactly output).
If you have ever found that it is used in prolog / epilogue code (in instructions like push {..., r9, ...} , stmfd sp!, {..., r9, ...} or their corresponding pop / ldmfd ), then he is saved. Otherwise, another scratch reg. The result may depend on your toolchain, kernel configuration settings, or ARM target.
However, if you compile the Thumb-2 kernel, it will not be saved. This is because Thumb-2 push / pop only works with lower registration (and lr / pc an additional way, push lr paired with pop pc ).
source share