Author: kib
Date: Tue Mar 15 15:42:53 2016
New Revision: 296908
URL: https://svnweb.freebsd.org/changeset/base/296908

Log:
  The PKRU state size is 4 bytes, its support makes the XSAVE area size
  non-multiple of 64 bytes.  Thereafter, the user state save area is
  misaligned, which triggers assertion in the debugging kernels, or
  segmentation violation on accesses for non-debugging configs.
  
  Force the desired alignment of the user save area as the fix
  (workaround is to disable bit 9 in the hw.xsave_mask loader tunable).
  This correction is required for booting on the upcoming Intel' Purley
  platform.
  
  Reported and tested by:       "Pieper, Jeffrey E" 
<jeffrey.e.pie...@intel.com>,
        jimharris
  Sponsored by: The FreeBSD Foundation
  MFC after:    3 days

Modified:
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/i386/i386/vm_machdep.c

Modified: head/sys/amd64/amd64/vm_machdep.c
==============================================================================
--- head/sys/amd64/amd64/vm_machdep.c   Tue Mar 15 15:31:17 2016        
(r296907)
+++ head/sys/amd64/amd64/vm_machdep.c   Tue Mar 15 15:42:53 2016        
(r296908)
@@ -102,8 +102,8 @@ get_pcb_user_save_td(struct thread *td)
        vm_offset_t p;
 
        p = td->td_kstack + td->td_kstack_pages * PAGE_SIZE -
-           cpu_max_ext_state_size;
-       KASSERT((p % 64) == 0, ("Unaligned pcb_user_save area"));
+           roundup2(cpu_max_ext_state_size, XSAVE_AREA_ALIGN);
+       KASSERT((p % XSAVE_AREA_ALIGN) == 0, ("Unaligned pcb_user_save area"));
        return ((struct savefpu *)p);
 }
 
@@ -122,7 +122,8 @@ get_pcb_td(struct thread *td)
        vm_offset_t p;
 
        p = td->td_kstack + td->td_kstack_pages * PAGE_SIZE -
-           cpu_max_ext_state_size - sizeof(struct pcb);
+           roundup2(cpu_max_ext_state_size, XSAVE_AREA_ALIGN) -
+           sizeof(struct pcb);
        return ((struct pcb *)p);
 }
 

Modified: head/sys/i386/i386/vm_machdep.c
==============================================================================
--- head/sys/i386/i386/vm_machdep.c     Tue Mar 15 15:31:17 2016        
(r296907)
+++ head/sys/i386/i386/vm_machdep.c     Tue Mar 15 15:42:53 2016        
(r296908)
@@ -127,8 +127,8 @@ get_pcb_user_save_td(struct thread *td)
        vm_offset_t p;
 
        p = td->td_kstack + td->td_kstack_pages * PAGE_SIZE -
-           cpu_max_ext_state_size;
-       KASSERT((p % 64) == 0, ("Unaligned pcb_user_save area"));
+           roundup2(cpu_max_ext_state_size, XSAVE_AREA_ALIGN);
+       KASSERT((p % XSAVE_AREA_ALIGN) == 0, ("Unaligned pcb_user_save area"));
        return ((union savefpu *)p);
 }
 
@@ -147,7 +147,8 @@ get_pcb_td(struct thread *td)
        vm_offset_t p;
 
        p = td->td_kstack + td->td_kstack_pages * PAGE_SIZE -
-           cpu_max_ext_state_size - sizeof(struct pcb);
+           roundup2(cpu_max_ext_state_size, XSAVE_AREA_ALIGN) -
+           sizeof(struct pcb);
        return ((struct pcb *)p);
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to