From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63238C433EF for ; Wed, 18 May 2022 19:58:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242270AbiERT6L (ORCPT ); Wed, 18 May 2022 15:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242217AbiERT6H (ORCPT ); Wed, 18 May 2022 15:58:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73951227817; Wed, 18 May 2022 12:58:06 -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 AA5686191F; Wed, 18 May 2022 19:58:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21195C34113; Wed, 18 May 2022 19:58:01 +0000 (UTC) Date: Wed, 18 May 2022 15:57:59 -0400 From: Steven Rostedt To: Xu Kuohai Cc: , , , , , Catalin Marinas , Will Deacon , Ingo Molnar , Daniel Borkmann , Alexei Starovoitov , Zi Shen Lim , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Thomas Gleixner , Borislav Petkov , Dave Hansen , , , Shuah Khan , Jakub Kicinski , Jesper Dangaard Brouer , Mark Rutland , Pasha Tatashin , Ard Biesheuvel , Daniel Kiss , Steven Price , Sudeep Holla , Marc Zyngier , Peter Collingbourne , Mark Brown , Delyan Kratunov , Kumar Kartikeya Dwivedi Subject: Re: [PATCH bpf-next v4 2/6] ftrace: Fix deadloop caused by direct call in ftrace selftest Message-ID: <20220518155759.4054d9a2@gandalf.local.home> In-Reply-To: <20220517071838.3366093-3-xukuohai@huawei.com> References: <20220517071838.3366093-1-xukuohai@huawei.com> <20220517071838.3366093-3-xukuohai@huawei.com> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 May 2022 03:18:34 -0400 Xu Kuohai wrote: > After direct call is enabled for arm64, ftrace selftest enters a > dead loop: > > : > 00 bti c > 01 mov x9, x30 : > 02 bl ----------> ret > | > lr/x30 is 03, return to 03 > | > 03 mov w0, #0x0 <-----------------------------| > | | > | dead loop! | > | | > 04 ret ---- lr/x30 is still 03, go back to 03 ----| > > The reason is that when the direct caller trace_direct_tramp() returns > to the patched function trace_selftest_dynamic_test_func(), lr is still > the address after the instrumented instruction in the patched function, > so when the patched function exits, it returns to itself! > > To fix this issue, we need to restore lr before trace_direct_tramp() > exits, so rewrite a dedicated trace_direct_tramp() for arm64. > > Reported-by: Li Huafei > Signed-off-by: Xu Kuohai > --- Acked-by: Steven Rostedt (Google) -- Steve