From owner-svn-src-all@FreeBSD.ORG Tue Nov 16 23:26:03 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36BEC1065670; Tue, 16 Nov 2010 23:26:03 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A7118FC1B; Tue, 16 Nov 2010 23:26:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oAGNQ2La070645; Tue, 16 Nov 2010 23:26:02 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oAGNQ2Ll070642; Tue, 16 Nov 2010 23:26:02 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201011162326.oAGNQ2Ll070642@svn.freebsd.org> From: Jung-uk Kim Date: Tue, 16 Nov 2010 23:26:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215415 - in head/sys: amd64/amd64 i386/i386 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Nov 2010 23:26:03 -0000 Author: jkim Date: Tue Nov 16 23:26:02 2010 New Revision: 215415 URL: http://svn.freebsd.org/changeset/base/215415 Log: Restore CR0 after MTRR initialization for correctness sakes. There will be no noticeable change because we enable caches before we enter here for both BSP and AP cases. Remove another pointless optimization for CR4.PGE bit while I am here. Modified: head/sys/amd64/amd64/amd64_mem.c head/sys/i386/i386/i686_mem.c Modified: head/sys/amd64/amd64/amd64_mem.c ============================================================================== --- head/sys/amd64/amd64/amd64_mem.c Tue Nov 16 22:44:58 2010 (r215414) +++ head/sys/amd64/amd64/amd64_mem.c Tue Nov 16 23:26:02 2010 (r215415) @@ -307,17 +307,17 @@ amd64_mrstoreone(void *arg) struct mem_range_desc *mrd; u_int64_t omsrv, msrv; int i, j, msr; - u_int cr4save; + u_long cr0, cr4; mrd = sc->mr_desc; /* Disable PGE. */ - cr4save = rcr4(); - if (cr4save & CR4_PGE) - load_cr4(cr4save & ~CR4_PGE); + cr4 = rcr4(); + load_cr4(cr4 & ~CR4_PGE); /* Disable caches (CD = 1, NW = 0). */ - load_cr0((rcr0() & ~CR0_NW) | CR0_CD); + cr0 = rcr0(); + load_cr0((cr0 & ~CR0_NW) | CR0_CD); /* Flushes caches and TLBs. */ wbinvd(); @@ -396,11 +396,9 @@ amd64_mrstoreone(void *arg) /* Enable MTRRs. */ wrmsr(MSR_MTRRdefType, rdmsr(MSR_MTRRdefType) | MTRR_DEF_ENABLE); - /* Enable caches (CD = 0, NW = 0). */ - load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); - - /* Restore PGE. */ - load_cr4(cr4save); + /* Restore caches and PGE. */ + load_cr0(cr0); + load_cr4(cr4); } /* Modified: head/sys/i386/i386/i686_mem.c ============================================================================== --- head/sys/i386/i386/i686_mem.c Tue Nov 16 22:44:58 2010 (r215414) +++ head/sys/i386/i386/i686_mem.c Tue Nov 16 23:26:02 2010 (r215415) @@ -301,17 +301,17 @@ i686_mrstoreone(void *arg) struct mem_range_desc *mrd; u_int64_t omsrv, msrv; int i, j, msr; - u_int cr4save; + u_long cr0, cr4; mrd = sc->mr_desc; /* Disable PGE. */ - cr4save = rcr4(); - if (cr4save & CR4_PGE) - load_cr4(cr4save & ~CR4_PGE); + cr4 = rcr4(); + load_cr4(cr4 & ~CR4_PGE); /* Disable caches (CD = 1, NW = 0). */ - load_cr0((rcr0() & ~CR0_NW) | CR0_CD); + cr0 = rcr0(); + load_cr0((cr0 & ~CR0_NW) | CR0_CD); /* Flushes caches and TLBs. */ wbinvd(); @@ -390,11 +390,9 @@ i686_mrstoreone(void *arg) /* Enable MTRRs. */ wrmsr(MSR_MTRRdefType, rdmsr(MSR_MTRRdefType) | MTRR_DEF_ENABLE); - /* Enable caches (CD = 0, NW = 0). */ - load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); - - /* Restore PGE. */ - load_cr4(cr4save); + /* Restore caches and PGE. */ + load_cr0(cr0); + load_cr4(cr4); } /*