Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1259435imm; Wed, 10 Oct 2018 11:35:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV60wC6O2wrEDr/yMiamyx3HqCk5YInssKD+kQrR0I+6P2ldVVbzJ38ewbjWzC7UKww0ws3IK X-Received: by 2002:a63:d502:: with SMTP id c2-v6mr30757144pgg.324.1539196542245; Wed, 10 Oct 2018 11:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539196542; cv=none; d=google.com; s=arc-20160816; b=YB041ZV1/oeykLtNJH2jKvG5EF/CRf+SoY4cbQE1q4HFnkoosYywwt2T2J6HX5kEGE M3L5MQWdSD/qzhB3qfQbezbShUDxxQMjV4LXCQQ3s+ax4VJ1a+fMY8qG7qkMkUccCHYu UD3Y6APf6XFbaVB1iVrRPusSrHzugDhIRQQnUQleqliIKHImfdwOPGDtaTsctKwXj1cR PCj+K1zgM/vB5Eod0IzGT48qKyZ9nZiDCavxACyjDdyTiyt+qy6n+2OePXgOuttP2CfC rg5VCwT/9b0xiqQHX7q2X/mFTE3eRLX/fztujtJcuf21juFqfCLNVfSfSD0dLAPgBcRh JbTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=7OBWmIX6s6oKY0cdT+LwhZf+vGO2BsOitv/wkSv9Fz8=; b=pV8gwX4IsBpeAbQGx54lJcIlLW1pwmFBPOAKceb4kLVhc4tDpDpM4bWNkSRv9ulcoC Ha+ceWDqLtwb5UpkV8zAS/ocq8/tKJCejNGGMW6kQ+SXHN74AcY7nUsD5zHnt9fpr8no rrdlHp5DjTN5Ah0d/w/KyJN4deYo1fMy9335+acKMzhzOrNjjW3N4dz9BG4CUIlAwEIK Ri7rsve5Euo25ZINSAVZQWHT8pjz1INxHc6nwfBF+LTORBxxgq9pzzMRF/6usH8c7biS f70ziL6F7+w/0A/ntPYs/Atfk5y7KlSYpXNRmPgJuV+meGUC7YI2xkWzugbTcGotyuOy DgPg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2-v6si23855597pgg.355.2018.10.10.11.35.25; Wed, 10 Oct 2018 11:35:42 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727101AbeJKB46 (ORCPT + 99 others); Wed, 10 Oct 2018 21:56:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55954 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726525AbeJKB46 (ORCPT ); Wed, 10 Oct 2018 21:56:58 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8F183083395; Wed, 10 Oct 2018 18:33:35 +0000 (UTC) Received: from treble (ovpn-124-83.rdu2.redhat.com [10.10.124.83]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8146417002; Wed, 10 Oct 2018 18:33:32 +0000 (UTC) Date: Wed, 10 Oct 2018 13:33:30 -0500 From: Josh Poimboeuf To: Andy Lutomirski 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 Subject: Re: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function" Message-ID: <20181010183330.ootwmz6deazg2k2n@treble> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181010181605.arsyjxwdztztrjih@treble> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 10 Oct 2018 18:33:36 +0000 (UTC) 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 01:16:05PM -0500, Josh Poimboeuf wrote: > > > +#define DEFINE_STATIC_CALL(tramp, func) \ > > > + DECLARE_STATIC_CALL(tramp, func); \ > > > + asm(".pushsection .text, \"ax\" \n" \ > > > + ".align 4 \n" \ > > > + ".globl " #tramp " \n" \ > > > + ".type " #tramp ", @function \n" \ > > > + #tramp ": \n" \ > > > + "jmp " #func " \n" \ > > > > I think this would be nicer as an indirect call that gets patched to a > > direct call so that the update mechanism works even before it's > > initialized. (Currently static_branch blows up horribly if you try to > > update one too early, and that's rather annoying IMO.) > > Yeah, that would be better. It would also allow trampoline function > pointers to work, which I think you mentioned elsewhere. And then I > shouldn't trample this code in __static_call_update() -- that was > already kind of nasty anyway. Re-reading your suggestion, I may have misunderstood what you're suggesting here, but I'm thinking about doing something like what you proposed earlier: GLOBAL(tramp) jmp *current_func(%rip) ENDPROC(tramp) That is, doing an indirect jump instead of the above direct jump, so that any previous references to the trampoline would still work (and it would also work during early boot). Though it should probably be a retpoline instead of an indirect jump. -- Josh