Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp312972pxb; Tue, 9 Feb 2021 00:35:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJylBo6TrRd56qb7xF2TyIDBwlWUDpBrdCHq2yvJMlNhhF4NsJHVUSYc2PWcDJPtjOWRKB3E X-Received: by 2002:a17:906:ecfb:: with SMTP id qt27mr20910055ejb.123.1612859724707; Tue, 09 Feb 2021 00:35:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612859724; cv=none; d=google.com; s=arc-20160816; b=Z1Kco/BX/YxIs713YKNDWuIvg+66H8i3I3J/Q+Nq/uUPZCvUspt2A5MCDMNWtivYWG Scsuz/ADjEi/9YVDZ9uknvERMyHPgdO3JRKauVh4W2CPVBn2sfiBgmwyQC5TJYlhym4a x/RcJ4nmlhJjfbzoykuTDHakegu7gLP5EHXvOjs3p7XYU4kMeczbeATtH5HrdOkD9x89 Il1yrbry6g5D8Dqbslf2K3555wmVBtszPzM+OVwqvYNXpZ+U60LtGMGNfYfr8whdRIDT bbUsVvkvPHzrBoI456oD5bZL4FxXs6dcXS0OZiv1g73ShMt9JjLl/4b5a/e7Bk7xzY5Z bnYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=pyfecs50P9KVsCyzzz/Gt8fE0sx9rerl2FkDGUpYXkM=; b=vXFYfP+4iEhaLV/Ik0uZSVgJ3dCUS18NXevJh+YYNfRHhDItI0mZNRWblZxK4vEboy LTEbrtA8f/tZobhAmVH5GPaSS8jq5+cxWk36j7DCVrVwAfmc4EPEJgon4Scymp8ZpVJj 90QYTAWoHqU+oJpEM6ZBND++nnZkb0m7d8T8hp+7cqz9m3A5CKkAWcyHhdcVsI60zjp4 Hh2oEZihu4yyB28Kh0aKqT/kKPxYPsL4xYyi6Ti2P9ihNvRaJlbYq5r3rR0Nio5PZfTG 8NBT0xuxguibnvbwOKrSFpXQAZ8p3/9d+MBSY612YOM0LodOhWK2VpTEEdCkxh+lgAjm i1QA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s10si13833507edj.416.2021.02.09.00.35.00; Tue, 09 Feb 2021 00:35:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229799AbhBIIdY (ORCPT + 99 others); Tue, 9 Feb 2021 03:33:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:49986 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229759AbhBIIdU (ORCPT ); Tue, 9 Feb 2021 03:33:20 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 760C3ACB7; Tue, 9 Feb 2021 08:32:35 +0000 (UTC) Date: Tue, 9 Feb 2021 09:32:34 +0100 (CET) From: Miroslav Benes To: Steven Rostedt cc: Peter Zijlstra , Josh Poimboeuf , Linus Torvalds , Borislav Petkov , Dave Hansen , x86-ml , lkml , Alexei Starovoitov , live-patching@vger.kernel.org Subject: Re: [GIT PULL] x86/urgent for v5.11-rc7 In-Reply-To: <20210208111546.5e01c3fb@gandalf.local.home> Message-ID: References: <20210207104022.GA32127@zn.tnic> <20210207175814.GF32127@zn.tnic> <20210207224540.ercf5657pftibyaw@treble> <20210208100206.3b74891e@gandalf.local.home> <20210208153300.m5skwcxxrdpo37iz@treble> <20210208111546.5e01c3fb@gandalf.local.home> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 8 Feb 2021, Steven Rostedt wrote: > On Mon, 8 Feb 2021 16:47:05 +0100 > Peter Zijlstra wrote: > > > > /* > > > * Convert a function address into the appropriate ftrace location. > > > * > > > * Usually this is just the address of the function, but on some architectures > > > * it's more complicated so allow them to provide a custom behaviour. > > > */ > > > #ifndef klp_get_ftrace_location > > > static unsigned long klp_get_ftrace_location(unsigned long faddr) > > > { > > > return faddr; > > > } > > > #endif powerpc has this static inline unsigned long klp_get_ftrace_location(unsigned long faddr) { /* * Live patch works only with -mprofile-kernel on PPC. In this case, * the ftrace location is always within the first 16 bytes. */ return ftrace_location_range(faddr, faddr + 16); } > > I suppose the trivial fix is to see if it points to endbr64 and if so, > > increment the addr by the length of that. > > I thought of that too. But one thing that may be possible, is to use > kallsym. I believe you can get the range of a function (start and end of > the function) from kallsyms. Then ask ftrace for the addr in that range > (there should only be one). And we can do this if a hard-coded value live above is not welcome. If I remember correctly, we used to have exactly this in the old versions of kGraft. We walked through all ftrace records, called kallsyms_lookup_size_offset() on every record's ip and if the offset+ip matched faddr (in this case), we returned the ip. Miroslav