Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5612214yba; Tue, 30 Apr 2019 18:36:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxByaSBuRKg02m5bOFQLkSUc+C18PvpVQDlu26Wc9XKOANB22APvg2dhjeNaTcVhaoCpDsC X-Received: by 2002:a17:902:442:: with SMTP id 60mr75336364ple.107.1556674604061; Tue, 30 Apr 2019 18:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556674604; cv=none; d=google.com; s=arc-20160816; b=Q1WM23tMkySzdRpt0G5cn2aLe+9Gf9PJd16OUgpiyaCThs/LuMCkbA74FS02PY/7gM QEOC7LSDWevnYdPXTyH1EwQZdknK6/3x84j5MTDMOLYYsdGRHJWdpmygy+a5hGb9PmrM JgrMnsqweWXQDhCZ2a8qOXiZrvPrL9cBSHXuquUsp/k5ItPVlvoO0us7XP/Ed9rPJEuM JB6YbdxwbB9EFLj3PBED9S4Pvz/dApjzh92qwuJqpIEJN+cyuKmfMGI9GE1b5SfrELzG a17CgZ/2ah4gnmvfnsGY3M8uEG9Cz+UIct6wX2AOPI3e0Ff/roBxaUWST17FrdOneevH yLFw== 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=zf6efFpuKQAbATkiVdgyWHbLWALnoEeuOXgaW2L64iY=; b=eSoLz8VblgMTgdp4wqRI2Nk/reM9orFuA42PTa1xuJp4t3dLqjjM5BiZAOG5WNCGOe bKFJj1dXqhuZ6O6v7GFITIKO1llHA+r7gu/C/MykafNa/xRhGIByrcOUsdNtKXtsuYDg 9w/IRPaXbZHwHAl9oB57EPurj5hrRHg6aJ3glcy935Yf5uN/KE0flqrQ7zVjRHEnDFO3 nt8+vnV8l7kWdCIm83iDt3cywiSi+IQKMsxXkauBIP65wsatSWDz2bG+dF4PJU843Z84 1YB928Iu6j+pEcbO/7UE6QcsZzC6As8zAfaT0rS0d33HErfqRpNZApETbhO9227D8oZq sYzg== 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 u79si40813511pfa.6.2019.04.30.18.36.25; Tue, 30 Apr 2019 18:36:44 -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 S1727344AbfEABfY (ORCPT + 99 others); Tue, 30 Apr 2019 21:35:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:57002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbfEABfX (ORCPT ); Tue, 30 Apr 2019 21:35:23 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 EC08A21734; Wed, 1 May 2019 01:35:19 +0000 (UTC) Date: Tue, 30 Apr 2019 21:35:17 -0400 From: Steven Rostedt To: Linus Torvalds Cc: Andy Lutomirski , Peter Zijlstra , 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 v2] ftrace/x86: Emulate call function while updating in breakpoint handler Message-ID: <20190430213517.7bcfaf8e@oasis.local.home> In-Reply-To: <20190430175334.423821c0@gandalf.local.home> References: <20190428133826.3e142cfd@oasis.local.home> <20190430135602.GD2589@hirez.programming.kicks-ass.net> <20190430130359.330e895b@gandalf.local.home> <20190430132024.0f03f5b8@gandalf.local.home> <20190430134913.4e29ce72@gandalf.local.home> <20190430175334.423821c0@gandalf.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-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 Tue, 30 Apr 2019 17:53:34 -0400 Steven Rostedt wrote: > + if (ftrace_location(ip)) { > + /* A breakpoint at the beginning of the function was hit */ > + if (in_nmi()) { > + /* NMIs have their own trampoline */ > + this_cpu_write(ftrace_bp_call_nmi_return, (void *)ip + MCOUNT_INSN_SIZE); > + regs->ip = (unsigned long) ftrace_emulate_call_nmi; > + return 1; > + } > + this_cpu_write(ftrace_bp_call_return, (void *)ip + MCOUNT_INSN_SIZE); > + if (regs->flags & X86_EFLAGS_IF) { > + regs->flags &= ~X86_EFLAGS_IF; > + regs->ip = (unsigned long) ftrace_emulate_call_irqoff; > + /* Tell lockdep here we are enabling interrupts */ > + trace_hardirqs_on(); This isn't good enough. The return from interrupt does call lockdep saying interrupts are disabled. Need to add the lockdep tracking in the asm as well. Probably easier to move it from inline asm to ftrace_X.S and use the lockdep TRACE_ON/OFF macros. -- Steve > + } else { > + regs->ip = (unsigned long) ftrace_emulate_call_irqon; > + } > + return 1; > + } else if (is_ftrace_caller(ip)) { > + /* An ftrace trampoline is being updated */ > + if (!ftrace_update_func_call) { > + /* If it's a jump, just need to skip it */ > + regs->ip += MCOUNT_INSN_SIZE -1; > + return 1; > + } > + if (in_nmi()) { > + /* NMIs have their own trampoline */ > + this_cpu_write(ftrace_bp_call_nmi_return, (void *)ip + MCOUNT_INSN_SIZE); > + regs->ip = (unsigned long) ftrace_emulate_call_update_nmi; > + return 1; > + } > + this_cpu_write(ftrace_bp_call_return, (void *)ip + MCOUNT_INSN_SIZE); > + if (regs->flags & X86_EFLAGS_IF) { > + regs->flags &= ~X86_EFLAGS_IF; > + regs->ip = (unsigned long) ftrace_emulate_call_update_irqoff; > + trace_hardirqs_on(); > + } else { > + regs->ip = (unsigned long) ftrace_emulate_call_update_irqon; > + } > + return 1; > + } > > - return 1; > + return 0; > }