Author: kib
Date: Tue Apr 24 13:44:19 2018
New Revision: 332932
URL: https://svnweb.freebsd.org/changeset/base/332932

Log:
  Correct undesirable interaction between caching of %cr4 in bhyve and
  invltlb_glob().
  
  Reviewed by:  grehan, jhb
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week
  Differential revision:        https://reviews.freebsd.org/D15138

Modified:
  head/sys/amd64/vmm/vmm_host.c

Modified: head/sys/amd64/vmm/vmm_host.c
==============================================================================
--- head/sys/amd64/vmm/vmm_host.c       Tue Apr 24 13:07:17 2018        
(r332931)
+++ head/sys/amd64/vmm/vmm_host.c       Tue Apr 24 13:44:19 2018        
(r332932)
@@ -61,7 +61,16 @@ vmm_host_state_init(void)
         */
        vmm_host_cr0 = rcr0() | CR0_TS;
 
-       vmm_host_cr4 = rcr4();
+       /*
+        * On non-PCID or PCID but without INVPCID support machines,
+        * we flush kernel i.e. global TLB entries, by temporary
+        * clearing the CR4.PGE bit, see invltlb_glob().  If
+        * preemption occurs at the wrong time, cached vmm_host_cr4
+        * might store the value with CR4.PGE cleared.  Since FreeBSD
+        * requires support for PG_G on amd64, just set it
+        * unconditionally.
+        */
+       vmm_host_cr4 = rcr4() | CR4_PGE;
 
        /*
         * Only permit a guest to use XSAVE if the host is using
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to