restore lost packages from 0.2.3 + fix overwritten 0.2.4 files

- Restore 29 recipe symlinks (libdrm, qtbase, dbus, sddm, pipewire, etc.)
- Restore 33 patches (KDE, libdrm, mesa, pipewire, sddm, wireplumber)
- Restore 20+ local/scripts (audit, lint, test, build helpers)
- Restore src/cook/scheduler.rs, status.rs, gnu-config/
- Restore scripts/patch-inclusion-gate.sh, run_mini1.sh, validate-collision-log.sh
- Recover TLC source from HEAD (was overwritten by 0.2.3 checkout)
- Recover 11 local/docs plans from HEAD (were overwritten)
- Recover qt6-wayland-smoke symlink from HEAD
- Fix MOTD: remove garbled ASCII art, use clean text
- Update version: 0.2.0 -> 0.2.4 in os-release, motd, config
- Reduce filesystem_size: 1536 -> 512 MiB
- Add ABSOLUTE RULE to AGENTS.md: never delete/ignore packages
- Reduce pcid scheme log verbosity: info -> debug
This commit is contained in:
2026-06-19 12:39:14 +03:00
parent ffbe098ef8
commit dc68054305
6418 changed files with 7066233 additions and 8670 deletions
@@ -0,0 +1,289 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2023 Alexander Graf <graf@amazon.com>
* Copyright (C) 2025 Microsoft Corporation, Mike Rapoport <rppt@kernel.org>
* Copyright (C) 2025 Google LLC, Changyuan Lyu <changyuanl@google.com>
* Copyright (C) 2025 Google LLC, Jason Miu <jasonmiu@google.com>
*/
#ifndef _LINUX_KHO_ABI_KEXEC_HANDOVER_H
#define _LINUX_KHO_ABI_KEXEC_HANDOVER_H
#include <linux/bits.h>
#include <linux/log2.h>
#include <linux/math.h>
#include <linux/types.h>
#include <asm/page.h>
/**
* DOC: Kexec Handover ABI
*
* Kexec Handover uses the ABI defined below for passing preserved data from
* one kernel to the next.
* The ABI uses Flattened Device Tree (FDT) format. The first kernel creates an
* FDT which is then passed to the next kernel during a kexec handover.
*
* This interface is a contract. Any modification to the FDT structure, node
* properties, compatible string, or the layout of the data structures
* referenced here constitutes a breaking change. Such changes require
* incrementing the version number in KHO_FDT_COMPATIBLE to prevent a new kernel
* from misinterpreting data from an older kernel. Changes are allowed provided
* the compatibility version is incremented. However, backward/forward
* compatibility is only guaranteed for kernels supporting the same ABI version.
*
* FDT Structure Overview:
* The FDT serves as a central registry for physical addresses of preserved
* data structures. The first kernel populates this FDT with references to
* memory regions and other metadata that need to persist across the kexec
* transition. The subsequent kernel then parses this FDT to locate and
* restore the preserved data.::
*
* / {
* compatible = "kho-v3";
*
* preserved-memory-map = <0x...>;
*
* <subnode-name-1> {
* preserved-data = <0x...>;
* blob-size = <0x...>;
* };
*
* <subnode-name-2> {
* preserved-data = <0x...>;
* blob-size = <0x...>;
* };
* ... ...
* <subnode-name-N> {
* preserved-data = <0x...>;
* blob-size = <0x...>;
* };
* };
*
* Root KHO Node (/):
* - compatible: "kho-v3"
*
* Indentifies the overall KHO ABI version.
*
* - preserved-memory-map: u64
*
* Physical memory address pointing to the root of the
* preserved memory map data structure.
*
* Subnodes (<subnode-name-N>):
* Subnodes can also be added to the root node to
* describe other preserved data blobs. The <subnode-name-N>
* is provided by the subsystem that uses KHO for preserving its
* data.
*
* - preserved-data: u64
*
* Physical address pointing to a subnode data blob that is also
* being preserved.
*
* - blob-size: u64
*
* Size in bytes of the preserved data blob. This is needed because
* blobs may use arbitrary formats (not just FDT), so the size
* cannot be determined from the blob content alone.
*/
/* The compatible string for the KHO FDT root node. */
#define KHO_FDT_COMPATIBLE "kho-v3"
/* The FDT property for the preserved memory map. */
#define KHO_FDT_MEMORY_MAP_PROP_NAME "preserved-memory-map"
/* The FDT property for preserved data blobs. */
#define KHO_SUB_TREE_PROP_NAME "preserved-data"
/* The FDT property for the size of preserved data blobs. */
#define KHO_SUB_TREE_SIZE_PROP_NAME "blob-size"
/**
* DOC: Kexec Handover ABI for vmalloc Preservation
*
* The Kexec Handover ABI for preserving vmalloc'ed memory is defined by
* a set of structures and helper macros. The layout of these structures is a
* stable contract between kernels and is versioned by the KHO_FDT_COMPATIBLE
* string.
*
* The preservation is managed through a main descriptor &struct kho_vmalloc,
* which points to a linked list of &struct kho_vmalloc_chunk structures. These
* chunks contain the physical addresses of the preserved pages, allowing the
* next kernel to reconstruct the vmalloc area with the same content and layout.
* Helper macros are also defined for storing and loading pointers within
* these structures.
*/
/* Helper macro to define a union for a serializable pointer. */
#define DECLARE_KHOSER_PTR(name, type) \
union { \
u64 phys; \
type ptr; \
} name
/* Stores the physical address of a serializable pointer. */
#define KHOSER_STORE_PTR(dest, val) \
({ \
typeof(val) v = val; \
typecheck(typeof((dest).ptr), v); \
(dest).phys = virt_to_phys(v); \
})
/* Loads the stored physical address back to a pointer. */
#define KHOSER_LOAD_PTR(src) \
({ \
typeof(src) s = src; \
(typeof((s).ptr))((s).phys ? phys_to_virt((s).phys) : NULL); \
})
/*
* This header is embedded at the beginning of each `kho_vmalloc_chunk`
* and contains a pointer to the next chunk in the linked list,
* stored as a physical address for handover.
*/
struct kho_vmalloc_hdr {
DECLARE_KHOSER_PTR(next, struct kho_vmalloc_chunk *);
};
#define KHO_VMALLOC_SIZE \
((PAGE_SIZE - sizeof(struct kho_vmalloc_hdr)) / \
sizeof(u64))
/*
* Each chunk is a single page and is part of a linked list that describes
* a preserved vmalloc area. It contains the header with the link to the next
* chunk and a zero terminated array of physical addresses of the pages that
* make up the preserved vmalloc area.
*/
struct kho_vmalloc_chunk {
struct kho_vmalloc_hdr hdr;
u64 phys[KHO_VMALLOC_SIZE];
};
static_assert(sizeof(struct kho_vmalloc_chunk) == PAGE_SIZE);
/*
* Describes a preserved vmalloc memory area, including the
* total number of pages, allocation flags, page order, and a pointer to the
* first chunk of physical page addresses.
*/
struct kho_vmalloc {
DECLARE_KHOSER_PTR(first, struct kho_vmalloc_chunk *);
unsigned int total_pages;
unsigned short flags;
unsigned short order;
};
/**
* DOC: KHO persistent memory tracker
*
* KHO tracks preserved memory using a radix tree data structure. Each node of
* the tree is exactly a single page. The leaf nodes are bitmaps where each set
* bit is a preserved page of any order. The intermediate nodes are tables of
* physical addresses that point to a lower level node.
*
* The tree hierarchy is shown below::
*
* root
* +-------------------+
* | Level 5 | (struct kho_radix_node)
* +-------------------+
* |
* v
* +-------------------+
* | Level 4 | (struct kho_radix_node)
* +-------------------+
* |
* | ... (intermediate levels)
* |
* v
* +-------------------+
* | Level 0 | (struct kho_radix_leaf)
* +-------------------+
*
* The tree is traversed using a key that encodes the page's physical address
* (pa) and its order into a single unsigned long value. The encoded key value
* is composed of two parts: the 'order bit' in the upper part and the
* 'shifted physical address' in the lower part.::
*
* +------------+-----------------------------+--------------------------+
* | Page Order | Order Bit | Shifted Physical Address |
* +------------+-----------------------------+--------------------------+
* | 0 | ...000100 ... (at bit 52) | pa >> (PAGE_SHIFT + 0) |
* | 1 | ...000010 ... (at bit 51) | pa >> (PAGE_SHIFT + 1) |
* | 2 | ...000001 ... (at bit 50) | pa >> (PAGE_SHIFT + 2) |
* | ... | ... | ... |
* +------------+-----------------------------+--------------------------+
*
* Shifted Physical Address:
* The 'shifted physical address' is the physical address normalized for its
* order. It effectively represents the PFN shifted right by the order.
*
* Order Bit:
* The 'order bit' encodes the page order by setting a single bit at a
* specific position. The position of this bit itself represents the order.
*
* For instance, on a 64-bit system with 4KB pages (PAGE_SHIFT = 12), the
* maximum range for the shifted physical address (for order 0) is 52 bits
* (64 - 12). This address occupies bits [0-51]. For order 0, the order bit is
* set at position 52.
*
* The following diagram illustrates how the encoded key value is split into
* indices for the tree levels, with PAGE_SIZE of 4KB::
*
* 63:60 59:51 50:42 41:33 32:24 23:15 14:0
* +---------+--------+--------+--------+--------+--------+-----------------+
* | 0 | Lv 5 | Lv 4 | Lv 3 | Lv 2 | Lv 1 | Lv 0 (bitmap) |
* +---------+--------+--------+--------+--------+--------+-----------------+
*
* The radix tree stores pages of all orders in a single 6-level hierarchy. It
* efficiently shares higher tree levels, especially due to common zero top
* address bits, allowing a single, efficient algorithm to manage all
* pages. This bitmap approach also offers memory efficiency; for example, a
* 512KB bitmap can cover a 16GB memory range for 0-order pages with PAGE_SIZE =
* 4KB.
*
* The data structures defined here are part of the KHO ABI. Any modification
* to these structures that breaks backward compatibility must be accompanied by
* an update to the "compatible" string. This ensures that a newer kernel can
* correctly interpret the data passed by an older kernel.
*/
/*
* Defines constants for the KHO radix tree structure, used to track preserved
* memory. These constants govern the indexing, sizing, and depth of the tree.
*/
enum kho_radix_consts {
/*
* The bit position of the order bit (and also the length of the
* shifted physical address) for an order-0 page.
*/
KHO_ORDER_0_LOG2 = 64 - PAGE_SHIFT,
/* Size of the table in kho_radix_node, in log2 */
KHO_TABLE_SIZE_LOG2 = const_ilog2(PAGE_SIZE / sizeof(phys_addr_t)),
/* Number of bits in the kho_radix_leaf bitmap, in log2 */
KHO_BITMAP_SIZE_LOG2 = PAGE_SHIFT + const_ilog2(BITS_PER_BYTE),
/*
* The total tree depth is the number of intermediate levels
* and 1 bitmap level.
*/
KHO_TREE_MAX_DEPTH =
DIV_ROUND_UP(KHO_ORDER_0_LOG2 - KHO_BITMAP_SIZE_LOG2,
KHO_TABLE_SIZE_LOG2) + 1,
};
struct kho_radix_node {
u64 table[1 << KHO_TABLE_SIZE_LOG2];
};
struct kho_radix_leaf {
DECLARE_BITMAP(bitmap, 1 << KHO_BITMAP_SIZE_LOG2);
};
#endif /* _LINUX_KHO_ABI_KEXEC_HANDOVER_H */
@@ -0,0 +1,46 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/**
* DOC: Kexec Metadata ABI
*
* The "kexec-metadata" subtree stores optional metadata about the kexec chain.
* It is registered via kho_add_subtree(), keeping it independent from the core
* KHO ABI. This allows the metadata format to evolve without affecting other
* KHO consumers.
*
* The metadata is stored as a plain C struct rather than FDT format for
* simplicity and direct field access.
*
* Copyright (c) 2026 Meta Platforms, Inc. and affiliates.
* Copyright (c) 2026 Breno Leitao <leitao@debian.org>
*/
#ifndef _LINUX_KHO_ABI_KEXEC_METADATA_H
#define _LINUX_KHO_ABI_KEXEC_METADATA_H
#include <linux/types.h>
#include <linux/utsname.h>
#define KHO_KEXEC_METADATA_VERSION 1
/**
* struct kho_kexec_metadata - Kexec metadata passed between kernels
* @version: ABI version of this struct (must be first field)
* @previous_release: Kernel version string that initiated the kexec
* @kexec_count: Number of kexec boots since last cold boot
*
* This structure is preserved across kexec and allows the new kernel to
* identify which kernel it was booted from and how many kexec reboots
* have occurred.
*
* __NEW_UTS_LEN is part of uABI, so it safe to use it in here.
*/
struct kho_kexec_metadata {
u32 version;
char previous_release[__NEW_UTS_LEN + 1];
u32 kexec_count;
} __packed;
#define KHO_METADATA_NODE_NAME "kexec-metadata"
#endif /* _LINUX_KHO_ABI_KEXEC_METADATA_H */
@@ -0,0 +1,247 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2025, Google LLC.
* Pasha Tatashin <pasha.tatashin@soleen.com>
*/
/**
* DOC: Live Update Orchestrator ABI
*
* Live Update Orchestrator uses the stable Application Binary Interface
* defined below to pass state from a pre-update kernel to a post-update
* kernel. The ABI is built upon the Kexec HandOver framework and uses a
* Flattened Device Tree to describe the preserved data.
*
* This interface is a contract. Any modification to the FDT structure, node
* properties, compatible strings, or the layout of the `__packed` serialization
* structures defined here constitutes a breaking change. Such changes require
* incrementing the version number in the relevant `_COMPATIBLE` string to
* prevent a new kernel from misinterpreting data from an old kernel.
*
* Changes are allowed provided the compatibility version is incremented;
* however, backward/forward compatibility is only guaranteed for kernels
* supporting the same ABI version.
*
* FDT Structure Overview:
* The entire LUO state is encapsulated within a single KHO entry named "LUO".
* This entry contains an FDT with the following layout:
*
* .. code-block:: none
*
* / {
* compatible = "luo-v1";
* liveupdate-number = <...>;
*
* luo-session {
* compatible = "luo-session-v1";
* luo-session-header = <phys_addr_of_session_header_ser>;
* };
*
* luo-flb {
* compatible = "luo-flb-v1";
* luo-flb-header = <phys_addr_of_flb_header_ser>;
* };
* };
*
* Main LUO Node (/):
*
* - compatible: "luo-v1"
* Identifies the overall LUO ABI version.
* - liveupdate-number: u64
* A counter tracking the number of successful live updates performed.
*
* Session Node (luo-session):
* This node describes all preserved user-space sessions.
*
* - compatible: "luo-session-v1"
* Identifies the session ABI version.
* - luo-session-header: u64
* The physical address of a `struct luo_session_header_ser`. This structure
* is the header for a contiguous block of memory containing an array of
* `struct luo_session_ser`, one for each preserved session.
*
* File-Lifecycle-Bound Node (luo-flb):
* This node describes all preserved global objects whose lifecycle is bound
* to that of the preserved files (e.g., shared IOMMU state).
*
* - compatible: "luo-flb-v1"
* Identifies the FLB ABI version.
* - luo-flb-header: u64
* The physical address of a `struct luo_flb_header_ser`. This structure is
* the header for a contiguous block of memory containing an array of
* `struct luo_flb_ser`, one for each preserved global object.
*
* Serialization Structures:
* The FDT properties point to memory regions containing arrays of simple,
* `__packed` structures. These structures contain the actual preserved state.
*
* - struct luo_session_header_ser:
* Header for the session array. Contains the total page count of the
* preserved memory block and the number of `struct luo_session_ser`
* entries that follow.
*
* - struct luo_session_ser:
* Metadata for a single session, including its name and a physical pointer
* to another preserved memory block containing an array of
* `struct luo_file_ser` for all files in that session.
*
* - struct luo_file_ser:
* Metadata for a single preserved file. Contains the `compatible` string to
* find the correct handler in the new kernel, a user-provided `token` for
* identification, and an opaque `data` handle for the handler to use.
*
* - struct luo_flb_header_ser:
* Header for the FLB array. Contains the total page count of the
* preserved memory block and the number of `struct luo_flb_ser` entries
* that follow.
*
* - struct luo_flb_ser:
* Metadata for a single preserved global object. Contains its `name`
* (compatible string), an opaque `data` handle, and the `count`
* number of files depending on it.
*/
#ifndef _LINUX_KHO_ABI_LUO_H
#define _LINUX_KHO_ABI_LUO_H
#include <uapi/linux/liveupdate.h>
/*
* The LUO FDT hooks all LUO state for sessions, fds, etc.
* In the root it also carries "liveupdate-number" 64-bit property that
* corresponds to the number of live-updates performed on this machine.
*/
#define LUO_FDT_SIZE PAGE_SIZE
#define LUO_FDT_KHO_ENTRY_NAME "LUO"
#define LUO_FDT_COMPATIBLE "luo-v1"
#define LUO_FDT_LIVEUPDATE_NUM "liveupdate-number"
#define LIVEUPDATE_HNDL_COMPAT_LENGTH 48
/**
* struct luo_file_ser - Represents the serialized preserves files.
* @compatible: File handler compatible string.
* @data: Private data
* @token: User provided token for this file
*
* If this structure is modified, LUO_SESSION_COMPATIBLE must be updated.
*/
struct luo_file_ser {
char compatible[LIVEUPDATE_HNDL_COMPAT_LENGTH];
u64 data;
u64 token;
} __packed;
/**
* struct luo_file_set_ser - Represents the serialized metadata for file set
* @files: The physical address of a contiguous memory block that holds
* the serialized state of files (array of luo_file_ser) in this file
* set.
* @count: The total number of files that were part of this session during
* serialization. Used for iteration and validation during
* restoration.
*/
struct luo_file_set_ser {
u64 files;
u64 count;
} __packed;
/*
* LUO FDT session node
* LUO_FDT_SESSION_HEADER: is a u64 physical address of struct
* luo_session_header_ser
*/
#define LUO_FDT_SESSION_NODE_NAME "luo-session"
#define LUO_FDT_SESSION_COMPATIBLE "luo-session-v2"
#define LUO_FDT_SESSION_HEADER "luo-session-header"
/**
* struct luo_session_header_ser - Header for the serialized session data block.
* @count: The number of `struct luo_session_ser` entries that immediately
* follow this header in the memory block.
*
* This structure is located at the beginning of a contiguous block of
* physical memory preserved across the kexec. It provides the necessary
* metadata to interpret the array of session entries that follow.
*
* If this structure is modified, `LUO_FDT_SESSION_COMPATIBLE` must be updated.
*/
struct luo_session_header_ser {
u64 count;
} __packed;
/**
* struct luo_session_ser - Represents the serialized metadata for a LUO session.
* @name: The unique name of the session, provided by the userspace at
* the time of session creation.
* @file_set_ser: Serialized files belonging to this session,
*
* This structure is used to package session-specific metadata for transfer
* between kernels via Kexec Handover. An array of these structures (one per
* session) is created and passed to the new kernel, allowing it to reconstruct
* the session context.
*
* If this structure is modified, `LUO_FDT_SESSION_COMPATIBLE` must be updated.
*/
struct luo_session_ser {
char name[LIVEUPDATE_SESSION_NAME_LENGTH];
struct luo_file_set_ser file_set_ser;
} __packed;
/* The max size is set so it can be reliably used during in serialization */
#define LIVEUPDATE_FLB_COMPAT_LENGTH 48
#define LUO_FDT_FLB_NODE_NAME "luo-flb"
#define LUO_FDT_FLB_COMPATIBLE "luo-flb-v1"
#define LUO_FDT_FLB_HEADER "luo-flb-header"
/**
* struct luo_flb_header_ser - Header for the serialized FLB data block.
* @pgcnt: The total number of pages occupied by the entire preserved memory
* region, including this header and the subsequent array of
* &struct luo_flb_ser entries.
* @count: The number of &struct luo_flb_ser entries that follow this header
* in the memory block.
*
* This structure is located at the physical address specified by the
* `LUO_FDT_FLB_HEADER` FDT property. It provides the new kernel with the
* necessary information to find and iterate over the array of preserved
* File-Lifecycle-Bound objects and to manage the underlying memory.
*
* If this structure is modified, LUO_FDT_FLB_COMPATIBLE must be updated.
*/
struct luo_flb_header_ser {
u64 pgcnt;
u64 count;
} __packed;
/**
* struct luo_flb_ser - Represents the serialized state of a single FLB object.
* @name: The unique compatibility string of the FLB object, used to find the
* corresponding &struct liveupdate_flb handler in the new kernel.
* @data: The opaque u64 handle returned by the FLB's .preserve() operation
* in the old kernel. This handle encapsulates the entire state needed
* for restoration.
* @count: The reference count at the time of serialization; i.e., the number
* of preserved files that depended on this FLB. This is used by the
* new kernel to correctly manage the FLB's lifecycle.
*
* An array of these structures is created in a preserved memory region and
* passed to the new kernel. Each entry allows the LUO core to restore one
* global, shared object.
*
* If this structure is modified, LUO_FDT_FLB_COMPATIBLE must be updated.
*/
struct luo_flb_ser {
char name[LIVEUPDATE_FLB_COMPAT_LENGTH];
u64 data;
u64 count;
} __packed;
/* Kernel Live Update Test ABI */
#ifdef CONFIG_LIVEUPDATE_TEST
#define LIVEUPDATE_TEST_FLB_COMPATIBLE(i) "liveupdate-test-flb-v" #i
#endif
#endif /* _LINUX_KHO_ABI_LUO_H */
@@ -0,0 +1,73 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_KHO_ABI_MEMBLOCK_H
#define _LINUX_KHO_ABI_MEMBLOCK_H
/**
* DOC: memblock kexec handover ABI
*
* Memblock can serialize its current memory reservations created with
* reserve_mem command line option across kexec through KHO.
* The post-KHO kernel can then consume these reservations and they are
* guaranteed to have the same physical address.
*
* The state is serialized using Flattened Device Tree (FDT) format. Any
* modification to the FDT structure, node properties, or the compatible
* strings constitutes a breaking change. Such changes require incrementing the
* version number in the relevant `_COMPATIBLE` string to prevent a new kernel
* from misinterpreting data from an old kernel.
*
* Changes are allowed provided the compatibility version is incremented.
* However, backward/forward compatibility is only guaranteed for kernels
* supporting the same ABI version.
*
* FDT Structure Overview:
* The entire memblock state is encapsulated within a single KHO entry named
* "memblock".
* This entry contains an FDT with the following layout:
*
* .. code-block:: none
*
* / {
* compatible = "memblock-v1";
*
* n1 {
* compatible = "reserve-mem-v1";
* start = <0xc06b 0x4000000>;
* size = <0x04 0x00>;
* };
* };
*
* Main memblock node (/):
*
* - compatible: "memblock-v1"
* Identifies the overall memblock ABI version.
*
* reserved_mem node:
* These nodes describe all reserve_mem regions. The node name is the name
* defined by the user for a reserve_mem region.
*
* - compatible: "reserve-mem-v1"
*
* Identifies the ABI version of reserve_mem descriptions
*
* - start: u64
*
* Physical address of the reserved memory region.
*
* - size: u64
*
* size in bytes of the reserved memory region.
*/
/* Top level memblock FDT node name. */
#define MEMBLOCK_KHO_FDT "memblock"
/* The compatible string for the memblock FDT root node. */
#define MEMBLOCK_KHO_NODE_COMPATIBLE "memblock-v1"
/* The compatible string for the reserve_mem FDT nodes. */
#define RESERVE_MEM_KHO_NODE_COMPATIBLE "reserve-mem-v1"
#endif /* _LINUX_KHO_ABI_MEMBLOCK_H */
@@ -0,0 +1,93 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2025, Google LLC.
* Pasha Tatashin <pasha.tatashin@soleen.com>
*
* Copyright (C) 2025 Amazon.com Inc. or its affiliates.
* Pratyush Yadav <ptyadav@amazon.de>
*/
#ifndef _LINUX_KHO_ABI_MEMFD_H
#define _LINUX_KHO_ABI_MEMFD_H
#include <linux/types.h>
#include <linux/kho/abi/kexec_handover.h>
/**
* DOC: memfd Live Update ABI
*
* memfd uses the ABI defined below for preserving its state across a kexec
* reboot using the LUO.
*
* The state is serialized into a packed structure `struct memfd_luo_ser`
* which is handed over to the next kernel via the KHO mechanism.
*
* This interface is a contract. Any modification to the structure layout
* constitutes a breaking change. Such changes require incrementing the
* version number in the MEMFD_LUO_FH_COMPATIBLE string.
*/
/**
* MEMFD_LUO_FOLIO_DIRTY - The folio is dirty.
*
* This flag indicates the folio contains data from user. A non-dirty folio is
* one that was allocated (say using fallocate(2)) but not written to.
*/
#define MEMFD_LUO_FOLIO_DIRTY BIT(0)
/**
* MEMFD_LUO_FOLIO_UPTODATE - The folio is up-to-date.
*
* An up-to-date folio has been zeroed out. shmem zeroes out folios on first
* use. This flag tracks which folios need zeroing.
*/
#define MEMFD_LUO_FOLIO_UPTODATE BIT(1)
/**
* struct memfd_luo_folio_ser - Serialized state of a single folio.
* @pfn: The page frame number of the folio.
* @flags: Flags to describe the state of the folio.
* @index: The page offset (pgoff_t) of the folio within the original file.
*/
struct memfd_luo_folio_ser {
u64 pfn:52;
u64 flags:12;
u64 index;
} __packed;
/*
* The set of seals this version supports preserving. If support for any new
* seals is needed, add it here and bump version.
*/
#define MEMFD_LUO_ALL_SEALS (F_SEAL_SEAL | \
F_SEAL_SHRINK | \
F_SEAL_GROW | \
F_SEAL_WRITE | \
F_SEAL_FUTURE_WRITE | \
F_SEAL_EXEC)
/**
* struct memfd_luo_ser - Main serialization structure for a memfd.
* @pos: The file's current position (f_pos).
* @size: The total size of the file in bytes (i_size).
* @seals: The seals present on the memfd. The seals are uABI so it is safe
* to directly use them in the ABI.
* @flags: Flags for the file. Unused flag bits must be set to 0.
* @nr_folios: Number of folios in the folios array.
* @folios: KHO vmalloc descriptor pointing to the array of
* struct memfd_luo_folio_ser.
*/
struct memfd_luo_ser {
u64 pos;
u64 size;
u32 seals;
u32 flags;
u64 nr_folios;
struct kho_vmalloc folios;
} __packed;
/* The compatibility string for memfd file handler */
#define MEMFD_LUO_FH_COMPATIBLE "memfd-v2"
#endif /* _LINUX_KHO_ABI_MEMFD_H */