Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3200094rdb; Thu, 16 Nov 2023 03:11:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEvJPBiMf1lRc3B3KltNYMGJyJhA+IgZl1xNsOfZYcLZuvqoCph39pBl34Q1Y7E9mQBSo8 X-Received: by 2002:a17:90b:1bc2:b0:280:8cef:c87d with SMTP id oa2-20020a17090b1bc200b002808cefc87dmr16483096pjb.19.1700133103911; Thu, 16 Nov 2023 03:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700133103; cv=none; d=google.com; s=arc-20160816; b=Rn9cS1qujaKRWIqZnTT0c1d2sJj3U2BZf+ciTIb3wwkctb9SOLHUxnSWH72oBXRthq VYnSKc5ZEGHjsSc54gztN/ISlmHYS/nGbbGP2NoK7bzss47QJAcBZ7jpO+eQY9lmnqpu Ab9qGa9VM2KUWcgMgnKP/HjJ8bSV6QjnT0V5OYZYmpNv0scnP+3vaKYDmBHSQ2QVtU4J QwCCu23kHA3s8w6x8+RJlBNnma22JfZCH96NePsOE0pGTLAJ7AxnjH0aIpVl6IUik+YZ YCMW2xRu8yNyRzsD2fpWGodd5sYtxh90R4p9Fr0ZV0nAHvvzQZlLL7XyaB1c3raTb3j4 QX/A== 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=KtZpY1mnL60kwAHZliQjlKpXW0GNGKYitu+HHjGXu68=; fh=NUvgzBPnV7jqniqznQUoKfSrPpkEoXAA2xULC5rB51M=; b=AkYzmvZ+D/HadYUmQu2Hfdpwk/7I0Q3CSvyzwuml801v3g5Zuql248bP0SYgaSra54 yp8f9A1hcVAm/og+e/xjnwqxhEm7ZUDPlerRB1gnBTERXM77v03aPKmuHjufeZoq746j x8L0nLpciMNdkdb4CBiHf/lm7fKbAYvRMhNtLDxBqwWUYSA9AeUMX3tbJvFiv0vxTNrQ qc7mZSUYY2TYvDyoU5iNPGkWu2W0rEalRlJ0CxLhAfQP7+397qzUoHRyzyjZm0x5tetV XKp13MtWB/9120msLSoeXEjOZ8vZHN/YsCybZ8rHYNuuDwSckx3vgAHZgJCboIBKrQH+ t7Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kFY3JkEN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bg7-20020a17090b0d8700b002808ca78d11si1764485pjb.52.2023.11.16.03.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 03:11:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kFY3JkEN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 58631806A638; Thu, 16 Nov 2023 03:11:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230431AbjKPLLU (ORCPT + 99 others); Thu, 16 Nov 2023 06:11:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345083AbjKPLLT (ORCPT ); Thu, 16 Nov 2023 06:11:19 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54042AA; Thu, 16 Nov 2023 03:11:16 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2C03C433C7; Thu, 16 Nov 2023 11:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700133076; bh=S39I4q3Z2eyaTdKnVU0kVAHPshukGXcnGgf90hu5hNI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kFY3JkENtL0CxjTkP/J8DwUB+SNQglfyJDHH7+sTiuRn0h/RUE7p3oaQ9qmm2EqUz lJ8fKPSOka5GNjCzNZHxSf7AG6Gxycoolw68U9X3zNLhbf+PorV19XXd+0AJ9dW/Xv Rs1D2g3X/xGGTH1hLuNRHeoRpA6X+9eMtKXDG3WLqM4c7l+4a5VetChSvtL3/ZQrwI U355iW85fbSl1wMHuMOjIACUU9o+H6yzVw3tyyJmpQB9iKCoTXzWcBj5tSPrEMsbRa JotGEznqCUVHoaEh6BM6b7ygvXrc8KQcKlmNu5a3klH/eu9lvDm5WiyUxcJJGGmqV1 WVw+8Ya70CViw== Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2c6b5841f61so7347201fa.0; Thu, 16 Nov 2023 03:11:15 -0800 (PST) X-Gm-Message-State: AOJu0Ywscy8wiDPGFjgcafrbTxcYyYihQieq1sou7jrvNexEPYYivadF zHsROOAexZil6XVizYMZPVhrmr2PpdWU8Lrqst4= X-Received: by 2002:a05:651c:20b:b0:2c6:edf1:b05e with SMTP id y11-20020a05651c020b00b002c6edf1b05emr580932ljn.15.1700133074166; Thu, 16 Nov 2023 03:11:14 -0800 (PST) MIME-Version: 1.0 References: <20231115095830.20607-1-quic_aiquny@quicinc.com> In-Reply-To: <20231115095830.20607-1-quic_aiquny@quicinc.com> From: Ard Biesheuvel Date: Thu, 16 Nov 2023 21:11:03 +1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/1] ARM: kprobes: Explicitly reserve r7 for local variables To: Maria Yu Cc: 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 16 Nov 2023 03:11:41 -0800 (PST) On Wed, 15 Nov 2023 at 19:58, 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 Reviewed-by: Ard Biesheuvel > --- > arch/arm/probes/kprobes/actions-thumb.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/arm/probes/kprobes/actions-thumb.c b/arch/arm/probes/kprobes/actions-thumb.c > index 51624fc263fc..c2fdaf9f6dba 100644 > --- a/arch/arm/probes/kprobes/actions-thumb.c > +++ b/arch/arm/probes/kprobes/actions-thumb.c > @@ -438,7 +438,7 @@ t16_simulate_branch(probes_opcode_t insn, > regs->ARM_pc = pc + (offset * 2); > } > > -static unsigned long __kprobes > +static unsigned long __kprobes __attribute__((optimize("no-omit-frame-pointer"))) > t16_emulate_loregs(probes_opcode_t insn, > struct arch_probes_insn *asi, struct pt_regs *regs) > { > @@ -521,7 +521,7 @@ t16_decode_hiregs(probes_opcode_t insn, struct arch_probes_insn *asi, > return INSN_GOOD; > } > > -static void __kprobes > +static void __kprobes __attribute__((optimize("no-omit-frame-pointer"))) > t16_emulate_push(probes_opcode_t insn, > struct arch_probes_insn *asi, struct pt_regs *regs) > { > @@ -557,7 +557,7 @@ t16_decode_push(probes_opcode_t insn, struct arch_probes_insn *asi, > return INSN_GOOD; > } > > -static void __kprobes > +static void __kprobes __attribute__((optimize("no-omit-frame-pointer"))) > t16_emulate_pop_nopc(probes_opcode_t insn, > struct arch_probes_insn *asi, struct pt_regs *regs) > { > @@ -576,7 +576,7 @@ t16_emulate_pop_nopc(probes_opcode_t insn, > ); > } > > -static void __kprobes > +static void __kprobes __attribute__((optimize("no-omit-frame-pointer"))) > t16_emulate_pop_pc(probes_opcode_t insn, > struct arch_probes_insn *asi, struct pt_regs *regs) > { > > base-commit: 9bacdd8996c77c42ca004440be610692275ff9d0 > -- > 2.17.1 >