linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pratyush Yadav <pratyush@kernel.org>
To: Mike Rapoport <rppt@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Alexander Graf <graf@amazon.com>,
	 Jason Miu <jasonmiu@google.com>,
	 Jonathan Corbet <corbet@lwn.net>,
	 Pasha Tatashin <pasha.tatashin@soleen.com>,
	 Pratyush Yadav <pratyush@kernel.org>,
	 kexec@lists.infradead.org, linux-doc@vger.kernel.org,
	 linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 5/6] kho: Relocate vmalloc preservation structure to KHO ABI header
Date: Tue, 20 Jan 2026 16:26:51 +0000	[thread overview]
Message-ID: <2vxzy0lscks4.fsf@kernel.org> (raw)
In-Reply-To: <20260105165839.285270-6-rppt@kernel.org> (Mike Rapoport's message of "Mon, 5 Jan 2026 18:58:38 +0200")

On Mon, Jan 05 2026, Mike Rapoport wrote:

> From: Jason Miu <jasonmiu@google.com>
>
> The `struct kho_vmalloc` defines the in-memory layout for preserving
> vmalloc regions across kexec. This layout is a contract between kernels
> and part of the KHO ABI.
>
> To reflect this relationship, the related structs and helper macros are
> relocated to the ABI header, `include/linux/kho/abi/kexec_handover.h`.
> This move places the structure's definition under the protection of the
> KHO_FDT_COMPATIBLE version string.
>
> The structure and its components are now also documented within the
> ABI header to describe the contract and prevent ABI breaks.
>
> Signed-off-by: Jason Miu <jasonmiu@google.com>
> Co-developed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
[...]
> +/* 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); \
> +	})

Nit: not a fan of exposing code internals to the ABI header. But without
this the definition of kho_vmalloc_hdr won't make any sense to someone
reading the doc without looking at the code. Dunno if we can do anything
better though...

> +
> +/*
> + * 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 an array of physical addresses of the pages that make up the
> + * preserved vmalloc area.

Perhaps also mention that the array is 0-terminated?

Looks good otherwise.

[...]

-- 
Regards,
Pratyush Yadav


  reply	other threads:[~2026-01-20 16:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05 16:58 [PATCH 0/6] kho: ABI headers and Documentation updates Mike Rapoport
2026-01-05 16:58 ` [PATCH 1/6] kho/abi: luo: make generated documentation more coherent Mike Rapoport
2026-01-20 15:48   ` Pratyush Yadav
2026-01-22 18:27   ` Pasha Tatashin
2026-01-05 16:58 ` [PATCH 2/6] kho/abi: memfd: " Mike Rapoport
2026-01-20 15:49   ` Pratyush Yadav
2026-01-22 18:28   ` Pasha Tatashin
2026-01-05 16:58 ` [PATCH 3/6] kho: docs: combine concepts and FDT documentation Mike Rapoport
2026-01-20 16:08   ` Pratyush Yadav
2026-01-20 18:35     ` Mike Rapoport
2026-01-20 18:36       ` Pratyush Yadav
2026-01-22 18:27   ` Pasha Tatashin
2026-01-05 16:58 ` [PATCH 4/6] kho: Introduce KHO FDT ABI header Mike Rapoport
2026-01-20 16:14   ` Pratyush Yadav
2026-01-22 18:29   ` Pasha Tatashin
2026-01-05 16:58 ` [PATCH 5/6] kho: Relocate vmalloc preservation structure to KHO " Mike Rapoport
2026-01-20 16:26   ` Pratyush Yadav [this message]
2026-01-20 18:42     ` Mike Rapoport
2026-01-20 18:56       ` Pratyush Yadav
2026-01-22 18:24         ` Pasha Tatashin
2026-01-05 16:58 ` [PATCH 6/6] kho/abi: add memblock " Mike Rapoport
2026-01-20 16:31   ` Pratyush Yadav
2026-01-20 18:44     ` Mike Rapoport
2026-01-22 18:25   ` Pasha Tatashin
2026-01-20 16:32 ` [PATCH 0/6] kho: ABI headers and Documentation updates Pratyush Yadav

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=2vxzy0lscks4.fsf@kernel.org \
    --to=pratyush@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=graf@amazon.com \
    --cc=jasonmiu@google.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=rppt@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