All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@intel.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: nigel@nigel.suspend2.net,
	Kexec Mailing List <kexec@lists.infradead.org>,
	linux-kernel@vger.kernel.org, "Rafael J. Wysocki" <rjw@sisk.pl>,
	Pavel Machek <pavel@ucw.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vivek Goyal <vgoyal@redhat.com>
Subject: Re: [PATCH] kexec based hibernation: a prototype of kexec multi-stage load
Date: Fri, 16 May 2008 10:56:15 +0800	[thread overview]
Message-ID: <1210906575.23707.189.camel@caritas-dev.intel.com> (raw)
In-Reply-To: <m14p8zgf43.fsf@frodo.ebiederm.org>

On Thu, 2008-05-15 at 19:25 -0700, Eric W. Biederman wrote:
> "Huang, Ying" <ying.huang@intel.com> writes:
> 
> > On Thu, 2008-05-15 at 11:39 -0700, Eric W. Biederman wrote:
> > [...]
> >> 2) After we figure out our address read the stack pointer from
> >>    a fixed location and simply set it.  (This is my preference)
> >
> > Just for confirmation (My English is poor).
> >
> > Do you mean that kernel A just read the stack top as re-entry point,
> > regardless of whether it is return address or argument 1?
> 
> What I was thinking was:
> 
> In kernel A()
> 
> relocate_new_kernel:
> 
>         ...
> 
>         call	*%eax
> 
> kexec_jump_back_entry:
>         /* This code should be PIC so figure out where we are */
>         call	1f
> 1:
>         popl	%edi
>         subl	$(1b - relocate_kernel), %edi
> 
>         /* Setup a safe stack */
>         leal    PAGE_SIZE(%edi), %esp
>         ...
> 
> 
> Then in purgatory we can read the address of kexec_jump_back_entry
> by examining 0(%esp) and export it in whatever fashion is sane.
> 
> However we reach kexec_jump_back_entry we should be fine.

I think it is reasonable to enable jumping back and forth more than one
time. So the following should be possible:

1. Jump from A to B (actually jump to purgatory, trigger the boot of B)
2. Jump from B to A
3. Jump from A to B again (jump to the kexec_jump_back_entry of B)
4. Jump from B to A
...

So it should be possible to get the re-entry point of kernel B in
kexec_jump_back_entry of kernel A too. So I think in
kexec_jump_back_entry, the caller's stack should be checked to get
re-entry point of peer. And the stack state is different depend on where
come from, from relocate_new_kernel() or return.

Best Regards,
Huang Ying


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

WARNING: multiple messages have this Message-ID (diff)
From: "Huang, Ying" <ying.huang@intel.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Vivek Goyal <vgoyal@redhat.com>, Pavel Machek <pavel@ucw.cz>,
	nigel@nigel.suspend2.net, "Rafael J. Wysocki" <rjw@sisk.pl>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Kexec Mailing List <kexec@lists.infradead.org>
Subject: Re: [PATCH] kexec based hibernation: a prototype of kexec multi-stage load
Date: Fri, 16 May 2008 10:56:15 +0800	[thread overview]
Message-ID: <1210906575.23707.189.camel@caritas-dev.intel.com> (raw)
In-Reply-To: <m14p8zgf43.fsf@frodo.ebiederm.org>

On Thu, 2008-05-15 at 19:25 -0700, Eric W. Biederman wrote:
> "Huang, Ying" <ying.huang@intel.com> writes:
> 
> > On Thu, 2008-05-15 at 11:39 -0700, Eric W. Biederman wrote:
> > [...]
> >> 2) After we figure out our address read the stack pointer from
> >>    a fixed location and simply set it.  (This is my preference)
> >
> > Just for confirmation (My English is poor).
> >
> > Do you mean that kernel A just read the stack top as re-entry point,
> > regardless of whether it is return address or argument 1?
> 
> What I was thinking was:
> 
> In kernel A()
> 
> relocate_new_kernel:
> 
>         ...
> 
>         call	*%eax
> 
> kexec_jump_back_entry:
>         /* This code should be PIC so figure out where we are */
>         call	1f
> 1:
>         popl	%edi
>         subl	$(1b - relocate_kernel), %edi
> 
>         /* Setup a safe stack */
>         leal    PAGE_SIZE(%edi), %esp
>         ...
> 
> 
> Then in purgatory we can read the address of kexec_jump_back_entry
> by examining 0(%esp) and export it in whatever fashion is sane.
> 
> However we reach kexec_jump_back_entry we should be fine.

