From patchwork Wed Jul 31 13:59:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20730 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A9FF0C32BB for ; Wed, 31 Jul 2024 14:00:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3658E63379; Wed, 31 Jul 2024 16:00:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="iZH+jKzO"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 713BB6198E for ; Wed, 31 Jul 2024 15:59:59 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5B86DF85 for ; Wed, 31 Jul 2024 15:59:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1722434351; bh=eqHwR1evMb7EhKijHWNnlouTO3Bknq5MaVJwRTQNs04=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iZH+jKzOlUjZNNH3APtdV9DHUI8Z9ZLpC6odr430uih4Z1zXpgc5wjT/daujBJ8E8 emv+TQcYaaWe1X0ow1RxcwUh9j1xV+G+4C5ebOweqSFOXddEp0GxxbyVGuU8otlCEZ tbG49HJVm6ovGSwhurg/9d/3Mk7xMr48/z7LkUto= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 1/4] libcamera: base: Add MemFd helper class Date: Wed, 31 Jul 2024 16:59:33 +0300 Message-ID: <20240731135936.2105-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240731135936.2105-1-laurent.pinchart@ideasonboard.com> References: <20240731135936.2105-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" libcamera creates memfds in two locations already, duplicating some code. Move the code to a new MemFd helper class. Signed-off-by: Laurent Pinchart Reviewed-by: Milan Zamazal Reviewed-by: Kieran Bingham Reviewed-by: Hans de Goede --- include/libcamera/base/memfd.h | 34 ++++++++ include/libcamera/base/meson.build | 1 + src/libcamera/base/memfd.cpp | 116 ++++++++++++++++++++++++++++ src/libcamera/base/meson.build | 1 + src/libcamera/dma_buf_allocator.cpp | 46 +---------- src/libcamera/shared_mem_object.cpp | 21 ++--- 6 files changed, 161 insertions(+), 58 deletions(-) create mode 100644 include/libcamera/base/memfd.h create mode 100644 src/libcamera/base/memfd.cpp diff --git a/include/libcamera/base/memfd.h b/include/libcamera/base/memfd.h new file mode 100644 index 000000000000..b0edd2de5d83 --- /dev/null +++ b/include/libcamera/base/memfd.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Ideas on Board Oy + * + * Anonymous file creation + */ + +#pragma once + +#include + +#include +#include + +namespace libcamera { + +class MemFd +{ +public: + enum class Seal { + None = 0, + Shrink = (1 << 0), + Grow = (1 << 1), + }; + + using Seals = Flags; + + static UniqueFD create(const char *name, std::size_t size, + Seals seals = Seal::None); +}; + +LIBCAMERA_FLAGS_ENABLE_OPERATORS(MemFd::Seal) + +} /* namespace libcamera */ diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build index bace25d56b13..2a0cee317204 100644 --- a/include/libcamera/base/meson.build +++ b/include/libcamera/base/meson.build @@ -21,6 +21,7 @@ libcamera_base_private_headers = files([ 'event_notifier.h', 'file.h', 'log.h', + 'memfd.h', 'message.h', 'mutex.h', 'private.h', diff --git a/src/libcamera/base/memfd.cpp b/src/libcamera/base/memfd.cpp new file mode 100644 index 000000000000..72474307af09 --- /dev/null +++ b/src/libcamera/base/memfd.cpp @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Ideas on Board Oy + * + * Anonymous file creation + */ + +#include + +#include +#include +#include +#include +#include + +#include + +/** + * \file base/memfd.h + * \brief Anonymous file creation + */ + +/* uClibc doesn't provide the file sealing API. */ +#ifndef __DOXYGEN__ +#if not HAVE_FILE_SEALS +#define F_ADD_SEALS 1033 +#define F_SEAL_SHRINK 0x0002 +#define F_SEAL_GROW 0x0004 +#endif +#endif + +namespace libcamera { + +LOG_DECLARE_CATEGORY(File) + +/** + * \class MemFd + * \brief Helper class to create anonymous files + * + * Anonymous files behave like regular files, and can be modified, truncated, + * memory-mapped and so on. Unlike regular files, they however live in RAM and + * don't have permanent backing storage. + */ + +/** + * \enum MemFd::Seal + * \brief Seals for the MemFd::create() function + * \var MemFd::Seal::None + * \brief No seals (used as default value) + * \var MemFd::Seal::Shrink + * \brief Prevent the memfd from shrinking + * \var MemFd::Seal::Grow + * \brief Prevent the memfd from growing + */ + +/** + * \typedef MemFd::Seals + * \brief A bitwise combination of MemFd::Seal values + */ + +/** + * \brief Create an anonymous file + * \param[in] name The file name (displayed in symbolic links in /proc/self/fd/) + * \param[in] size The file size + * \param[in] seals The file seals + * + * This function is a helper that wraps anonymous file (memfd) creation and + * sets the file size and optional seals. + * + * \return The descriptor of the anonymous file if creation succeeded, or an + * invalid UniqueFD otherwise + */ +UniqueFD MemFd::create(const char *name, std::size_t size, Seals seals) +{ +#if HAVE_MEMFD_CREATE + int ret = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC); +#else + int ret = syscall(SYS_memfd_create, name, MFD_ALLOW_SEALING | MFD_CLOEXEC); +#endif + if (ret < 0) { + ret = errno; + LOG(File, Error) + << "Failed to allocate memfd storage for " << name + << ": " << strerror(ret); + return {}; + } + + UniqueFD memfd(ret); + + ret = ftruncate(memfd.get(), size); + if (ret < 0) { + ret = errno; + LOG(File, Error) + << "Failed to set memfd size for " << name + << ": " << strerror(ret); + return {}; + } + + if (seals) { + int fileSeals = (seals & Seal::Shrink ? F_SEAL_SHRINK : 0) + | (seals & Seal::Grow ? F_SEAL_GROW : 0); + + ret = fcntl(memfd.get(), F_ADD_SEALS, fileSeals); + if (ret < 0) { + ret = errno; + LOG(File, Error) + << "Failed to seal the memfd for " << name + << ": " << strerror(ret); + return {}; + } + } + + return memfd; +} + +} /* namespace libcamera */ diff --git a/src/libcamera/base/meson.build b/src/libcamera/base/meson.build index 7a7fd7e4ca87..4a228d335ba4 100644 --- a/src/libcamera/base/meson.build +++ b/src/libcamera/base/meson.build @@ -10,6 +10,7 @@ libcamera_base_sources = files([ 'file.cpp', 'flags.cpp', 'log.cpp', + 'memfd.cpp', 'message.cpp', 'mutex.cpp', 'object.cpp', diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp index c06eca7d04ec..be6efb89fbb7 100644 --- a/src/libcamera/dma_buf_allocator.cpp +++ b/src/libcamera/dma_buf_allocator.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -22,6 +21,7 @@ #include #include +#include /** * \file dma_buf_allocator.cpp @@ -126,54 +126,16 @@ DmaBufAllocator::~DmaBufAllocator() = default; * \brief Check if the DmaBufAllocator instance is valid * \return True if the DmaBufAllocator is valid, false otherwise */ - -/* uClibc doesn't provide the file sealing API. */ -#ifndef __DOXYGEN__ -#if not HAVE_FILE_SEALS -#define F_ADD_SEALS 1033 -#define F_SEAL_SHRINK 0x0002 -#endif -#endif - UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size) { /* Size must be a multiple of the page size. Round it up. */ std::size_t pageMask = sysconf(_SC_PAGESIZE) - 1; size = (size + pageMask) & ~pageMask; -#if HAVE_MEMFD_CREATE - int ret = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC); -#else - int ret = syscall(SYS_memfd_create, name, MFD_ALLOW_SEALING | MFD_CLOEXEC); -#endif - if (ret < 0) { - ret = errno; - LOG(DmaBufAllocator, Error) - << "Failed to allocate memfd storage for " << name - << ": " << strerror(ret); - return {}; - } - - UniqueFD memfd(ret); - - ret = ftruncate(memfd.get(), size); - if (ret < 0) { - ret = errno; - LOG(DmaBufAllocator, Error) - << "Failed to set memfd size for " << name - << ": " << strerror(ret); - return {}; - } - /* udmabuf dma-buffers *must* have the F_SEAL_SHRINK seal. */ - ret = fcntl(memfd.get(), F_ADD_SEALS, F_SEAL_SHRINK); - if (ret < 0) { - ret = errno; - LOG(DmaBufAllocator, Error) - << "Failed to seal the memfd for " << name - << ": " << strerror(ret); + UniqueFD memfd = MemFd::create(name, size, MemFd::Seal::Shrink); + if (!memfd.isValid()) return {}; - } struct udmabuf_create create; @@ -182,7 +144,7 @@ UniqueFD DmaBufAllocator::allocFromUDmaBuf(const char *name, std::size_t size) create.offset = 0; create.size = size; - ret = ::ioctl(providerHandle_.get(), UDMABUF_CREATE, &create); + int ret = ::ioctl(providerHandle_.get(), UDMABUF_CREATE, &create); if (ret < 0) { ret = errno; LOG(DmaBufAllocator, Error) diff --git a/src/libcamera/shared_mem_object.cpp b/src/libcamera/shared_mem_object.cpp index 809fbdaf95de..022645e71a35 100644 --- a/src/libcamera/shared_mem_object.cpp +++ b/src/libcamera/shared_mem_object.cpp @@ -13,9 +13,9 @@ #include #include #include -#include #include -#include + +#include /** * \file shared_mem_object.cpp @@ -58,22 +58,11 @@ SharedMem::SharedMem() = default; */ SharedMem::SharedMem(const std::string &name, std::size_t size) { -#if HAVE_MEMFD_CREATE - int fd = memfd_create(name.c_str(), MFD_CLOEXEC); -#else - int fd = syscall(SYS_memfd_create, name.c_str(), MFD_CLOEXEC); -#endif - if (fd < 0) + UniqueFD memfd = MemFd::create(name.c_str(), size); + if (!memfd.isValid()) return; - fd_ = SharedFD(std::move(fd)); - if (!fd_.isValid()) - return; - - if (ftruncate(fd_.get(), size) < 0) { - fd_ = SharedFD(); - return; - } + fd_ = SharedFD(std::move(memfd)); void *mem = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_.get(), 0); From patchwork Wed Jul 31 13:59:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20731 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D8F1CBDC71 for ; Wed, 31 Jul 2024 14:00:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9236C63377; Wed, 31 Jul 2024 16:00:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="u5gvqy8x"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B587763373 for ; Wed, 31 Jul 2024 16:00:00 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BE1FDF85 for ; Wed, 31 Jul 2024 15:59:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1722434353; bh=77zpJSFoPZJqYJyQ1SYf77gaxo8dLAeY+OC+qai2asY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=u5gvqy8x/hQ+CYPw+JMV3Xqb18+xCSvc8kD1ZnWlkLd3mELNfU8l9oVK0er0Aonho PD1y/agMgs9+gz5nIeLF1U1AEisM1MZrvZyWTnD+TpWQlXH8so19PpBI48gMLi7nGK Ge/6aeVLf7/Lj0Sph/Fx28ze6MTOhJ4gjhJtjbH8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 2/4] libcamera: base: memfd: Handle uClibc compatibility with function wrapper Date: Wed, 31 Jul 2024 16:59:34 +0300 Message-ID: <20240731135936.2105-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240731135936.2105-1-laurent.pinchart@ideasonboard.com> References: <20240731135936.2105-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" uClibc doesn't provide memfd_create(), which led libcamera to open-code the call using syscall(). Sprinkling the code with #ifdef's isn't the most readable option, so improve it by providing a local implementation of memfd_create(), and call the function unconditionally from MemFd::create(). This makes the main code path more readable. Suggested-by: Nicolas Dufresne Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Nicolas Dufresne Reviewed-by: Hans de Goede --- src/libcamera/base/memfd.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libcamera/base/memfd.cpp b/src/libcamera/base/memfd.cpp index 72474307af09..d95adb91615c 100644 --- a/src/libcamera/base/memfd.cpp +++ b/src/libcamera/base/memfd.cpp @@ -20,15 +20,26 @@ * \brief Anonymous file creation */ -/* uClibc doesn't provide the file sealing API. */ #ifndef __DOXYGEN__ +namespace { + +/* uClibc doesn't provide the file sealing API. */ #if not HAVE_FILE_SEALS #define F_ADD_SEALS 1033 #define F_SEAL_SHRINK 0x0002 #define F_SEAL_GROW 0x0004 #endif + +#ifndef HAVE_MEMFD_CREATE +int memfd_create(const char *name, unsigned int flags) +{ + return syscall(SYS_memfd_create, name, flags); +} #endif +} /* namespace */ +#endif /* __DOXYGEN__ */ + namespace libcamera { LOG_DECLARE_CATEGORY(File) @@ -72,11 +83,7 @@ LOG_DECLARE_CATEGORY(File) */ UniqueFD MemFd::create(const char *name, std::size_t size, Seals seals) { -#if HAVE_MEMFD_CREATE int ret = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC); -#else - int ret = syscall(SYS_memfd_create, name, MFD_ALLOW_SEALING | MFD_CLOEXEC); -#endif if (ret < 0) { ret = errno; LOG(File, Error) From patchwork Wed Jul 31 13:59:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20732 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 47A21C32BB for ; Wed, 31 Jul 2024 14:00:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 02E6763379; Wed, 31 Jul 2024 16:00:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MQ30k1aO"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 366226337A for ; Wed, 31 Jul 2024 16:00:02 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 337C9F85 for ; Wed, 31 Jul 2024 15:59:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1722434354; bh=skpyVrxR5RbAG5xfRsqnolQwCUyVpjAZQxTdOw9ogsY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MQ30k1aO5qEGGiPuw6TsLsCnneHvRQNNCjGTfdLjX7OmEERnpJL4W6YkgajXf/cI2 6P472VjRd+QVL/Ca1A7w4SWfiI3wiFZh46+UE2aLPMNV3gLEsAwXgd48gSNYW16w7t ZQeRu61RHHU0xlIGIAgCTs8rqixl+L5NwvYmPT8Y= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 3/4] libcamera: shared_mem_object: Prevent memfd from shrinking or growing Date: Wed, 31 Jul 2024 16:59:35 +0300 Message-ID: <20240731135936.2105-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240731135936.2105-1-laurent.pinchart@ideasonboard.com> References: <20240731135936.2105-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The memfd underlying the SharedMem object must not shrink, or memory corruption will happen. Prevent this by setting the shrink seal on the file. As there's no valid use case for growing the memory either, set the grow seal as well. Signed-off-by: Laurent Pinchart Reviewed-by: Milan Zamazal Reviewed-by: Kieran Bingham Reviewed-by: Hans de Goede --- src/libcamera/shared_mem_object.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcamera/shared_mem_object.cpp b/src/libcamera/shared_mem_object.cpp index 022645e71a35..d4c7991ad16a 100644 --- a/src/libcamera/shared_mem_object.cpp +++ b/src/libcamera/shared_mem_object.cpp @@ -58,7 +58,8 @@ SharedMem::SharedMem() = default; */ SharedMem::SharedMem(const std::string &name, std::size_t size) { - UniqueFD memfd = MemFd::create(name.c_str(), size); + UniqueFD memfd = MemFd::create(name.c_str(), size, MemFd::Seal::Shrink | + MemFd::Seal::Grow); if (!memfd.isValid()) return; From patchwork Wed Jul 31 13:59:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20733 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D8962BDC71 for ; Wed, 31 Jul 2024 14:00:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8383363378; Wed, 31 Jul 2024 16:00:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HTFAuh4B"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9FB0B6337E for ; Wed, 31 Jul 2024 16:00:03 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9FC8BF85 for ; Wed, 31 Jul 2024 15:59:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1722434355; bh=Knu62KiGoHOCCQU/vXuC0BXDHWrzsPsQ2qf1DsZw6QM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HTFAuh4BkktOmblQ9Y/PYwrEdReXx+p1e+VYMWjCcgQ2vWA8fTyNWHeBOiIZZc7Xl MJ/938fx6ukyLpS3JmAxt6tdbk7VC4VrHWb1b9gPP2gYfLIYDOLb26fo/L9V1mkP5U 1D0rINhv1VEVXdsHmkfBtjOjnzw1uQnfYlUVFLLE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 4/4] libcamera: software_isp: Remove file seal TODO item Date: Wed, 31 Jul 2024 16:59:36 +0300 Message-ID: <20240731135936.2105-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240731135936.2105-1-laurent.pinchart@ideasonboard.com> References: <20240731135936.2105-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The file seal TODO item has been addressed. Remove it. Signed-off-by: Laurent Pinchart Reviewed-by: Milan Zamazal Reviewed-by: Kieran Bingham Reviewed-by: Hans de Goede --- src/libcamera/software_isp/TODO | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/libcamera/software_isp/TODO b/src/libcamera/software_isp/TODO index 6bdc590531ca..9978afc0317b 100644 --- a/src/libcamera/software_isp/TODO +++ b/src/libcamera/software_isp/TODO @@ -1,22 +1,3 @@ -1. Setting F_SEAL_SHRINK and F_SEAL_GROW after ftruncate() - ->> SharedMem::SharedMem(const std::string &name, std::size_t size) ->> : name_(name), size_(size), mem_(nullptr) ->> ->> ... ->> ->> if (ftruncate(fd_.get(), size_) < 0) ->> return; -> -> Should we set the GROW and SHRINK seals (in a separate patch) ? - -Yes, this can be done. -Setting F_SEAL_SHRINK and F_SEAL_GROW after the ftruncate() call above could catch -some potential errors related to improper access to the shared memory allocated by -the SharedMemObject. - ---- - 2. Reconsider stats sharing >>> +void SwStatsCpu::finishFrame(void)