Re: [PATCH 03/11] objtool: Convert ANNOTATE_RETPOLINE_SAFE to ANNOTATE

From: Sean Christopherson
Date: Wed Dec 06 2023 - 18:32:05 EST


On Mon, Dec 04, 2023, Peter Zijlstra wrote:
>
> --- a/arch/x86/include/asm/nospec-branch.h
> +++ b/arch/x86/include/asm/nospec-branch.h
> @@ -193,12 +193,7 @@
> * objtool the subsequent indirect jump/call is vouched safe for retpoline
> * builds.
> */
> -.macro ANNOTATE_RETPOLINE_SAFE
> -.Lhere_\@:
> - .pushsection .discard.retpoline_safe
> - .long .Lhere_\@
> - .popsection
> -.endm
> +#define ANNOTATE_RETPOLINE_SAFE ANNOTATE type=ANNOTYPE_RETPOLINE_SAFE
>
> /*
> * (ab)use RETPOLINE_SAFE on RET to annotate away 'bare' RET instructions
> @@ -317,11 +312,7 @@
>
> #else /* __ASSEMBLY__ */
>
> -#define ANNOTATE_RETPOLINE_SAFE \
> - "999:\n\t" \
> - ".pushsection .discard.retpoline_safe\n\t" \
> - ".long 999b\n\t" \
> - ".popsection\n\t"
> +#define ANNOTATE_RETPOLINE_SAFE ASM_ANNOTATE(ANNOTYPE_RETPOLINE_SAFE)

This fails for some of my builds that end up with CONFIG_OBJTOOl=n. Adding a
stub for ASM_ANNOTATE() gets me past that:

@@ -156,6 +171,7 @@
#define STACK_FRAME_NON_STANDARD(func)
#define STACK_FRAME_NON_STANDARD_FP(func)
#define ANNOTATE_NOENDBR
+#define ASM_ANNOTATE(x)
#define ASM_REACHABLE
#else
#define ANNOTATE_INTRA_FUNCTION_CALL

but then I run into other issues:

arch/x86/kernel/relocate_kernel_32.S: Assembler messages:
arch/x86/kernel/relocate_kernel_32.S:96: Error: Parameter named `type' does not exist for macro `annotate'
arch/x86/kernel/relocate_kernel_32.S:166: Error: Parameter named `type' does not exist for macro `annotate'
arch/x86/kernel/relocate_kernel_32.S:174: Error: Parameter named `type' does not exist for macro `annotate'
arch/x86/kernel/relocate_kernel_32.S:200: Error: Parameter named `type' does not exist for macro `annotate'
arch/x86/kernel/relocate_kernel_32.S:220: Error: Parameter named `type' does not exist for macro `annotate'
arch/x86/kernel/relocate_kernel_32.S:285: Error: Parameter named `type' does not exist for macro `annotate'