I think it is reasonable to enable jumping back and forth more than one
time. So the following should be possible:

1. Jump from A to B (actually jump to purgatory, trigger the boot of B)
2. Jump from B to A
3. Jump from A to B again (jump to the kexec_jump_back_entry of B)
4. Jump from B to A
...

So it should be possible to get the re-entry point of kernel B in
kexec_jump_back_entry of kernel A too. So I think in
kexec_jump_back_entry, the caller's stack should be checked to get
re-entry point of peer. And the stack state is different depend on where
come from, from relocate_new_kernel() or return.

Best Regards,
Huang Ying


  reply	other threads:[~2008-05-16  2:50 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-12  6:40 [PATCH] kexec based hibernation: a prototype of kexec multi-stage load Huang, Ying
2008-05-12  6:40 ` Huang, Ying
2008-05-13  5:34 ` Vivek Goyal
2008-05-13  5:34   ` Vivek Goyal
2008-05-14  1:57   ` Huang, Ying
2008-05-14  1:57     ` Huang, Ying
2008-05-14  2:56     ` Vivek Goyal
2008-05-14  2:56       ` Vivek Goyal
2008-05-14  3:37       ` Huang, Ying
2008-05-14  3:37         ` Huang, Ying
2008-05-14 21:43         ` Eric W. Biederman
2008-05-14 21:43           ` Eric W. Biederman
2008-05-15  2:40           ` Huang, Ying
2008-05-15  2:40             ` Huang, Ying
2008-05-15  4:57           ` Huang, Ying
2008-05-15  4:57             ` Huang, Ying
2008-05-15 18:39             ` Eric W. Biederman
2008-05-15 18:39               ` Eric W. Biederman
2008-05-16  1:41               ` Huang, Ying
2008-05-16  1:41                 ` Huang, Ying
2008-05-16  2:25                 ` Eric W. Biederman
2008-05-16  2:25                   ` Eric W. Biederman
2008-05-16  2:56                   ` Huang, Ying [this message]
2008-05-16  2:56                     ` Huang, Ying
2008-05-16  3:27                     ` Vivek Goyal
2008-05-16  3:27                       ` Vivek Goyal
2008-05-16 13:40                       ` Vivek Goyal
2008-05-16 13:40                         ` Vivek Goyal
2008-05-18  1:59                       ` Eric W. Biederman
2008-05-18  1:59                         ` Eric W. Biederman
2008-05-16  3:33                     ` Eric W. Biederman
2008-05-16  3:33                       ` Eric W. Biederman
2008-05-16  2:00             ` Vivek Goyal
2008-05-16  2:00               ` Vivek Goyal
2008-05-16  2:19               ` Huang, Ying
2008-05-16  2:19                 ` Huang, Ying
2008-05-16  2:55                 ` Eric W. Biederman
2008-05-16  2:55                   ` Eric W. Biederman
2008-05-16  4:52                   ` Huang, Ying
2008-05-16  4:52                     ` Huang, Ying
2008-05-16 13:36                     ` Vivek Goyal
2008-05-16 13:36                       ` Vivek Goyal
2008-05-16 11:58   ` Pavel Machek
2008-05-16 11:58     ` Pavel Machek

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=1210906575.23707.189.camel@caritas-dev.intel.com \
    --to=ying.huang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nigel@nigel.suspend2.net \
    --cc=pavel@ucw.cz \
    --cc=rjw@sisk.pl \
    --cc=vgoyal@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.