Author: kib
Date: Mon Sep 17 15:34:19 2018
New Revision: 338712
URL: https://svnweb.freebsd.org/changeset/base/338712

Log:
  Calculate PTI, PCID and INVPCID modes earlier, before ifuncs are resolved.
  
  This will be used in following conversion of pmap_activate_sw().
  
  Reviewed by:  alc, markj
  Sponsored by: The FreeBSD Foundation
  Approved by:  re (gjb)
  Differential revision:        https://reviews.freebsd.org/D17181

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/machdep.c
==============================================================================
--- head/sys/amd64/amd64/machdep.c      Mon Sep 17 14:59:05 2018        
(r338711)
+++ head/sys/amd64/amd64/machdep.c      Mon Sep 17 15:34:19 2018        
(r338712)
@@ -1581,6 +1581,21 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
         */
        identify_cpu2();
 
+       /*
+        * Check for pti, pcid, and invpcid before ifuncs are
+        * resolved, to correctly select the implementation for
+        * pmap_activate_sw_mode().
+        */
+       pti = pti_get_default();
+       TUNABLE_INT_FETCH("vm.pmap.pti", &pti);
+       TUNABLE_INT_FETCH("vm.pmap.pcid_enabled", &pmap_pcid_enabled);
+       if ((cpu_feature2 & CPUID2_PCID) != 0 && pmap_pcid_enabled) {
+               invpcid_works = (cpu_stdext_feature &
+                   CPUID_STDEXT_INVPCID) != 0;
+       } else {
+               pmap_pcid_enabled = 0;
+       }
+
        link_elf_ireloc(kmdp);
 
        /*
@@ -1645,9 +1660,6 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
        mtx_init(&dt_lock, "descriptor tables", NULL, MTX_DEF);
 
        /* exceptions */
-       pti = pti_get_default();
-       TUNABLE_INT_FETCH("vm.pmap.pti", &pti);
-
        for (x = 0; x < NIDT; x++)
                setidt(x, pti ? &IDTVEC(rsvd_pti) : &IDTVEC(rsvd), SDT_SYSIGT,
                    SEL_KPL, 0);

Modified: head/sys/amd64/amd64/pmap.c
==============================================================================
--- head/sys/amd64/amd64/pmap.c Mon Sep 17 14:59:05 2018        (r338711)
+++ head/sys/amd64/amd64/pmap.c Mon Sep 17 15:34:19 2018        (r338712)
@@ -1179,11 +1179,7 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
        pmap_init_pat();
 
        /* Initialize TLB Context Id. */
-       TUNABLE_INT_FETCH("vm.pmap.pcid_enabled", &pmap_pcid_enabled);
-       if ((cpu_feature2 & CPUID2_PCID) != 0 && pmap_pcid_enabled) {
-               /* Check for INVPCID support */
-               invpcid_works = (cpu_stdext_feature & CPUID_STDEXT_INVPCID)
-                   != 0;
+       if (pmap_pcid_enabled) {
                for (i = 0; i < MAXCPU; i++) {
                        kernel_pmap->pm_pcids[i].pm_pcid = PMAP_PCID_KERN;
                        kernel_pmap->pm_pcids[i].pm_gen = 1;
@@ -1204,8 +1200,6 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
                 * during pcpu setup.
                 */
                load_cr4(rcr4() | CR4_PCIDE);
-       } else {
-               pmap_pcid_enabled = 0;
        }
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to