Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3798323imm; Mon, 8 Oct 2018 09:39:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV6359JU/MkGoPLlDE3/CHUr58qProXNqbhZPZ3pGqz7l4XZqb8bEOJGz7WYZLMZiQIoFTydP X-Received: by 2002:a63:ef0b:: with SMTP id u11-v6mr21929441pgh.283.1539016793979; Mon, 08 Oct 2018 09:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539016793; cv=none; d=google.com; s=arc-20160816; b=z/gGI/hZjWcI+R2yWciRjrxmK/7lMdvnno0w8SdQdtFMSiT1RRKafxI0o1kkHGbIK2 TQiXFCnf3txjJhX9HG4A9/NnyZu1n67kq4FyMpk9G5FlHjJ1GM3mshV9ThslHuutUCb6 rjTdVretpYQ0pEo+Ug7s3Wcl7q2UamPwI3lz54e8V1Oaeo1+sWuwhsCdo2HhrEWbPN2p ndNq2IXTfJHGOqhT18AtzWL28ZpIQDYtz4ZmPpqI3g62zfOYdMw/aaFO2FZPUQWRU5Jh qMy7fzDKCHWrUHfCGVQkDMd1RyxNAXKPbTELv23pXiVk2IlcwJEK+dIgknMwH2jWrKpw Ib2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=GsE1z0CxjnyUbrQEYuS+qeBDWiP8l3hwq1BmchFm5Ug=; b=cqD3vFNXsWVtm9qiqo+wAL81wDxiJ/Id39P5DaSgb39D+0UM7aF/vTHSYq9DtdTTKl 61jX5H5zvGDKOL7n9ggenNrqt3k03qBPW/Of/KOqBX5UfAOR7P1dlZTU/A02siOqAAbK Cr+ixDg39zO3vLHhKEOMPZ8wCU4ihgsuTsLXTDrTnc75fpft21H7+5oJ1JHkHQVk7cFP u5i/dunsydW0tROoyUNfZ6Ia7ul43T6I5wzWwtmdlF9kGIAcDtHK8hAn37SGcOfrdn09 C0dJwum1JY1FjEgnLDV/RpZVedEa6CosN6eVvBMYbwVyyffbGo0A32zeBwgqIejB6s1c M5nw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e193-v6si18885418pfc.131.2018.10.08.09.39.38; Mon, 08 Oct 2018 09:39:53 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbeJHXwG convert rfc822-to-8bit (ORCPT + 99 others); Mon, 8 Oct 2018 19:52:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:43106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726434AbeJHXwG (ORCPT ); Mon, 8 Oct 2018 19:52:06 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8FA552089D; Mon, 8 Oct 2018 16:39:30 +0000 (UTC) Date: Mon, 8 Oct 2018 12:39:28 -0400 From: Steven Rostedt To: Andy Lutomirski Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Linus Torvalds , Ingo Molnar , Andrew Morton , Thomas Gleixner , Masami Hiramatsu , Mathieu Desnoyers , Matthew Helsley , "Rafael J . Wysocki" , David Woodhouse , Paolo Bonzini , Josh Poimboeuf , Jason Baron , Jiri Kosina , ard.biesheuvel@linaro.org, Andy Lutomirski Subject: Re: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function" Message-ID: <20181008123929.0d5313cb@gandalf.local.home> In-Reply-To: References: <20181006015110.653946300@goodmis.org> <20181006015720.634688468@goodmis.org> <20181006121211.GA5663@hirez.programming.kicks-ass.net> <20181006093905.46276505@vmware.local.home> <20181008072134.GB5663@hirez.programming.kicks-ass.net> <20181008155757.GC5663@hirez.programming.kicks-ass.net> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 8 Oct 2018 09:29:56 -0700 Andy Lutomirski wrote: > > On Oct 8, 2018, at 8:57 AM, Peter Zijlstra wrote: > > > > On Mon, Oct 08, 2018 at 01:33:14AM -0700, Andy Lutomirski wrote: > >>> Can't we hijack the relocation records for these functions before they > >>> get thrown out in the (final) link pass or something? > >> > >> I could be talking out my arse here, but I thought we could do this, > >> too, then changed my mind. The relocation records give us the > >> location of the call or jump operand, but they don’t give the address > >> of the beginning of the instruction. > > > > But that's like 1 byte before the operand, right? We could even double check > > this by reading back that byte and ensuring it is in fact 0xE8 (CALL). > > > > AFAICT there is only the _1_ CALL encoding, and that is the 5 byte: E8 , > > so if we have the PLT32 location, we also have the instruction location. Or am > > I missing something? > > There’s also JMP and Jcc, any of which can be used for rail calls, but those are also one byte. I suppose GCC is unlikely to emit a prefixed form of any of these. So maybe we really can assume they’re all one byte. > > But there is a nasty potential special case: anything that takes the function’s address. This includes jump tables, computed gotos, and plain old function pointers. And I suspect that any of these could have one of the rather large number of CALL/JMP/Jcc bytes before the relocation by coincidence. > FYI, your email client is horrible to read from decent email clients :-p Anyway, I'd like to have these "dynamic functions" be "special" where they can't be added to tables or what not. If you need to add one to a table or function pointer, then you need to have a wrapper function that does the call. I think we can come up with some kind of wrapper or linker magic to enforce this too. -- Steve