From: Tarun Sahu <tarunsahu@google.com>
To: Pasha Tatashin <pasha.tatashin@soleen.com>,
Mike Rapoport <rppt@kernel.org>,
robin.murphy@arm.com, maz@kernel.org, will@kernel.org,
David Matlack <dmatlack@google.com>,
Alexander Graf <graf@amazon.com>,
seanjc@google.com, jgg@nvidia.com, loganodell@google.com,
arnd@arndb.de, dwmw2@infradead.org, baolu.lu@linux.intel.com,
Bjorn Helgaas <bhelgaas@google.com>,
oupton@kernel.org, alex@shazbot.org, gle.com@google.com,
pbonzini@redhat.com, Andrew Morton <akpm@linux-foundation.org>,
kevin.tian@intel.com, joro@8bytes.org
Cc: kvmarm@lists.linux.dev, linux-pci@vger.kernel.org,
Pratyush Yadav <pratyush@kernel.org>,
kexec@lists.infradead.org, kvm@vger.kernel.org,
iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
skhawaja@google.com, sagis@google.com,
linux-arch@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Tarun Sahu <tarunsahu@google.com>
Subject: [PATCH v4 11/19] liveupdate: Add feature header to struct luo_file_set_ser
Date: Tue, 10 Nov 2026 05:01:54 +0000 [thread overview]
Message-ID: <20261110050202.529473-12-tarunsahu@google.com> (raw)
In-Reply-To: <20261110050202.529473-1-tarunsahu@google.com>
Precede struct luo_file_set_ser with struct kho_ser_hdr via
DECLARE_KHO_SER so future file-set metadata features can append fields
to struct luo_file_set_ser without breaking compatibility between
adjacent kernels.
Reserve space for both the session feature header and the file-set
feature header in each session block-set entry, initialize the file-set
feature header in luo_file_freeze(), and validate incoming required
features in luo_file_deserialize() before accessing payload fields.
Signed-off-by: Tarun Sahu <tarunsahu@google.com>
---
include/linux/kho/abi/luo.h | 15 ++++++++-------
kernel/liveupdate/luo_file.c | 32 ++++++++++++++++++++++----------
kernel/liveupdate/luo_internal.h | 7 ++++---
kernel/liveupdate/luo_session.c | 14 +++++++-------
4 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/include/linux/kho/abi/luo.h b/include/linux/kho/abi/luo.h
index 425c52c494f1..bd19211c64e1 100644
--- a/include/linux/kho/abi/luo.h
+++ b/include/linux/kho/abi/luo.h
@@ -112,21 +112,21 @@ static_assert(!IS_ENABLED(CONFIG_64BIT) ||
* @count: The total number of files that were part of this session during
* serialization. Used for iteration and validation during
* restoration.
+ *
+ * Preceded by &struct kho_ser_hdr.
*/
struct luo_file_set_ser {
u64 files;
u64 count;
};
-static_assert(sizeof(struct luo_file_set_ser) == 16);
-static_assert(!IS_ENABLED(CONFIG_64BIT) ||
- __alignof__(struct luo_file_set_ser) == 8);
+DECLARE_KHO_SER(luo_file_set_ser, 16, 0, 0);
/**
* 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 pointer to the files belonging to this session.
+ * @name: The unique name of the session, provided by the userspace at
+ * the time of session creation.
+ * @file_set_fhdr: Serialized pointer to the 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
@@ -137,7 +137,8 @@ static_assert(!IS_ENABLED(CONFIG_64BIT) ||
*/
struct luo_session_ser {
char name[LIVEUPDATE_SESSION_NAME_LENGTH];
- DECLARE_KHOSER_PTR(file_set_ser, struct luo_file_set_ser *);
+ DECLARE_KHOSER_PTR(file_set_fhdr,
+ DECLARE_KHO_SER_HDR(luo_file_set_ser, *));
};
DECLARE_KHO_SER(luo_session_ser, 72, 0, 0);
diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c
index a39992da504f..02d09a80d785 100644
--- a/kernel/liveupdate/luo_file.c
+++ b/kernel/liveupdate/luo_file.c
@@ -440,8 +440,8 @@ static void __luo_file_unfreeze(struct luo_file_set *file_set,
/**
* luo_file_freeze - Freezes all preserved files and serializes their metadata.
- * @file_set: The file_set whose files are to be frozen.
- * @file_set_ser: Where to put the serialized file_set.
+ * @file_set: The file_set whose files are to be frozen.
+ * @file_set_fhdr: Where to put the serialized file_set.
*
* This function is called from the reboot() syscall path, just before the
* kernel transitions to the new image via kexec. Its purpose is to perform the
@@ -472,12 +472,14 @@ static void __luo_file_unfreeze(struct luo_file_set *file_set,
* Return: 0 on success, or a negative errno on failure.
*/
int luo_file_freeze(struct luo_file_set *file_set,
- struct luo_file_set_ser *file_set_ser)
+ DECLARE_KHO_SER_HDR(luo_file_set_ser, *file_set_fhdr))
{
+ struct luo_file_set_ser *file_set_ser;
struct luo_file *luo_file;
struct kho_block_set_it it;
int err;
+ kho_ser_init(file_set_fhdr, luo_file_set_ser);
if (!file_set->count)
return 0;
@@ -506,6 +508,7 @@ int luo_file_freeze(struct luo_file_set *file_set,
file_ser->token = luo_file->token;
}
+ file_set_ser = kho_ser_payload(file_set_fhdr, luo_file_set_ser);
file_set_ser->count = file_set->count;
file_set_ser->files = kho_block_set_head_pa(&file_set->block_set);
@@ -519,8 +522,8 @@ int luo_file_freeze(struct luo_file_set *file_set,
/**
* luo_file_unfreeze - Unfreezes all files in a file_set and clear serialization
- * @file_set: The file_set whose files are to be unfrozen.
- * @file_set_ser: Serialized file_set.
+ * @file_set: The file_set whose files are to be unfrozen.
+ * @file_set_fhdr: Serialized file_set.
*
* This function rolls back the state of all files in a file_set after the
* freeze phase has begun but must be aborted. It is the counterpart to
@@ -534,13 +537,13 @@ int luo_file_freeze(struct luo_file_set *file_set,
* the reboot() syscall, after luo_file_freeze() has been called.
*/
void luo_file_unfreeze(struct luo_file_set *file_set,
- struct luo_file_set_ser *file_set_ser)
+ DECLARE_KHO_SER_HDR(luo_file_set_ser, *file_set_fhdr))
{
if (!file_set->count)
return;
__luo_file_unfreeze(file_set, NULL);
- memset(file_set_ser, 0, sizeof(*file_set_ser));
+ memset(file_set_fhdr, 0, kho_ser_size(luo_file_set_ser));
}
/**
@@ -780,8 +783,8 @@ static int luo_file_deserialize_one(struct luo_file_set *file_set,
/**
* luo_file_deserialize - Reconstructs the list of preserved files in the new kernel.
- * @file_set: The incoming file_set to fill with deserialized data.
- * @file_set_ser: Serialized KHO file_set data from the previous kernel.
+ * @file_set: The incoming file_set to fill with deserialized data.
+ * @file_set_fhdr: Serialized KHO file_set data from the previous kernel.
*
* This function is called during the early boot process of the new kernel. It
* takes the raw, contiguous memory block of 'struct luo_file_ser' entries,
@@ -804,12 +807,21 @@ static int luo_file_deserialize_one(struct luo_file_set *file_set,
* Context: Called from session deserialization.
*/
int luo_file_deserialize(struct luo_file_set *file_set,
- struct luo_file_set_ser *file_set_ser)
+ DECLARE_KHO_SER_HDR(luo_file_set_ser, *file_set_fhdr))
{
+ struct luo_file_set_ser *file_set_ser;
struct luo_file_ser *file_ser;
struct kho_block_set_it it;
int err;
+ if (!file_set_fhdr)
+ return -EINVAL;
+
+ err = kho_ser_validate(file_set_fhdr, luo_file_set_ser);
+ if (err)
+ return err;
+
+ file_set_ser = kho_ser_payload(file_set_fhdr, luo_file_set_ser);
if (!file_set_ser->files) {
WARN_ON(file_set_ser->count);
return 0;
diff --git a/kernel/liveupdate/luo_internal.h b/kernel/liveupdate/luo_internal.h
index dac6644bfb18..e22a8cf39d91 100644
--- a/kernel/liveupdate/luo_internal.h
+++ b/kernel/liveupdate/luo_internal.h
@@ -8,6 +8,7 @@
#ifndef _LINUX_LUO_INTERNAL_H
#define _LINUX_LUO_INTERNAL_H
+#include <linux/kho/abi/luo.h>
#include <linux/liveupdate.h>
#include <linux/uaccess.h>
#include <linux/kho_block.h>
@@ -104,14 +105,14 @@ int luo_session_deserialize(void);
int luo_preserve_file(struct luo_file_set *file_set, u64 token, int fd);
void luo_file_unpreserve_files(struct luo_file_set *file_set);
int luo_file_freeze(struct luo_file_set *file_set,
- struct luo_file_set_ser *file_set_ser);
+ DECLARE_KHO_SER_HDR(luo_file_set_ser, *file_set_fhdr));
void luo_file_unfreeze(struct luo_file_set *file_set,
- struct luo_file_set_ser *file_set_ser);
+ DECLARE_KHO_SER_HDR(luo_file_set_ser, *file_set_fhdr));
int luo_retrieve_file(struct luo_file_set *file_set, u64 token,
struct file **filep);
int luo_file_finish(struct luo_file_set *file_set);
int luo_file_deserialize(struct luo_file_set *file_set,
- struct luo_file_set_ser *file_set_ser);
+ DECLARE_KHO_SER_HDR(luo_file_set_ser, *file_set_fhdr));
void luo_file_set_init(struct luo_file_set *file_set);
void luo_file_set_destroy(struct luo_file_set *file_set);
diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_session.c
index 641bd67ce76e..6513fde3ecfe 100644
--- a/kernel/liveupdate/luo_session.c
+++ b/kernel/liveupdate/luo_session.c
@@ -132,7 +132,7 @@ struct luo_session_global {
};
#define LUO_SESSION_SER_SIZE (kho_ser_size(luo_session_ser) + \
- sizeof(struct luo_file_set_ser))
+ kho_ser_size(luo_file_set_ser))
static struct luo_session_global luo_session_global = {
.incoming = {
@@ -227,7 +227,7 @@ static void luo_session_unfreeze_one(struct luo_session *session,
{
guard(mutex)(&session->mutex);
luo_file_unfreeze(&session->file_set,
- KHOSER_LOAD_PTR(ser->file_set_ser));
+ KHOSER_LOAD_PTR(ser->file_set_fhdr));
}
static int luo_session_freeze_one(struct luo_session *session,
@@ -235,7 +235,7 @@ static int luo_session_freeze_one(struct luo_session *session,
{
guard(mutex)(&session->mutex);
return luo_file_freeze(&session->file_set,
- KHOSER_LOAD_PTR(ser->file_set_ser));
+ KHOSER_LOAD_PTR(ser->file_set_fhdr));
}
static int luo_session_release(struct inode *inodep, struct file *filep)
@@ -560,14 +560,14 @@ int __init luo_session_setup_incoming(u64 sessions_pa)
static struct luo_session_ser *
luo_session_ser_init(DECLARE_KHO_SER_HDR(luo_session_ser, *fhdr))
{
- struct luo_file_set_ser *file_set_ser;
+ DECLARE_KHO_SER_HDR(luo_file_set_ser, *file_set_fhdr);
struct luo_session_ser *ser;
kho_ser_init(fhdr, luo_session_ser);
- file_set_ser = (void *)fhdr + kho_ser_size(luo_session_ser);
+ file_set_fhdr = (void *)fhdr + kho_ser_size(luo_session_ser);
ser = kho_ser_payload(fhdr, luo_session_ser);
- KHOSER_STORE_PTR(ser->file_set_ser, file_set_ser);
+ KHOSER_STORE_PTR(ser->file_set_fhdr, file_set_fhdr);
return ser;
}
@@ -601,7 +601,7 @@ static int luo_session_deserialize_one(struct luo_session_header *sh,
scoped_guard(mutex, &session->mutex) {
err = luo_file_deserialize(&session->file_set,
- KHOSER_LOAD_PTR(ser->file_set_ser));
+ KHOSER_LOAD_PTR(ser->file_set_fhdr));
}
if (err) {
pr_warn("Failed to deserialize files for session [%s] %pe\n",
--
2.56.0.506.g506a7eabc5-goog
next prev parent reply other threads:[~2026-11-10 5:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 5:01 [PATCH v4 00/19] kho, liveupdate: Add feature header for fine-grained ABI compatibility Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 01/19] liveupdate, kho: Remove __packed from KHO, LUO and memfd ABI structures Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 02/19] kho: block: Record the entry size in the block header Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 03/19] kho, memfd_luo: Reference struct kho_vmalloc via serialized pointer Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 04/19] liveupdate: Reference struct luo_file_set_ser " Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 05/19] kho: Add feature header for fine-grained ABI compatibility Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 06/19] kho: kexec_metadata: Add the feature header Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 07/19] kho: vmalloc: " Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 08/19] kho: block: Add the feature header to blocks Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 09/19] liveupdate: Add feature header to struct luo_ser Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 10/19] liveupdate: Add feature header to struct luo_session_ser Tarun Sahu
2026-11-10 5:01 ` Tarun Sahu [this message]
2026-11-10 5:01 ` [PATCH v4 12/19] liveupdate: Add feature header to struct luo_file_ser Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 13/19] liveupdate: Add feature header to struct luo_flb_header_ser Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 14/19] liveupdate: Add feature header to struct luo_flb_ser Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 15/19] PCI: liveupdate: Add feature header to struct pci_ser Tarun Sahu
2026-11-10 5:01 ` [PATCH v4 16/19] PCI: liveupdate: Add feature header to struct pci_dev_ser Tarun Sahu
2026-11-10 5:02 ` [PATCH v4 17/19] mm: memfd_luo: Add feature header to struct memfd_luo_ser Tarun Sahu
2026-11-10 5:02 ` [PATCH v4 18/19] mm: memfd_luo: Add feature header to struct memfd_luo_folio_ser Tarun Sahu
2026-11-10 5:02 ` [PATCH v4 19/19] kho: Add KUnit test for the feature header helpers Tarun Sahu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261110050202.529473-12-tarunsahu@google.com \
--to=tarunsahu@google.com \
--cc=akpm@linux-foundation.org \
--cc=alex@shazbot.org \
--cc=arnd@arndb.de \
--cc=baolu.lu@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=dmatlack@google.com \
--cc=dwmw2@infradead.org \
--cc=gle.com@google.com \
--cc=graf@amazon.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kexec@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pci@vger.kernel.org \
--cc=loganodell@google.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=pasha.tatashin@soleen.com \
--cc=pbonzini@redhat.com \
--cc=pratyush@kernel.org \
--cc=robin.murphy@arm.com \
--cc=rppt@kernel.org \
--cc=sagis@google.com \
--cc=seanjc@google.com \
--cc=skhawaja@google.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®