Re: [PATCH 1/2] x86/fred: Fix build with clang

From: H. Peter Anvin
Date: Sat Jan 27 2024 - 13:15:47 EST


On January 27, 2024 1:37:27 AM PST, Xin Li <xin3.li@xxxxxxxxx> wrote:
>As clang doesn't allow .fill to refernece a symbol before it's defined,
>use asm_fred_entrypoint_user instead of asm_fred_entrypoint_kernel.
>
>Fixes: 5e0636a41485 ("x86/fred: FRED entry/exit and dispatch code")
>Reported-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
>Link: https://lore.kernel.org/lkml/20240126100050.GAZbOC0g3Rlr6otZcT@fat_crate.local/
>Signed-off-by: Xin Li <xin3.li@xxxxxxxxx>
>---
> arch/x86/entry/entry_64_fred.S | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>diff --git a/arch/x86/entry/entry_64_fred.S b/arch/x86/entry/entry_64_fred.S
>index eedf98de7538..5427e0da190d 100644
>--- a/arch/x86/entry/entry_64_fred.S
>+++ b/arch/x86/entry/entry_64_fred.S
>@@ -43,13 +43,12 @@ SYM_INNER_LABEL(asm_fred_exit_user, SYM_L_GLOBAL)
> _ASM_EXTABLE_TYPE(1b, asm_fred_entrypoint_user, EX_TYPE_ERETU)
> SYM_CODE_END(asm_fred_entrypoint_user)
>
>-.fill asm_fred_entrypoint_kernel - ., 1, 0xcc
>-
> /*
> * The new RIP value that FRED event delivery establishes is
> * (IA32_FRED_CONFIG & ~FFFH) + 256 for events that occur in
> * ring 0, i.e., asm_fred_entrypoint_user + 256.
> */
>+ .fill asm_fred_entrypoint_user + 256 - ., 1, 0xcc
> .org asm_fred_entrypoint_user + 256
> SYM_CODE_START_NOALIGN(asm_fred_entrypoint_kernel)
> FRED_ENTER

.fill and .org here are redundant; in fact, there two directives mean exactly the same thing except that .org implicitly subtracts the current offset.