Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp162408yba; Wed, 8 May 2019 18:21:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0xy05KjvUx4b8tOamjkODiw1DxNTYOVb5v6BHZ2EFKi0gwUasuMQXj2p7DiObmIC7ezJY X-Received: by 2002:a65:5181:: with SMTP id h1mr1790241pgq.167.1557364907291; Wed, 08 May 2019 18:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557364907; cv=none; d=google.com; s=arc-20160816; b=Vy5G58qIQkYtSeR06QXlDx29xgAemHHbEHTJo0R0KXmMkaTGN73HTroLXtneb0OjWB XwNFKq01RCUSBu8AF95ugItH/fAjNDhP4QXDr0vdme1RKaUM8SoI2Dkg91RJY+L6Q3ZW ojXPMDgfvma2oLJXMHdFZf+SIsDKHAohAnlnSFxn/QJgMqbHzOsWonj6ArBKjRBI/+bl GVThSK0V4g3MUHffAc43aP73/EmyGnqPhsEMlCZo1/EY6ZhM2tQb4sFfqeCuigNj+mNs f4nbmtj76rsir0gCul8KOAq0//Ff9UmsvQB97ZGHpi+4GBf1mqUxeh9bX59BydmN454T LzOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=9UDJb8fx2rehY0ATalIWPe8TtCxXc3XdosLrjQLOy1E=; b=BxHBgpD/9Rsd5kGFQM9mw2Xix7Xd7VemWt95hFN1TTP7/HVaF4a9sDxBgT6H7TaLmq jHdwRDrYwK2XCM4HoFVi+EEDsIejJjAIkODTyx9pzTF8vw7eb4mMtziCxCA4p+/vex3i Eag275EkIMP98qmMtYK7fl0IIcrMPPY1JopIgV52HmrD1d/4fOnlil38bFK66XnKr7Gb 6VoCyygkTZtzyyvNrUWYHbH8OcO6RxLwV3MYvUF/nP9DJejE+uvGu7YW+dX9R/aiU6mM M/aDK7cBiViCRxzgq2fMF6tADvecjAJtHYFbjXHdNgiAGU9ZXgEi7M9OpBrLsBNytc64 RCKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qY45YTDq; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si796111pge.550.2019.05.08.18.21.30; Wed, 08 May 2019 18:21:47 -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; dkim=pass header.i=@kernel.org header.s=default header.b=qY45YTDq; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726411AbfEIBUk (ORCPT + 99 others); Wed, 8 May 2019 21:20:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:58304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725778AbfEIBUk (ORCPT ); Wed, 8 May 2019 21:20:40 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 034DC2173E; Thu, 9 May 2019 01:20:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557364838; bh=oPvPuQ74RU1mLepyoEpxjH/yNzo+8P7yFE0PP+o30Oo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qY45YTDqXQdybXAQAMPwVnrkEhhduuYyYkgZFawIL7jWuKNHik7uqDaNUS3XVNRj8 AAQqoQ2qMYdJRnT+93TWVWISLbHNk7va1yNGo0Pn8rb9yfZQqhAbAJ5krp21kfGlqw +6NfvKyNEYNLW1ddu9dBVyeqRDyn61IFvUHXciZM= Date: Thu, 9 May 2019 10:20:30 +0900 From: Masami Hiramatsu To: Josh Poimboeuf Cc: Peter Zijlstra , 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: <20190509102030.dfa62e058f09d0d8cbdd6053@kernel.org> In-Reply-To: <20190508184848.qerg3flv3ej3xsev@treble> References: <20190508074901.982470324@infradead.org> <20190508080612.721269814@infradead.org> <20190508115416.nblx7c2kocidpytm@treble> <20190508120416.GL2589@hirez.programming.kicks-ass.net> <20190508124248.u5ukpbhnh4wpiccq@treble> <20190508153907.GM2589@hirez.programming.kicks-ass.net> <20190508184848.qerg3flv3ej3xsev@treble> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Josh, On Wed, 8 May 2019 13:48:48 -0500 Josh Poimboeuf wrote: > On Wed, May 08, 2019 at 05:39:07PM +0200, Peter Zijlstra wrote: > > On Wed, May 08, 2019 at 07:42:48AM -0500, Josh Poimboeuf wrote: > > > On Wed, May 08, 2019 at 02:04:16PM +0200, Peter Zijlstra wrote: > > > > > > 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. > > > > What all these sites do (and maybe we should look at unifying them > > somehow) is turn a CALL frame (aka RET-IP) into an exception frame (aka > > pt_regs). > > > > So regs->ip will be the return address (which is fixed up to be the CALL > > address in the handler). > > But from what I can tell, trampoline_handler() hard-codes regs->ip to > point to kretprobe_trampoline(), and the original return address is > placed in regs->sp. > > Masami, is there a reason why regs->ip doesn't have the original return > address and regs->sp doesn't have the original SP? I think that would > help the unwinder understand things. Yes, for regs->ip, there is a histrical reason. Since previously, we had an int3 at trampoline, so the user (kretprobe) handler expects that regs->ip is trampoline address and ri->ret_addr is original return address. It is better to check the other archs, but I think it is possible to change the regs->ip to original return address, since no one cares such "fixed address". :) For the regs->sp, there are 2 reasons. For x86-64, it's just for over-optimizing (reduce stack usage). I think we can make a gap for putting return address, something like "kretprobe_trampoline:\n" #ifdef CONFIG_X86_64 " pushq %rsp\n" /* Make a gap for return address */ " pushq 0(%rsp)\n" /* Copy original stack pointer */ " pushfq\n" SAVE_REGS_STRING " movq %rsp, %rdi\n" " call trampoline_handler\n" /* Push the true return address to the bottom */ " movq %rax, 20*8(%rsp)\n" RESTORE_REGS_STRING " popfq\n" " addq $8, %rsp\n" /* Skip original stack pointer */ For i386 (x86-32), there is no other way to keep ®s->sp as the original stack pointer. It has to be changed with this series, maybe as same as x86-64. Thank you, -- Masami Hiramatsu