From: Jun Sun <jsun@junsun.net>
To: "linux-os (Dick Johnson)" <linux-os@analogic.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: failed 'ljmp' in linear addressing mode
Date: Mon, 27 Nov 2006 15:16:46 -0800 [thread overview]
Message-ID: <20061127231646.GA21627@srv.junsun.net> (raw)
In-Reply-To: <Pine.LNX.4.61.0611270843500.4092@chaos.analogic.com>
On Mon, Nov 27, 2006 at 08:58:57AM -0500, linux-os (Dick Johnson) wrote:
>
> I think it probably resets the instant that you turn off paging. To
> turn off paging, you need to copy some code (properly linked) to an
> area where there is a 1:1 mapping between virtual and physical addresses.
> A safe place is somewhere below 1 megabyte. Then you need to set up a
> call descriptor so you can call that code (you can ljump if you never
> plan to get back). You then need to clear interrupts on all CPUs (use a
> spin-lock). Once you are executing from the new area, you reset your
> segments to the new area. The call descriptor would have already set
> CS, as would have the long-jump. At this time you can turn off paging
> and flush the TLB. You are now in linear-address protected mode.
>
Thanks for the reply. But I am pretty much sure I did above correctly.
I use single-instruction infinite loop in the call path to verify
that control does reach last 'ljmp' but not the jump destination.
Below is the hack I made to machine_kexec.c file. As you can see, I
managed to make the identical mapping between virtual and physical addresses.
Note I did not copy the code into the first 1M. In fact the code
is located at 0xc0477000 (0x00477000 in physical). I thought that should be
OK as I did not really go all the way back to real-address mode.
That last suspect I have now is the wrong value in CS descriptor. Does kernel
have a suitable CS descriptor for the last ljmep to 0x10000000 in linear
addressing mode? The CS descriptor seems to be a pretty dark magic to me ...
Cheers.
Jun
-----------------
diff -Nru linux-2.6.17.14-1st/arch/i386/kernel/machine_kexec.c.orig linux-2.6.17.14-1st/arch/i386/kernel/machine_kexec.c
--- linux-2.6.17.14-1st/arch/i386/kernel/machine_kexec.c.orig 2006-10-13 11:55:04.000000000 -0700
+++ linux-2.6.17.14-1st/arch/i386/kernel/machine_kexec.c 2006-11-22 15:01:45.000000000 -0800
@@ -212,3 +212,19 @@
rnk = (relocate_new_kernel_t) reboot_code_buffer;
(*rnk)(page_list, reboot_code_buffer, image->start, cpu_has_pae);
}
+
+extern void do_os_switching(void);
+void os_switch(void)
+{
+ void (*foo)(void);
+
+ /* absolutely no irq */
+ local_irq_disable();
+
+ /* create identity mapping */
+ foo=virt_to_phys(do_os_switching);
+ identity_map_page((unsigned long)foo);
+
+ /* jump to the real address */
+ foo();
+}
next prev parent reply other threads:[~2006-11-27 23:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-22 23:41 Jun Sun
2006-11-27 13:58 ` linux-os (Dick Johnson)
2006-11-27 23:16 ` Jun Sun [this message]
2006-11-28 13:46 ` linux-os (Dick Johnson)
2006-11-28 19:45 ` Jun Sun
2006-11-28 23:49 ` linux-os (Dick Johnson)
2006-11-29 1:40 ` Jun Sun
2006-11-30 4:53 ` Jun Sun
2006-11-30 16:17 ` Phillip Susi
2006-12-01 22:20 ` Jun Sun
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=20061127231646.GA21627@srv.junsun.net \
--to=jsun@junsun.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.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
all inboxes | Powered by JetHome®