From owner-freebsd-hackers Mon Jul 23 12: 7:54 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from meow.osd.bsdi.com (meow.osd.bsdi.com [204.216.28.88]) by hub.freebsd.org (Postfix) with ESMTP id 1381137B405 for ; Mon, 23 Jul 2001 12:07:48 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: from laptop.baldwin.cx (john@jhb-laptop.osd.bsdi.com [204.216.28.241]) by meow.osd.bsdi.com (8.11.4/8.11.2) with ESMTP id f6NJ7dv00677; Mon, 23 Jul 2001 12:07:39 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: Date: Mon, 23 Jul 2001 12:07:44 -0700 (PDT) From: John Baldwin To: Weiguang SHI Subject: RE: jmp after setting PE? Cc: freebsd-hackers@FreeBSD.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 -- 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