Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2463107rdh; Wed, 27 Sep 2023 03:32:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECKhnIGItuAWSk4cgIRoQJATDrJEJxNkD3I5eC6PQG/EbJTWOmzh5hG4DNSaFdKGwa4iHJ X-Received: by 2002:aca:1102:0:b0:3a7:d566:8b5e with SMTP id 2-20020aca1102000000b003a7d5668b5emr1546095oir.44.1695810767117; Wed, 27 Sep 2023 03:32:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695810767; cv=none; d=google.com; s=arc-20160816; b=FOsUDByTXyonJpSRhwdblgDYVG2GLB0QgbQ0Vxc5jVK+5syq+NSLjlJXCGM3Ro9Jmd W9f7QF06jVssl4F8uGNEER3gkZcUFhtnm9kKiE7WvVgYoFO3ZRx8W4JJxvlUtqWIz2H/ aq06vJn411+llcq78kiqYCOVtyOsZc3e13TOosNeVNAc6ncvWJQWQW6UaRIpE8wdW4vZ 8x/zWWI/JkzvWhtctAtJYJjpRRfkT0wvImTGGGPMtfsyfFODhuWpD9jtO/eu2/t7Brpx auWMpflKUtRGjzs+go82UFGDBJ5ecaqAR66WGsammbW/a3Q98L8TFRPu/pOhYwERjzbK fgQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=MsEOCkf764Q3dKIqalGeljSWHcCsOgwi2vMZJMsT/4A=; fh=6z7D/fzwe/n26OIhr+lLw7PK2lEJR79hAw0R8+QEBAI=; b=YiZKeEcbTwITq8ziQIAxWMWWidzgJs16qznJ/UI/4TlkxA3dbohmpuGb8Riaf2sRXU mYFcycy55PusqU8KMC5qfAaX2WcEUi5vXjYntZ8NNkI3OZVz6O/BEQYD11XKL/WjYvjf 4laRRH9LXnyEd5DUJt7KmgTEz4mPWC8RHoupL71iWB2agoeYY4UXrTEDA8ywMJtLulWA sWgxjcncSR4tBQctLVJZ/EsTvLXuxPu3wOYy7suEWNsPCfUNaqHPLctaAuvI9EczH2uH 8Bo7OeM+bgF0xJ9vx6ytsuIcD7hLvpdPbndgpXXooDYsRV8LrKpgtPQdyhA8IRDQV16S /Qnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RJ2L3aiM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id r12-20020aa7988c000000b006933e759416si589392pfl.305.2023.09.27.03.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 03:32:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RJ2L3aiM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0358281BE2CC; Wed, 27 Sep 2023 03:23:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231422AbjI0KXd (ORCPT + 99 others); Wed, 27 Sep 2023 06:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231235AbjI0KXG (ORCPT ); Wed, 27 Sep 2023 06:23:06 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB668449A; Wed, 27 Sep 2023 03:11:19 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84DF4C433C8; Wed, 27 Sep 2023 10:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695809478; bh=AsqrDF9NU5xeBJ5ZD8/j8B6x2uUVmpdua9PB6GUbGBU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RJ2L3aiM74bOH7cDQ4Jb3leOE49w45romXH+DmI9x30rE3CErmU1XRY2KNXxJES7m Sm0uVOwqtYyCOPZIiEvmXxO4SLjmfOoCUhI1LYyrzm1Fr0xDnFS+A/hEYQ7zCC3Kj2 BPDe/uBTiqybVVN4/OCW7TSSJdphz/spEFLcL6eb8XrcEnYPV8Qq4oLDdJfMALxuS7 yLmJqt74fBvM7AoQkgnFkUCGWuQ53tUJK+X2QSiM4vvZqDsv0NX/v8ClNC3NMk5TAi nqZ3sLehBXVwIWYUZzqIh+qM0oCAudKRSuV+hbc4R93FgC3kB8weQGXHHtKWPWpP4A UHnvDbnXcdpxQ== Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2c12fc235fbso124029621fa.0; Wed, 27 Sep 2023 03:11:18 -0700 (PDT) X-Gm-Message-State: AOJu0YyVGhzuOGyi3SWnMBPkp18zKw3Bws8RgFsgWzh//Pr8tl/C8Wtz hvdZ3BIH+V2y1YQqgqguzoNKT7VUlQxVGEANHb0= X-Received: by 2002:a2e:700d:0:b0:2bc:fd50:573d with SMTP id l13-20020a2e700d000000b002bcfd50573dmr678352ljc.23.1695809476737; Wed, 27 Sep 2023 03:11:16 -0700 (PDT) MIME-Version: 1.0 References: <20230927055954.3755-1-quic_aiquny@quicinc.com> In-Reply-To: From: Ard Biesheuvel Date: Wed, 27 Sep 2023 10:11:05 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ARM: kprobes: Explicitly assign register for local variables To: "Aiqun(Maria) Yu" Cc: linux@armlinux.org.uk, mhiramat@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@quicinc.com, quic_lijuang@quicinc.com, linux-arm-msm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 27 Sep 2023 03:23:42 -0700 (PDT) On Wed, 27 Sept 2023 at 09:44, Aiqun(Maria) Yu wr= ote: > > On 9/27/2023 5:26 PM, Ard Biesheuvel wrote: > > Hello Maria, > > > > On Wed, 27 Sept 2023 at 06:00, Maria Yu wrote= : > >> > >> Registers r7 is removed in clobber list, so compiler may choose r7 for > >> local variables usage, while r7 will be actually updated by the inline= asm > >> code. > > > > The inline asm does not update R7, it preserves and restores it. > That is the asm is updating r7 purposely and compiler still choose r7 > for the asm local varialbe and use it inside the asm code. > So the change is to fix the issue when "r7 is removed from the clobber > list of current asm code while actually r7 shouldn't be choosed for the > current asm local variables". > The issue is only reproducible when ftrace is not enabled, and r7 is > removed from the current clobber list. > > Let me have the assemble code that will make you understand better. > > --the original code: > "mov r11, r7 \n\t" > ... > "ldmia %[regs], {r0-r7} \n\t" > "blx %[fn] \n\t" > ... > "mov r7, r11 \n\t" > > --After compile to choose register for [fn] and [regs]. > mov r11, r7 > ldr=E2=80=83=E2=80=83r7, [r1, #16] //r7 used for store asi->insn_fn > ... > ldmia.w=E2=80=83=E2=80=83ip, {r0, r1, r2, r3, r4, r5, r6, r7} > blx r7 > ... > mov r7,r11 > > The current change is to avoid by fix the registers for local variable > usage and not choose r7 for [fn]. > OK, I understand now, thanks. Would it help if we just always enabled frame pointers for this source file= ? --- a/arch/arm/probes/kprobes/Makefile +++ b/arch/arm/probes/kprobes/Makefile @@ -9,6 +9,7 @@ test-kprobes-objs :=3D test-core.o ifdef CONFIG_THUMB2_KERNEL obj-$(CONFIG_KPROBES) +=3D actions-thumb.o checkers-thumb.o test-kprobes-objs +=3D test-thumb.o +KBUILD_CFLAGS +=3D -fno-omit-frame-pointer else obj-$(CONFIG_KPROBES) +=3D actions-arm.o checkers-arm.o obj-$(CONFIG_OPTPROBES) +=3D opt-arm.o