Date: Mon, 23 Jul 2001 12:07:44 -0700 (PDT) From: John Baldwin <jhb@FreeBSD.org> To: Weiguang SHI <weiguang_shi@hotmail.com> Cc: freebsd-hackers@FreeBSD.org Subject: RE: jmp after setting PE? Message-ID: <XFMail.010723120744.jhb@FreeBSD.org> In-Reply-To: <F25C2DWpmy20h08xWI00000162e@hotmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 21-Jul-01 Weiguang SHI wrote: > Hi, > > Please forgive me if this seems too easy. > > "http://people.freebsd.org/~jhb/386htm/s10_03.htm" says: > > Immediately after setting the PE flag, the initialization code must > flush the processor's instruction prefetch queue by > executing a JMP instruction. The 80386 fetches and decodes > instructions and addresses before they are used; however, > after a change into protected mode, the prefetched instruction > information (which pertains to real-address mode) is > no longer valid. A JMP forces the processor to discard the invalid > information. > > "/home/src/sys/i386/i386" says: > > 329 /* Now enable paging */ > 330 movl R(_IdlePTD), %eax > 331 movl %eax,%cr3 /* load ptd addr > into mm > 332 movl %cr0,%eax /* get control word > */ > 333 orl $CR0_PE|CR0_PG,%eax /* enable paging */ > 334 movl %eax,%cr0 /* and let's page > NOW! * > 335 > 336 #ifdef BDE_DEBUGGER > 337 /* > 338 * Complete the adjustments for paging so that we can keep tracing > throu > 339 * initi386() after the low (physical) addresses for the gdt and idt > bec > 340 * invalid. > 341 */ > 342 call bdb_commit_paging > 343 #endif > 344 > 345 pushl $begin /* jump to high > virtuali > 346 ret We are already in protected mode when the kernel starts (the boot blocks call us from protected mode) so this isn't turning on the PE bit. Line 333 is somewhat misleading (the comment is more accurate) and should probably read: orl $CRO_PG,%eax If PE isn't on by the time we get here we would have blown up by now anyways. -- John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.010723120744.jhb>