Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2484777rdb; Wed, 15 Nov 2023 01:59:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2YRPYZqwVqrDxQn6s5mmdL38As54tE+lIi9DyMbvWOwlYtw2OHzR+J3OzyrqDY/ZqXUUq X-Received: by 2002:a05:6359:5a4:b0:16b:f8cc:99ce with SMTP id ee36-20020a05635905a400b0016bf8cc99cemr4136684rwb.21.1700042368860; Wed, 15 Nov 2023 01:59:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700042368; cv=none; d=google.com; s=arc-20160816; b=039sdrH7PSfpKAWNj8aitdLx5wKDGxILXhBU4D0yGbDik22U9DxulPgK++7WPZyT09 yAfCXI+8Tjz1vYkAfYE/3T8yVTrLyXz0/gFF+yj3J6A5NWvBagcOyOMHf4Uwaqu4ILR4 qXyFt39pMA79sr1Erg25eNrt3X2YEOeeCBOAsuPxLeLLs731PgtoMCAf1LTXKHx4m4K2 6odinJpqxpKi75KJYuPPGaJvmT32nKgx39IezAL96MAuEQpcolfwNl8FNgd9WEuW2c7P CMSIqm0Tchddd6HykcNHyIJMe85lCJaM0O6ZkKGUX7A7OKcqNRIrZchW7b2i1h4lIPxj JKxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=GLwXmtvMjTXbDM2nrBNbYXCfGPprVUbImDq/3p/gXHw=; fh=mz4pBSZe9QISzLTPc6bhL0B7QFXfxd/HJZwItUIxO08=; b=gqPCzWzcNA1LOkD4R6jjV9szJZoX8FnkIgSs/DArXQ2a0yHWfj/SNvLwKmfuCjFpz9 MmpNI/ebSrlJ5p/PjJ0L1fy+wWSxFVMR6QEwLt/5w0DOE1RAdxIRtuVK8Fu4s0QhZ68u LWyz4/PWlRwcr/9tJFh2wYAlHHgYsfaSutlYYJ8m0T/Sy0o4OozwJv/kF6Sc97GBzJJw NtkMkfGm4eu5tZv1d3IQaI794bm1OZNEJlGd6ecbWjMzMY0+wS2PEdp7nVmAuQQLJAwF s8vxySUSxjfyWpXkU+tikyVTeTtvP/eyH6pJPh0doV1Cof3Pd1o/WKHs8fiGDlfT8HZz LYVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=AIPNsjcA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id w123-20020a636281000000b005bdfb94f475si9903125pgb.637.2023.11.15.01.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 01:59:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=AIPNsjcA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A4207802F271; Wed, 15 Nov 2023 01:59:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234869AbjKOJ7F (ORCPT + 99 others); Wed, 15 Nov 2023 04:59:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234852AbjKOJ7E (ORCPT ); Wed, 15 Nov 2023 04:59:04 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF9BB11C; Wed, 15 Nov 2023 01:58:59 -0800 (PST) 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 Content-Type: text/plain 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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 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, 15 Nov 2023 01:59:21 -0800 (PST) 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 --- 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