Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2383160imm; Thu, 11 Oct 2018 09:22:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV61NbmeCq+luyTCNg1rDNnguzp0FjPdfYsTqilJz4QQbgEFouk8vyUtoXVZSkM/pWOdDKlAh X-Received: by 2002:a63:2903:: with SMTP id p3-v6mr2047768pgp.188.1539274963097; Thu, 11 Oct 2018 09:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539274963; cv=none; d=google.com; s=arc-20160816; b=ru1a/nhzs4KdhCqO/l5Em4i+Xht7dDYcaWPBRex4OnfbuhUtnZmtQ/bk9wgxb6ZV0y 9LaeWutIO9K3JWzWgDfT+UOxKrAUHwTZo8kShZfiGfkxR1yzZ5I8w6JrGxtia2v1VRgy Sf/JN3TFPPSKbHVd8ymniLDXfqFqKeB+DZQriN4s7OpGQAS7ZgJK7htfGIahLjoRD+VZ cvTDF1ELOdSwkNg74oquuh9WEDMkCii9A4sCsY+GOZWNIFlH1d0Vssv1nWvXPfHHbvhh 0CTFwRTGVBy3LQFeLE3NbGRn48KxX56e18Wu3iKIIIy+kZYtTC9gXeKWeEm/jCDbZyUq HiAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=8YgZF3nM28BReU0c6f/QqyOk3H86PJZeln6QJBbxNb8=; b=mlJKyPsEVpu3gM2JLQFzAlkUeApIi5CG49Iim/m1+e/RTv4sdShyZA0vlY7bT4OmCY wCPk8XV3DwCbNXdHYKfpAmMpK5YtoMiFec0keeDHk4AZngFHK8SomnHvUBcij8tK7Y/f Dnoinos9KLbLj565QvnoLxuVAw0/Uk5v8YkR6XBHUShGu3WMI4CE46jghTmq4RlYeD5G P/VRjtzYo/S7ie5G3z4FAaoiEu3EDIIcCh4B8YOjmoq7yh0ZL3Bra2sFM6KgvlL/gp5m GW+m3m/nnglW1FZEWkkK9w5u+E/nhWWeFZbEkF0Tt2slXdASORB4p/jo2FWrOYl/gal+ YdEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=CwSj5mWp; 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 e6-v6si25595754pgm.437.2018.10.11.09.22.27; Thu, 11 Oct 2018 09:22:43 -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=CwSj5mWp; 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 S1729755AbeJKXsi (ORCPT + 99 others); Thu, 11 Oct 2018 19:48:38 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39899 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728262AbeJKXsi (ORCPT ); Thu, 11 Oct 2018 19:48:38 -0400 Received: by mail-pl1-f195.google.com with SMTP id w14-v6so4468874plp.6 for ; Thu, 11 Oct 2018 09:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=8YgZF3nM28BReU0c6f/QqyOk3H86PJZeln6QJBbxNb8=; b=CwSj5mWpYyNwiuEbE1zI/ExFWQ1Efndx1501FyHYDObLBk3iyUjCjR+/IsGoGP2AmN F6m4DSyWebus2xyUuUl9fmPQUhKuNegBMobq4n4VIm6YonPeEbKwm8N1758Vy2dSBaYV zEZeR4brGUyzYR3ktAs7HoPKlJ4rH2tHi4Ne+xuq4LctVew+oeuLoCzHzeHyBbaminaJ FjSY2LgEWzEe595ImfnPkPU1nQI7L0+LsA0lfA2tKQjDx4T0wdJBwaA4n+KWvZO2Tofq hn3kLofCD1dILJPKj08gVlpCbY1SQvNbCsUWnBZVCDJVBIlDtsN7rO6lf9L0isDZccxL /olQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=8YgZF3nM28BReU0c6f/QqyOk3H86PJZeln6QJBbxNb8=; b=LE2zFcc01H5hBBZCEFwcdQHgXv3AmGhO6xQMEa7q7EW7jl4Lfi3u/gcZSwrTh/AF2t dFYi5ROGvkhsWphEvyr4A+rwilL23L6l8dfpnon544zxWBUjFfan8mltuYnjahPDx8Ic I7ECKtl2Ma8qPniQMMAxQh549IWuo2CTBCRQOq1qxheqNrhAENn0MY4rKZNw39A09ZXG zYBFCMYdD3Vu/zgU5vx7cBj4ol0fkrn4gr+mIj/qot7NZPBcRGHXemwUF405hmCZXFJq k4zaYbu8y7PyaqVIzkvatlC9G3gWYvm1FrGu9ZBwpxIMsOR5wRN9GY+JcTJxQtRk5yyT EqTA== X-Gm-Message-State: ABuFfohD/e94QycdDQlOyVNVVJK0YKItt2rPNhwYQQlXicElgASgvWuN rQ6FYrsOdsdE8ilSvNn7+VVhRA== X-Received: by 2002:a17:902:124:: with SMTP id 33-v6mr2223430plb.205.1539274842280; Thu, 11 Oct 2018 09:20:42 -0700 (PDT) Received: from [192.168.0.178] (c-71-202-137-17.hsd1.ca.comcast.net. [71.202.137.17]) by smtp.gmail.com with ESMTPSA id o85-v6sm59037184pfk.94.2018.10.11.09.20.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 09:20:41 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function" From: Andy Lutomirski X-Mailer: iPhone Mail (16A366) In-Reply-To: <20181011125258.ihsdmonepaoc5xtb@treble> Date: Thu, 11 Oct 2018 09:20:40 -0700 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-Transfer-Encoding: quoted-printable Message-Id: References: <20181008155757.GC5663@hirez.programming.kicks-ass.net> <20181009021710.qwt5hpntyeps44h3@treble> <20181008235750.59da83ae@gandalf.local.home> <20181010175237.e7m3sldcu2maoqcq@treble> <20181010181605.arsyjxwdztztrjih@treble> <20181010181741.lc4l7kjvcmoxrw5b@treble> <20181011030738.wwy6grnss67txd2l@treble> <20181011125258.ihsdmonepaoc5xtb@treble> To: Josh Poimboeuf Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Oct 11, 2018, at 5:52 AM, Josh Poimboeuf wrote: >=20 >> On Wed, Oct 10, 2018 at 10:07:38PM -0500, Josh Poimboeuf wrote: >>> On Wed, Oct 10, 2018 at 02:13:22PM -0700, Andy Lutomirski wrote: >>>> On Wed, Oct 10, 2018 at 11:17 AM Josh Poimboeuf w= rote: >>>>=20 >>>>> 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 =3D tramp >>>>>>> + >>>>>>=20 >>>>>> Confused. What's the __static_call_tramp_##tramp variable for? And >>>>>> why is a DECLARE_ macro defining a variable? >>>>>=20 >>>>> This is the magic needed for objtool to find all the call sites. >>>>>=20 >>>>> 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. >>>>=20 >>>> 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 b= y >>>> the kernel. >>>>=20 >>>=20 >>> Ah, right, and objtool runs on a per-object basis so it has no other >>> way to know what symbols are actually static calls. >>>=20 >>> There's another way to skin this cat, though: >>>=20 >>> extern typeof(func) __static_call_trampoline_##tramp; >>> #define tramp __static_call_trampoline_##tramp >>>=20 >>> 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? >=20 > I went with something similar in the latest version. It's less > surprising in a couple of ways: >=20 > - DECLARE_STATIC_CALL doesn't have the magic objtool definition. >=20 > - Call sites use the static_call() wrapper, which makes static calls > clearly visible. Seems reasonable. Also, for a real patch, it should be straightforward to ha= ve a fallback implementation in include/linux/static_call.h that just derefe= rences the pointer.