Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4999959yba; Wed, 8 May 2019 06:26:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyv7dPB/m0GueMi2f/tXmYltgn9zyeRpWpROHthKHG07YUF/DmoB8HeNzbQnKnToyVay1S9 X-Received: by 2002:a17:902:854c:: with SMTP id d12mr47491496plo.150.1557322004979; Wed, 08 May 2019 06:26:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557322004; cv=none; d=google.com; s=arc-20160816; b=nMzzqGWaReFB45mESq2oPY2h7TJXsVLI4s2+sh7eL01rMalgngHRmc7VrlPzbQuDWw XwQfLkXmmdWZPyAK0j0I604VxICRYqpcbzIWifS5vJNaMPFNUTsZfJtUE4TvCz36uNUK mbuWPAT2vmHSQYM9ChKD3HEb5TINxiIk60Iihu7AnfA5E6v/l8mEog+gILcS0JICZjd1 J0BDVobEQHSKR4EpYqLP9+20Hij/nyiJfb+z+15PnSmi4it9aQNW88/FOaqVsAyfka9Y qV0kZhj4T2eXkafL7aZ1V26+S5WPWV9tQLTeq0YnhqRkMZpIvVLC8Fg1gIefFXxbIVha LjSQ== 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=WtSXTUk2G0Suyzcf2hE6Me4atsX5G2msN1+TTVp7YuY=; b=CQPrB/nwqNi0RoZJv+vTdEDqkA4JUiY7TDRgqfwknqy0hN3YQVo1mRDSQiQ6IzWvCv tQKgMBIL9yC6iiqf4J1pno4pkeBCRgN5al6r8Pn0wlqV2b1KwKbER/6LLrvnQxT4V9+H /Xpukq4uPgv4OrvfOS/X8vomKgTD3JzIl+w7OBV/VWsNenhroqnf2wR88SP57R3CVJpj NDZ4FI+tpir6Gy6uw2d060byA/Cgdni/vVWBZZeCas/8dAVl3Iyx0rOyeYfH4qukyWEm oFWOZDygxaFKAiSSQvkE3Z2hC8UAe6Bb9UKhb+2AeK73TNTO+2AXW6O3wT3F8LVFm7F/ +a2A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si22051522plp.26.2019.05.08.06.26.28; Wed, 08 May 2019 06:26:44 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727169AbfEHMm5 (ORCPT + 99 others); Wed, 8 May 2019 08:42:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22190 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726527AbfEHMm5 (ORCPT ); Wed, 8 May 2019 08:42:57 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6C90307E04C; Wed, 8 May 2019 12:42:56 +0000 (UTC) Received: from treble (ovpn-123-166.rdu2.redhat.com [10.10.123.166]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12FFE19729; Wed, 8 May 2019 12:42:50 +0000 (UTC) Date: Wed, 8 May 2019 07:42:48 -0500 From: Josh Poimboeuf To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Ingo Molnar , Andrew Morton , Andy Lutomirski , Nicolai Stange , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Shuah Khan , Konrad Rzeszutek Wilk , Tim Chen , Sebastian Andrzej Siewior , Mimi Zohar , Juergen Gross , Nick Desaulniers , Nayna Jain , Masahiro Yamada , Joerg Roedel , linux-kselftest@vger.kernel.org, Masami Hiramatsu Subject: Re: [PATCH 2/4] x86/kprobes: Fix frame pointer annotations Message-ID: <20190508124248.u5ukpbhnh4wpiccq@treble> References: <20190508074901.982470324@infradead.org> <20190508080612.721269814@infradead.org> <20190508115416.nblx7c2kocidpytm@treble> <20190508120416.GL2589@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190508120416.GL2589@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 08 May 2019 12:42:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 08, 2019 at 02:04:16PM +0200, Peter Zijlstra wrote: > On Wed, May 08, 2019 at 06:54:16AM -0500, Josh Poimboeuf wrote: > > On Wed, May 08, 2019 at 09:49:03AM +0200, Peter Zijlstra wrote: > > > The kprobe trampolines have a FRAME_POINTER annotation that makes no > > > sense. It marks the frame in the middle of pt_regs, at the place of > > > saving BP. > > > > > > Change it to mark the pt_regs frame as per the ENCODE_FRAME_POINTER > > > from the respective entry_*.S. > > > > > > Signed-off-by: Peter Zijlstra (Intel) > > > --- > > > arch/x86/kernel/kprobes/common.h | 32 +++++++++++++++++++++++--------- > > > 1 file changed, 23 insertions(+), 9 deletions(-) > > > > > > --- a/arch/x86/kernel/kprobes/common.h > > > +++ b/arch/x86/kernel/kprobes/common.h > > > @@ -6,14 +6,15 @@ > > > > > > #include > > > > > > +#ifdef CONFIG_X86_64 > > > + > > > #ifdef CONFIG_FRAME_POINTER > > > -# define SAVE_RBP_STRING " push %" _ASM_BP "\n" \ > > > - " mov %" _ASM_SP ", %" _ASM_BP "\n" > > > +#define ENCODE_FRAME_POINTER \ > > > + " leaq 1(%rsp), %rbp\n" > > > #else > > > -# define SAVE_RBP_STRING " push %" _ASM_BP "\n" > > > +#define ENCODE_FRAME_POINTER > > > #endif > > > > > +#ifdef CONFIG_FRAME_POINTER > > > +#define ENCODE_FRAME_POINTER \ > > > + " movl %esp, %ebp\n" \ > > > + " andl $0x7fffffff, %ebp\n" > > > +#else > > > +#define ENCODE_FRAME_POINTER > > > +#endif > > > > We should put these macros in a header file somewhere (including > > stringified versions). > > Probably a good idea. I'll frob them into asm/frame.h. > > Do the x86_64 variants also want some ORC annotation? Maybe so. Though it looks like regs->ip isn't saved. The saved registers might need to be tweaked. I'll need to look into it. -- Josh