From owner-svn-src-all@freebsd.org Mon Feb 18 16:02:02 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 01D6A14E0566; Mon, 18 Feb 2019 16:02:02 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 848716DED6; Mon, 18 Feb 2019 16:02:01 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 515C3822F; Mon, 18 Feb 2019 16:02:01 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x1IG215N081252; Mon, 18 Feb 2019 16:02:01 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x1IG21wm081251; Mon, 18 Feb 2019 16:02:01 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201902181602.x1IG21wm081251@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 18 Feb 2019 16:02:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r344256 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 344256 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 848716DED6 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 18 Feb 2019 16:02:02 -0000 Author: kib Date: Mon Feb 18 16:02:00 2019 New Revision: 344256 URL: https://svnweb.freebsd.org/changeset/base/344256 Log: amd64: cleanup pmap_init_pat(). The pmap_works variable is always true for amd64. Remove it, the branch in the initialization taken when false, and corresponding sysctl. Remove pat_table[] local array, work on pat_index[] directly. Collapse whole initialization to not override already assigned values. Add comment explaining the choice for PAT4 and PAT7. Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week MFC note: Leave the sysctl around Differential revision: https://reviews.freebsd.org/D19225 Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Mon Feb 18 15:28:12 2019 (r344255) +++ head/sys/amd64/amd64/pmap.c Mon Feb 18 16:02:00 2019 (r344256) @@ -353,10 +353,6 @@ pt_entry_t pg_nx; static SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters"); -static int pat_works = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, pat_works, CTLFLAG_RD, &pat_works, 1, - "Is page attribute table fully functional?"); - static int pg_ps_enabled = 1; SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &pg_ps_enabled, 0, "Are large page mappings enabled?"); @@ -1222,7 +1218,6 @@ pmap_bootstrap(vm_paddr_t *firstaddr) void pmap_init_pat(void) { - int pat_table[PAT_INDEX_SIZE]; uint64_t pat_msr; u_long cr0, cr4; int i; @@ -1233,45 +1228,32 @@ pmap_init_pat(void) /* Set default PAT index table. */ for (i = 0; i < PAT_INDEX_SIZE; i++) - pat_table[i] = -1; - pat_table[PAT_WRITE_BACK] = 0; - pat_table[PAT_WRITE_THROUGH] = 1; - pat_table[PAT_UNCACHEABLE] = 3; - pat_table[PAT_WRITE_COMBINING] = 3; - pat_table[PAT_WRITE_PROTECTED] = 3; - pat_table[PAT_UNCACHED] = 3; + pat_index[i] = -1; + pat_index[PAT_WRITE_BACK] = 0; + pat_index[PAT_WRITE_THROUGH] = 1; + pat_index[PAT_UNCACHEABLE] = 3; + pat_index[PAT_WRITE_COMBINING] = 6; + pat_index[PAT_WRITE_PROTECTED] = 5; + pat_index[PAT_UNCACHED] = 2; - /* Initialize default PAT entries. */ + /* + * Initialize default PAT entries. + * Leave the indices 0-3 at the default of WB, WT, UC-, and UC. + * Program 5 and 6 as WP and WC. + * + * Leave 4 and 7 as WB and UC. Note that a recursive page table + * mapping for a 2M page uses a PAT value with the bit 3 set due + * to its overload with PG_PS. + */ pat_msr = PAT_VALUE(0, PAT_WRITE_BACK) | PAT_VALUE(1, PAT_WRITE_THROUGH) | PAT_VALUE(2, PAT_UNCACHED) | PAT_VALUE(3, PAT_UNCACHEABLE) | PAT_VALUE(4, PAT_WRITE_BACK) | - PAT_VALUE(5, PAT_WRITE_THROUGH) | - PAT_VALUE(6, PAT_UNCACHED) | + PAT_VALUE(5, PAT_WRITE_PROTECTED) | + PAT_VALUE(6, PAT_WRITE_COMBINING) | PAT_VALUE(7, PAT_UNCACHEABLE); - if (pat_works) { - /* - * Leave the indices 0-3 at the default of WB, WT, UC-, and UC. - * Program 5 and 6 as WP and WC. - * Leave 4 and 7 as WB and UC. - */ - pat_msr &= ~(PAT_MASK(5) | PAT_MASK(6)); - pat_msr |= PAT_VALUE(5, PAT_WRITE_PROTECTED) | - PAT_VALUE(6, PAT_WRITE_COMBINING); - pat_table[PAT_UNCACHED] = 2; - pat_table[PAT_WRITE_PROTECTED] = 5; - pat_table[PAT_WRITE_COMBINING] = 6; - } else { - /* - * Just replace PAT Index 2 with WC instead of UC-. - */ - pat_msr &= ~PAT_MASK(2); - pat_msr |= PAT_VALUE(2, PAT_WRITE_COMBINING); - pat_table[PAT_WRITE_COMBINING] = 2; - } - /* Disable PGE. */ cr4 = rcr4(); load_cr4(cr4 & ~CR4_PGE); @@ -1286,8 +1268,6 @@ pmap_init_pat(void) /* Update PAT and index table. */ wrmsr(MSR_PAT, pat_msr); - for (i = 0; i < PAT_INDEX_SIZE; i++) - pat_index[i] = pat_table[i]; /* Flush caches and TLBs again. */ wbinvd();