[PATCH] Re: BOOT_CS
From: Coywolf Qi Hunt
Date: Sun Feb 22 2004 - 23:46:29 EST
Jamie Lokier wrote:
Coywolf Qi Hunt wrote:
(the jump and indirect branch aren't guaranteed to have the
proper effects, although technically neither should be required due to
the %cr0 write):
???
IMHO, why bother to re-reload %cs again?
In setup.S, %cs is reloaded already. The enable paging code maps the
address identically, so %cs already contains the proper selector.
It's to flush the instruction prefetch queue: that's one of the side
effects of ljmp.
Re-loading %cs and flushing prefetch queue are two different things.
I recall an Intel manual that said ljmp is required when switching
between real and protected modes, to flush the prefetch queue.
Not necessarily ljmp, imho
Unfortunately I don't remember what that manual said about just setting PG.
I'd guess that current generation CPUs don't care about ljmp when
changing modes, but older ones certainly do.
-- Jamie
FYI, intel's example code located in STARTUP.ASM Listing arround line
180, chapter 9, IA-32 Intel Architecture Software Developer's Manual,
Volume 3: System Programming Guide
Please consider my patch for this issue.
Coywolf
--
Coywolf Qi Hunt
Admin of http://GreatCN.org and http://LoveCN.org
--- head.S.orig 2004-02-18 11:57:16.000000000 +0800
+++ head.S 2004-02-23 12:35:24.000000000 +0800
@@ -115,10 +115,8 @@
movl %cr0,%eax
orl $0x80000000,%eax
movl %eax,%cr0 /* ..and set paging (PG) bit */
- jmp 1f /* flush the prefetch-queue */
-1:
- movl $1f,%eax
- jmp *%eax /* make sure eip is relocated */
+ pushl $1f /* flush the prefetch-queue */
+ ret /* and normalize $eip */
1:
/* Set up the stack pointer */
lss stack_start,%esp