Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp591738lqp; Wed, 12 Jun 2024 10:09:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUP4PRiPPemevOpbQPc7iEw/mBoIYDZkPV4YqtBOFpGnnD5t2pNTni+JCFm+/GBtz7HTM77W616dzFbAR5eIJ0UGLt3Y92iSe1r1Kes7Q== X-Google-Smtp-Source: AGHT+IFShn/ITtpyM7xRml1nIpY9mVlGeNAljd9Eu7foABnly1lQUJScQpc5o9ns85e9e453UtKO X-Received: by 2002:a05:6e02:1fc5:b0:375:a348:3aa0 with SMTP id e9e14a558f8ab-375cd149f26mr26376485ab.9.1718212162900; Wed, 12 Jun 2024 10:09:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718212162; cv=pass; d=google.com; s=arc-20160816; b=ToQEa5GmJb8VwZgXCMdqLSRP9fu5XI0WMcNS6NkqhAojzCy8ys1Hw81/wCuTyyn2Wt SR7ihE2+kp0PQRKFi2s/IVmj2X8aZKfIFrORi7t7kN28kMyIiBEN1fkHWfRft5RSUWpM oKtB2eBngPZEc+wQ8C6AjtXY2SpI76xWE+4AqUg/fv1FXRP9S++jvM0GwLbQpDL6/Hcs FlGnBk+6Rw0e0GMEk4l3gorUP6J2EU2HhXyGn/fblSrSJGYKcTrnfK4zqNWSP7Kja8uW 5QPf3qnuhRYRquFtoBBPqZhgIPBwbS8Yl11GqnpQUpeoa5Y4KW2i0yWKs8irdC4Xtywa eJAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ocpRwy0sziQcbAmBE7fGUEw2nPXigRY3R3IXpRSwnH0=; fh=aSwvfeKVFL+nEyHQHdru3uYfXO7R071n+sXz/FHllKs=; b=Q8IAdxuYbSWYxyFb7dGllSEkYcqomSl6BDAc1/p1pkZGh6F3icS3d11OblzprNGvKp 8ZLsZpSyjTmYJ5V3SAtR/83BtfceJuc4aTAgthCw+Uok11apc7lGcssvpNvkQgR3pk2u UhTPjG7Iox4hVeeDq8JNOBuDvS5b6VhHML+ykOK5INfbPkWNTpY8UwCk3rBA8bNwrgLj ZFUb7yUvBHg8tE7pIOkBh4UsxVG0Xvh3QJVJRyGoAS3YugMerzTJAOPS7lBAgmtR4b1y P9vkBW4lzQpE6uF76RBsD2lvhYpUzfRiEL/R0WitmxIhoR1AWOY1FvUEYpZayiLXDBRs 4V5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ipCgHn1e; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-211978-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6eba43362a5si7027964a12.406.2024.06.12.10.09.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 10:09:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211978-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ipCgHn1e; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-211978-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211978-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5FFFB284C8F for ; Wed, 12 Jun 2024 17:09:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67B67183064; Wed, 12 Jun 2024 17:07:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ipCgHn1e" Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D40ED28DB3; Wed, 12 Jun 2024 17:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718212044; cv=none; b=YpdWuzk5VcnwclnMLCKTzkUK2f5rk0Uc2LWzrfdWoBmM9vIFvXA4B6WGi/q8BWPZI5JgoF6013iigpBZyRTSxeTDsTJ8AQoiWiGKRS5Zo5NHzwvKlT8taugAGCNjL0ymxztL1OEbCEmNFZuZFu5LxeO5BzJNIf8dL213MB1nwIY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718212044; c=relaxed/simple; bh=SKfMsfpuRskP07jTZ/SF0CfZ2NDTe3YEm/3ZVgENZfc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=EgsIRE/Lutnirdh2faWtvDJKWTdu9Gpju7vf+MyuWpUOPBOrJb3MUpu/FTuTzCq19ccn1kK49So0rcFIbigZLhaIGiMCZSqiYFcg9e8rcn5y62dJWwYa2IU+bmGQY1C5w8qq2QnEfz5hvcpSrb1d0kcl+wFKDWZgQqpxWUXiCC4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ipCgHn1e; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-35f2c0b7701so71094f8f.0; Wed, 12 Jun 2024 10:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718212041; x=1718816841; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ocpRwy0sziQcbAmBE7fGUEw2nPXigRY3R3IXpRSwnH0=; b=ipCgHn1eQ+rSMNmPMdbOstbi0sIP2PygQTEmimVoCtoIHGuISwS5sev7qycV8jR+NG d0LX/ketYMyPpB0DruUiahzlzsSb6cAJ0JEFlAiYVipGmbcc1BuAkZgoTkTBeiV5b3jC 6G8Sn41CcsFdWuyQIHfkLvjfTf139F62oYJiiO4FcZ/YVt6gw0TX5cmzJSqZQu8Og9JJ Ga6drkL65HhwhZpB4+2xr70/m6z6jh2979l+C68V6AjVkXrSP45+HCFN/tEX5ny9pavL Kvwukjm0YXwHrwEd+PTbQBryUV5k5VwSTbpMXYuflch/yzkjxPCKkTrYMINsdjVtmEAt FHMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718212041; x=1718816841; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ocpRwy0sziQcbAmBE7fGUEw2nPXigRY3R3IXpRSwnH0=; b=ub8Mx3xmBAtMminwPjmDrkfBa3FbCK1mZiWK+R8cVFsKYd2Ql3+fYE+uKwz/3+K1Ks Kbe+6mQPjkD6wk6iodagWj8owmSJms/Y8Jd6IDQgi8v26UOD3t75lXWAz4UdOMpCMb3O n4QZcbDIVvtq74DeIj1q29dQq/14WfozCcg+NkWObz7g7uunxhXrFJQiQuy0VRAhENoO CINsR+L+4HynFZdoHK7T9bVn9sPFI+umrqwvoRd2YbTMg9gXBo8/EIoDUcqmxF8Mkqtu EK/5TUFU0QBbW3O9fuvkHBJX3PWGW1R6+EVYEoHV1Fg0MPD0lfnOweyzY4GZHVmaRuZT R1MQ== X-Forwarded-Encrypted: i=1; AJvYcCUw1P74wX/vtylHTgaMYVIdZ8DrKDBJFRrnOsEhHQY2IRyie2DAxst8EBNvNxXaUG3s7AHsue79/kXcef2yjlotbxV0lZuZpQrWB39g X-Gm-Message-State: AOJu0Yy0PHSWC7PYoYqc7CjtaAQAxHPWk/SLgXMA8K4WbKTGeJxwD4Ef wC01XeFdbSXB7BqgqIG1TLVJRcdA1YukwRVqu+2VK1CrpL56TvqnLnDZYbQQzPfUCTdL9HyNhff 21vEUC41iL90wrs2YqX9yuCH8cl8= X-Received: by 2002:adf:f748:0:b0:35f:10b2:b588 with SMTP id ffacd0b85a97d-360718defc4mr314071f8f.18.1718212040907; Wed, 12 Jun 2024 10:07:20 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Alexei Starovoitov Date: Wed, 12 Jun 2024 10:07:09 -0700 Message-ID: Subject: Re: [PATCH bpf-next v6 3/3] arm64/cfi,bpf: Use DEFINE_CFI_TYPE in arm64 To: Maxwell Bland Cc: "open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)" , 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 , open list , Josh Poimboeuf , Puranjay Mohan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 12, 2024 at 8:32=E2=80=AFAM Maxwell Bland = wrote: > > 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/alternat= ive.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 =3D __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 =3D __kcfi_typeid___bpf_call= back_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 =3D func - cfi_get_offset(); > + return READ_ONCE(*hashp); Please avoid the code churn. Just squash it into the previous patch. pw-bot: cr