Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp16046lqm; Mon, 10 Jun 2024 11:10:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTnfdyuHepFhBGG93ebVoM72d15JJzp0H8yr9gf6ZY8BQpvkwISz2oBJyrWokdHsPJALBdXEeqheO+QoRRkjFvWhwtOEYFCvdN49BeGQ== X-Google-Smtp-Source: AGHT+IGLKINbdVsjvleQP1K5sIkhqAjbp9IaWxa9m2Cx0YaVf5RaI3nmu5SiuNpYsr01Y1dCkFnz X-Received: by 2002:a17:906:e08c:b0:a6f:2eeb:c2b8 with SMTP id a640c23a62f3a-a6f2eebc3e7mr95407766b.3.1718043036069; Mon, 10 Jun 2024 11:10:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718043036; cv=pass; d=google.com; s=arc-20160816; b=UGFoBEw0jzDFsriQs71vx24xE0jrCXq4s/gt0aL3E2mRbJbxx5st7KQWo6Yo5mH2fS puB3iilVtzU4X/CAgPbCKRKQ1zSBY0+uGhINkzLzsl8Z98t1HmN2t9UzlW0SpLdKL7qV I3lRAWaoed95DFlWhLUc9Mjnv3Yk/QW3OfqT9e+rTbbd5tDIL8VY0jTxD040ZJTOMwm7 FuGVLQqAsttq5CFMISWGKWVgV6TWT+BnRej8caytQpm93GHy+ns2xPETdkM4FpVqCMtL E6wpmibNuDH9KBm4LtgQMXvY2tp1uDHE1T62rdObKdoCLpv1c52Gg5LSERQyFP19/loj /aXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JCButQwjvZVZNyRkDdtQ7rOg+hf/mkn6MXierihoty0=; fh=6T1cn+zZISETfkSQY+ffbsWoINvS+CfK4zu/XnbAny8=; b=SdKopPOSS9pOUuDH+DiySyDYxtnKsWUai8QVeSUkCDU4z2a0gEaBHunM4kJfRQpmCh O8zmVZj8G0am3ptB4MTKo1xVLgzgqe6/gpTY+mx4FhZkgLWFMUCoeKlhaZQLgo8vpEAG YvwsRmmJNvFpEMbOqI46ppuxag2o4ZWouN+hMiVARwhWZoeusD7GaxwYoFMH9R37jjFJ V+J32Nvm5QOqTJ56HFcQtaXWMtWZbvW3dLC/w45/OLZJqsXMwVqJGt2pwkEHJ0orbhNH NP67MtnOGbrsfrDoxe1zcUHTf+c+GUYnj/CsgqKtnweoXR0MN5wkM4gwnQsGNBj/FvFo wtJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@motorola.com header.s=DKIM202306 header.b="Auuy7MG/"; arc=pass (i=1 spf=pass spfdomain=motorola.com dkim=pass dkdomain=motorola.com dmarc=pass fromdomain=motorola.com); spf=pass (google.com: domain of linux-kernel+bounces-208710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208710-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6ef954a30fsi300400466b.392.2024.06.10.11.10.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 11:10:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@motorola.com header.s=DKIM202306 header.b="Auuy7MG/"; arc=pass (i=1 spf=pass spfdomain=motorola.com dkim=pass dkdomain=motorola.com dmarc=pass fromdomain=motorola.com); spf=pass (google.com: domain of linux-kernel+bounces-208710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208710-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 983D71F222A0 for ; Mon, 10 Jun 2024 18:10:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEA9C14B975; Mon, 10 Jun 2024 18:09:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=motorola.com header.i=@motorola.com header.b="Auuy7MG/" Received: from mx0a-00823401.pphosted.com (mx0a-00823401.pphosted.com [148.163.148.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 836F57E761; Mon, 10 Jun 2024 18:09:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.148.104 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718042991; cv=none; b=aLjbhZ10L+fNGt1WW3G3j+qhjW86u7T1B0Ieh5lD5UKXHMXrNv13HY7/NvL/bIPqzuLcK5ZLSu6JNGNIvgUYt6KEQAA2shk3q15jZ1+KEyHaawvq0HsMExB4JRIC1tbhvfur5V2dJc0n46QeVFcD9x5wcIBY/VbfXzTqeOI/LXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718042991; c=relaxed/simple; bh=VMAGW0oB8N8oHwmlZO78JAp91DNuXS2+2Hv5FK2UPzw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IGiADsqpvff5vED00ZhG3zLTwuKwAfL2pd9aGu95dVEKRHrONYk00ssCQJQ+63PTHEC+EsB/rhxnj/zmtR+9g+UkxVe2a5hNb0mAT5gMq3Ago7Hu4tUAa+67MI5iRH+PuiBvib6JFOrotCgjAVJOeYuoGcaS1eS+NjGlfhVd6ho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=motorola.com; spf=pass smtp.mailfrom=motorola.com; dkim=pass (2048-bit key) header.d=motorola.com header.i=@motorola.com header.b=Auuy7MG/; arc=none smtp.client-ip=148.163.148.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=motorola.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=motorola.com Received: from pps.filterd (m0355088.ppops.net [127.0.0.1]) by m0355088.ppops.net (8.18.1.2/8.18.1.2) with ESMTP id 45ABm98Q002176; Mon, 10 Jun 2024 18:09:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=DKIM202306; bh=JCButQwjvZVZNyRkDdtQ7rO g+hf/mkn6MXierihoty0=; b=Auuy7MG/eYyQO2j/HY+HwmdSM/To4BwhQSNUuYD mBj7Ez1Z1LvB5NXDoH7nIOpsIv9voZPDm0hxhmi5OU1Ym77L2nBN+jUsOCIKT3Ev GU3pRsnOxVLUWc4CBIvb9zdEmhJknXgcEY6Aep2z9bO0A+V9QahgTbTQ4VBUESfm 6FiWvZZkvRYJ2AEittN4DrrqjlrvUSnmBbiQOjBXs+62atkgtowLix9+rG/eVWel qdIOdLCRvtqxDtm5/xliA691usMjGKOFoDLSsxyXIa8LKNJTlWHJrooCPf3wVX5s wwzSR/Qp2WNC9SUJQYx27BtjMrxvWE6gCLG3sihQIKvXkHA== Received: from va32lpfpp01.lenovo.com ([104.232.228.21]) by m0355088.ppops.net (PPS) with ESMTPS id 3yn4ft2ax8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Jun 2024 18:09:26 +0000 (GMT) Received: from va32lmmrp02.lenovo.com (va32lmmrp02.mot.com [10.62.176.191]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by va32lpfpp01.lenovo.com (Postfix) with ESMTPS id 4Vyfvn0XBZzhWB3; Mon, 10 Jun 2024 18:09:25 +0000 (UTC) Received: from ilclasset02 (ilclasset02.mot.com [100.64.49.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: mbland) by va32lmmrp02.lenovo.com (Postfix) with ESMTPSA id 4Vyfvm4nzfz2VZ3B; Mon, 10 Jun 2024 18:09:24 +0000 (UTC) Date: Mon, 10 Jun 2024 13:09:23 -0500 From: Maxwell Bland To: "open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)" Cc: Catalin Marinas , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Zi Shen Lim , Mark Rutland , Suzuki K Poulose , Mark Brown , linux-arm-kernel@lists.infradead.org, open list , Josh Poimboeuf , Puranjay Mohan Subject: [PATCH bpf-next v5 3/3] arm64/cfi,bpf: Use DEFINE_CFI_TYPE in arm64 Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Proofpoint-GUID: DUHw64W3JWg0MRvl_rezKK9v29hYaxtk X-Proofpoint-ORIG-GUID: DUHw64W3JWg0MRvl_rezKK9v29hYaxtk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-10_04,2024-06-10_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 bulkscore=0 spamscore=0 priorityscore=1501 malwarescore=0 phishscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406100137 Corrects Puranjay Mohan's commit to adopt Mark Rutland's suggestion of using a C CFI type macro in kCFI+BPF. Signed-off-by: Maxwell Bland --- arch/arm64/kernel/alternative.c | 46 ++++----------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c index 1715da7df137..d7a58eca7665 100644 --- a/arch/arm64/kernel/alternative.c +++ b/arch/arm64/kernel/alternative.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "alternatives: " fmt +#include #include #include #include @@ -302,53 +303,16 @@ EXPORT_SYMBOL(alt_cb_patch_nops); #ifdef CONFIG_CFI_CLANG struct bpf_insn; - /* Must match bpf_func_t / DEFINE_BPF_PROG_RUN() */ extern unsigned int __bpf_prog_runX(const void *ctx, const struct bpf_insn *insn); - -/* - * Force a reference to the external symbol so the compiler generates - * __kcfi_typid. - */ -__ADDRESSABLE(__bpf_prog_runX); - -/* u32 __ro_after_init cfi_bpf_hash = __kcfi_typeid___bpf_prog_runX; */ -asm ( -" .pushsection .data..ro_after_init,\"aw\",@progbits \n" -" .type cfi_bpf_hash,@object \n" -" .globl cfi_bpf_hash \n" -" .p2align 2, 0x0 \n" -"cfi_bpf_hash: \n" -" .word __kcfi_typeid___bpf_prog_runX \n" -" .size cfi_bpf_hash, 4 \n" -" .popsection \n" -); - +DEFINE_CFI_TYPE(cfi_bpf_hash, __bpf_prog_runX); /* Must match bpf_callback_t */ extern u64 __bpf_callback_fn(u64, u64, u64, u64, u64); - -__ADDRESSABLE(__bpf_callback_fn); - -/* u32 __ro_after_init cfi_bpf_subprog_hash = __kcfi_typeid___bpf_callback_fn; */ -asm ( -" .pushsection .data..ro_after_init,\"aw\",@progbits \n" -" .type cfi_bpf_subprog_hash,@object \n" -" .globl cfi_bpf_subprog_hash \n" -" .p2align 2, 0x0 \n" -"cfi_bpf_subprog_hash: \n" -" .word __kcfi_typeid___bpf_callback_fn \n" -" .size cfi_bpf_subprog_hash, 4 \n" -" .popsection \n" -); - +DEFINE_CFI_TYPE(cfi_bpf_subprog_hash, __bpf_callback_fn); u32 cfi_get_func_hash(void *func) { - u32 hash; - - if (get_kernel_nofault(hash, func - cfi_get_offset())) - return 0; - - return hash; + u32 *hashp = func - cfi_get_offset(); + return READ_ONCE(*hashp); } #endif -- 2.39.2