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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C57CC433F5 for ; Wed, 2 Feb 2022 08:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EAH6cYKYwaZPUNMFugGGlUSiJs2cIShvTBNyXQ8QjQA=; b=mMnD7OSKf743fg vdHx+vPBbxqd4bUEBCnbW8Re/EYDmVRQW6K1QXSmwfe1gTDFJs4z7BBT9quK/cz1wikhu1eF1hGWg HKeccDX98Car1JpUIY1epyyTzXjX9TiME8B4lmBXMR5dMp9OSZRiEDCGVA87CeLkyI9TUzxCZDhL+ S0rtFbJUjKgi+OZJE3OGkMUe8f44gQHR+oYRj9994khk6216Cn6746RRGHLdmjK9dhhzq8NUzDilD o5841m/QHEPZZhkZ4o6fAhaQVUDEt9L2ZedywVM6rN8OvEdo46f7xKecUDuwhsGa1fcF12lBdPQ8P csN1hrFgCHFH7DEZY45A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFAZF-00EUxe-Is; Wed, 02 Feb 2022 08:00:41 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFAZC-00EUwo-EO for linux-arm-kernel@lists.infradead.org; Wed, 02 Feb 2022 08:00:40 +0000 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 68B25617B2 for ; Wed, 2 Feb 2022 08:00:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD674C36AE2 for ; Wed, 2 Feb 2022 08:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643788836; bh=bhPp8jUboeAMU+LKBlmrjgWX1GDhy/KJB4+DOALglXc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=uAMUnEjJkLqaZ0TzoH6ij2SOhFCzKOWO4gf2jOpJ+qkW2M+n6yCoIzFxLs+QoE/KL kR0QubN0FI5LsRLiwJtTCuiwcQVZxybUWy/z9SQSAx2t3PRh5ufRT/EV0KlEF4x6wy dB/vxRMF8+hrCF5DPj0x6tx97rQoK97lKJVmQIwvqbfolt1BX1hA+KwQG9fI6d1AAc WAGLgBjpUZhBtQvzrviSgxG6xa4AmYylqYvsvgYXc12QOiYjwkjRw6DzB9RtmYQodM TEUOjbdespvrDsShJF/p1RvPxcfAS2l31FshHZrm2Tdd4cOzWRUfL/zqbhdeGSSxx7 94LaYdh414w1w== Received: by mail-wm1-f41.google.com with SMTP id l12-20020a7bc34c000000b003467c58cbdfso3893382wmj.2 for ; Wed, 02 Feb 2022 00:00:36 -0800 (PST) X-Gm-Message-State: AOAM53060azeb/baSA/HjIq1v26WK81qx4ok8//Z6JzEi3EUeqnMGjwg C/uKevKKBDsnUuObo1qAY6mW9DbsQxG+vY30zJU= X-Google-Smtp-Source: ABdhPJyH63WxpOYMKPvbROZX11WgAKBk57tx3UKM/bE19opOvMSsrz+sG+INmdZPsigP2CU25LWNWvCigY/H7xLZpAs= X-Received: by 2002:a1c:a90d:: with SMTP id s13mr4930170wme.32.1643788835143; Wed, 02 Feb 2022 00:00:35 -0800 (PST) MIME-Version: 1.0 References: <20220131170347.381551-1-ardb@kernel.org> <20220131170347.381551-10-ardb@kernel.org> <20220201221839.2617126c5b19ca4caafe2851@kernel.org> <20220202151033.ebe29e1256d19781ffc87ca3@kernel.org> In-Reply-To: <20220202151033.ebe29e1256d19781ffc87ca3@kernel.org> From: Ard Biesheuvel Date: Wed, 2 Feb 2022 09:00:22 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 09/12] ARM: kprobes: treat R7 as the frame pointer register in Thumb2 builds To: Masami Hiramatsu Cc: Russell King , Linux ARM , Steven Rostedt , Sudeep Holla , Cristian Marussi , Nathan Chancellor , Nick Desaulniers , Arnd Bergmann , Linus Walleij X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220202_000038_580863_4E1B91BD X-CRM114-Status: GOOD ( 35.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 2 Feb 2022 at 07:10, Masami Hiramatsu wrote: > > On Tue, 1 Feb 2022 15:05:25 +0100 > Ard Biesheuvel wrote: > > > On Tue, 1 Feb 2022 at 14:18, Masami Hiramatsu wrote: > > > > > > On Mon, 31 Jan 2022 18:03:44 +0100 > > > Ard Biesheuvel wrote: > > > > > > > Thumb2 code uses R7 as the frame pointer rather than R11, because the > > > > opcodes to access it are generally shorter. > > > > > > > > This means that there are cases where we cannot simply add it to the > > > > clobber list of an asm() block, but need to preserve/restore it > > > > explicitly, or the compiler may complain in some cases (e.g., Clang > > > > builds with ftrace enabled). > > > > > > > > Since R11 is not special in that case, clobber it instead, and use it to > > > > preserve/restore the value of R7. > > > > > > Thanks Ard for fixing thumb2 issue! > > > > No problem. Although I'm still not 100% sure we can simply > > preserve/restore the frame pointer like that. What is the expected > > result when an exception occurs in the kprobes emulation code? > > What kind of exception would you mean? If it is a synchronous > exception and can return to where the exception happens, the > all registers must be restored. So as long as it is restored > it is OK to me. > So what should happen if a backtrace is triggered while the kprobes emulation code is calling into a function? > > The main problem is that with unwind info unwinding, the stack pointer > > and the frame pointer need to be mutually in sync, and with the > > kprobes stack frames in the middle, this is no longer correct - the > > emulated code is executed with the frame pointer value that was > > captured when the probe was hit, by the stack has a couple of frames > > added. > > > > > BTW, have you build the kernel with CONFIG_KPROBES_SANITY_TEST=y? > > > It should check the backtrace from kprobe and kretprobe at boot time. > > > > > > > Just checked, and those work fine. > > Thank you for testing! > > Reviewed-by: Masami Hiramatsu > Thanks! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel