Index | Thread | Search

From:
Yuichiro NAITO <naito.yuichiro@gmail.com>
Subject:
Re: lang/luajit add support of IBT for amd64
To:
stu@spacehopper.org
Cc:
ports@openbsd.org
Date:
Wed, 15 Oct 2025 15:45:20 +0900

Download raw body.

Thread
From: Stuart Henderson <stu@spacehopper.org>
Subject: Re: lang/luajit add support of IBT for amd64
Date: Wed, 15 Oct 2025 07:31:01 +0100

> On 2025/10/15 08:52, Yuichiro NAITO wrote:
>> Thanks for the diff. It works for me on amd64. I don't have IBT featured
>> test environment on i386 but checked building successfully. While the build,
>> I saw the following warning message.
> 
> The endbr* instructions decode as a "long nop" on 64-bit capable CPUs
> but on some older 32-bit CPUs they result in an illegal instruction.
> 
> OpenBSD doesn't enable IBT on i386 anyway so adding endbr32 doesn't
> make sense. It restrict the CPUs the code can run on but there's no
> benefit.
> 
>> ./lj_emit_x86.h:73:13: warning: unused function 'emit_endbr' [-Wunused-function]
>>    73 | static void emit_endbr(ASMState *as)
>>       |             ^~~~~~~~~~
>> 1 warning generated.
>> ```
>> 
>> I would like to update your patch as the following to suppress the warning.
> 
> better to do this instead, I think.
> 
> --- patches/patch-src_lj_emit_x86_h.orig	Wed Oct 15 07:24:44 2025
> +++ patches/patch-src_lj_emit_x86_h	Wed Oct 15 07:25:17 2025
> @@ -3,18 +3,16 @@ amd64 bti fixes
>  Index: src/lj_emit_x86.h
>  --- src/lj_emit_x86.h.orig
>  +++ src/lj_emit_x86.h
> -@@ -70,6 +70,15 @@ static LJ_AINLINE MCode *emit_op(x86Op xo, Reg rr, Reg
> +@@ -70,6 +70,13 @@ static LJ_AINLINE MCode *emit_op(x86Op xo, Reg rr, Reg
>     return p;
>   }
>   
> ++#if LJ_64
>  +static void emit_endbr(ASMState *as)
>  +{
> -+#if LJ_64
>  +  emit_u32(as, 0xfa1e0ff3);      // endbr64
> -+#else
> -+  emit_u32(as, 0xfb1e0ff3);      // endbr32
> -+#endif
>  +}
> ++#endif
>  +
>   /* op + modrm */
>   #define emit_opm(xo, mode, rr, rb, p, delta) \

Ah, This removes endbr named function completely for i386, and makes
it clear not to support it. It seems nice to me. Thank you.

-- 
Yuichiro NAITO (naito.yuichiro@gmail.com)