Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6428309yba; Wed, 1 May 2019 12:05:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkjcM/xRk0aK9QwOlr5CqNC35WhuzSMqcKFFGCAeoXq9a4bbd/jIhNM98EwMz+qVx26Uot X-Received: by 2002:a62:4554:: with SMTP id s81mr81538750pfa.66.1556737548015; Wed, 01 May 2019 12:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556737548; cv=none; d=google.com; s=arc-20160816; b=cqTddCc/VBaGVjJsCr6yMfyJdhm/MjdWfQLDhMINhHatVY2h15UIizuQNdOPGk6uAH jWX0iHBVJShCdIHKo6qF0vFuJ/gWs/6O+SSN8eQZ2bivU2qjQYIULwuhjHhTghCObR1C JsDmWAlSInZwsvjKgvo0jHSFk2cHvGbgio57TQQvwq11sHQbngsJpQb4uFe9w0rquDYq KJxfRzZB8EtXaqsBh2B/7dyb2Jr6Qgj0mb5CQkkDQO3SiLeSCwbTp1shllq7co3TgWhi Rabl/b85x8pd8TseDFx3VYWnHzMu6LhpGuGQQKPk9D0m7/ASLFRM/0X3Iwv6OZTcV6bR 2Sig== 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:dkim-signature; bh=VNCyKNchmG8uJyDZBNfvh+ZXwPXv3ObxEe6ybUIbxas=; b=JG/Op5ZoNSQZYEfuVGFK81LtdHOwYiAFQ6eHwqpdhSID73RGBzUC+AixX1RmSmstEg gmVX80aF1WltVjvvFHf2gy/0SZKy/wZ7bCT9cueFWgKt0VTUf3cozukeoq2haAbgkAls ZK0AAalHAoMvjWVVS0vUyiV3XoyMDP+yeRvki5XNymMFG22wC8dKYSnQqorcyAnhQEah yD9Cd4F/8MHOk4ynkLNmKYjItJUQf0z5r0FnOasCjvOXXp3N3R8PAJIOD4jh33zvxPYA 0bx7P5N8tc12QLphpHkiGAUZ3nJAHs3h5LoJrqeMetsyzz6bMoRfRV5JcMeYRGedbyZ3 CAWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="ZPHh/iHX"; 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 j24si27994726pgh.320.2019.05.01.12.05.31; Wed, 01 May 2019 12:05:48 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="ZPHh/iHX"; 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 S1726189AbfEATEV (ORCPT + 99 others); Wed, 1 May 2019 15:04:21 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37302 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726096AbfEATEU (ORCPT ); Wed, 1 May 2019 15:04:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VNCyKNchmG8uJyDZBNfvh+ZXwPXv3ObxEe6ybUIbxas=; b=ZPHh/iHX909FhdEWVMA4QJdeW sLpmidqy0xvcDozQ+OXAes5vq91NYUU8aWQX86/k9ygeaIY4C7zZMqciOMHZ5R1OoZshv/ZPdS+K9 u1PoDqxV0n/W43OV4ZA4s7ibK6p3RWi5YjKnVE8oCGoooF0f7HgqqqOkUfPzmRSaX8pRohKrfopVj EL1OQIax2iEVJGug2UG2gK7rSdYoYkZI4YzDwida3M3580xWnQVXqAkq+B42Wz50U3v4QZ0BV8z4m vc1eMsAwaflmpXsQfy08fXm43c2+yfdiZ0P8nvRJ6GDxEf0U0pMeCIHa+EDvgIm1EKKdmbrxvjHNk FoGC73ovw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLuWF-0005bC-D6; Wed, 01 May 2019 19:03:51 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 8B6B7984EB4; Wed, 1 May 2019 21:03:48 +0200 (CEST) Date: Wed, 1 May 2019 21:03:48 +0200 From: Peter Zijlstra To: Steven Rostedt Cc: Linus Torvalds , Andy Lutomirski , Nicolai Stange , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , the arch/x86 maintainers , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Shuah Khan , Konrad Rzeszutek Wilk , Tim Chen , Sebastian Andrzej Siewior , Mimi Zohar , Juergen Gross , Nick Desaulniers , Nayna Jain , Masahiro Yamada , Joerg Roedel , Linux List Kernel Mailing , live-patching@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" Subject: Re: [RFC][PATCH] ftrace/x86: Emulate call function while updating in breakpoint handler Message-ID: <20190501190348.GT7905@worktop.programming.kicks-ass.net> References: <20190430135602.GD2589@hirez.programming.kicks-ass.net> <20190430130359.330e895b@gandalf.local.home> <20190430132024.0f03f5b8@gandalf.local.home> <20190430134913.4e29ce72@gandalf.local.home> <20190501131117.GW2623@hirez.programming.kicks-ass.net> <20190501145824.08aed43a@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190501145824.08aed43a@gandalf.local.home> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 01, 2019 at 02:58:24PM -0400, Steven Rostedt wrote: > > + if (ftrace_location(ip)) { > > + int3_emulate_call(regs, ftrace_update_func_call); > > Should be: > > int3_emulate_call(regs, (unsigned long)ftrace_regs_caller); Ah, I lost the plot a little there. > > + return 1; > > + } else if (is_ftrace_caller(ip)) { > > + if (!ftrace_update_func_call) { > > + int3_emulate_jmp(regs, regs->ip - INT3_INSN_SIZE + CALL_INSN_SIZE); > > I see what you did here, but I think: > > int3_emulate_jmp(regs, ip + CALL_INSN_SIZE); > > looks better. But that said, we could in the beginning do: > > ip = regs->ip - INT3_INSN_SIZE; > > instead of > > ip = regs->ip - 1; > > I made these updates and posted them to Linus. I was actually considering: static inline void int3_emulate_nop(struct pt_regs *regs, unsigned long size) { int3_emulate_jmp(regs, regs->ip - INT3_INSN_SIZE + size); } And then the above becomes: int3_emulate_nop(regs, CALL_INSN_SIZE); Hmm?