From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796054950; b=IjmrUSrsVDDJufnV7AyMjWuXcI2unulSYUz1Gv7mUeCRQNdNIk7EEm/wpH39lio+8HpA 8X+i2xrTZdJQOgwyPFJuFwlW5lMyqoBnnve3LkPdGVEy34ZbXH4ZYxTRWH9zeUnK5h1qS 8ee4L3eQ+L7BaGWtD7WO2o9O5cbdLhoPFrDijkJOAxQgsyjeonUepNmL6Z2q1pjksYW5I eCk8kD069tpr11YkzCdt9IF2sbrxGr1M9AB5lSTx7CnLjfZgx68tD018Iofg3YrzeZJM5 tsdZXFSZx7x5hmkQWAiQbJ5yYmW/5Xn5V/VytRLSLnpOTr8KNj71hs2xOBjcwnDr25w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796054950; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=ng7JKT+d7LhusyfuKZG7g7vIxpAUFYCcvWTENnG9jvA=; b=bU5WAeafxEZk/o0vv+ir93p8udQ1Jn2EwqjPA8C0pUuoN1BDTF0Po/sxyYBNhpdkliDN GSL6EYQiSArGwDor62cBz4F6rREgtaALgF4hWHLp8pT+vcZc5Y0jLSiVCJl7EkfVRYpXo 49EmAoHgf8os6VuNJuZzb0bJQs6hzxrKjm1suwB2HFuylcDYiHNbRydBdjqHAGJ7yREvU 9fr1JU2waU+pifubdfGwJ5r03aWcn+zACqEQ6NXJGvo+bbJa7AmwHfTD4DmyANrbA9qqx OD9HgS8uuyRwTGo2Gvx5iEn87FI+TaWCrCBs4yURZp7oHpIWgOkOuoZFVEBbx9UCVxw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--tarunsahu.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=HF9qHeCX; arc=none smtp.remote-ip=209.85.218.72 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60D3E606A329 for ; Mon, 30 Nov 2026 16:09:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 60D3E606A329 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--tarunsahu.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=HF9qHeCX Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-c508bafaddfso816112066b.1 for ; Mon, 30 Nov 2026 08:09:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796054948; x=1796659748; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ng7JKT+d7LhusyfuKZG7g7vIxpAUFYCcvWTENnG9jvA=; b=HF9qHeCXL2GiLm7IFKri7p47HSsWAeYafBpueK5THu9Yps3nMTL3YisMg7qj2wCkcU kExyfsW+bfZbvjDC/49nOVkINHy9KQuqwCQlAxugqakbCl847DthpZmlxSC50wW2j+4r bKb7+iOthXcHRLq37omP6ZQ0h2C04MIqQyzSyodOzowGV3WCQTKu8fqDleBDcjDN3QgE tcOKWHSKm+bECEIToQrweb9z2gd52UpLrL6qDjpB3erMjHdrCjsMkEX1sPGPZ4jSw4Bs FImXiy8/74364juKRc7uEB8sHuoKlMiLrsezo4rBLCBGHFysX+vUGV51PqxBR3TiZlnD U1pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796054948; x=1796659748; h=content-type: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:content-type; bh=ng7JKT+d7LhusyfuKZG7g7vIxpAUFYCcvWTENnG9jvA=; b=BBVVR9GpgJf5EEPmh/zQBZs6a61Ds2HMuLIMe9WBg04exWYwb5hI+0gKo/nt/qwg5P fnDCgPl6qaj1NRlP2J3qYRSv1vOU4ReIyOANzqUbV5cE2r9JkMLst+UDPPQYVWiHKBLY XlTz1I0L2TIic59kwmKnDku9cTQTkMT/eMHpojbn9yrw7/M0oEZRTYN0J4rXCxJl2D/q aBFBFKeMQhgX8c+opmnfyQcWFS4juE8xVt0EB5EnfXWo8v5C6yLMU3Y68C6SdCIJw6Ip owBJmlTIGuip/IW3gbry3CYK0ZSsx4ENhkrsQ52l/rY54bfmQkjpFEF+PYd9x/CKnKqS +kYQ== X-Forwarded-Encrypted: i=1; AL+hErEEMAUgu4GNicT+zFqSo2BnwOV2hf9OJtummvUh2adW9bihRNRVaVNao6/Unx4a2dgy37ntZfiRl2ReEdI=@vger.kernel.org X-Gm-Message-State: APuU4Z/ETXp8oMjVAKPafghDHSunZxK8h2U8KriD2SeqnelFOttOmdel VY+gkzqu4p8KVj+Sd+FhhA8gLk1NnPEzb92KDPp7WBr08jH2DKQyPYPoV3MBMzO6a/kZiBFHkwu 3SjUOl5Bf7IenkiooQA== X-Received: from ejzr19.prod.google.com ([2002:a17:906:c293:b0:c3f:8199:7182]) (user=tarunsahu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:906:17c9:b0:c46:7ec3:fde7 with SMTP id a640c23a62f3a-c513a8920damr2165728166b.31.1796054947137; Mon, 30 Nov 2026 08:09:07 -0800 (PST) Date: Mon, 30 Nov 2026 16:09:06 +0000 In-Reply-To: <2vxzh5h3wjv8.fsf@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261110050202.529473-1-tarunsahu@google.com> <20261110050202.529473-8-tarunsahu@google.com> <2vxzh5h3wjv8.fsf@kernel.org> Message-ID: <9huzpkvmmhct.fsf@tarunix.c.googlers.com> Subject: Re: [PATCH v4 07/19] kho: vmalloc: Add the feature header From: tarunsahu@google.com To: Pratyush Yadav Cc: Pasha Tatashin , Mike Rapoport , robin.murphy@arm.com, maz@kernel.org, will@kernel.org, David Matlack , Alexander Graf , seanjc@google.com, jgg@nvidia.com, loganodell@google.com, arnd@arndb.de, dwmw2@infradead.org, baolu.lu@linux.intel.com, Bjorn Helgaas , oupton@kernel.org, alex@shazbot.org, gle.com@google.com, pbonzini@redhat.com, Andrew Morton , kevin.tian@intel.com, joro@8bytes.org, kvmarm@lists.linux.dev, linux-pci@vger.kernel.org, Pratyush Yadav , 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 Content-Type: text/plain; charset="UTF-8" Pratyush Yadav writes: > On Tue, Nov 10 2026, Tarun Sahu wrote: > >> Register struct kho_vmalloc with the KHO serialization feature header >> mechanism to allow future additive fields or feature extensions without >> breaking live update ABI compatibility. >> >> Add DECLARE_KHO_SER(kho_vmalloc, 16, 0, 0) to register the 16-byte >> structure with 0 required and 0 optional features. Update function >> prototypes in include/linux/kexec_handover.h to take >> DECLARE_KHO_SER_HDR(kho_vmalloc, *fhdr) parameters, documenting which >> registered structure the feature header belongs to while enforcing >> compile-time type verification. >> >> In kho_preserve_vmalloc(), initialize the feature header with >> kho_ser_init() and access the payload fields via kho_ser_payload(). >> In kho_restore_vmalloc(), validate incoming required features with >> kho_ser_validate() and access payload fields via kho_ser_payload(). >> In kho_unpreserve_vmalloc(), access payload fields via kho_ser_payload(). >> The chunk page format and traversal remain unchanged. >> >> Update memfd_luo and test_kho to pass typed feature header pointers >> and use kho_ser_size() for allocation sizing. >> >> Signed-off-by: Tarun Sahu > [...] >> diff --git a/include/linux/kho/abi/memfd.h b/include/linux/kho/abi/memfd.h >> index 7b49dd6d7e2a..b0597c438973 100644 >> --- a/include/linux/kho/abi/memfd.h >> +++ b/include/linux/kho/abi/memfd.h >> @@ -80,9 +80,9 @@ static_assert(!IS_ENABLED(CONFIG_64BIT) || >> * @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: Pointer to KHO vmalloc descriptor for the array of >> - * struct memfd_luo_folio_ser. >> + * @nr_folios: Number of folios in the folios array. >> + * @folios_fhdr: Pointer to KHO vmalloc descriptor for the array of >> + * struct memfd_luo_folio_ser. >> */ >> struct memfd_luo_ser { >> u64 pos; >> @@ -90,7 +90,7 @@ struct memfd_luo_ser { >> u32 seals; >> u32 flags; >> u64 nr_folios; >> - DECLARE_KHOSER_PTR(folios, struct kho_vmalloc *); >> + DECLARE_KHOSER_PTR(folios_fhdr, DECLARE_KHO_SER_HDR(kho_vmalloc, *)); > > This doesn't _only_ point to the feature header. It points to the > vmalloc buffer of of folios, conceptually. So it should be called > "folios". Reading folios_fhdr everywhere is super confusing and hard to > read. Users of KHO vmalloc should be pointing to the KHO malloc > serialization structure, not to its headers or so on. > > The feature header is an implementation detail of kho_vmalloc (same for > others). It should not be visible to its callers. Sounds good to me. > >> }; >> >> static_assert(sizeof(struct memfd_luo_ser) == 40); >> diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c >> index 641a3b4c88fb..6e428df717cc 100644 >> --- a/kernel/liveupdate/kexec_handover.c >> +++ b/kernel/liveupdate/kexec_handover.c >> @@ -1378,20 +1378,20 @@ static void kho_vmalloc_unpreserve_chunk(struct kho_vmalloc_chunk *chunk, >> /** >> * kho_preserve_vmalloc - preserve memory allocated with vmalloc() across kexec >> * @ptr: pointer to the area in vmalloc address space >> - * @preservation: placeholder for preservation metadata >> + * @fhdr: placeholder for preservation metadata >> * >> * Instructs KHO to preserve the area in vmalloc address space at @ptr. The >> * physical pages mapped at @ptr will be preserved and on successful return >> - * @preservation will hold the physical address of a structure that describes >> - * the preservation. >> + * @fhdr will hold the preservation metadata. >> * >> * NOTE: The memory allocated with vmalloc_node() variants cannot be reliably >> * restored on the same node >> * >> * Return: 0 on success, error code on failure >> */ >> -int kho_preserve_vmalloc(void *ptr, struct kho_vmalloc *preservation) >> +int kho_preserve_vmalloc(void *ptr, DECLARE_KHO_SER_HDR(kho_vmalloc, *fhdr)) >> { >> + struct kho_vmalloc *vmalloc_ser; >> struct kho_vmalloc_chunk *chunk; >> struct vm_struct *vm = find_vm_area(ptr); >> unsigned int order, flags, nr_contig_pages; >> @@ -1404,13 +1404,18 @@ int kho_preserve_vmalloc(void *ptr, struct kho_vmalloc *preservation) >> if (vm->flags & ~KHO_VMALLOC_SUPPORTED_FLAGS) >> return -EOPNOTSUPP; >> >> + kho_ser_init(fhdr, kho_vmalloc); >> + >> + vmalloc_ser = kho_ser_payload(fhdr, kho_vmalloc); >> + >> flags = vmalloc_flags_to_kho(vm->flags); >> order = get_vm_area_page_order(vm); >> + vmalloc_ser->order = order; > > Nit: Why is this moving around? Seems like a stray change. > > Also, renaming preservation to vmalloc_ser adds a lot of noise to your > diff. Perhaps keep it as-is for now? I tried to make it clear that each structure is serialized individually. like every *_ser comes with a hdr. >> >> chunk = new_vmalloc_chunk(NULL); >> if (!chunk) >> return -ENOMEM; >> - KHOSER_STORE_PTR(preservation->first, chunk); >> + KHOSER_STORE_PTR(vmalloc_ser->first, chunk); >> >> nr_contig_pages = (1 << order); >> for (int i = 0; i < vm->nr_pages; i += nr_contig_pages) { > [...] > > -- > Regards, > Pratyush Yadav