From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 65D463857C66 for ; Fri, 29 Jan 2021 02:10:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 65D463857C66 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-376-6_hPUZtDPe6eQjOY9C55aA-1; Thu, 28 Jan 2021 21:09:59 -0500 X-MC-Unique: 6_hPUZtDPe6eQjOY9C55aA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E5B0100C60A; Fri, 29 Jan 2021 02:09:58 +0000 (UTC) Received: from greed.delorie.com (ovpn-114-77.rdu2.redhat.com [10.10.114.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F370960BE2; Fri, 29 Jan 2021 02:09:57 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.14.7/8.14.7) with ESMTP id 10T29uhJ007085; Thu, 28 Jan 2021 21:09:56 -0500 From: DJ Delorie To: "Madhavan T. Venkataraman" Cc: libffi-discuss@sourceware.org Subject: Re: [RFC PATCH v3 2/5] x86: Support for Static Trampolines In-Reply-To: <78a00ccd-3724-2a2d-3c59-f4a2b7a309cd@linux.microsoft.com> (madvenka@linux.microsoft.com) Date: Thu, 28 Jan 2021 21:09:56 -0500 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libffi-discuss@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libffi-discuss mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jan 2021 02:10:02 -0000 "Madhavan T. Venkataraman" writes: > So, the definition is like this: > > #if !defined(GENERATE_LIBFFI_MAP) && defined(__ASSEMBLER__) \ > && defined(__CET__) > # include > # define _CET_NOTRACK notrack > #else > # define _CET_ENDBR > # define _CET_NOTRACK > #endif > > Where we include cet.h, CET_ENDBR may still be defined either > as endbr64 or empty depending on __CET__ & 1 being non-zero or > zero, right? > > So, would something like this work? I suspect you only need one trampoline template, with __CET_ENDBR in it. Use .align instead of hardcoding the right number of NOPs, and other logic to figure out the repeat counts. It's safe to execute endbr64 when CET is not enabled.