Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3932172imu; Mon, 12 Nov 2018 03:03:21 -0800 (PST) X-Google-Smtp-Source: AJdET5ewW+woQlE2LkoiI6DoB9cfycFUXApdmlDil9JURoBqcxcbuf+RKdwFpFzuzdy/5lTlbv+f X-Received: by 2002:a62:76c9:: with SMTP id r192-v6mr450415pfc.17.1542020601023; Mon, 12 Nov 2018 03:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542020600; cv=none; d=google.com; s=arc-20160816; b=joMd0HNJKK4WyK2u1QTeM+ickdN1ZrpdWnSZ49fgXJoaHdqwm/h3IFojAQbmDu9N9s GUJFV5KseKrHmcUOLIxQ8I6WfytM2TYgExyMYVuvFdqnmw3cnxrMms2LaU4An8Theeo8 uhUlRfqteoISPaNShlmC2bjkpheFYwmL9KBWxRmfIjshl58VePCrrJuYGRq6AGZRXWcX +/7FbfhoLaJPG/lg8qzMHRq+hfozwqBRf/W3IS9c3qq449xXlsNBBLTmwdspd8kKtgzS ddFQYQc0HmnXRyGqixbdhfT+Ghk980hcY9GTYhJfNP2YHUQKcvhkqiRu0SCVjoUc4u2v JUew== 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; bh=QrcGqgx2MALHISCbjlqYy8suewnk4e7VWGlGyF+3pVQ=; b=I36Mo2YWAaL2cXJMSo9lNplyYJCKU63Crl3cCGKIYtuNpsAeg5hQ1dF4vxB3nRLMUt EUN+xkvzrSRlaztTRtbMmZWjP/fXo76MJ01gzNgiIENdGMpOs5IujYLwkDCVJRDjIv7D HCFkWZi+//pcZyuiOMsDsPNsJdQt8xwh/wed1y25yYLi14qlBEn5vixm6ZXPavP3mUv/ Eona2mn8CmtzUVC+HHCD7FJIWIR754dzCwvKi5kunw6ryb+0pcS0PCou1UidVekDt5LA Mt5ynIHYoN8als7PBTw/LLjZlwLHxy/Ofx+c19RyhEXg4LGrz3ewYEmDtXRYn0eVAqgn kUyw== 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 w17-v6si16106364pgk.497.2018.11.12.03.03.05; Mon, 12 Nov 2018 03:03:20 -0800 (PST) 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 S1729238AbeKLUyN (ORCPT + 99 others); Mon, 12 Nov 2018 15:54:13 -0500 Received: from verein.lst.de ([213.95.11.211]:49788 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728431AbeKLUyN (ORCPT ); Mon, 12 Nov 2018 15:54:13 -0500 Received: by newverein.lst.de (Postfix, from userid 2005) id 931DE67358; Mon, 12 Nov 2018 12:01:27 +0100 (CET) Date: Mon, 12 Nov 2018 12:01:27 +0100 From: Torsten Duwe To: Ard Biesheuvel Cc: Will Deacon , Catalin Marinas , Julien Thierry , Steven Rostedt , Josh Poimboeuf , Ingo Molnar , Arnd Bergmann , AKASHI Takahiro , linux-arm-kernel , Linux Kernel Mailing List , live-patching@vger.kernel.org Subject: Re: [PATCH v4 2/3] arm64: implement live patching Message-ID: <20181112110127.GA30967@lst.de> References: <20181026142008.D922868C94@newverein.lst.de> <20181026142152.5F0D868C95@newverein.lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 08, 2018 at 01:42:35PM +0100, Ard Biesheuvel wrote: > On 26 October 2018 at 16:21, Torsten Duwe wrote: > > /* The program counter just after the ftrace call site */ > > str lr, [x9, #S_PC] > > + > > /* The stack pointer as it was on ftrace_caller entry... */ > > add x28, fp, #16 > > str x28, [x9, #S_SP] > > Please drop this hunk Sure. I missed that one during cleanup. > > @@ -233,6 +234,10 @@ ftrace_common: ^^^^^^^^^^^^^^ > > ldr x28, [fp, 8] > > str x28, [x9, #S_LR] /* to pt_regs.r[30] */ > > > > +#if defined(CONFIG_LIVEPATCH) && defined(CONFIG_FUNCTION_GRAPH_TRACER) > > + mov x28, lr /* remember old return address */ > > +#endif > > + > > ldr_l x2, function_trace_op, x0 > > ldr x1, [fp, #8] > > sub x0, lr, #8 /* function entry == IP */ > > @@ -245,6 +250,17 @@ ftrace_call: > > > > bl ftrace_stub > > > > +#if defined(CONFIG_LIVEPATCH) && defined(CONFIG_FUNCTION_GRAPH_TRACER) > > + /* Is the trace function a live patcher an has messed with > > + * the return address? > > + */ > > + add x9, sp, #16 /* advance to pt_regs for restore */ > > + ldr x0, [x9, #S_PC] > > + cmp x0, x28 /* compare with the value we remembered */ > > + /* to not call graph tracer's "call" mechanism twice! */ > > + b.ne ftrace_common_return > > Is ftrace_common_return guaranteed to be in range? Conditional > branches have only -/+ 1 MB range IIRC. It's the same function. A "1f" would do the same job, but the long label is a talking identifier that saves a comment. I'd more be worried about the return from the graph trace caller, which happens to be the _next_ function ;-) If ftrace_caller or graph_caller grow larger than a meg, something else is _very_ wrong. > > +#endif > > + > > #ifdef CONFIG_FUNCTION_GRAPH_TRACER > > Can we fold these #ifdef blocks together (i.e, incorporate the > conditional livepatch sequence here) I'll see how to make it fit. But remember some people might want ftrace but no live patching capability. Thanks for the review! Torsten