Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3446442rdb; Thu, 16 Nov 2023 09:37:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNbKDPTlL2jKl0zecJEXaoZH6MyTdp8qCmOXukiHKSWf4aLGqlOXT3jO86hTYiy/MuLGnM X-Received: by 2002:a05:6a00:ad5:b0:6bd:7cbd:15ae with SMTP id c21-20020a056a000ad500b006bd7cbd15aemr20537332pfl.26.1700156222340; Thu, 16 Nov 2023 09:37:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700156222; cv=none; d=google.com; s=arc-20160816; b=KQzBZZJCuM/gVKzWulx9dLKl++VXdVEsckAfzqUvDIbfm6GxDG+1AeGk8cq8rRpTfz HkdczVCf/rpJtWj7F/bc1cqY2Mb2yASikr0Rfl+8eudEDZsL9IR1GaBPTxu+oVKzLvgS otznV+KjUEYHOrsUD4+kHtIGwqw+I0VxM34Jc0HAr2Rw1HC4tiCMzCO2VxMlNSBXdiqA 9+NTc/ttUfeTqQe7oV6SpdyZK7QV+pYz7INVbzSDIBwjRS94tZwXO7VUyRYIxxkyOzPP 2Po99OzH0vjMR25T0Sl/cv4kQI5YXcf/uCGLXV9xBLRpOjYvq0sjgm/y45qYqtUKoTpl SIYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=56BHP8C+uMytWcDTLAW9Z0FxdMNXxNV3BalxRkroVYw=; fh=E8Y5PsKvzqNZpvgblp8awIutrTY/TWSc8zsxxtmmavc=; b=sGDV7g5q6Jxf3aJ2KGdcg3FZ96OLyOuEFRqoIwBzdm43RDSd6QFkfkD35/Zu+4nSXH WlmRlGGIQF9sS5DOnuBvTPzdoVBs0Y88JefbRPbsdzr023ifrn42+9wPSqMbHOwYCFNz E3myjdAePl/Oc8/022RvtK4m2kuNF1BebqzD9Lhbod6BZ2B2Cp55gDH2EMYJus8ZIkPb uZyqfkW2DgI8QBe5uhGEbGKMwxxFs1PMGBULt3EBffNSqZNwNQGKjdRKct+W76sYXSfM pSxmvNHnu2uALtkoILAWkFdaXetYQX8CaKKmbECzjiHkzIvxfLwv/FZr5GVPfuwd2TkK Tp4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qi+VGp9K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id a65-20020a639044000000b005bdf597ed49si9425001pge.56.2023.11.16.09.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 09:37:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qi+VGp9K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 45C8880DF99B; Thu, 16 Nov 2023 09:36:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345297AbjKPRgg (ORCPT + 99 others); Thu, 16 Nov 2023 12:36:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjKPRgf (ORCPT ); Thu, 16 Nov 2023 12:36:35 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2357181; Thu, 16 Nov 2023 09:36:31 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D666C433CA; Thu, 16 Nov 2023 17:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700156191; bh=f1MamAR5SJ3kDTjLLdjTFc1hoxE9qI+fWDwWO5NMT60=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Qi+VGp9KMuy53sSyo9JaYaStSahW4hFHR/Suwj+5r4y4WvPvgyrZInEteXBZcAoJs f/rwFVrvf5FolsF2Hu9V1sUhCzA+Rg9M6AB9UGrsH6D69tVfsgM3uYFuqrmfQD0/B7 SEOTQpToXnIpqKBKKAzXOvaNGp3tZR2Poy1ajpotdPx7KXa0u4hmeriCrfiFhQ55TF Pttk1+KPYB56y9H219EQFJFwjDrqGPn7AVC4UzYV6tiPFWc0ytcbf5F46iehDZTyjM 7xV3T/EWu/UXvhkyIsc/My0BtSIuagc1/3IpxkAA1Rsj03yFJVJlhi7920zJEEG+AC fb2+zqpfbVp0A== Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2c5210a1515so14917731fa.0; Thu, 16 Nov 2023 09:36:31 -0800 (PST) X-Gm-Message-State: AOJu0YystFm6zEjxmvJs6CRAdRfvWuYBzOUvzfQXFRLbuT5FCPnCx3/P j3xos+2hhZV+LN4fNSSyAjlFHrR8meygV6s7bhE= X-Received: by 2002:a2e:9bd7:0:b0:2c7:4220:56fc with SMTP id w23-20020a2e9bd7000000b002c7422056fcmr7417802ljj.11.1700156189690; Thu, 16 Nov 2023 09:36:29 -0800 (PST) MIME-Version: 1.0 References: <20231115095830.20607-1-quic_aiquny@quicinc.com> <20231116172418.GA174808@dev-arch.thelio-3990X> In-Reply-To: <20231116172418.GA174808@dev-arch.thelio-3990X> From: Ard Biesheuvel Date: Fri, 17 Nov 2023 03:36:17 +1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/1] ARM: kprobes: Explicitly reserve r7 for local variables To: Nathan Chancellor Cc: Maria Yu , linux@armlinux.org.uk, mhiramat@kernel.org, kernel@quicinc.com, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_lijuang@quicinc.com, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.3 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Thu, 16 Nov 2023 09:36:59 -0800 (PST) On Fri, 17 Nov 2023 at 03:24, Nathan Chancellor wrote: > > On Wed, Nov 15, 2023 at 05:58:30PM +0800, 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. This caused the runtime behavior wrong. > > While those kind of reserved registers cannot be set to clobber list > > because of error like "inline asm clobber list contains reserved > > registers". > > Explicitly reserve r7 by adding attribute no-omit-frame-pointer for needed > > function, then in T32 asm code r7 is used as a frame pointer and is not > > available for use as a general-purpose register. > > Note that "no-omit-frame-pointer" will make the code size a little bigger > > to store the stack frame pointer. So limited to needed functions can have > > the less impact than the full source file. > > > > Fixes: dd12e97f3c72 ("ARM: kprobes: treat R7 as the frame pointer register in Thumb2 builds") > > Signed-off-by: Maria Yu > > Cc: stable@vger.kernel.org > > This causes warnings with clang: > > arch/arm/probes/kprobes/actions-thumb.c:441:47: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes] > 441 | static unsigned long __kprobes __attribute__((optimize("no-omit-frame-pointer"))) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/arm/probes/kprobes/actions-thumb.c:524:38: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes] > 524 | static void __kprobes __attribute__((optimize("no-omit-frame-pointer"))) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/arm/probes/kprobes/actions-thumb.c:560:38: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes] > 560 | static void __kprobes __attribute__((optimize("no-omit-frame-pointer"))) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/arm/probes/kprobes/actions-thumb.c:579:38: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes] > 579 | static void __kprobes __attribute__((optimize("no-omit-frame-pointer"))) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 4 warnings generated. > > Furthermore, as far as I am aware, the optimize attribute has other issues so > its use is discouraged, see commits 080b6f407635 ("bpf: Don't rely on GCC > __attribute__((optimize)) to disable GCSE") and a7223f5bfcae ("powerpc: Avoid > broken GCC __attribute__((optimize))"). > Ah yes, apalogies for missing that. I did a test build with Clang but I did not spot the errors. So Unreviewed-by: .... Maria, please use the Makefile based per-file CFLAGS override that I suggested before. There is really no reason to make this per-function.