Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2320231ima; Mon, 22 Oct 2018 07:55:49 -0700 (PDT) X-Google-Smtp-Source: AJdET5dMytLL1FDwkrbWLp6tSBzQxOzo1BBujUPyxDVRE5umk1Qlc+/IGill+v/EjlGjs6PKteRg X-Received: by 2002:a17:902:7847:: with SMTP id e7-v6mr5769933pln.104.1540220149220; Mon, 22 Oct 2018 07:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540220149; cv=none; d=google.com; s=arc-20160816; b=CWCFr+9jhj30W3pqY/nN1tk2rv+qWNFlZfQb1McNBfVxoOia1n8eIn+XkCZNh4WCy+ r3LmytZYHbq7f0LGoXwsXgyo6ksjiu3W9K5lseEYqa0UXNI785TRLPYMDBUKbPaJoyQm wgoWosAPtGHc0QTS5YlHjPuqmpvO4i9xTPzXBxeSe/zdmvwH9CGSpwV3LvH6uDPrTgJk F0+q9yBcvXCdNa5f83jA5D/x2doMbce5ggWd62TLD4iCfMucL27WphNTrOM9ecCUwo96 +dVULBMl8yWEW796s4cvliRO06QPieWCH4wXn6+Pre4QOOW+lLI/d0yojf/FhDkW+V4M tYWA== 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=jxKtUYuCQ7T2Eufj3X61QJc04YNgpaD008gTT3UdsKA=; b=b79w5amCuYixPXFi3GwHzoeFVanBLwnAIr313KuOoUHmkdwo2UbeqO83Yrd9UltWHL +MwBKv6cMKlBdM0gdUmStFMZMh0TZFHLJxCNOGivpBmJBXK2W+xO9guPG2l7qKLV7wem xKjpxofwxdIUh02KwSGVYOi6ze9zEGO/7FjWg8YCKRavLEzzw2T1PZF2qdwfH4PN94GN LBNNAjjW44S2s4Z2ISc9VGnvszIt14qxi9t491sJEL0BsJBEyxrbmLmqymsv6LVGdGlu Wg8tmovfbaMi59XE5cy3P9hFX82/c451+HadI4pt/ErFmwbXX8mw5OgIjmsxg26VSRzv YRjg== 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 k192-v6si33572078pgc.415.2018.10.22.07.55.33; Mon, 22 Oct 2018 07:55:49 -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 S1728247AbeJVXNm (ORCPT + 99 others); Mon, 22 Oct 2018 19:13:42 -0400 Received: from verein.lst.de ([213.95.11.211]:36907 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727702AbeJVXNm (ORCPT ); Mon, 22 Oct 2018 19:13:42 -0400 Received: by newverein.lst.de (Postfix, from userid 2005) id 3ADE168BDF; Mon, 22 Oct 2018 16:54:48 +0200 (CEST) Date: Mon, 22 Oct 2018 16:54:48 +0200 From: Torsten Duwe To: Miroslav Benes Cc: Ard Biesheuvel , Jessica Yu , 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 v3 3/4] arm64: implement live patching Message-ID: <20181022145448.GA22918@lst.de> References: <20181001140910.086E768BC7@newverein.lst.de> <20181001141652.5478C68BE1@newverein.lst.de> <20181018125820.iw54zbirq74ulknj@linux-8ccs> 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 Mon, Oct 22, 2018 at 02:53:10PM +0200, Miroslav Benes wrote: > On Sat, 20 Oct 2018, Ard Biesheuvel wrote: > > So I suppose this could get interesting in cases where modules are far > > away from the kernel (i.e., more than -/+ 128 MB). Fortunately, the > > modules themselves are always placed in a 128 MB window, but this > > window could be out of reach for branches into the kernel proper. If > > we find ourselves in the situation where we need to patch calls into > > the kernel proper to point into this module, this may get interesting, > > since the PLT entries *must* be allocated along with the module that > > contains the branch instruction, or the PLT entry itself may be out of > > range, defeating the purpose. > > Hm... Torsten, didn't you have to solve something similar in powerpc case? At address ranges: that was the TOC pointer issue, that is an array of addresses and other 64-bit constants with a reference to it kept in a register, whose value is local to any module. PPC64 needs 5 instructions to load a 64-bit value immediate, arm has the ldr_l macro. So in short: no. We were discussing a few nasty tricks to reconstruct the TOC value from the code addresses, but ended up with a solution that is clean in that respect. At PLTs: ppc64 uses, IIRC, a regular trampoline slot to get to all called functions, including ftrace and friends. So for e.g. live patch kernels the total number, as predetermined, is only incremented by 2. Only the trampoline _code_ for ftrace was modified. I assume with "branches" you mean "branch with link" a.k.a a subroutine call? All references to external symbols are allocated a PLT entry, right? ftrace / live patching calls are alway intercepted at the called function. ===========--------======--------- The interceptor then uses a special trampoline to go to ftrace_caller, which does the rest. Am I missing something? Torsten