public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Madhavan T. Venkataraman" <madvenka@linux.microsoft.com>
To: DJ Delorie <dj@redhat.com>
Cc: libffi-discuss@sourceware.org
Subject: Re: [RFC PATCH v3 2/5] x86: Support for Static Trampolines
Date: Thu, 28 Jan 2021 21:24:16 -0600	[thread overview]
Message-ID: <edd515af-e6de-4bf6-d7b8-58296d00848d@linux.microsoft.com> (raw)
In-Reply-To: <xnpn1ofofk.fsf@greed.delorie.com>



On 1/28/21 8:48 PM, DJ Delorie wrote:
> 
> Sure, you still need to use the __CET_ENDBR macro in your trampoline.
> And it might be tricky to compute the number of iterations per page (I
> understand about the packing ;)
> 
> I'm just saying you don't need both CET and non-CET trampolines.
> 
> A CET-enabled trampoline should work in a CET-disabled system.
> 

You are right. I only needed two versions because of the nops for aligment.

However, I think I can address your concern. Now that we are able to
define ENDBR_PRESENT, we can define the trampoline size in the header like
this

#ifdef ENDBR_PRESENT
#define	UNIX64_TRAMP_SIZE	40
#else
#define UNIX64_TRAMP_SIZE	32
#endif

Then, in the trampoline code table:

C(trampoline_code_table):
        .rept   UNIX64_TRAMP_MAP_SIZE / UNIX64_TRAMP_SIZE
        _CET_ENDBR
        subq    $16, %rsp               /* Make space on the stack */
        movq    %r10, (%rsp)            /* Save %r10 on stack */
        movq    4077(%rip), %r10        /* Copy data into %r10 */
        movq    %r10, 8(%rsp)           /* Save data on stack */
        movq    4073(%rip), %r10        /* Copy code into %r10 */
        jmp     *%r10                   /* Jump to code */
	nop
	nop
#ifdef ENDBR_PRESENT
        nop
        nop
        nop
        nop
#endif
        .endr
ENDF(C(trampoline_code_table))


This is cool. We only need one table.

Thanks.

Madhavan

  reply	other threads:[~2021-01-29  3:24 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1ef5c7e1c9a6ebb140a476ba555ec955681f4fba>
2021-01-15 18:46 ` [RFC PATCH v3 0/5] Libffi " madvenka
2021-01-15 18:46   ` [RFC PATCH v3 1/5] " madvenka
2021-01-27  3:31     ` DJ Delorie
2021-01-27 21:51       ` Madhavan T. Venkataraman
2021-01-27 22:15         ` DJ Delorie
2021-01-27 22:43           ` Madhavan T. Venkataraman
2021-01-15 18:46   ` [RFC PATCH v3 2/5] x86: Support for " madvenka
2021-01-27  3:31     ` DJ Delorie
2021-01-28 21:59       ` Madhavan T. Venkataraman
2021-01-28 22:17         ` DJ Delorie
2021-01-28 23:25           ` Madhavan T. Venkataraman
2021-01-29  2:09             ` DJ Delorie
2021-01-29  2:38               ` Madhavan T. Venkataraman
2021-01-29  2:48                 ` DJ Delorie
2021-01-29  3:24                   ` Madhavan T. Venkataraman [this message]
2021-01-29  6:07                     ` DJ Delorie
2021-02-01 19:46                 ` DJ Delorie
2021-01-15 18:46   ` [RFC PATCH v3 3/5] i386: " madvenka
2021-01-15 18:46   ` [RFC PATCH v3 4/5] arm64: " madvenka
2021-01-15 18:46   ` [RFC PATCH v3 5/5] arm: " madvenka
2021-01-26 23:41   ` [RFC PATCH v3 0/5] Libffi " Anthony Green
2021-01-27 17:20     ` Madhavan T. Venkataraman
2021-01-27 18:00       ` Anthony Green
2021-01-27 19:45         ` Madhavan T. Venkataraman
2021-01-28 14:21           ` Anthony Green
2021-01-28 17:01             ` Madhavan T. Venkataraman
2021-02-05 18:20               ` Madhavan T. Venkataraman
2021-02-05 18:46                 ` Anthony Green
2021-02-05 19:38                   ` Madhavan T. Venkataraman
2021-02-07 16:09                     ` Madhavan T. Venkataraman

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=edd515af-e6de-4bf6-d7b8-58296d00848d@linux.microsoft.com \
    --to=madvenka@linux.microsoft.com \
    --cc=dj@redhat.com \
    --cc=libffi-discuss@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).