From: "Huang, Ying" <ying.huang@intel.com>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.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,
linux-pm@lists.linux-foundation.org,
Kexec Mailing List <kexec@lists.infradead.org>
Subject: Re: [PATCH -mm] kexec jump -v9
Date: Thu, 15 May 2008 10:32:42 +0800 [thread overview]
Message-ID: <1210818762.23707.102.camel@caritas-dev.intel.com> (raw)
In-Reply-To: <20080514205204.GJ30469@redhat.com>
On Wed, 2008-05-14 at 16:52 -0400, Vivek Goyal wrote:
[...]
> Ok, I have done some testing on this patch. Currently I have just
> tested switching back and forth between two kernels and it is working for
> me.
Thanks.
[...]
> > +/*
> > + * Entry point for jumping back from kexeced kernel, the paging is
> > + * turned off.
> > + */
> > +kexec_jump_back_entry:
> > + call 1f
> > +1:
> > + popl %ebx
> > + subl $(1b - kexec_relocate_page), %ebx
> > + movl %edi, KJUMP_ENTRY_OFF(%ebx)
> > + movl CP_VA_CONTROL_PAGE(%ebx), %edi
> > + lea STACK_TOP(%ebx), %esp
> > + movl CP_PA_SWAP_PAGE(%ebx), %eax
> > + movl CP_PA_BACKUP_PAGES_MAP(%ebx), %edx
> > + pushl %eax
> > + pushl %edx
> > + call swap_pages
> > + addl $8, %esp
> > + movl CP_PA_PGD(%ebx), %eax
> > + movl %eax, %cr3
> > + movl %cr0, %eax
> > + orl $(1<<31), %eax
> > + movl %eax, %cr0
> > + lea STACK_TOP(%edi), %esp
> > + movl %edi, %eax
> > + addl $(virtual_mapped - kexec_relocate_page), %eax
> > + pushl %eax
> > + ret
>
> Upon re-entering the kernel, what happens to GDT table? So gdtr will be
> pointing to GDT of other kernel (which is not there as pages have been
> swapped)? Do we need to reload the gdtr upon re-entering the kernel.
After re-entering the kernel and returning from machine_kexec,
restore_processor_state() is called, where the GDTR and some other CPU
state such as FPU, IDT, etc are restored.
> [..]
> > @@ -197,8 +282,54 @@ identity_mapped:
> > xorl %eax, %eax
> > movl %eax, %cr3
> >
> > + movl CP_PA_SWAP_PAGE(%edi), %eax
> > + pushl %eax
> > + pushl %ebx
> > + call swap_pages
> > + addl $8, %esp
> > +
> > + /* To be certain of avoiding problems with self-modifying code
> > + * I need to execute a serializing instruction here.
> > + * So I flush the TLB, it's handy, and not processor dependent.
> > + */
> > + xorl %eax, %eax
> > + movl %eax, %cr3
> > +
> > + /* set all of the registers to known values */
> > + /* leave %esp alone */
> > +
> > + movl KJUMP_MAGIC_OFF(%edi), %eax
> > + cmpl $KJUMP_MAGIC_NUMBER, %eax
> > + jz 1f
> > + xorl %edi, %edi
> > + xorl %eax, %eax
> > + xorl %ebx, %ebx
> > + xorl %ecx, %ecx
> > + xorl %edx, %edx
> > + xorl %esi, %esi
> > + xorl %ebp, %ebp
> > + ret
> > +1:
> > + popl %edx
> > + movl CP_PA_SWAP_PAGE(%edi), %esp
> > + addl $PAGE_SIZE_asm, %esp
> > + pushl %edx
> > +2:
> > + call *%edx
>
> > + movl %edi, %edx
> > + popl %edi
> > + pushl %edx
> > + jmp 2b
> > +
>
> What does above piece of code do? Looks like redundant for switching
> between the kernels? After call *%edx, we never return here. Instead
> we come back to "kexec_jump_back_entry"?
For switching between the kernels, this is redundant. Originally another
feature of kexec jump is to call some code in physical mode. This is
used to provide a C ABI to called code.
Now, Eric suggests to use a C ABI compatible mode to pass the jump back
entry point too, that is, use the return address on stack instead of %
edi. I think that is reasonable. Maybe we can revise this code to be
compatible with C ABI and provide a convenient interface for both kernel
and other physical mode code.
> [..]
> > --- /dev/null
> > +++ b/Documentation/i386/jump_back_protocol.txt
> > @@ -0,0 +1,66 @@
> > + THE LINUX/I386 JUMP BACK PROTOCOL
> > + ---------------------------------
> > +
> > + Huang Ying <ying.huang@intel.com>
> > + Last update 2007-12-19
> > +
> > +Currently, the following versions of the jump back protocol exist.
> > +
> > +Protocol 1.00: Jumping between original kernel and kexeced kernel
> > + support. Calling ordinary C function support.
> > +
> > +
> > +*** JUMP BACK ENTRY
> > +
> > +At jump back entry of callee, the CPU must be in 32-bit protected mode
> > +with paging disabled; the CS, DS, ES and SS must be 4G flat segments;
> > +CS must have execute/read permission, and DS, ES and SS must have
> > +read/write permission; interrupt must be disabled; the contents of
> > +registers and corresponding memory must be as follow:
> > +
> > +Offset/Size Meaning
> > +
> > +%edi Real jump back entry of caller if supported,
> > + otherwise 0.
> > +%esp Stack top pointer, the size of stack is about 4k bytes.
> > +(%esp)/4 Helper jump back entry of caller if %edi != 0,
> > + otherwise undefined.
> > +
>
> I am not sure what is helper jump back entry? I understand that you
> are using %edi to pass around entry point between two kernels. Can
> you please shed some more light on this?
Helper jump back entry is used to provide a C ABI to some physical mode
code other than kernel. It is the above redundant code.
Best Regards,
Huang Ying
next prev parent reply other threads:[~2008-05-15 2:27 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-06 3:13 [PATCH -mm] kexec jump -v9 Huang, Ying
2008-03-11 21:10 ` Vivek Goyal
2008-03-11 21:59 ` Nigel Cunningham
2008-03-11 23:55 ` Eric W. Biederman
2008-03-12 0:09 ` david
2008-03-12 2:14 ` Huang, Ying
2008-03-12 18:53 ` Vivek Goyal
2008-03-13 0:01 ` Eric W. Biederman
2008-03-11 22:18 ` Rafael J. Wysocki
2008-03-12 2:02 ` Eric W. Biederman
2008-03-12 2:26 ` Huang, Ying
2008-03-11 23:24 ` Pavel Machek
2008-03-11 23:49 ` Rafael J. Wysocki
2008-03-12 1:55 ` Huang, Ying
2008-03-12 15:01 ` [linux-pm] " Alan Stern
2008-03-12 21:53 ` Rafael J. Wysocki
2008-03-13 0:33 ` Eric W. Biederman
2008-03-13 17:03 ` Rafael J. Wysocki
2008-03-13 23:07 ` Eric W. Biederman
2008-03-14 1:31 ` Rafael J. Wysocki
[not found] ` <m1prtsug2e.fsf@ebiederm.dsl.xmission.com>
2008-03-18 23:52 ` Pavel Machek
2008-03-19 0:08 ` Rafael J. Wysocki
2008-03-19 2:33 ` Alan Stern
[not found] ` <m1ve3jtmxk.fsf@ebiederm.dsl.xmission.com>
2008-03-19 15:01 ` Alan Stern
2008-03-19 19:28 ` Rafael J. Wysocki
2008-03-20 10:40 ` Pavel Machek
2008-03-20 22:45 ` Rafael J. Wysocki
2008-03-20 23:01 ` Alan Stern
2008-03-20 23:22 ` Pavel Machek
2008-03-20 23:40 ` Rafael J. Wysocki
2008-03-21 0:36 ` Rafael J. Wysocki
2008-03-21 0:52 ` Alan Stern
2008-03-21 22:05 ` Nigel Cunningham
2008-03-22 16:21 ` Pavel Machek
2008-03-22 17:45 ` Rafael J. Wysocki
2008-03-22 20:49 ` Alan Stern
2008-03-22 21:29 ` Rafael J. Wysocki
2008-05-14 22:38 ` Eric W. Biederman
2008-05-14 23:47 ` Rafael J. Wysocki
2008-05-15 20:55 ` Eric W. Biederman
2008-05-15 21:20 ` Rafael J. Wysocki
2008-05-14 20:41 ` Maxim Levitsky
2008-05-14 23:34 ` Eric W. Biederman
2008-03-12 8:57 ` Pavel Machek
2008-03-12 0:00 ` Nigel Cunningham
2008-03-12 1:45 ` Huang, Ying
2008-03-12 2:17 ` Eric W. Biederman
2008-03-12 6:54 ` Huang, Ying
2008-03-12 19:37 ` Vivek Goyal
2008-03-14 8:03 ` Huang, Ying
2008-03-21 19:12 ` Vivek Goyal
2008-03-25 7:25 ` Huang, Ying
2008-03-12 19:47 ` Vivek Goyal
2008-04-09 9:34 ` Pavel Machek
2008-04-09 12:30 ` Vivek Goyal
2008-05-14 16:03 ` Vivek Goyal
2008-05-14 17:49 ` Vivek Goyal
2008-05-14 20:52 ` Vivek Goyal
2008-05-15 2:32 ` Huang, Ying [this message]
2008-05-15 20:09 ` Vivek Goyal
2008-05-16 1:48 ` Huang, Ying
2008-05-16 1:51 ` Vivek Goyal
2008-05-16 2:08 ` Huang, Ying
2008-05-16 12:13 ` Pavel Machek
2008-05-15 5:41 ` Huang, Ying
2008-05-15 18:42 ` Eric W. Biederman
2008-05-16 0:51 ` Vivek Goyal
2008-05-16 1:35 ` Eric W. Biederman
2008-05-16 1:55 ` Huang, Ying
2008-05-27 7:27 ` Huang, Ying
2008-05-27 22:15 ` Vivek Goyal
2008-05-28 1:35 ` Huang, Ying
2008-05-14 22:30 ` Eric W. Biederman
2008-05-14 23:55 ` Rafael J. Wysocki
2008-05-15 22:03 ` Eric W. Biederman
2008-05-15 23:20 ` Rafael J. Wysocki
2008-05-16 12:18 ` Pavel Machek
2008-05-16 14:20 ` [linux-pm] " Alan Stern
2008-05-15 1:42 ` Huang, Ying
2008-05-15 19:05 ` Rafael J. Wysocki
2008-05-15 14:14 ` [linux-pm] " Alan Stern
2008-05-15 20:48 ` Eric W. Biederman
2008-05-15 21:07 ` Alan Stern
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=1210818762.23707.102.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=linux-pm@lists.linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox