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 <g...@amazon.com> >>> >>> +/* >>> + * If KHO is active, only process its scratch areas to ensure we are not >>> + * stepping onto preserved memory. >>> + */ >> >> Same thing on the imperative voice here. >> >> I'm also not fully understanding the comment. Do these "scratch" regions >> basically represent all the memory that's not being handed over? It's >> not obvious. > > Scratch memory represents areas created at the boot of the first kernel and > it's known that scratch areas won't contain any memory that's being handed > over. > >>> diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c >>> index 57120f0749cc3..c314212a5ecd5 100644 >>> --- a/arch/x86/kernel/e820.c >>> +++ b/arch/x86/kernel/e820.c >>> @@ -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?