Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp606078pxb; Mon, 25 Oct 2021 14:49:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb4lkfS4fnEUcA23emMW0rKveE74kqe0XRjx1hqNoaVKMMNlV6ObwqydofHRB7jRBGEx6G X-Received: by 2002:a63:701b:: with SMTP id l27mr8237697pgc.341.1635198596523; Mon, 25 Oct 2021 14:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635198596; cv=none; d=google.com; s=arc-20160816; b=vYHKBlr0FDoQ9AUIN4zhYJnEi4AM5ukuM9o+l0u0I9qA76pqp/xAMyYCx9/bPHURIh RDY5CX3PtdOGbRWuQbJKJ9P9xD9A/tMAg06CAATdbrEFUQtEP42VQMxzlfyeb0/05Iia cjJJ0KDMhPggRECoITcLubYGG3UF9SBHVvpchqFllssjUbp3Ukhe7j5NDhNToEQeFY5x 1hFbBsZ8SFEMo4dziLkuJ2CjWNMrpF+ZTO020kFvSBbvd6gV9WsCQayRWIcFXZso09X4 WdcazvrHXgRAy7YVMggZImjgNsS99nwAPjFnLE/9owwvvqnGKOz/LzrR6VzAtlEus/FN I+SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=70GK+yvJjDYkD23oasIKOHoqG+JRgMO44YnDHoxRbOE=; b=gFKZBPOTyOtteMur6yBASkn2DB4IVtqaOoKc6ZETGv3iJNUUJdSIMeL6979ekyIhze 0HiAbnT38qXS2sC3bqaN8XMjOpCMsbQ2rXx7B+omvHfD0QK92VXcf+biQrToo2MKLCA5 AkyqfSffzHq2Sx9j/kyiDQWy0CQQCd4R2qsk4hiAzwjuJyKO3joTHdtiEH9cD9F4v2Fe KsKv0LRB0nlOTuIP6Erk2fViue7Sbvl1ZEqVTRYwD/fuig5NpcyqOmwzFB0Pj+YZqWaq 6enDGb3tLn23EUarUH5zIbd5SV6LvXeE3xD8LoGvUZ+pHKINZCe0CUA0YqHBhTyW4Wt8 u6GQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si2159562plp.231.2021.10.25.14.49.43; Mon, 25 Oct 2021 14:49:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233517AbhJYO2T convert rfc822-to-8bit (ORCPT + 99 others); Mon, 25 Oct 2021 10:28:19 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:42929 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233522AbhJYO2S (ORCPT ); Mon, 25 Oct 2021 10:28:18 -0400 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-45-NSW77ASPPcCfQF4garZMjA-1; Mon, 25 Oct 2021 15:25:54 +0100 X-MC-Unique: NSW77ASPPcCfQF4garZMjA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.24; Mon, 25 Oct 2021 15:25:53 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.024; Mon, 25 Oct 2021 15:25:53 +0100 From: David Laight To: 'Frederic Weisbecker' , Peter Zijlstra , Ard Biesheuvel CC: LKML , James Morse , Quentin Perret , Catalin Marinas , Will Deacon , Mark Rutland Subject: RE: [PATCH 2/4] arm64: implement support for static call trampolines Thread-Topic: [PATCH 2/4] arm64: implement support for static call trampolines Thread-Index: AQHXyZrPgIVfu8vswkCI9TVLTUwuCavjxAog Date: Mon, 25 Oct 2021 14:25:53 +0000 Message-ID: <1b19fbeccf3d4a75a5ed3a507d29f7dd@AcuMS.aculab.com> References: <20211025122102.46089-1-frederic@kernel.org> <20211025122102.46089-3-frederic@kernel.org> In-Reply-To: <20211025122102.46089-3-frederic@kernel.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frederic Weisbecker > Sent: 25 October 2021 13:21 > > Implement arm64 support for the 'unoptimized' static call variety, which > routes all calls through a single trampoline that is patched to perform a > tail call to the selected function. > > It is expected that the direct branch instruction will be able to cover > the common case. However, given that static call targets may be located > in modules loaded out of direct branching range, we need a fallback path > that loads the address into R16 and uses a branch-to-register (BR) > instruction to perform an indirect call. > ... > +void arch_static_call_transform(void *site, void *tramp, void *func, bool tail) > +{ > + /* > + * -0x8 > + * 0x0 bti c <--- trampoline entry point > + * 0x4 > + * 0x8 ldr x16, > + * 0xc cbz x16, 20 > + * 0x10 br x16 > + * 0x14 ret > + */ Since the 'ldr x16, ' is just a 32bit constant (for a pc-relative load). Can't you save a word by making offset 0x4 > ? Or am I missing something? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)