Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp769579pxv; Fri, 9 Jul 2021 08:35:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4oF11l8VdjKCabkqnDWT2R58y9+nbd7BS87+R1sjvLFSngnTqCM79iuVEAqC3gC8KRQUp X-Received: by 2002:a05:6402:4393:: with SMTP id o19mr47106747edc.263.1625844929843; Fri, 09 Jul 2021 08:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625844929; cv=none; d=google.com; s=arc-20160816; b=RKz6VVj+G9iQoK2I4ouY9dd58O4IcQcEXPdF1jdNvL4Omj6NZDbCcTphczxzKm+zNI plP4IQPX0QsHYjPVAx8KKi1t1999xSrqkJ/0C+8/bFa/dx+1JyvrZhIeispBAMXn0dXK OelEkR2RAETSUtM8bVSlALtCmCyZc5MzUA5zkfJday5FKUVHqszWEaHX43Yxrj9lsmxm ysBfN/jsmrOzqZ0FYvUF41dhyMDC/H51md8E6oXj/0ZstcqwpE2uqN9cYM0a1bJGZNPc F7jTAfOnX3Khcdlz+g5s8XugZx0RsshZFj8KzSbmFS6Owcj4S77u2GLEV2xy391qGAgR OGqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=HULvGrlv18ZT/jyMx7FY0dVpDDWoE72LpYUXM9v7UUw=; b=eMrooGdy6BLRDJKZ2x9rZY89o49kjii6ncGv5RpdTWR/0SiKEFXJxRg48gVTZyF/a2 mzrXvsl1xwFKLsroRZeSBaEWeNlcNkUYKm8hb3KPfEOJTii1bU6iONcLyjRsVJWjwhzo 8Q4JfgPb38g0UhBEZ5j661LcWUdG1ImUOMYQrLThQIRoZ6m0aXhvUHx6bOljFbv/ILtb 3bIvrcgMZBr27epWWWq3alePnFMrzptsRaD1SPssIghf7mC3oT4aquCamet/83Y3lCA6 UN+p7fG0gyD7nkx957WOePhKrWVRv3zjjD90mEW1iPNx/mHdrS62zZLUPjjvXt298rKe EvYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nAuK98c1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t10si7166746edd.423.2021.07.09.08.34.46; Fri, 09 Jul 2021 08:35:29 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nAuK98c1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232345AbhGIPe2 (ORCPT + 99 others); Fri, 9 Jul 2021 11:34:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232248AbhGIPe2 (ORCPT ); Fri, 9 Jul 2021 11:34:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E700F613C1; Fri, 9 Jul 2021 15:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625844704; bh=EJGDTErqhFfO+4+vO3fnUq+RuTjIL8rzCpz3Xvt7RAg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nAuK98c1w4esf+28ABqRQMXZ/TSLSo9cs01eDTxLDD0GrdE4WUkH+DmwMCQUdYjlJ wdNRiLZJvshUGJUkF+BBUz6X9Bd9mOwMhoyy3LxVlWM7eHfVVLpCOtly+/JM8DupTL 85Pl0hown2YU/9o/yw/N+1LWRZnglUVckqA4YW8yukfeZGkO1fWC+VLyDny/h+lHNX HGM9eG0HFYOyCFpSyxraIk6ozDWDBAVCLqRkU2t2KxJASRnz4Q9zE+tdKUnV68/NQD x0BWRQq6fHp0I8QnjnQntzO4ArOqSNuvEQ+gi2g20UhdcNLGqD0slG59NtV5nX1LY7 lbDQ1y6yAOYvw== Date: Sat, 10 Jul 2021 00:31:40 +0900 From: Masami Hiramatsu To: Ingo Molnar Cc: Steven Rostedt , Josh Poimboeuf , X86 ML , Daniel Xu , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kuba@kernel.org, mingo@redhat.com, ast@kernel.org, Thomas Gleixner , Borislav Petkov , Peter Zijlstra , kernel-team@fb.com, yhs@fb.com, linux-ia64@vger.kernel.org, Abhishek Sagar , Andrii Nakryiko Subject: Re: [PATCH -tip v8 05/13] x86/kprobes: Add UNWIND_HINT_FUNC on kretprobe_trampoline code Message-Id: <20210710003140.8e561ad33d42f9ac78de6a15@kernel.org> In-Reply-To: References: <162399992186.506599.8457763707951687195.stgit@devnote2> <162399996966.506599.810050095040575221.stgit@devnote2> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 5 Jul 2021 10:02:47 +0200 Ingo Molnar wrote: > > * Masami Hiramatsu wrote: > > > From: Josh Poimboeuf > > > > Add UNWIND_HINT_FUNC on kretporbe_trampoline code so that ORC > > information is generated on the kretprobe_trampoline correctly. > > What is a 'kretporbe'? Oops, it's a typo. > > > Note that when the CONFIG_FRAME_POINTER=y, since the > > kretprobe_trampoline skips updating frame pointer, the stack frame > > of the kretprobe_trampoline seems non-standard. So this marks it > > is STACK_FRAME_NON_STANDARD() and undefine UNWIND_HINT_FUNC. > > What does 'marks it is' mean? Sorry, I meant, this marks the kretprobe_trampoline as non-standard stack frame by STACK_FRAME_NON_STANDARD(). > > 'undefine' UNWIND_HINT_FUNC? > > Doesn't the patch do the exact opposite: > > > +#define UNWIND_HINT_FUNC \ > > + UNWIND_HINT(ORC_REG_SP, 8, UNWIND_HINT_TYPE_FUNC, 0) > > But it does undefine it in a specific spot: Yes, if you think this is not correct way, what about the following? #ifdef CONFIG_FRAME_POINTER STACK_FRAME_NON_STANDARD(kretprobe_trampoline); #define KRETPROBE_UNWIND_HINT_FUNC #else #define KRETPROBE_UNWIND_HINT_FUNC UNWIND_HINT_FUNC #endif > > Anyway, with the frame pointer, FP unwinder can unwind the stack > > frame correctly without that hint. > > > > Signed-off-by: Josh Poimboeuf > > Signed-off-by: Masami Hiramatsu > > Tested-by: Andrii Nakryik > > I have to say these changelogs are very careless. Sorry for inconvenience... > > > +#else > > + > > In headers, in longer CPP blocks, please always mark the '#else' branch > with what it is the else branch of. OK. > > See the output of: > > kepler:~/tip> git grep '#else' arch/x86/include/asm/ | head Thanks for the hint! > > > +#ifdef CONFIG_FRAME_POINTER > > +/* > > + * kretprobe_trampoline skips updating frame pointer. The frame pointer > > + * saved in trampoline_handler points to the real caller function's > > + * frame pointer. Thus the kretprobe_trampoline doesn't seems to have a > > + * standard stack frame with CONFIG_FRAME_POINTER=y. > > + * Let's mark it non-standard function. Anyway, FP unwinder can correctly > > + * unwind without the hint. > > s/doesn't seems to have a standard stack frame > /doesn't have a standard stack frame > > There's nothing 'seems' about the situation - it's a non-standard function > entry and stack frame situation, and the unwinder needs to know about it. OK. > > > +STACK_FRAME_NON_STANDARD(kretprobe_trampoline); > > +#undef UNWIND_HINT_FUNC > > +#define UNWIND_HINT_FUNC > > +#endif > > /* > > * When a retprobed function returns, this code saves registers and > > * calls trampoline_handler() runs, which calls the kretprobe's handler. > > @@ -1031,6 +1044,7 @@ asm( > > /* We don't bother saving the ss register */ > > #ifdef CONFIG_X86_64 > > " pushq %rsp\n" > > + UNWIND_HINT_FUNC > > " pushfq\n" > > SAVE_REGS_STRING > > " movq %rsp, %rdi\n" > > @@ -1041,6 +1055,7 @@ asm( > > " popfq\n" > > #else > > " pushl %esp\n" > > + UNWIND_HINT_FUNC > > " pushfl\n" > > SAVE_REGS_STRING > > " movl %esp, %eax\n" > > Why not provide an appropriate annotation method in , > so that other future code can use it too instead of reinventing the wheel? Would you mean we should define the UNWIND_HINT_FUNC as a macro which depends on CONFIG_FRAME_POINTER, in ? Josh, what would you think? Thank you, -- Masami Hiramatsu