Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4351237imm; Mon, 8 Oct 2018 20:46:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV61iiyma6rpHJXuRvkCudAbT3+czc/GEsrbL2N5xJkGR8KQwNl/mHFia3GEWSVFod+vxU0Bo X-Received: by 2002:a62:c40f:: with SMTP id y15-v6mr28118457pff.161.1539056797277; Mon, 08 Oct 2018 20:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539056797; cv=none; d=google.com; s=arc-20160816; b=0i6YAqIhr6jMi4NCuZre8oLwSn7sCbnVgGs5v6ZkijmZWdHJZmtp7RquG+BRfo9bby NfJvbkQsDkyho0w+WG+3GIXLtdGT7q53f8RTrDczMEls2vqzn61HIdc/jzM8Kc9EKlrS TfOiTmELpX3twSA7p1xG0xiXP2Ev/H9+c3CG2swtc+NDIwEGXE89ZwNtQueTqrmVQB4J 4Hdd9q/+Div4+keJQdtADzDuKQjM3vVQIxQSuEN682xwrU9vC0a8HvinqMvoaRcZ6F8r QeU6Nhr7ky8iyaefLEFusOmwL9chqptqwoBQD9kv/jTUYoePoEDjdzEQlNAC0kExqLed LmRw== 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 :dkim-signature; bh=lK/CO/mAJoDnjGNk5BEsIDKCSa3QeeccoS2JrtYXKXE=; b=fQ9yIFdnD+GcDDjQXByXcCnEKIFR6ihdESzgLZZOrELQcZ/QqwHkcJ+caHNLs2mkMa 2TxtKZIsF8TwjcDJIeFEJZWWD7fwpHnSyMLr3gaVFxC4r1p7U7aQI3pM1Vho1sSs9YlI hKsKKUkEkGI5iyNdtfvq3uJZggO/ThINu/MuRaC/uie0HsZYlCJ1kcpF9yZrVXpl+4uo Zuggx5bvSrbDVgY9mFM9W9Jt98frNlhIv3qUyxrFebXJSBaicqw+vHhzEhPoGrsunt19 FrlCEDUUdvQxK8bqD5DdR0UNkPXHzlANQf6lo01WCdylN1pjgyLji6AoJRFW/yxxQrv9 0wWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y1PgeYG5; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7-v6si19168247plq.32.2018.10.08.20.46.22; Mon, 08 Oct 2018 20:46:37 -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=@kernel.org header.s=default header.b=Y1PgeYG5; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726503AbeJIK64 (ORCPT + 99 others); Tue, 9 Oct 2018 06:58:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:51924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbeJIK64 (ORCPT ); Tue, 9 Oct 2018 06:58:56 -0400 Received: from devbox (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (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 CA3F62077C; Tue, 9 Oct 2018 03:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539056646; bh=7wj4aMoFQ0dYpT7wtlEKeVqG8wIOflWbhKLJCv9luNk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Y1PgeYG5IVT9H6gyM83PXZn8lQSLfraReBb5ckWXevYrByYzYMlX6fWNk+f+v4lKa ecalwgVY7UTeutfd/Elg0NuS5yn1bmAefERgN4eKwvcyQzytZNpIxSUDTIbaZuKI6e 1bTCmacTRhBymVM/ykS9iU5ad2XF85+ZkeeZe+HQ= Date: Tue, 9 Oct 2018 12:44:01 +0900 From: Masami Hiramatsu To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Ingo Molnar , Andrew Morton , Thomas Gleixner , Peter Zijlstra , Masami Hiramatsu , Mathieu Desnoyers , Matthew Helsley , "Rafael J . Wysocki" , David Woodhouse , Paolo Bonzini , Josh Poimboeuf , Jason Baron , Jiri Kosina Subject: Re: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function" Message-Id: <20181009124401.6005e2a39c760851aa54e600@kernel.org> In-Reply-To: <20181006015720.634688468@goodmis.org> References: <20181006015110.653946300@goodmis.org> <20181006015720.634688468@goodmis.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 05 Oct 2018 21:51:11 -0400 Steven Rostedt wrote: > +typedef long dynfunc_t; > + > +struct dynfunc_struct; > + > +#define arch_dynfunc_trampoline(name, def) \ > + asm volatile ( \ > + ".globl dynfunc_" #name "; \n\t" \ > + "dynfunc_" #name ": \n\t" \ > + "jmp " #def " \n\t" \ > + ".balign 8 \n \t" \ > + : : : "memory" ) > + I have just a question, what is this different from livepatch? :) I think we can replace the first 5 bytes of the default function to jmp instruction (to alternative function) instead of making this trampoline. IOW, as far as I can see, this is changing ---- call %reg (or retpoline_reg) ---- to ---- call dynfunc_A dynfunc_A: jmp func_A or altered_func_A ---- If so, why don't we put the jmp on default func_A directly? ---- call func_A func_A: "jmp altered_func" or "original sequence" ---- (this is idealy same as jprobes did) Of course we have to arbitrate it with ftrace (fentry) but it may not so hard (simplest way is just adding "notrace" on the default function) BTW, I think "dynamic_function" may not correct name, it may be "alternative_function" or something like that, because this function must be replaced system-wide and this means we can not use this for generic function pointer usage which depends on thread context (like file_operations). But good for something pluggable code (LSM?). Thank you, -- Masami Hiramatsu