[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [MINI-OS PATCH 02/12] kexec: add final kexec stage
On Fri, Mar 21, 2025 at 5:25 AM Juergen Gross <jgross@xxxxxxxx> wrote: > > Add the code and data definitions of the final kexec stage. > > Put the code and related data into a dedicated section in order to be > able to copy it to another location. For this reason there must be no > absolute relocations being used in the code or data. > > Being functionally related, add a function for adding a final kexec > action. > > Signed-off-by: Juergen Gross <jgross@xxxxxxxx> > --- /dev/null > +++ b/arch/x86/kexec.c > @@ -0,0 +1,109 @@ > + > +/* > + * Final stage of kexec. Copies all data to the final destinations, zeroes > + * .bss and activates new kernel. > + * Must be called with interrupts off. Stack, code and data must be > + * accessible via identity mapped virtual addresses (virt == phys). Copying > + * and zeroing is done using virtual addresses. > + * No relocations inside the function are allowed, as it is copied to an > + * allocated page before being executed. "page" is stated here. Do we need an ASSERT later? > + */ > +void do_kexec(void *kexec_page) > +{ > + unsigned long actions; > + unsigned long stack; > + unsigned long final; > + unsigned long phys; > + > + actions = get_kexec_addr(kexec_page, kexec_actions); > + stack = get_kexec_addr(kexec_page, kexec_stack + KEXEC_STACK_LONGS); > + final = get_kexec_addr(kexec_page, kexec_final); > + phys = get_kexec_addr(kexec_page, kexec_phys); > + > + memcpy(kexec_page, _kexec_start, KEXEC_SECSIZE); > + asm("cli\n\t" > + "mov %0, %%"ASM_SP"\n\t" > + "mov %1, %%"ASM_ARG1"\n\t" > + "mov %2, %%"ASM_ARG2"\n\t" > + "jmp *%3" > + :"=m" (stack), "=m" (actions), "=m" (phys) Aren't these inputs and not outputs? > + :"m" (final)); > +} > + > +#endif /* CONFIG_KEXEC */ > diff --git a/include/kexec.h b/include/kexec.h > index 6fd96774..722be456 100644 > --- a/include/kexec.h > +++ b/include/kexec.h > @@ -1,7 +1,34 @@ > + > +int kexec_add_action(int action, void *dest, void *src, unsigned int len); > + > +#define KEXEC_SECSIZE ((unsigned long)_kexec_end - (unsigned > long)_kexec_start) Add a build assertion here? Or maybe the correct amount is allocated and it doesn't matter. Generally looks good. Regards, Jason
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |