Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2868376yba; Mon, 6 May 2019 12:55:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhh26vjNMCbAlOxBsgn0hkVJa2hsu6UA+twOe/P2api91Jd6U9JxWMJo6eld01ngEpfp/c X-Received: by 2002:a63:4553:: with SMTP id u19mr33224538pgk.353.1557172524454; Mon, 06 May 2019 12:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557172524; cv=none; d=google.com; s=arc-20160816; b=hWbFjlv/Vlh+TN688N7LA9EPAoqKxIwhKCPqc1IAvXJ6xh7yDCYuBy0QPMzD+ITEMR k2RMYXuYz3nIfywkDmv/SfVdJFcZZ9J+M6eURO4EDIMnIvbemQCC8EjKbW1rzxOC+Zkm 4IBza9p/sdMxpXdCvR/7Mor3tNJUb/0evTb8iWRcGRg1IYI9pi5bXsS93srldBrNb9L5 jgc65Bqb68QDpgEUnrE+wph5dsygRGY4SL3Q+p/L8K+c7i+VoQDZXRcdmBU6ESFxi2Ao iCxkZ3PXc0Y3UuzrZUNqZQrbhfZuCcwmu5xC85xkleYxNtnvK4s7DEwL5RNHWajcYTnl /vzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=v4kkKa3SRWQVadtU9idY39CCQftkxcpIoOM0XAJqBTM=; b=yIOzace/p5+3YgSGvxFyiV25hblCySh2zbrp8O50emjy/nWiORVRwJEpFC4Me/bccB dLv6q24BwuRU7vMG+XEY8AnAkpIUGovIOwSuIqAdEgCgVnVVjmnvkKWQJYbzjk+l7wcY Kt1W9lR9TJ9s4WsGm/aS7qRgyNa6n3mNO8ITwteDjJBMA2zez5aDKI+1feM4CFAPSbvq 8qHQz7tFsSEF9XXFH96xxZaiP5ChjkY2ZQoj9H1qhh2DWe6Zf+8NelPj9BpDMJ+95zg+ 7MGrpfbA0nvlwFkI9MKIPF4m2SH3sn4FhrwvX5cVVim9IfuQFUhlrIV0G9zrvBhOYPI+ Ljgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=cdF+EPKS; 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 j63si8147958pge.132.2019.05.06.12.55.08; Mon, 06 May 2019 12:55:24 -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=@linux-foundation.org header.s=google header.b=cdF+EPKS; 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 S1726584AbfEFTxc (ORCPT + 99 others); Mon, 6 May 2019 15:53:32 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43604 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbfEFTxc (ORCPT ); Mon, 6 May 2019 15:53:32 -0400 Received: by mail-lf1-f65.google.com with SMTP id u27so9785420lfg.10 for ; Mon, 06 May 2019 12:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v4kkKa3SRWQVadtU9idY39CCQftkxcpIoOM0XAJqBTM=; b=cdF+EPKS6Ge2/s30X7OzfVs/i8EBdXNa487B1p2vGBTd+n7CgEMvurpKHpXcLVem3u rzevt8MxZIrbBVHT/2blPyzn4vnzFxGcHXwbP4Rlh59f3LBxbz5pPdNbdmV6lS7efsQa 93j00k6IAskp5TeuRRIvJP0yqXdlZxHNFN5Nw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=v4kkKa3SRWQVadtU9idY39CCQftkxcpIoOM0XAJqBTM=; b=JwP7q6Pg/DIPEfmu88PbWaP7YujOaH7+8Bpr1/zm16YW5f7cHOjPzAIdmqmEb0C80p +6BcxxZz6Dej1poQ66mhsuzvOha0T/miDNJHv2b2Fz/RB1CPzWw4Hwuz9GhJOMvkyOlP N0d3UXimIExDZHuLQymk91Q3AAHgqvhInG3VBBeHfx4wjJSXrMd8X1+AeVRNFX/d8lGa ME3Pl4kEN/nOUnNUO4Zkf0gnIpjH1lSXVO5wxleHK3vUR8hJtW8hGXO7+wFhUcCFgwHq nEE2Ch6e9yhvgYd6zd95AFn1RVyXdhu6Yhh8e0uO+NyKpc0RsesGP5cQHb4nPEqQozHs WJbA== X-Gm-Message-State: APjAAAWIiUeREOLLqDo3stcIenu2OUyZrEgEGlarveYP0DYd4jZH5xhK AaLcpe2HbHYzvti3zjEZiFff/dKtIzE= X-Received: by 2002:ac2:55b5:: with SMTP id y21mr8391971lfg.84.1557172409666; Mon, 06 May 2019 12:53:29 -0700 (PDT) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id k8sm1090668ljc.91.2019.05.06.12.53.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 12:53:29 -0700 (PDT) Received: by mail-lf1-f48.google.com with SMTP id v18so7849770lfi.1 for ; Mon, 06 May 2019 12:53:29 -0700 (PDT) X-Received: by 2002:ac2:43cf:: with SMTP id u15mr13815824lfl.67.1557171988295; Mon, 06 May 2019 12:46:28 -0700 (PDT) MIME-Version: 1.0 References: <20190502181811.GY2623@hirez.programming.kicks-ass.net> <20190502202146.GZ2623@hirez.programming.kicks-ass.net> <20190502185225.0cdfc8bc@gandalf.local.home> <20190502193129.664c5b2e@gandalf.local.home> <20190502195052.0af473cf@gandalf.local.home> <20190503092959.GB2623@hirez.programming.kicks-ass.net> <20190503092247.20cc1ff0@gandalf.local.home> <2045370D-38D8-406C-9E94-C1D483E232C9@amacapital.net> <20190506081951.GJ2606@hirez.programming.kicks-ass.net> <20190506095631.6f71ad7c@gandalf.local.home> <20190506130643.62c35eeb@gandalf.local.home> <20190506145745.17c59596@gandalf.local.home> In-Reply-To: <20190506145745.17c59596@gandalf.local.home> From: Linus Torvalds Date: Mon, 6 May 2019 12:46:11 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC][PATCH 1/2] x86: Allow breakpoints to emulate call functions To: Steven Rostedt Cc: Peter Zijlstra , Andy Lutomirski , Linux List Kernel Mailing , Ingo Molnar , Andrew Morton , 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 , "open list:KERNEL SELFTEST FRAMEWORK" , stable Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 6, 2019 at 11:57 AM Steven Rostedt wrote: > > You should have waited another week to open that merge window ;-) Hmm. I'm looking at it while the test builds happen, and since I don't see what's wrong in the low-level entry code, I'm looking at the ftrace code instead. What's going on here? *pregs = int3_emulate_call(regs, (unsigned long)ftrace_regs_caller); that line makes no sense. Why would we emulate a call to ftrace_regs_caller()? That function sets up a pt_regs, and then calls ftrace_stub(). But we *have* pt_regs here already with the right values. Why isn't this just a direct call to ftrace_stub() from within the int3 handler? And the thing is, calling ftrace_regs_caller() looks wrong, because that's not what happens for *real* mcount handling, which uses that "create_trampoline()" to create the thing we're supposed to really use? Anyway, I simply don't understand the code, so I'm confused. But why is the int3 emulation creating a call that doesn't seem to match what the instruction that we're actually rewriting is supposed to do? IOW, it looks to me like ftrace_int3_handler() is actually emulating something different than what ftrace_modify_code() is actually modifying the code to do! Since the only caller of ftrace_modify_code() is update_ftrace_func(), why is that function not just saving the target and we'd emulate the call to that? Using anything else looks crazy? But as mentioned, I just don't understand the ftrace logic. It looks insane to me, and much more likely to be buggy than the very simple entry code. Linus