Re: [PATCH] LoongArch: Define the symbol fault as a local label in fpu.S

From: Jinyang He
Date: Tue Aug 29 2023 - 04:47:14 EST


On 2023-08-29 14:45, Xi Ruoyao wrote:

On Tue, 2023-08-29 at 14:28 +0800, Tiezhu Yang wrote:
The initial aim is to silence the following objtool warnings:

  arch/loongarch/kernel/fpu.o: warning: objtool: _save_fp_context() falls through to next function fault()
  arch/loongarch/kernel/fpu.o: warning: objtool: _restore_fp_context() falls through to next function fault()
  arch/loongarch/kernel/fpu.o: warning: objtool: _save_lsx_context() falls through to next function fault()
  arch/loongarch/kernel/fpu.o: warning: objtool: _restore_lsx_context() falls through to next function fault()
  arch/loongarch/kernel/fpu.o: warning: objtool: _save_lasx_context() falls through to next function fault()
  arch/loongarch/kernel/fpu.o: warning: objtool: _restore_lasx_context() falls through to next function fault()

Obviously, the symbol fault is not a function, it is just a local label,
Hmm why? To me this seems a function. We don't branch to it but store
its address (a "function pointer") in the extable.

And these warnings do not make any sense to me:

/* snip */

diff --git a/arch/loongarch/kernel/fpu.S b/arch/loongarch/kernel/fpu.S
index b4032de..7defe50 100644
--- a/arch/loongarch/kernel/fpu.S
+++ b/arch/loongarch/kernel/fpu.S
@@ -521,7 +521,7 @@ SYM_FUNC_START(_restore_lasx_context)
        jr      ra
_restore_lasx_context returns with this instruction. How can it fall
through into fault?

I think it is because objtool will check ex_table. Something special here. (in special.c)

So this function control flow reaches another global function, caused warning. (Just some impressions)


Thanks,

Jinyang


 SYM_FUNC_END(_restore_lasx_context)
-SYM_FUNC_START(fault)
+SYM_CODE_START_LOCAL(fault)
        li.w    a0, -EFAULT                             # failure
        jr      ra
-SYM_FUNC_END(fault)
+SYM_CODE_END(fault)