Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795870829; b=J9w2KPeMXO5Gp8lV7NzJK2JKX+FGXyNmSmDwUOAuWspoEjT8lorcLkIy4ddHBZODEMVt n/k3M7YjmoYKEE5pEcgoxTHHFMV57ifNRYdtNq5FmpHXEWls07D/a2VShU+qCFpmFxz6J Fn5xafBG4ODzh6eZdqcSWyClz6BMshnKKsDxJMWY3BDfYFWBy999kSYq1Q0WMtG71RjME ThtIVfjQdtSSoFLgRME+6SoGebspNXdBMAO6qT6KuNgO/5Y/SCnBH+1j2bvE8yhmU/aCT 57ErJVhmRtwHijOVj2Hf8s/JStuBdsZ5cuQtzIoZ5q67S3MPizfKzCSq8yqSwT68MIg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795870829; 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=d6BkAp7ECdk7km8IXzswx291+eDVbqVT1bK4nfJre9c=; b=XXxN/Xhc1AkilYeTgzfLg7CTu0dAzHFd3qDSL6VgH52ljqkuz4HZmMHSTLkbcxxv8ybs xHf5zy8Oa+neX/bvUHQdP2ZLIMw372NsH4a+0Mkzfmn9t/KlK8BbBS8mrVkwth919eIOI NUKjYjQm1h3s+cXD32N5GV6lDYbK39aWo//W+QxzPRTZn+eZeD+14AYKlI2vI9Fo/O2Uu WoUvqfWV4WOfcshe6xG35nW9Rn5A9siUlJC4eyOvsfZsLkIQ9823QMKOV/KcU2psFG+r6 nTJOkJyMdk3BSbT6QFT1pg3qAyW49COBD45zWt6H3uWENfSwVn9i6aAc+LDJppJeJEA== 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=CiK14xPr; arc=none smtp.remote-ip=209.85.218.69 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (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 2777A606A326 for ; Sat, 28 Nov 2026 13:00:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2777A606A326 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=CiK14xPr Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-c40aa03ded8so847759266b.2 for ; Sat, 28 Nov 2026 05:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795870826; x=1796475626; 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=d6BkAp7ECdk7km8IXzswx291+eDVbqVT1bK4nfJre9c=; b=CiK14xPrrxHAZcwKgPYEry9+8DB6qjeyuPWTq4AOlSVBmohXvdN4g7RiDUUIXGWP4p 1JLJPdNM1KahxhvxRDlR5yzyG/cKY2PmiAyPQCGDNSfCO7Aq4vuHTneXz+O+lHn2O1sc aacTiStOd/Tjxgy8E+neiHJjfDoIAj87Iceg2tSkzteWsgc5HryrdqU3QtswvgtHyCaT iVfB1J6NV4MkUAgzkS6Ka9jB6ZMKFSaHki8xW4WHrEch7/skS6RFRYGpUCUi4zDaXQMd sjxqXzPk+sSwfqw4lkErvjgRg+nPbfR+hNo8mMTFKsvYFrxuuaCh1TbpC2c8vla+9MRq 0u5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795870826; x=1796475626; 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=d6BkAp7ECdk7km8IXzswx291+eDVbqVT1bK4nfJre9c=; b=MM5pOQyUS/xp5UR8vvls9O6w8WQOxLkiqC2C/joPopqkTmPFOJWqPU8QdnTHoGmuw3 6XiReEtWiv7uuze/c1aDOBkfv/UQ/sST9QWwNsWrJV8aA6UqXaBI295H6kQb8Wnret9E WfLy7IW6pEYy9D+DzFP8miPeTjoDPYz6I5VI9rAnBJfz5A4HKEZt3inMYmQ+REK++hrz hDzC3x2TN2sWRK2w72Ch1ryHv5cBx0PVaSjL1mBHxFzT0i9KvAqE/Zk/caovqBgzsvYI uLov2YEJ4rOjrxvlVajng8mTQemwvN4XE5knyJ26HcpkjFfHWQtXvWxLkYj/i2aoysG3 8bYw== X-Forwarded-Encrypted: i=1; AL+hErEcniCYzYxAJ57wrGV3g/QmR/aOStUBLZnXR9PAioio1SujbFSCqQUADNgYhdYdfqFmrpY=@vger.kernel.org X-Gm-Message-State: APuU4Z+uaDw2AnO+umjkNNyHTx0IePxyKWjuO3e+7b0iVr9YkQ0k4OAb M6AUjmIdK/VEQuNUFtkP4HCg1I8tJXfH7cwlcJk8WhneC646oUviy+uhw0wW001omiZjRm1UDvl r66FP/RL5c/B27FoPkg== X-Received: from ejtf9.prod.google.com ([2002:a17:906:4949:b0:c31:8840:5c0c]) (user=tarunsahu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:906:3d21:b0:c51:24a4:1dfb with SMTP id a640c23a62f3a-c513ac7edecmr1624478866b.40.1795870826056; Sat, 28 Nov 2026 05:00:26 -0800 (PST) Date: Sat, 28 Nov 2026 13:00:25 +0000 In-Reply-To: X-Mailing-List: kvm@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-3-tarunsahu@google.com> Message-ID: <9huzpkvpglg6.fsf@tarunix.c.googlers.com> Subject: Re: [PATCH v4 02/19] kho: block: Record the entry size in the block header From: tarunsahu@google.com To: Mike Rapoport Cc: Pasha Tatashin , 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" Mike Rapoport writes: > On Tue, Nov 10, 2026 at 05:01:45AM +0000, Tarun Sahu wrote: >> Subsystems using the KHO Serialization Blocks framework currently do >> not record the serialized entry size in the block header. The entry size >> is only known to individual callers, which must track and store it in an >> owning serialized data structure. If a newer source kernel adds fields >> to an entry, the changed entry size breaks the stride when an older >> target kernel iterates over blocks. >> >> Add an entry_size field to struct kho_block_header_ser. On the outgoing >> side, record bs->entry_size into every block header during allocation. >> During restoration, derive the entry stride directly from the block >> header instead of relying on caller-supplied dimensions. The >> kho_block_set_init() interface remains unchanged. A zero entry size, >> or one that differs between blocks of a set, is rejected during >> restoration. >> >> This change modifies the serialized layout of struct kho_block_header_ser > > Imperative voice please. Okay, Will take care of that everywhere. Thanks > >> and shifts the offset of serialized entries within preserved blocks. >> Bump KHO_FDT_COMPATIBLE from kho-v4 to kho-v5 so that pre-v5 and post-v5 >> kernels cleanly reject mismatched handover state during boot. Also >> update the stale compatible string example in the documentation. >> >> Suggested-by: Pratyush Yadav >> Signed-off-by: Tarun Sahu >> --- >> include/linux/kho/abi/block.h | 10 ++++---- >> include/linux/kho/abi/kexec_handover.h | 6 ++--- >> kernel/liveupdate/kho_block.c | 32 +++++++++++++++++++++++--- >> 3 files changed, 38 insertions(+), 10 deletions(-) >> >> @@ -264,8 +274,21 @@ int kho_block_set_restore(struct kho_block_set *bs, u64 head_pa) >> } >> >> while (next_pa) { >> + u64 capacity; >> + >> ser = phys_to_virt(next_pa); >> - if (!ser->count || ser->count > bs->count_per_block) { >> + if (!ser->entry_size || (entry_size && ser->entry_size != entry_size)) { >> + pr_warn("Block contains invalid entry size: %llu\n", >> + ser->entry_size); >> + err = -EINVAL; >> + goto err_destroy; >> + } >> + entry_size = ser->entry_size; >> + bs->entry_size = entry_size; >> + capacity = (KHO_BLOCK_SIZE - sizeof(*ser)) / bs->entry_size; >> + bs->count_per_block = capacity; > > Nit: can't we just initialize bs->count_per_block directly and drop > 'capacity' and the change of the following line? > > We are not very strict with 80-chars limit in kho/luo anyway. > Sounds good. I will update it. ~Tarun >> + >> + if (!ser->count || ser->count > capacity) { >> pr_warn("Block contains invalid entry count: %llu\n", >> ser->count); >> err = -EINVAL; > > -- > Sincerely yours, > Mike.