From 6a2dc768f058ce96479e7ed524d27fcf59657f5b Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Wed, 16 Dec 2020 22:10:43 +0100 Subject: OvmfPkg/VirtioFsDxe: introduce the basic FUSE request/response headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce the VIRTIO_FS_FUSE_REQUEST and VIRTIO_FS_FUSE_RESPONSE structures, which are the common headers for the various FUSE request/response structures. Introduce the VirtioFsFuseNewRequest() helper function for populating VIRTIO_FS_FUSE_REQUEST, from parameters and from a VIRTIO_FS-level request counter. Introduce the VirtioFsFuseCheckResponse() helper function for verifying most FUSE response types that begin with the VIRTIO_FS_FUSE_RESPONSE header. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Philippe Mathieu-Daudé Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3097 Signed-off-by: Laszlo Ersek Message-Id: <20201216211125.19496-7-lersek@redhat.com> Acked-by: Ard Biesheuvel --- OvmfPkg/Include/IndustryStandard/VirtioFs.h | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'OvmfPkg/Include') diff --git a/OvmfPkg/Include/IndustryStandard/VirtioFs.h b/OvmfPkg/Include/IndustryStandard/VirtioFs.h index ea7d80d15d..521288b03f 100644 --- a/OvmfPkg/Include/IndustryStandard/VirtioFs.h +++ b/OvmfPkg/Include/IndustryStandard/VirtioFs.h @@ -49,4 +49,53 @@ typedef struct { } VIRTIO_FS_CONFIG; #pragma pack () +// +// FUSE-related definitions follow. +// +// From virtio-v1.1-cs01-87fa6b5d8155, 5.11 File System Device: "[...] The +// driver acts as the FUSE client mounting the file system. The virtio file +// system device provides the mechanism for transporting FUSE requests [...]" +// +// Unfortunately, the documentation of the FUSE wire protocol is lacking. The +// Virtio spec (as of this writing) simply defers to +// "include/uapi/linux/fuse.h" in the Linux kernel source -- see the reference +// in virtio spec file "introduction.tex", at commit 87fa6b5d8155. +// +// Of course, "include/uapi/linux/fuse.h" is a moving target (the virtio spec +// does not specify a particular FUSE interface version). The OvmfPkg code +// targets version 7.31, because that's the lowest version that the QEMU +// virtio-fs daemon supports at this time -- see QEMU commit 72c42e2d6551 +// ("virtiofsd: Trim out compatibility code", 2020-01-23). +// +// Correspondingly, Linux's "include/uapi/linux/fuse.h" is consulted as checked +// out at commit (c6ff213fe5b8^) = d78092e4937d ("fuse: fix page dereference +// after free", 2020-09-18); that is, right before commit c6ff213fe5b8 ("fuse: +// add submount support to ", 2020-09-18) introduces FUSE +// interface version 7.32. +// +#define VIRTIO_FS_FUSE_MAJOR 7 +#define VIRTIO_FS_FUSE_MINOR 31 + +#pragma pack (1) +// +// Request-response headers common to all request types. +// +typedef struct { + UINT32 Len; + UINT32 Opcode; + UINT64 Unique; + UINT64 NodeId; + UINT32 Uid; + UINT32 Gid; + UINT32 Pid; + UINT32 Padding; +} VIRTIO_FS_FUSE_REQUEST; + +typedef struct { + UINT32 Len; + INT32 Error; + UINT64 Unique; +} VIRTIO_FS_FUSE_RESPONSE; +#pragma pack () + #endif // VIRTIO_FS_H_ -- cgit v1.2.3