Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1696566pxv; Sat, 10 Jul 2021 12:09:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWABd8n5sqCxYXZkimmhY/sx3bWWXrBZqbXa644PKj4eCKLFKDzzGT2Yb4upaFR5TTNxm2 X-Received: by 2002:a17:907:6297:: with SMTP id nd23mr43240588ejc.62.1625944191424; Sat, 10 Jul 2021 12:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625944191; cv=none; d=google.com; s=arc-20160816; b=OLZgheW2ISvk7ofqpfY4Mvm7Sr+gBEBuVwoXgVgw1zeAdvWtJi3pOIKtYjHj9lydfd bntf6AnlKSwYJTFQA7pd4Gy8kil5JYZr4iPwnk04MgHP8s7Z1FGdSwkWGS2psN2zi8BT wfoa31OoR1efFxrwJxJz0OMIqK8uF4RqksQM6we6WtgCuyBNKPPZl3hIPToy6RwdoBnG WdcI1DJe9kOy2ISHrp7vMo8cAH/4+9+NM5lSeYClvtVlM0MApsKDF6LeFvltL7FV5J+z hxWMUQ7qqxF6/i2Gj327Cg/+uBmZq1+rckt3mrXvfJfhtr878DDEI+pTJsed/GGHY/AZ k7Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WY2G4cBLrLCEOZ7o93bnRE51RtVPXt+mCwJHsXQT/sk=; b=LrUQwmvFNIMqxPcQuG1jELxAxARKW3x9dRs3r6p0GqQYwOhTf5jftja9JrPPDndzID k68VkI4+136uLE+jwXDw63Dzobpfeet3XUdhWNwcL1oAhuS10jfeI3jYLqVNXIEvjUJt SwGHEsKc2/u4K4RmgKBUmxUu3CtP67eSi/+Pxcaiy5w8aH2pA/YzWgcitwpgewxU2SN9 CsmTM0lNb9sWy7CYAf2MAQwzBBqV1z4wNZwgf52bkhZbRiY/l6wrNa+Xkl7FOWOttcfT TNaXvxCxjpDbGBpZxM/fO/MtUbyuJGHBdijZNWbEbsVZZ3BG0bxNOihY9BPEG30U4yMw 8rTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XXTZkcvH; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s24si11640313ejs.124.2021.07.10.12.09.21; Sat, 10 Jul 2021 12:09:51 -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=@redhat.com header.s=mimecast20190719 header.b=XXTZkcvH; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbhGJTEz (ORCPT + 99 others); Sat, 10 Jul 2021 15:04:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44252 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbhGJTEy (ORCPT ); Sat, 10 Jul 2021 15:04:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625943728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WY2G4cBLrLCEOZ7o93bnRE51RtVPXt+mCwJHsXQT/sk=; b=XXTZkcvHZkq1so90VDRAz0j+m4P+ZCdDIse+eHWthPDjt++jhDdeUMf3YkIGHpCQBNTQB0 vSTFufMDopBvItrDeYaiEuHUYVj6+tWPQ3yr1ZMK2+yRK4HwrMv2QQC9kk2h0SBFlJjinU LUK5/BC64MjIko5pAPrQQ+p/rKlcdp0= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-120-T-rFOrsDOLadi0KBxkComA-1; Sat, 10 Jul 2021 15:02:07 -0400 X-MC-Unique: T-rFOrsDOLadi0KBxkComA-1 Received: by mail-qk1-f200.google.com with SMTP id a6-20020a37b1060000b02903b488f9d348so9764869qkf.20 for ; Sat, 10 Jul 2021 12:02:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WY2G4cBLrLCEOZ7o93bnRE51RtVPXt+mCwJHsXQT/sk=; b=AwOYv4psFbyyDxB4yOAaFNUDH4sqt4/49uZvbyvGfQXQ78pEWCg6OjGO6H9DyMwZME nBkd9/Mg8Z2wpVeLA6j5eOwNx24orB1NU3oazcwSrlM4hh2ScoraCuQQXNPVptNRbiIg hBgl2sUPN4GknwzN1lABG7tFTs/RxkQCxNvpufMV25d7Yh5ZVXfOiS2priR8dM1Khcbg G3vDY+EALzxSqyzK3kEnmrEoqAJzdTXFNJe/hTWP/yzQpf7IPXcz3ASN9G1qTY0erDSS cLYDiVjbvyYTxi2gbB3apt+yzIW9nByQT0O8m13dAFXBYD2dcsWQh9LsuN5LILfqPaXV 75nA== X-Gm-Message-State: AOAM5339c5q7vJVcCtALJptftx7paGnxK+trywPHQS83lFEw0Sw3tY/l wn+FRwrV9kGHTySVRtQEqTrUxDA3gBk5TLzcwOB9kQ98I4VNCY5U0Zlj2MbZ0Z5cE9t55AY0MBu vzgpMFDJa/7YPF54E1Ee4Fbqg X-Received: by 2002:a05:620a:109a:: with SMTP id g26mr9206574qkk.25.1625943726997; Sat, 10 Jul 2021 12:02:06 -0700 (PDT) X-Received: by 2002:a05:620a:109a:: with SMTP id g26mr9206558qkk.25.1625943726757; Sat, 10 Jul 2021 12:02:06 -0700 (PDT) Received: from treble ([2600:1700:6e32:6c00::15]) by smtp.gmail.com with ESMTPSA id 5sm3597556qtb.22.2021.07.10.12.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Jul 2021 12:02:06 -0700 (PDT) Date: Sat, 10 Jul 2021 12:01:43 -0700 From: Josh Poimboeuf To: Masami Hiramatsu Cc: Ingo Molnar , Steven Rostedt , 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: <20210710190143.lrcsyal2ggubv43v@treble> References: <162399992186.506599.8457763707951687195.stgit@devnote2> <162399996966.506599.810050095040575221.stgit@devnote2> <20210710003140.8e561ad33d42f9ac78de6a15@kernel.org> <20210710104104.3a270168811ac38420093276@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210710104104.3a270168811ac38420093276@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 10, 2021 at 10:41:04AM +0900, Masami Hiramatsu wrote: > Hi Ingo and Josh, > > On Sat, 10 Jul 2021 00:31:40 +0900 > Masami Hiramatsu wrote: > > > > > +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? > > I think I got what you meant. Let me summarize the issue. > > In case of CONFIG_FRAME_POINTER=n, it is OK just adding UNWIND_HINT_FUNC. > > In case of CONFIG_FRAME_POINTER=y, without STACK_FRAME_NON_STANDARD(), > the objtool complains that a CALL instruction without the frame pointer. > --- > arch/x86/kernel/kprobes/core.o: warning: objtool: __kretprobe_trampoline()+0x25: call without frame pointer save/setup > --- > > If we just add STACK_FRAME_NON_STANDARD() with UNWIND_HINT_FUNC macro, > the objtool complains that non-standard function has unwind hint. > --- > arch/x86/kernel/kprobes/core.o: warning: objtool: __kretprobe_trampoline()+0x1: BUG: why am I validating an ignored function? I'm thinking this latter warning indicates an objtool bug (as the BUG warning claims). If a function is ignored with STACK_FRAME_NON_STANDARD() then objtool should probably also ignore its hints. Then we should be able to get rid of the #undef/#ifdef UNWIND_HINT_FUNC silliness. The other warning is correct and STACK_FRAME_NON_STANDARD() still needs to be behind '#ifdef CONFIG_FRAME_POINTER' since the function is missing a frame pointer. So maybe we can make a STACK_FRAME_NON_STANDARD_FP() or similar. I'll post a few patches. -- Josh