[PATCH v6 11/14] x86: add KHO support

Mike Rapoport rppt at kernel.org
Tue Apr 29 09:32:33 PDT 2025


On Tue, Apr 29, 2025 at 09:06:19AM -0700, Dave Hansen wrote:
> On 4/29/25 01:06, Mike Rapoport wrote:
> > On Mon, Apr 28, 2025 at 03:05:55PM -0700, Dave Hansen wrote:
> >> On 4/10/25 22:37, Changyuan Lyu wrote:
> >>> From: Alexander Graf <graf at amazon.com>
> >>>
> >>> @@ -1300,6 +1300,24 @@ void __init e820__memblock_setup(void)
> >>>  		memblock_add(entry->addr, entry->size);
> >>>  	}
> >>>  
> >>> +	/*
> >>> +	 * At this point with KHO we only allocate from scratch memory.
> >>> +	 * At the same time, we configure memblock to only allow
> >>> +	 * allocations from memory below ISA_END_ADDRESS which is not
> >>> +	 * a natural scratch region, because Linux ignores memory below
> >>> +	 * ISA_END_ADDRESS at runtime. Beside very few (if any) early
> >>> +	 * allocations, we must allocate real-mode trapoline below
> >>
> >> 						trampoline ^
> >>
> >>> +	 * ISA_END_ADDRESS.
> >>> +	 *
> >>> +	 * To make sure that we can actually perform allocations during
> >>> +	 * this phase, let's mark memory below ISA_END_ADDRESS as scratch
> >>> +	 * so we can allocate from there in a scratch-only world.
> >>> +	 *
> >>> +	 * After real mode trampoline is allocated, we clear scratch
> >>> +	 * marking from the memory below ISA_END_ADDRESS
> >>> +	 */
> >>> +	memblock_mark_kho_scratch(0, ISA_END_ADDRESS);
> >>
> >> This isn't making a whole ton of sense to me.
> >>
> >> Is this *only* to facilitate possible users that need <ISA_END_ADDRESS
> >> allocations? If so, please say that.
> >>
> >> I _think_ this is trying to say that KHO kernels are special and are
> >> trying to only allocate from scratch areas. But <ISA_END_ADDRESS
> >> allocations are both necessary and not marked by KHO _as_ a scratch area
> >> which causes a problem.
> > 
> > Yes :)
> 
> So, on both of these, could the submitters please add or revise the
> comments to make it more clear?

Is this one clearer?

	/*
	 * At this point memblock is only allowed to allocate from memory
	 * below 1M (aka ISA_END_ADDRESS) up until direct map is completely set
	 * up in init_mem_mapping().
	 *
	 * KHO kernels are special and use only scratch memory for memblock
	 * allocations, but memory below 1M is ignored by kernel after early
	 * boot and cannot be naturally marked as scratch.
	 *
	 * To allow allocation of the real-mode trampoline and a few (if any)
	 * other very early allocations from below 1M forcibly mark the memory
	 * below 1M as scratch.
	 *
	 * After real mode trampoline is allocated, we clear that scratch
	 * marking.
	 */
	memblock_mark_kho_scratch(0, SZ_1M);

-- 
Sincerely yours,
Mike.



More information about the kexec mailing list