From: Chao Gao <chao.gao@intel.com>
To: Mathias Krause <minipli@grsecurity.net>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>, <kvm@vger.kernel.org>
Subject: Re: [kvm-unit-tests PATCH 6/8] x86/cet: Simplify IBT test
Date: Mon, 23 Jun 2025 13:32:01 +0800 [thread overview]
Message-ID: <aFjm0WsQHj2ELpMd@intel.com> (raw)
In-Reply-To: <20250620153912.214600-7-minipli@grsecurity.net>
On Fri, Jun 20, 2025 at 05:39:10PM +0200, Mathias Krause wrote:
>The inline assembly of cet_ibt_func() does unnecessary things and
>doesn't mention the clobbered registers.
>
>Fix that by reducing the code to what's needed (an indirect jump to a
>target lacking the ENDBR instruction) and passing and output register
>variable for it.
>
>Signed-off-by: Mathias Krause <minipli@grsecurity.net>
>---
> x86/cet.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
>diff --git a/x86/cet.c b/x86/cet.c
>index fbfcf7d1ab23..b41443c1e67d 100644
>--- a/x86/cet.c
>+++ b/x86/cet.c
>@@ -36,18 +36,17 @@ static uint64_t cet_shstk_func(void)
>
> static uint64_t cet_ibt_func(void)
> {
>+ unsigned long tmp;
> /*
> * In below assembly code, the first instruction at label 2 is not
> * endbr64, it'll trigger #CP with error code 0x3, and the execution
> * is terminated when HW detects the violation.
> */
> printf("No endbr64 instruction at jmp target, this triggers #CP...\n");
>- asm volatile ("movq $2, %rcx\n"
>- "dec %rcx\n"
>- "leaq 2f(%rip), %rax\n"
>- "jmp *%rax \n"
>- "2:\n"
>- "dec %rcx\n");
>+ asm volatile ("leaq 2f(%%rip), %0\n\t"
>+ "jmpq *%0\n\t"
>+ "2:"
>+ : "=r"(tmp));
@tmp isn't needed. We can still use "rax" and list it as clobbered.
> return 0;
> }
>
>--
>2.47.2
>
next prev parent reply other threads:[~2025-06-23 5:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 15:39 [kvm-unit-tests PATCH 0/8] x86: CET fixes and enhancements Mathias Krause
2025-06-20 15:39 ` [kvm-unit-tests PATCH 1/8] x86: Avoid top-most page for vmalloc on x86-64 Mathias Krause
2025-06-23 4:50 ` Chao Gao
2025-06-20 15:39 ` [kvm-unit-tests PATCH 2/8] x86/cet: Fix flushing shadow stack mapping Mathias Krause
2025-06-20 15:39 ` [kvm-unit-tests PATCH 3/8] x86/cet: Use NONCANONICAL for non-canonical address Mathias Krause
2025-06-20 15:39 ` [kvm-unit-tests PATCH 4/8] x86/cet: Make shadow stack less fragile Mathias Krause
2025-06-20 15:39 ` [kvm-unit-tests PATCH 5/8] x86/cet: Avoid unnecessary function pointer casts Mathias Krause
2025-06-20 15:39 ` [kvm-unit-tests PATCH 6/8] x86/cet: Simplify IBT test Mathias Krause
2025-06-23 5:32 ` Chao Gao [this message]
2025-06-20 15:39 ` [kvm-unit-tests PATCH 7/8] x86/cet: Track and verify #CP error code Mathias Krause
2025-06-20 15:39 ` [kvm-unit-tests PATCH 8/8] x86/cet: Test far returns too Mathias Krause
2025-06-23 5:50 ` Chao Gao
2025-06-23 2:36 ` [kvm-unit-tests PATCH 0/8] x86: CET fixes and enhancements Chao Gao
2025-06-23 13:57 ` Mathias Krause
2025-06-23 14:17 ` Sean Christopherson
[not found] <e53b66b9-6b32-4834-a34e-17c307c19a82@grsecurity.net>
2025-06-23 20:29 ` [kvm-unit-tests PATCH 6/8] x86/cet: Simplify IBT test Mathias Krause
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=aFjm0WsQHj2ELpMd@intel.com \
--to=chao.gao@intel.com \
--cc=kvm@vger.kernel.org \
--cc=minipli@grsecurity.net \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.