From patchwork Wed Nov 15 09:58:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aiqun Yu (Maria)" X-Patchwork-Id: 13456446 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 A85CFC47072 for ; Wed, 15 Nov 2023 09:59:28 +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:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=UjF/yLCAhnwl5Uoy+xSSPnl5+HwfD6Q2uH8nK9hHuug=; b=YnwAIWhuj/dLR3 FGZISRal0MmqJfszmILgZqkadG7Z1i6ZPM/V/CWDqEuHmmmx00fxdMWbtOEs4UrB3H3Bo2C9zSabO jbi8S1JwGg7AzhyqQ2yAbBBXr4xikXVyZ5WGE3HAxa+7u3NpsfSyLlAf3YKokDXaoBirWf/yUZKIo mENEcvUrGz1AtqSFo005Vg8r12zg9SRVcGHbiQTlNS8bTprsARZC9Wj9LYwjJepkIMUDeF2ssbVPk 7YDYmS8Z251GoAHeIyu6RqFVV3nQjVSU+q/iXlUlUyO2OnS+DtnEcbKULCrh02Bv5QPL/IZDWQ5Fz daRMGGlhK37xwptkTPMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r3Cfk-000ObD-2G; Wed, 15 Nov 2023 09:59:00 +0000 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r3Cfi-000Oae-0i for linux-arm-kernel@lists.infradead.org; Wed, 15 Nov 2023 09:58:59 +0000 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AF97QW7010206; Wed, 15 Nov 2023 09:58:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=GLwXmtvMjTXbDM2nrBNbYXCfGPprVUbImDq/3p/gXHw=; b=AIPNsjcAFSJJ3IGhVEtFcsbDJvAR3B/2YZL7aNtMmPmoenYArHvnh1g38/huWqH89Jsn pCng7ay0mjNRMzyBD/7mWWHKq5JAyUCV+rHoT6wVCbQYtvoOPMUtptUnELWKnkx6Bc5H vcTEU2pAxR8DrZMZLNhY9/fC6aWgtM82m8UN7TBgnOPdjdaMbgfCjJ+RkcmkX+R0qK7N 1f7ttsQqUmiEDNbuO11nRAcrsRe4JBvygt8ss4QRjNv4KvPDoYFBFkaqj1SEN5zAlITy ivyay1Zrx/bTqjdM5lJSb5N90hObF74WRy8rSjp/Pu0ni8IMAdG7Sp9guvOLwkEFUQbB Xw== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ucfka9hdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 09:58:50 +0000 Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AF9woR1005753 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Nov 2023 09:58:50 GMT Received: from aiquny2-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Wed, 15 Nov 2023 01:58:44 -0800 From: Maria Yu To: , , CC: Maria Yu , , , , , , Subject: [PATCH v2 1/1] ARM: kprobes: Explicitly reserve r7 for local variables Date: Wed, 15 Nov 2023 17:58:30 +0800 Message-ID: <20231115095830.20607-1-quic_aiquny@quicinc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: CnoBJsaifzwKBk2Ab9I793wa8RzQnEcq X-Proofpoint-GUID: CnoBJsaifzwKBk2Ab9I793wa8RzQnEcq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-15_07,2023-11-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 clxscore=1011 spamscore=0 bulkscore=0 phishscore=0 mlxscore=0 mlxlogscore=334 priorityscore=1501 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311150075 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231115_015858_290965_F9BBD9FE X-CRM114-Status: GOOD ( 17.37 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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(-) base-commit: 9bacdd8996c77c42ca004440be610692275ff9d0 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) {