Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp820008lqh; Thu, 28 Mar 2024 18:54:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFyHW3oN/oywX5NtbiVWLPeK294n+RMVs2QdrQlYJrBwV4ofsqLoJZdgHNobRCoxoWb5IWbZum9ACvFDp19qtZ1shp59gDK2SXSoj2lQ== X-Google-Smtp-Source: AGHT+IGd6R2zQROlkp9YOQCir2SPJenSn9zXHngJXvqXFQhC//EARX5ZjVS8YvVLuKJ8B1H62Jqg X-Received: by 2002:a05:6214:1107:b0:696:7ff4:7f7b with SMTP id e7-20020a056214110700b006967ff47f7bmr931458qvs.41.1711677295031; Thu, 28 Mar 2024 18:54:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711677295; cv=pass; d=google.com; s=arc-20160816; b=IGK+N1f7pPH9JVcoJ3Zq7jO0uH5VNvxlikG2U8dCZia4fQoS4pbvWz/5z/jedY5y1B yoWivrvUOuAtyPneaL8xmOdhYgtEh+VmvzuZK82mNiqz2Nu9Erh8hkwaro3BO50BxcSl 4sZs+jjeTB4Jx79LnoxiJNVL7Vr1f0K4xKgQKE1fOEsdcmglykVju9xohpReXLB431QL 7s+9WI1ZuqPioU9ui0njV9J5VGChIwMTWqSdCPoBQ3/+bclZl57lejFeRSq9hha+yu/5 fSY53vaQfeGDr6icTo9j2FTHzAMMv7JsDMUsnDAC4C5FpjiwLAu+grJxZtIaqXzwN1+a En0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=/zH4C1QJ9QRhJsDuWqk5xHws80AiBqqvhiaKJmoPnqo=; fh=rCEguVd8bqW+IBfFP7Gg5KNs5YeKVFoDUEn2d7BI4FQ=; b=PzLCWc2T3IFqS+RoA3+ZU0ud/GNgz8l54N7LXuv3gHKJyfA0ZjX0OA5xNB6Gn0DQVV 1ltqu++mICIRXYnaRZ9EeygXoAyRLLyoqYN3iWkP5k4qlPvgYs+PLXMDid3EAkKVdpsV sPu2afDTRiPX5q7fs4GK5Nv3/9J4fZSmL32s64Mw1cLH0s5rcMXNftR2DgZnxJu5IYhQ 2ff+qYS0Ci431hHOHhphFbJqgPcvtYQbTp5zyWFekrXXWthXpxWg23BvJQLF+IlL0r62 bMR0z4PvlvR36TbrzauMeP2qaj5jCgRD29lVHVGeNRs5eu6yg9JIvsz7laCRUxO027gv Qr4A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VVRlV2AB; arc=pass (i=1 spf=pass spfdomain=flex--drosen.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-123981-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123981-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a12-20020a0ce38c000000b0069671f24fd2si2759167qvl.252.2024.03.28.18.54.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 18:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123981-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VVRlV2AB; arc=pass (i=1 spf=pass spfdomain=flex--drosen.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-123981-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123981-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id AEA151C268BD for ; Fri, 29 Mar 2024 01:54:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5F822C6B5; Fri, 29 Mar 2024 01:54:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VVRlV2AB" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 61D92210FF for ; Fri, 29 Mar 2024 01:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711677246; cv=none; b=rnV6c8540UKEsdA9Uc/UnOHqQL+tMfcef0bpV9jNSCWiMht8pzaFibguyTDqDZmqbSvtY7o2702XNRUwJty+lrMm6COEFZraHSOvo5cFQ0ZWr2XRyDrLcZGcmxK4UoHhObnyoyAO3AHiUqFEcaaYk3XnjAqNKMjvYbylSSbubT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711677246; c=relaxed/simple; bh=Wc6g5oUwOwJMcy8zr/T7dnynkvOgSwhcOrIXewXrDos=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=teO9D3AS3Gpn/wFqvZD3ZBVb0dRcp+qn47MR9VAovUX8EadTTuESYFmzkRrAqwDGrQi+I7zjQB8NptpD6azS0u9szu945tJHp/uXquw9MT602916tZvfYiGsMndsL7nfp6D6fpL4G3vw+6+VKJbF3dv/fYhq1uYvATWnLWIQwVM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--drosen.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VVRlV2AB; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--drosen.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-60cd62fa20fso30384777b3.3 for ; Thu, 28 Mar 2024 18:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711677244; x=1712282044; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=/zH4C1QJ9QRhJsDuWqk5xHws80AiBqqvhiaKJmoPnqo=; b=VVRlV2AB4xLteIv7NdqAcWA487whBLy522o5Uoqki3PBN2l1tVi7VZYIMv36wcWfIF 2h6DavLDcwkX20y7dV3tKxoRF3V5gulrKAGtDonIc/bi/Y/IUO8H+dhjq9iMFgx/WafB o1DlV31/hO1e90foGbMyYrix1k9czDEXIN99mRV9RrZwcTvm2zbcQRYsasropiDwxwnq rM9+aVFAuwEZUFPySGXXQjrGOr4U9w2heyUYBc0kn48DWmWqLHD1JpZkElvBMDSHj8Iz 8kIox+T7X/e2otUw1nqqODbYcx3+3jgEDe5Z6UGb0zVa4NUQLXSWBylVRYjnNDpEjPWq O/2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711677244; x=1712282044; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/zH4C1QJ9QRhJsDuWqk5xHws80AiBqqvhiaKJmoPnqo=; b=lZPjlXCV4LRUjeLyl9OOGwnClGP0wSQpIkaAVQi8sk/3yoN+L1ngDDxE/cCKbGYHgi C5WvI3nWrHo4NfCvfzt0gZ1RCdFDa9rL2jiKZTEj3OUK1sFtfeHv+uVXEONDSH7SXm1n t8rOFsPzrUbcFpMFpYBw72Pscq7Q0uSIKTz3GG+M7zR7Sa2PWU4FpA9Dczgt6vv5jtwP xocCBLUNok6nLBBQcREKNQ4h8NKvEhdvsDDED9FU+zChj21mS6HfxHI0PV9jCTDQPV0F 3x/VyURS1geZfutg8v8UO1DDJSrGB4QZZxDRpggS2iuLn0brwTUt3qZ7AdG2ODQb30YK uwjA== X-Forwarded-Encrypted: i=1; AJvYcCVsyCMM7pLZuA+z2ldbYrZcatT731ohDUJUtSnifbRdJWX9EE3zC0sH7DChq+ceEU3JD+0kcX2VUJc7wSlRgUto8Yz3prYrexstuq33 X-Gm-Message-State: AOJu0Yxg+GkRFgyV1PlelVplz5CPccHbpYJVlWzdIem5CCxE0Os259CW osD27eQO85r4E8kwkWi8vc7FYlh/PsiL1irEQvUeIUzjAcMJqTu4dUUvAmf60g3PunMvDVMQ0me oBQ== X-Received: from drosen.mtv.corp.google.com ([2620:15c:211:201:fcce:d6ab:804c:b94b]) (user=drosen job=sendgmr) by 2002:a05:6902:e0f:b0:dc6:44d4:bee0 with SMTP id df15-20020a0569020e0f00b00dc644d4bee0mr85414ybb.7.1711677244476; Thu, 28 Mar 2024 18:54:04 -0700 (PDT) Date: Thu, 28 Mar 2024 18:53:17 -0700 In-Reply-To: <20240329015351.624249-1-drosen@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240329015351.624249-1-drosen@google.com> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240329015351.624249-3-drosen@google.com> Subject: [RFC PATCH v4 02/36] fuse-bpf: Add data structures for fuse-bpf From: Daniel Rosenberg To: Miklos Szeredi , bpf@vger.kernel.org, Alexei Starovoitov Cc: Amir Goldstein , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Eduard Zingerman , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Jonathan Corbet , Joanne Koong , Mykola Lysenko , Christian Brauner , kernel-team@android.com, Daniel Rosenberg Content-Type: text/plain; charset="UTF-8" These structures will be used to interact between the fuse bpf calls and normal userspace calls Signed-off-by: Daniel Rosenberg --- include/linux/bpf_fuse.h | 84 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 include/linux/bpf_fuse.h diff --git a/include/linux/bpf_fuse.h b/include/linux/bpf_fuse.h new file mode 100644 index 000000000000..ce8b1b347496 --- /dev/null +++ b/include/linux/bpf_fuse.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2022 Google LLC. + */ + +#ifndef _BPF_FUSE_H +#define _BPF_FUSE_H + +#include +#include + +struct fuse_buffer { + void *data; + unsigned size; + unsigned alloc_size; + unsigned max_size; + int flags; +}; + +/* These flags are used internally to track information about the fuse buffers. + * Fuse sets some of the flags in init. The helper functions sets others, depending on what + * was requested by the bpf program. + */ +// Flags set by FUSE +#define BPF_FUSE_IMMUTABLE (1 << 0) // Buffer may not be written to +#define BPF_FUSE_VARIABLE_SIZE (1 << 1) // Buffer length may be changed (growth requires alloc) +#define BPF_FUSE_MUST_ALLOCATE (1 << 2) // Buffer must be re allocated before allowing writes + +// Flags set by helper function +#define BPF_FUSE_MODIFIED (1 << 3) // The helper function allowed writes to the buffer +#define BPF_FUSE_ALLOCATED (1 << 4) // The helper function allocated the buffer + +/* + * BPF Fuse Args + * + * Used to translate between bpf program parameters and their userspace equivalent calls. + * Variable sized arguments are held in fuse_buffers. To access these, bpf programs must + * use kfuncs to access them as dynptrs. + * + */ + +#define FUSE_MAX_ARGS_IN 3 +#define FUSE_MAX_ARGS_OUT 2 + +struct bpf_fuse_arg { + union { + void *value; + struct fuse_buffer *buffer; + }; + unsigned size; + bool is_buffer; +}; + +struct bpf_fuse_meta_info { + uint64_t nodeid; + uint32_t opcode; + uint32_t error_in; +}; + +struct bpf_fuse_args { + struct bpf_fuse_meta_info info; + uint32_t in_numargs; + uint32_t out_numargs; + uint32_t flags; + struct bpf_fuse_arg in_args[FUSE_MAX_ARGS_IN]; + struct bpf_fuse_arg out_args[FUSE_MAX_ARGS_OUT]; +}; + +// Mirrors for struct fuse_args flags +#define FUSE_BPF_FORCE (1 << 0) +#define FUSE_BPF_OUT_ARGVAR (1 << 6) +#define FUSE_BPF_IS_LOOKUP (1 << 11) + +static inline void *bpf_fuse_arg_value(const struct bpf_fuse_arg *arg) +{ + return arg->is_buffer ? arg->buffer : arg->value; +} + +static inline unsigned bpf_fuse_arg_size(const struct bpf_fuse_arg *arg) +{ + return arg->is_buffer ? arg->buffer->size : arg->size; +} + +#endif /* _BPF_FUSE_H */ -- 2.44.0.478.gd926399ef9-goog