Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1411532imm; Wed, 10 Oct 2018 14:14:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV62hLkFWB+zfAZWM3kQjEssKns7so9NWLAp4808zTbJfDd/XNNrlqsbqWEEUV8LAHHiRMELP X-Received: by 2002:a17:902:1021:: with SMTP id b30-v6mr35144894pla.23.1539206057849; Wed, 10 Oct 2018 14:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539206057; cv=none; d=google.com; s=arc-20160816; b=lIuhc2U9qMQpBbpqaErA42Z36WlY/0WT0ITfqedVAeZiGThm47H4jkLUZZUmjijHSd VwjbPKdeHVcemtbZTNiaPrZJSwcgfQ4+mErc7uGWFdIiTcbprFkjTt3YQw7F9ByOnJQj THS4bsBkOwHJRAesWTMa0/GjomvlTrlofxOKm6cABD/0vBpZEi+/XcLNjEZ3BOitkSwT Ibg0xck+32GaES7g3pp/Ofg0mvdxWYY4Wscnsb15eftN9vQIbxSI4IGcx3o/uD2qCEqI 3xFIzOVcpkNrq5G6xnJAM89m6gbkAgTV8vz8EkPcnGrvaK2/WXBLA4PLLCEF1ukL+GrM 6/Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=h8A3UipERG3NT0ECb7Z+ZqIoiaKdw+Gx0wMsxByRRS0=; b=H/7oRi/bPMEudHfsGOvpp3Hp6A1dD3h8aIbCgl9VPHhPit1DUq0hqIUIocx/+FLtfv 9Tp9a8gz44pr0mMzbRgIgJHuOyPCQlJlDdycXw5uFkLJk7JkPYiobp2D+nVIFgZMGpss +N/WF3sB25OKXhsh/PmUIDXB/5bNkSvLa22nJsR9MP031R+ejgATD3H7eUJ2t913NsW4 vigiWb9ZaozAZN8cAqOrlPip//Yj3kqpNXEuu3OuzDh3rQ6/rF7GtN1D11FRJrzMSoJN H4D2rflAezXyG8J45tkZARL0agFAk1tZ04Efy4oA4n5PSZxEevd5Q1p1sX5KCS+ZNhAw C1rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=aUzNJhui; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i128-v6si30630476pfb.256.2018.10.10.14.14.02; Wed, 10 Oct 2018 14:14:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=aUzNJhui; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725984AbeJKEhd (ORCPT + 99 others); Thu, 11 Oct 2018 00:37:33 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41652 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725810AbeJKEhd (ORCPT ); Thu, 11 Oct 2018 00:37:33 -0400 Received: by mail-wr1-f68.google.com with SMTP id x12-v6so7265446wru.8 for ; Wed, 10 Oct 2018 14:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h8A3UipERG3NT0ECb7Z+ZqIoiaKdw+Gx0wMsxByRRS0=; b=aUzNJhui/U7FOOPMqzgdsx+n+Dr7tuJH9MHkftWeMfhFHYYq554bxT+e8AHEOpdAsw au6J0Vg/eLfDLNNiQIfsnKbSmTM5v9AgtJzhtRaS02qt74Bgn58g+6lUqdaF/0tIGAee nSnR9AKz/kKErEbxYBnKt0KDm8oXuXR1PRA4g5Qg8Dz3cJiug22lysRY1uf5yqQpZVl8 vbtRVmoK1KFUg9U2kj2vSPQCa3VBjuk8O8ajdxWHdwWeQVUaQhBTSbJ8o9SPr1LuYDqa NtJBNrBITtG2B/H4qLC++8WUCs9LTetK+FftNgraaa4cx/omQz/tJqptdH8EVm9YCjIO ImJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h8A3UipERG3NT0ECb7Z+ZqIoiaKdw+Gx0wMsxByRRS0=; b=ON4H74hdmf/Boj1DvpqacOoBqGVX8KueCMPAw+eyaXrk1usfCuksl5TWWN/6JkBunm +baDYYsDU8zNxj7grLC0zzYwCMOctxflKKW45bR5DA4+9jJwh8W2iDTC4XLUtzZXRzWE 8J94LKvnopUBKvMByj5pANLMZl9OA2MWczwj7WIo+wCUvdOVKsidEgWhw6UEccfPV1zG /CpgofwhgTmHO/nnPdfKRw+/6cTceFcFUWxqj8/IQzwwD/RUX7za35Uj0EkzkKdNMtUP /61s7ve/jcIgcbWwfHXB4e5mCvGro4XPtMo7UVfVrg/1JGtke/cODtLMwqipgZdQKVM4 XPIw== X-Gm-Message-State: ABuFfogSY2woxYCAKyZ8d/N+pHDkkG46TqGqfoT2JdTtpWsaUx/BQQ6S uMvrJAxsFQj3uBB0GDatbmMcylSWTC6zYV9XK4O3yQ== X-Received: by 2002:adf:82e3:: with SMTP id 90-v6mr23853652wrc.131.1539206014436; Wed, 10 Oct 2018 14:13:34 -0700 (PDT) MIME-Version: 1.0 References: <20181006093905.46276505@vmware.local.home> <20181008072134.GB5663@hirez.programming.kicks-ass.net> <20181008155757.GC5663@hirez.programming.kicks-ass.net> <20181009021710.qwt5hpntyeps44h3@treble> <20181008235750.59da83ae@gandalf.local.home> <20181010175237.e7m3sldcu2maoqcq@treble> <20181010181605.arsyjxwdztztrjih@treble> <20181010181741.lc4l7kjvcmoxrw5b@treble> In-Reply-To: <20181010181741.lc4l7kjvcmoxrw5b@treble> From: Andy Lutomirski Date: Wed, 10 Oct 2018 14:13:22 -0700 Message-ID: Subject: Re: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function" To: Josh Poimboeuf Cc: Steven Rostedt , Peter Zijlstra , LKML , Linus Torvalds , Ingo Molnar , Andrew Morton , Thomas Gleixner , Masami Hiramatsu , Mathieu Desnoyers , Matthew Helsley , "Rafael J. Wysocki" , David Woodhouse , Paolo Bonzini , Jason Baron , Jiri Kosina , Ard Biesheuvel , Andrew Lutomirski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 10, 2018 at 11:17 AM Josh Poimboeuf wrote: > > On Wed, Oct 10, 2018 at 01:16:05PM -0500, Josh Poimboeuf wrote: > > On Wed, Oct 10, 2018 at 11:03:43AM -0700, Andy Lutomirski wrote: > > > > +#define DECLARE_STATIC_CALL(tramp, func) \ > > > > + extern typeof(func) tramp; \ > > > > + static void __used __section(.discard.static_call_tramps) \ > > > > + *__static_call_tramp_##tramp = tramp > > > > + > > > > > > Confused. What's the __static_call_tramp_##tramp variable for? And > > > why is a DECLARE_ macro defining a variable? > > > > This is the magic needed for objtool to find all the call sites. > > > > The variable itself isn't needed, but the .discard.static_call_tramps > > entry is. Objtool reads that section to find out which function call > > sites are targeted to a static call trampoline. > > To clarify: objtool reads that section to find out which functions are > really static call trampolines. Then it annotates all the instructions > which call/jmp to those trampolines. Those annotations are then read by > the kernel. > Ah, right, and objtool runs on a per-object basis so it has no other way to know what symbols are actually static calls. There's another way to skin this cat, though: extern typeof(func) __static_call_trampoline_##tramp; #define tramp __static_call_trampoline_##tramp And objtool could recognize it by name. But, of course, you can't put a #define in a macro. But maybe there's a way to hack it up with a static inline? Anyway, your way is probably fine with a few caveats: - It won't really work if the call comes from a .S file. - There should probably be a comment to help de-confuse future people like me :)