Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3937893imu; Mon, 12 Nov 2018 03:08:35 -0800 (PST) X-Google-Smtp-Source: AJdET5ejhteWyeYRWFlkcaQRhh2FCojS9zFspsEUvw+rW9ihlnpGPQjIUF7t+jTfk34ASrXP7rD9 X-Received: by 2002:a17:902:5e4:: with SMTP id f91-v6mr513232plf.75.1542020915746; Mon, 12 Nov 2018 03:08:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542020915; cv=none; d=google.com; s=arc-20160816; b=R6aopXudN9ayd+/b1cH9GFpnwQstrrRq5DTjOeFdUAHrUsPjfGsyXVjUVmxRQ9OYqg G9dpaGp6J2jqWmEccwWX2H0ztP3N0qvgD4CnbQcbj/30SD8fAnjoeTNU5MAOikj5iQ+K 1cQkU9LWZlN93O1HtOrBBzObzzBMTAsGhk4gnsj3ZtKivnbGBjR9t3ol4zJE0Ui4CjyQ +Ion8l8auoF6BnjT72xCKMxgqdRAKwznTVsV8Cxo2HLlTVuedF2x0DjUJ9eUC++IA4Ar ysquVkDxrkg3rgjK/qBRxlcKADDhxkFy+0WSVTY4FobGZr3d0/bdi4QRQtPsOSBpMPxG q4tw== 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=8YezcMUk03N87CvBb8SLjCGbVQkYfKSc0s2gnQldkZg=; b=HCl4D6C+3eC86QG8JZJidpQM6Fxo0RUAKMgV5KZCShtpJcbC+o+K+bA5VxRzBPkgnZ q168W4Ags7ZrTsxIXjzDTi6/GsqfGJZ/0Ie3oruYF/9HYdaLGGCbVcV3EPyiUi/8WcAk UyFxHVZwsiyQ+2F6o7MK0a0BpSOLPaNBba5Yvq/TG+PU4TemO6EkIs73wUenOuqDjNPV DlVxrD7brYjnmA4zLczhIw25o7db1C+HeReIg359h4FXpfyj+FpXQj8WVJDenxEBEi5e V/6N6yxSsuaiiHgYXCR1NipGCqfSK8f0u7LqDuQHH8f7vhY9xOnesLcf4ZNHgcnSv6Rh wvSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GdIvPT77; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j7-v6si16398542plt.349.2018.11.12.03.08.20; Mon, 12 Nov 2018 03:08:35 -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; dkim=pass header.i=@linaro.org header.s=google header.b=GdIvPT77; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729345AbeKLU7K (ORCPT + 99 others); Mon, 12 Nov 2018 15:59:10 -0500 Received: from mail-io1-f66.google.com ([209.85.166.66]:36010 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729233AbeKLU7K (ORCPT ); Mon, 12 Nov 2018 15:59:10 -0500 Received: by mail-io1-f66.google.com with SMTP id m19so239239ioh.3 for ; Mon, 12 Nov 2018 03:06:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8YezcMUk03N87CvBb8SLjCGbVQkYfKSc0s2gnQldkZg=; b=GdIvPT77oHnGKF7K6dPpIODvAjRSoJB8Ppara6ycXiwOsh3fyLJ/tvDH3jpfj/d17T 2byf3FhcJi6pj+MWxRWe7kg+gAdtsNQcJ3m7ULFQ6NETwxQNhormsBHcdwhs+eTuUZu0 l6xBYOP8DiAokqE7eWgj1ho4p2ByXXnxwpgG4= 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=8YezcMUk03N87CvBb8SLjCGbVQkYfKSc0s2gnQldkZg=; b=aPtbiGD8yzxLbEwlYYSCreNegXW57Y9cXYE4AjSUZQ5Z96c758AJYO7cdnzOk2Fn2/ cQ6jI0QgBtnljXmaLAAQqqVXWBF+aPQVMObD0MvT9v94YLsjCogrfmZLZAaYwgTcLw4c 5cDdkb/SsgIKsy8oUE4hUpJ+2H47IECHAQRRUbFu8x3gr4DlmVfk0CF9bQrvc+4ddPJB vfx2KVP0bEdKrTBOcUmOoOXajRdVR119PaZ6i39fwLOSw0EmtJr0btCcQFhoHuPRxv5e OBufPJuEmsHWcJbOlIRoakbcvAnJ4Gfv4+mjt0dw3/ejhPZJM7x4YlmF0T4+czwJIr/K y0YA== X-Gm-Message-State: AGRZ1gKw7uIVi+hnH1GT38OSTxvCjp+6TCAfJiF+5ynRwL8s5nDH3De4 Jvwfo+S935/+KRi5YzAYFVvQ4QY0/8Sk+eVnvhlESw== X-Received: by 2002:a6b:5d01:: with SMTP id r1mr315724iob.170.1542020784131; Mon, 12 Nov 2018 03:06:24 -0800 (PST) MIME-Version: 1.0 References: <20181026142008.D922868C94@newverein.lst.de> <20181026142152.5F0D868C95@newverein.lst.de> <20181112110127.GA30967@lst.de> In-Reply-To: <20181112110127.GA30967@lst.de> From: Ard Biesheuvel Date: Mon, 12 Nov 2018 12:06:13 +0100 Message-ID: Subject: Re: [PATCH v4 2/3] arm64: implement live patching To: Torsten Duwe 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 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, 12 Nov 2018 at 12:01, Torsten Duwe wrote: > > 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. > Ah ok. I confused myself into thinking that ftrace_common_return() was defined in another compilation unit > > > +#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. > Sure. I simply mean turning this #if defined(CONFIG_LIVEPATCH) && defined(CONFIG_FUNCTION_GRAPH_TRACER) #endif #ifdef CONFIG_FUNCTION_GRAPH_TRACER #endif into #ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifdef CONFIG_LIVEPATCH #endif #endif