Re: [PATCH 26/26] KVM: x86: asi: Add some mitigations on address space transitions

From: Shivank Garg
Date: Tue Aug 20 2024 - 06:52:51 EST


Hi Brendan,

> .:: Minor issues
>
> - fill_return_buffer() causes an “unreachable instruction” objtool
> warning. I haven’t investigated this.

> +
> +.pushsection .noinstr.text, "ax"
> +SYM_CODE_START(fill_return_buffer)
> + __FILL_RETURN_BUFFER(%_ASM_AX,RSB_CLEAR_LOOPS)
> + RET
> +SYM_CODE_END(fill_return_buffer)
> +.popsection
>

I'm getting this error when buiding the ASI patchset:

OBJCOPY modules.builtin.modinfo
GEN modules.builtin
GEN .vmlinux.objs
MODPOST Module.symvers
ERROR: modpost: "fill_return_buffer" [arch/x86/kvm/kvm.ko] undefined!
make[2]: *** [scripts/Makefile.modpost:145: Module.symvers] Error 1
make[1]: *** [/home/shivank/linux/Makefile:1871: modpost] Error 2
make: *** [Makefile:240: __sub-make] Error 2

I'm wondering if we need to annotate the asm code with
UNWIND_HINT_FUNC and EXPORT the fill_return_buffer and to avoid this?

---
diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S
index db5b8ee01efe..4084ab49e2a7 100644
--- a/arch/x86/lib/retpoline.S
+++ b/arch/x86/lib/retpoline.S
@@ -399,7 +399,9 @@ EXPORT_SYMBOL(__x86_return_thunk)

.pushsection .noinstr.text, "ax"
SYM_CODE_START(fill_return_buffer)
+ UNWIND_HINT_FUNC
__FILL_RETURN_BUFFER(%_ASM_AX,RSB_CLEAR_LOOPS)
RET
SYM_CODE_END(fill_return_buffer)
+__EXPORT_THUNK(fill_return_buffer)
.popsection
---

This solved the issue for me.

Thanks,
Shivank