Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp564721pxb; Tue, 9 Feb 2021 07:18:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfg77O6LtEUMK9bKpapQWixRa/r3DJStBdtaQ1JoDeOC+N7B30KMrJ61OrCsQkF7r0coFm X-Received: by 2002:a17:906:3395:: with SMTP id v21mr22547438eja.331.1612883926833; Tue, 09 Feb 2021 07:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612883926; cv=none; d=google.com; s=arc-20160816; b=vbHyFt1yegwi0rOWQZ5QybZFDF0J+YEeAufVsVIKewK+vZf9WXrFAEXVUxTZNzJEOa gAwvTuHmITvyWIBxKxpRld80SHy1aXPvsD3A6fJwkIvXhN3iHNazXpsXVdRx+DmJKnjb 9WXIFe2Fy5rDsOUmQBUWP+apGTG1E8YJSIxL9f+NJ/8O6PJ5B2de52BRDg62/qljA4KJ QgDY2EcAk+5DtCOkV6pb4W3Qln2QNctgOJ3FrOvH40xUWRolRocpZyDsXttGbfSpA/Fr Y/r6rjkobj87+YBeh/Tt8edTaXyOV4ufYMCz5LwwvczafIN47rc0qVwYUZaIQa7+Dn/O 8law== 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=y/22GnivNiWT91YkSEdHF/UG1V4g5uKzorzUB3rr6Ps=; b=o4SdPNdgv5ex7YCQ7MVM85dZ1XXaA7CHQLX8j11MB2tin79qZCDIv7uPBhBLGHNtV8 fS2BcGVlIIQMfcT8QfPuQTJJrrazl+iOtuSFbxEqry+AZ7XtpSHBR2kx6PBSflZogied 1xsKhudzSYXuBk28UsBXcKIK84CJulISDmFEbNVJe+RF9DJocu/8VpxLTKsn/voL3QFK 4IcFIyaU1Q9I6FONUdVwutI5KcfT/ZCDnUgp+dSCrGmbzKmOIkEWJRcQ9mKYsBR57i3Y fdouJi1QjWVnSEmheUa248L8t8+gTUjyk1enJVSReSakoOQVd5viOdyGcY0Euv4QOwsr WE7w== 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 cc22si15513126edb.80.2021.02.09.07.18.22; Tue, 09 Feb 2021 07:18:46 -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 S232418AbhBIPQt (ORCPT + 99 others); Tue, 9 Feb 2021 10:16:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:44366 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231654AbhBIPQs (ORCPT ); Tue, 9 Feb 2021 10:16:48 -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 DCF20B1E0; Tue, 9 Feb 2021 15:16:05 +0000 (UTC) Date: Tue, 9 Feb 2021 16:16:05 +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: <20210209094953.65d2f322@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> <20210209094953.65d2f322@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 Tue, 9 Feb 2021, Steven Rostedt wrote: > On Tue, 9 Feb 2021 09:32:34 +0100 (CET) > Miroslav Benes wrote: > > > 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. > > Either way is fine. Question is, should we just wait till CET is > implemented for the kernel before making any of these changes? Just knowing > that we have a solution to handle it may be good enough for now. I'd prefer it to be a part of CET enablement patch set. Miroslav