Message ID | 20241006214956.24339-15-dpsmith@apertussolutions.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Boot modules for Hyperlaunch | expand |
On 2024-10-06 17:49, Daniel P. Smith wrote: > Use struct boot_module fields, start and size, when calculating the relocation > address and size. It also ensures that early_mod references are kept in sync. > > Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com> > --- > xen/arch/x86/setup.c | 36 +++++++++++++++++------------------- > 1 file changed, 17 insertions(+), 19 deletions(-) > > diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c > index f968758048ed..4f540c461b26 100644 > --- a/xen/arch/x86/setup.c > +++ b/xen/arch/x86/setup.c > @@ -1490,7 +1490,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) > struct boot_module *bm = &bi->mods[j]; > unsigned long size; > > - size = PAGE_ALIGN(bm->headroom + bm->mod->mod_end); > + size = PAGE_ALIGN(bm->headroom + bm->size); Is there a mismatch from mod_end in PFNs to bm->size in bytes? Or is mod_start in pfns and mod_end in bytes? > > if ( bi->mods[j].flags & BOOTMOD_FLAG_X86_RELOCATED ) > continue; > @@ -1504,13 +1504,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) > > if ( s < end && > (bm->headroom || > - ((end - size) >> PAGE_SHIFT) > bm->mod->mod_start) ) > + paddr_to_pfn(end - size) > paddr_to_pfn(bm->start)) ) Drop the paddr_to_pfn if both sides are now in bytes? > { > - move_memory(end - size + bm->headroom, > - (uint64_t)bm->mod->mod_start << PAGE_SHIFT, > - bm->mod->mod_end); > - bm->mod->mod_start = (end - size) >> PAGE_SHIFT; > - bm->mod->mod_end += bm->headroom; > + move_memory(end - size + bm->headroom, bm->start, bm->size); > + bm->start = (end - size); > + bm->mod->mod_start = paddr_to_pfn(bm->start); > + bm->size += bm->headroom; > + bm->mod->mod_end = bm->size; > bm->flags |= BOOTMOD_FLAG_X86_RELOCATED; > } > } > @@ -1700,13 +1698,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) > > for ( i = 0; i < bi->nr_modules; ++i ) > { > - set_pdx_range(bi->mods[i].mod->mod_start, > - bi->mods[i].mod->mod_start + > - PFN_UP(bi->mods[i].mod->mod_end)); > + set_pdx_range(paddr_to_pfn(bi->mods[i].mod->mod_start), > + paddr_to_pfn(bi->mods[i].mod->mod_start) + Shouldn't these be paddr_to_pfn(bi->mods[i].start) ? > + PFN_UP(bi->mods[i].size)); > map_pages_to_xen( > - (unsigned long)mfn_to_virt(bi->mods[i].mod->mod_start), > - _mfn(bi->mods[i].mod->mod_start), > - PFN_UP(bi->mods[i].mod->mod_end), PAGE_HYPERVISOR); > + (unsigned long)maddr_to_virt(bi->mods[i].start), > + maddr_to_mfn(bi->mods[i].start), > + PFN_UP(bi->mods[i].size), PAGE_HYPERVISOR); First argument should fit on same line as map_pages_to_xen(). > } > > #ifdef CONFIG_KEXEC Regards, Jason
On 10/7/24 16:44, Jason Andryuk wrote: > On 2024-10-06 17:49, Daniel P. Smith wrote: >> Use struct boot_module fields, start and size, when calculating the >> relocation >> address and size. It also ensures that early_mod references are kept >> in sync. >> >> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com> >> --- >> xen/arch/x86/setup.c | 36 +++++++++++++++++------------------- >> 1 file changed, 17 insertions(+), 19 deletions(-) >> >> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c >> index f968758048ed..4f540c461b26 100644 >> --- a/xen/arch/x86/setup.c >> +++ b/xen/arch/x86/setup.c >> @@ -1490,7 +1490,7 @@ void asmlinkage __init noreturn >> __start_xen(unsigned long mbi_p) >> struct boot_module *bm = &bi->mods[j]; >> unsigned long size; >> - size = PAGE_ALIGN(bm->headroom + bm->mod->mod_end); >> + size = PAGE_ALIGN(bm->headroom + bm->size); > > Is there a mismatch from mod_end in PFNs to bm->size in bytes? Or is > mod_start in pfns and mod_end in bytes? The conversion is the latter, mod_start is in PFN and mod_end is in bytes. >> if ( bi->mods[j].flags & BOOTMOD_FLAG_X86_RELOCATED ) >> continue; >> @@ -1504,13 +1504,13 @@ void asmlinkage __init noreturn >> __start_xen(unsigned long mbi_p) >> if ( s < end && >> (bm->headroom || >> - ((end - size) >> PAGE_SHIFT) > bm->mod->mod_start) ) >> + paddr_to_pfn(end - size) > paddr_to_pfn(bm->start)) ) > > Drop the paddr_to_pfn if both sides are now in bytes? True, both are in addresses, will drop. >> { >> - move_memory(end - size + bm->headroom, >> - (uint64_t)bm->mod->mod_start << PAGE_SHIFT, >> - bm->mod->mod_end); >> - bm->mod->mod_start = (end - size) >> PAGE_SHIFT; >> - bm->mod->mod_end += bm->headroom; >> + move_memory(end - size + bm->headroom, bm->start, >> bm->size); >> + bm->start = (end - size); >> + bm->mod->mod_start = paddr_to_pfn(bm->start); >> + bm->size += bm->headroom; >> + bm->mod->mod_end = bm->size; >> bm->flags |= BOOTMOD_FLAG_X86_RELOCATED; >> } >> } > >> @@ -1700,13 +1698,13 @@ void asmlinkage __init noreturn >> __start_xen(unsigned long mbi_p) >> for ( i = 0; i < bi->nr_modules; ++i ) >> { >> - set_pdx_range(bi->mods[i].mod->mod_start, >> - bi->mods[i].mod->mod_start + >> - PFN_UP(bi->mods[i].mod->mod_end)); >> + set_pdx_range(paddr_to_pfn(bi->mods[i].mod->mod_start), >> + paddr_to_pfn(bi->mods[i].mod->mod_start) + > > Shouldn't these be > paddr_to_pfn(bi->mods[i].start) > ? Correct, will fix. >> + PFN_UP(bi->mods[i].size)); >> map_pages_to_xen( >> - (unsigned long)mfn_to_virt(bi->mods[i].mod->mod_start), >> - _mfn(bi->mods[i].mod->mod_start), >> - PFN_UP(bi->mods[i].mod->mod_end), PAGE_HYPERVISOR); >> + (unsigned long)maddr_to_virt(bi->mods[i].start), >> + maddr_to_mfn(bi->mods[i].start), >> + PFN_UP(bi->mods[i].size), PAGE_HYPERVISOR); > > First argument should fit on same line as map_pages_to_xen(). If it fits, yes I will move it up. v/r, dps
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f968758048ed..4f540c461b26 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1490,7 +1490,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) struct boot_module *bm = &bi->mods[j]; unsigned long size; - size = PAGE_ALIGN(bm->headroom + bm->mod->mod_end); + size = PAGE_ALIGN(bm->headroom + bm->size); if ( bi->mods[j].flags & BOOTMOD_FLAG_X86_RELOCATED ) continue; @@ -1504,13 +1504,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( s < end && (bm->headroom || - ((end - size) >> PAGE_SHIFT) > bm->mod->mod_start) ) + paddr_to_pfn(end - size) > paddr_to_pfn(bm->start)) ) { - move_memory(end - size + bm->headroom, - (uint64_t)bm->mod->mod_start << PAGE_SHIFT, - bm->mod->mod_end); - bm->mod->mod_start = (end - size) >> PAGE_SHIFT; - bm->mod->mod_end += bm->headroom; + move_memory(end - size + bm->headroom, bm->start, bm->size); + bm->start = (end - size); + bm->mod->mod_start = paddr_to_pfn(bm->start); + bm->size += bm->headroom; + bm->mod->mod_end = bm->size; bm->flags |= BOOTMOD_FLAG_X86_RELOCATED; } } @@ -1542,11 +1542,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i = 0; i < bi->nr_modules; ++i ) { - uint64_t s = (uint64_t)bi->mods[i].mod->mod_start - << PAGE_SHIFT; + uint64_t s = (uint64_t)bi->mods[i].start; reserve_e820_ram(&boot_e820, s, - s + PAGE_ALIGN(bi->mods[i].mod->mod_end)); + s + PAGE_ALIGN(bi->mods[i].size)); } if ( !xen_phys_start ) @@ -1624,9 +1623,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) map_e = boot_e820.map[j].addr + boot_e820.map[j].size; for ( j = 0; j < bi->nr_modules; ++j ) { - uint64_t end = pfn_to_paddr( - bi->mods[j].mod->mod_start) + - bi->mods[j].mod->mod_end; + uint64_t end = bi->mods[j].start + + bi->mods[j].size; if ( map_e < end ) map_e = end; @@ -1700,13 +1698,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 0; i < bi->nr_modules; ++i ) { - set_pdx_range(bi->mods[i].mod->mod_start, - bi->mods[i].mod->mod_start + - PFN_UP(bi->mods[i].mod->mod_end)); + set_pdx_range(paddr_to_pfn(bi->mods[i].mod->mod_start), + paddr_to_pfn(bi->mods[i].mod->mod_start) + + PFN_UP(bi->mods[i].size)); map_pages_to_xen( - (unsigned long)mfn_to_virt(bi->mods[i].mod->mod_start), - _mfn(bi->mods[i].mod->mod_start), - PFN_UP(bi->mods[i].mod->mod_end), PAGE_HYPERVISOR); + (unsigned long)maddr_to_virt(bi->mods[i].start), + maddr_to_mfn(bi->mods[i].start), + PFN_UP(bi->mods[i].size), PAGE_HYPERVISOR); } #ifdef CONFIG_KEXEC
Use struct boot_module fields, start and size, when calculating the relocation address and size. It also ensures that early_mod references are kept in sync. Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com> --- xen/arch/x86/setup.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)