From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32163C2D0A3 for ; Thu, 29 Oct 2020 11:28:34 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A4ED620791 for ; Thu, 29 Oct 2020 11:28:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eH2oLj8t"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="hgsK5c9Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4ED620791 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FhiUS3MeR9yiqDEjGFWJ+wVpY7Ew/jD3Pv9L8p5Y9F0=; b=eH2oLj8tp/HX1o2lspFxBwgVg Ko9RKXe6ZLKh2LQ34qFGJRQmbfQSJkEv2zQM6QVtRl/Mjvfy1mZcCFTHtbbwOH1bWERXXZ3kRF1Yp RMpp+5EWaTFmxeq9xV8xtvg9xN6/iEpwCsKZN3ZmCWYM/CLPivMuQ3sULW+VQs6sJHUFShPKlFGu4 v2olQBps8J6O729Vktp0KC/Ev8/v5fwR+zFP/y0FeEsBDdz35nhfVZCLVjSOf0uA7oaWJyBW07gxF fm04yCW1EUGt88f/SyxSpgdXMyJTf+XBcwcRHOkzSiJOYZ945mvfm7pyEheYbfGmv2z8OuxJlwQMT QrYGANRNQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY663-0001Ge-5c; Thu, 29 Oct 2020 11:27:59 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY660-0001Fa-2a for linux-arm-kernel@lists.infradead.org; Thu, 29 Oct 2020 11:27:56 +0000 Received: by mail-wm1-x343.google.com with SMTP id d3so2061907wma.4 for ; Thu, 29 Oct 2020 04:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=jEgob9dcduoBIQZ5vqz8+KO6kGwe6kbL8TTsfRoyFaI=; b=hgsK5c9QSr85qCrEb3zoBIK8iwwm5OZE4btHwnLyJU8/y9xruWZJk1wjFOJPbjJmad /SaPOH+s379wdnkawHukGHL1qPFwSebudpczUfUou9JIPQ3YXEe9PWaFkM9xV4KpPKmb 7u/RSOK8qfkmqr9Zx3hA5YxWqeIhazCIkmEvnmHYhJfZgangXW6+X0p0oZSBHMC6AX/Q XkuW29Mb6951c3WcL1ElAjhKN5+MnhAUEoatzkixJU52ne1nVV5IpyZtZmhDDw8Wh6sP wzVV4Q5FJLjvTakr8PX7JYYqufCzZzuAVNeh3pE7m26wARQJU+nqqomHsQzqw/fKkE2p 0h3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jEgob9dcduoBIQZ5vqz8+KO6kGwe6kbL8TTsfRoyFaI=; b=S8MPHqt0R52AW0BtEx6yaZdCK/P6CiVpsbcYH728+qH2FP1UV/mdH7kApcedxmzQZY ZDJPnfBkh1CQcnKAGLf6hdasdhnThKzAPLa8vo4stnz6w7UNucr6jpMwkMaUfqw+Abx7 AXfVy0X1CAh2o4fxaVyZjl+6qSP2Dj3XQypjvwtxik8JZQ/348k1DnqlDrrrTGWmDWyS JUTRPxU5u4FGPnltzROT6z4S+98y1f27LGsBaEUB/EbfaIY7OPR+fPjGlICqozWY7cmU cD/x33dOso83iWmsLL4bXH3M2JSAdpYYxUUjcpIDOUWssXIkAwyQwDnkRtjAVB1Auyed KavQ== X-Gm-Message-State: AOAM530jLzrCjVaQ/bnBV70S+u6aRs0Xd/XLDniFN8jJCPLTvuXpByTJ RJW3HYcjZe8pu20WUcHgfGqEcw== X-Google-Smtp-Source: ABdhPJydnt2eRXhK0vgrpHeDhOm2jyZm/6zG4iRMPWQsrH0rT+s5TNXiuVOQIoUtkw81H+Ltwp9A5Q== X-Received: by 2002:a7b:c055:: with SMTP id u21mr3826632wmc.27.1603970871808; Thu, 29 Oct 2020 04:27:51 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) by smtp.gmail.com with ESMTPSA id p13sm4500181wrt.73.2020.10.29.04.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 04:27:51 -0700 (PDT) Date: Thu, 29 Oct 2020 11:27:47 +0000 From: Quentin Perret To: Ard Biesheuvel Subject: Re: [PATCH v2] arm64: implement support for static call trampolines Message-ID: <20201029112747.GA4090840@google.com> References: <20201028184114.6834-1-ardb@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201028184114.6834-1-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201029_072756_152392_A4B4F3B5 X-CRM114-Status: GOOD ( 17.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Peter Zijlstra , catalin.marinas@arm.com, james.morse@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Ard, On Wednesday 28 Oct 2020 at 19:41:14 (+0100), Ard Biesheuvel wrote: > diff --git a/arch/arm64/include/asm/static_call.h b/arch/arm64/include/asm/static_call.h > new file mode 100644 > index 000000000000..7ddf939d57f5 > --- /dev/null > +++ b/arch/arm64/include/asm/static_call.h > @@ -0,0 +1,32 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _ASM_STATIC_CALL_H > +#define _ASM_STATIC_CALL_H > + > +/* > + * We have to account for the possibility that the static call site may > + * be updated to refer to a target that is out of range for an ordinary > + * 'B' branch instruction, and so we need to pre-allocate some space for > + * a ADRP/ADD/BR sequence. > + */ > +#define __ARCH_DEFINE_STATIC_CALL_TRAMP(name, insn) \ > + asm(".pushsection .static_call.text, \"ax\" \n" \ > + ".align 5 \n" \ > + ".globl " STATIC_CALL_TRAMP_STR(name) " \n" \ > + STATIC_CALL_TRAMP_STR(name) ": \n" \ > + "hint 34 /* BTI C */ \n" \ > + insn " \n" \ > + "ret \n" \ > + "nop \n" \ > + "nop \n" \ > + "adrp x16, " STATIC_CALL_KEY(name) " \n" \ > + "ldr x16, [x16, :lo12:" STATIC_CALL_KEY(name) "] \n" \ > + "br x16 \n" \ > + ".popsection \n") Still trying to understand all this in details, so bear with me, but is there any way this could be turned into the 'inline' static call variant? That is, could we have a piece of inline assembly at all static_call locations that would do a branch-link, with basically x0-x18 and x29,x30 in the clobber list (+ some have some magic to place the parameters in the right register, like we do for SMCCC calls for instance). That'd save a branch to the trampoline. Ideally we'd need a way to tell the compile 'this inline assembly code does a function call', but I'm not aware of any easy way to do that (other that marking register clobbered + probably other things that I'm missing). In any case, I was looking forward to an arm64 static call port so thanks for putting that together. Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel