Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2255738pxp; Mon, 21 Mar 2022 15:06:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBhLOLGtF5WKRGT6lcDRVjN/mTefVbPazJAtZZnZTXaktR8xWOy3pR5eG+ahudGccZV8dM X-Received: by 2002:a63:e041:0:b0:381:1bac:ac85 with SMTP id n1-20020a63e041000000b003811bacac85mr19756597pgj.380.1647900402391; Mon, 21 Mar 2022 15:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647900402; cv=none; d=google.com; s=arc-20160816; b=CUc8y06iOY+tooxS2Ca4soWq5wO5fieu0+3td6OESG2pD2bm3Pm3tEHffvEdzw/cla 5TTmEWS2acJsGrJ/PtQy7jUg7Xn+ErtQi5h9WywXJsX5rPaea3j0NC3hYv0olu0uBgHK ObTDhsIZ0epVwAKZ3pZ4PP45JIJcgQSGqLh7xU0aFDwmpERb38yXp4UBsAiu6w2ZM4EZ UaeAvVYBadKzihgNM+Cef4vOIEnZP4UXwPo6a9zelzpYo7byeENy8S/CscV6/u8oqdMw XRHLvxxHE7ett/9jBlYz20/FGf2bidga59jtZ3T1RGcMbk1xsXb5dRxX1KtRbe4tgzQi w14A== 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; bh=GgX2CLJB8Us4JetcMM8U07LWtYW/rV9PUQpDd2KsWYk=; b=WgFIeHw51FgXL+fo9iIpT/e7+KBSZCW5zwR2ldnp0fndYsZh/JKL7WqhfmRIp/1fyO zlZWBG3FQVtBXz1yYXijEaKxhZJmnWWVDdBZzlq//hznEwJz1GQBHi9SFSXzL+O6hNMz z8yWjQm0aR4VPczHfSX5jGCAqRKuNmrdY4WIBcE80T8ejMorRZWTNLwgJloVvNm6Jk60 mg37gFZdyTJMpbtsn4uMxBf6fvUqafcZSNuU/c/uHUPZMpgmo8cvZVWU7RXH//rHbQpn cX7bH9ARDE72JH2MK3wHhIXE7tH7xaF1MKMX2mtdgm//Ii4lf0GIiHYq/hA2crXpFhV0 GIWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b21-20020a63cf55000000b003816043ef07si13952422pgj.252.2022.03.21.15.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:06:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F05F62BDA; Mon, 21 Mar 2022 14:29:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350222AbiCUP3l (ORCPT + 99 others); Mon, 21 Mar 2022 11:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350211AbiCUP3i (ORCPT ); Mon, 21 Mar 2022 11:29:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA10FDEE7; Mon, 21 Mar 2022 08:28:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5659961047; Mon, 21 Mar 2022 15:28:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3725BC340E8; Mon, 21 Mar 2022 15:28:07 +0000 (UTC) Date: Mon, 21 Mar 2022 11:28:05 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: Stephen Rothwell , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Linux Kernel Mailing List , Linux Next Mailing List , mhiramat@kernel.org, ast@kernel.org, hjl.tools@gmail.com, rick.p.edgecombe@intel.com, rppt@kernel.org, linux-toolchains@vger.kernel.org, Andrew.Cooper3@citrix.com, ndesaulniers@google.com Subject: Re: linux-next: build warnings after merge of the tip tree Message-ID: <20220321112805.1393f9b9@gandalf.local.home> In-Reply-To: References: <20220321140327.777f9554@canb.auug.org.au> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 21 Mar 2022 14:04:05 +0100 Peter Zijlstra wrote: > Ahh, something tracing. I'll go do some patches on top of it. > > Also, folks, I'm thinking we should start to move to __fexit__, if CET > SHSTK ever wants to come to kernel land return trampolines will > insta-stop working. > > Hjl, do you think we could get -mfexit to go along with -mfentry ? If we do every add a -mfexit, we will need to add a __ftail__ call. Because, the current function exit tracing works for functions, even with tail calls. int funcA () { [..] return funcB(); } Can turn into: [..] pop all stack from funcA load reg params to funcB jmp funcB Then when funcB does does it's [..] ret It will pop the call site of funcA (not the call site of funcB) and return to wherever called funcA with the proper return values. This currently works with function graph and kretprobe tracing because of the shadow stack. Let's say we traced both funcA and funcB funcA: call __fentry__ Replace caller address with graph_trampoline and store the return caller into the shadow stack. [..] jmp funcB funcB: call __fentry__ Replace caller address with graph_trampoline and store the return caller (which is the graph_trampoline that was switched earlier) in the shadow stack. [..] ret Returns to the graph_trampoline and we trace the return of funcB. Then we pop off the shadow stack and jump to that. But the shadow stack had a call to the graph_trampoline, which gets called again. Returns to the graph_trampoline and we trace the return of funcA. Then we pop off the shadow stack and jump to that, which is the original caller to funcA. That is, the current algorithm traces the end of both funcA and funcB without issue, because of how the shadow stack works. Now if we add a __fexit__, we will need a way to tell the tracers how to record this scenario. That is why I'm thinking of a jmp to __ftail__. Perhaps something like: funcA: call __fentry__ [..] push address of funcB jmp __ftail__ jmp funcB Where, __ftail__ would do at the end: ret To jump to funcB and we skip the jmp to funcB anyway. And to "nop" it out, we would have to convert it to. funcA: call __fentry__ [..] jmp 1 jmp __ftail__ 1: jmp funcB This is one way I can think of if we include a __fexit__. But to maintain backward compatibility to function graph tracing (which is a requirement), we need to be able to handle such cases. Perhaps this is a good topic to bring up at Plumbers? :-) Do I need to submit a tracing MC, or can we have this conversation at a compiler / toolchain MC? -- Steve