From: "H. Peter Anvin" <hpa@zytor.com>
To: Peter Zijlstra <peterz@infradead.org>, x86@kernel.org
Cc: kees@kernel.org, alyssa.milburn@intel.com,
scott.d.constable@intel.com, joao@overdrivepizza.com,
andrew.cooper3@citrix.com, samitolvanen@google.com,
nathan@kernel.org, alexei.starovoitov@gmail.com,
mhiramat@kernel.org, ojeda@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH] x86,ibt: Use UDB instead of 0xEA
Date: Thu, 14 Aug 2025 18:27:44 -0700 [thread overview]
Message-ID: <2c121572-8fde-4288-80ca-ab79f2b22cce@zytor.com> (raw)
In-Reply-To: <20250814111732.GW4067720@noisy.programming.kicks-ass.net>
On 2025-08-14 04:17, Peter Zijlstra wrote:
> Hi!
>
> A while ago FineIBT started using the instruction 0xEA to generate #UD.
> All existing parts will generate #UD in 64bit mode on that instruction.
>
> However; Intel/AMD have not blessed using this instruction, it is on
> their 'reserved' list for future use.
>
> Peter Anvin worked the committees and got use of 0xD6 blessed, and it
> will be called UDB (per the next SDM or so).
>
> Reworking the FineIBT code to use UDB wasn't entirely trivial, and I've
> had to switch the hash register to EAX in order to free up some bytes.
>
> Per the x86_64 ABI, EAX is used to pass the number of vector registers
> for varargs -- something that should not happen in the kernel. More so,
> we build with -mskip-rax-setup, which should leave EAX completely unused
> in the calling convention.
>
> The code boots and passes the LKDTM CFI_FORWARD_PROTO test for various
> combinations (non exhaustive so far).
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Looks good to me (and using %eax will save one byte per call site as
well), but as per our IRC discussion, *my understanding* is that the
best possible performance (least branch predictor impact across
implementations) is to use a forward branch with a 2E prefix (jcc,pn in
GAS syntax) rather than a reverse branch, if space allows.
-hpa
next prev parent reply other threads:[~2025-08-15 1:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 11:17 [RFC][PATCH] x86,ibt: Use UDB instead of 0xEA Peter Zijlstra
2025-08-14 11:23 ` Peter Zijlstra
2025-08-14 19:40 ` Nathan Chancellor
2025-08-15 1:27 ` H. Peter Anvin [this message]
2025-08-15 7:49 ` Peter Zijlstra
2025-08-15 10:28 ` Peter Zijlstra
2025-08-15 10:30 ` Peter Zijlstra
2025-08-15 10:43 ` Andrew Cooper
2025-08-15 10:59 ` Peter Zijlstra
2025-08-15 11:19 ` Andrew Cooper
2025-08-15 17:14 ` H. Peter Anvin
2025-08-15 17:21 ` Andrew Cooper
2025-08-15 17:28 ` H. Peter Anvin
2025-08-15 5:42 ` Alexei Starovoitov
2025-08-15 7:57 ` Peter Zijlstra
2025-08-15 8:28 ` Leon Hwang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c121572-8fde-4288-80ca-ab79f2b22cce@zytor.com \
--to=hpa@zytor.com \
--cc=alexei.starovoitov@gmail.com \
--cc=alyssa.milburn@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=joao@overdrivepizza.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=nathan@kernel.org \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=samitolvanen@google.com \
--cc=scott.d.constable@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox