Author: vangyzen
Date: Fri Jun 12 21:17:56 2020
New Revision: 362121
URL: https://svnweb.freebsd.org/changeset/base/362121

Log:
  FPU init: allocate initial state from UMA to ensure alignment
  
  The Intel Instruction Set Reference says this about the XSAVE instruction:
  
      Use of a destination operand not aligned to 64-byte boundary
      (in either 64-bit or 32-bit modes) results in a general-protection
      (#GP) exception.
  
  This alignment happens naturally when all malloc buckets are powers
  of two.  However, this change is necessary on some systems when
  certain non-power-of-two (and non-multiple of 64) malloc buckets
  are defined.
  
  Reviewed by:  cem; kib; earlier version by jhb
  MFC after:    2 weeks
  Sponsored by: Dell EMC Isilon
  Differential Revision:        https://reviews.freebsd.org/D25098

Modified:
  head/sys/amd64/amd64/fpu.c
  head/sys/i386/i386/npx.c

Modified: head/sys/amd64/amd64/fpu.c
==============================================================================
--- head/sys/amd64/amd64/fpu.c  Fri Jun 12 21:12:26 2020        (r362120)
+++ head/sys/amd64/amd64/fpu.c  Fri Jun 12 21:17:56 2020        (r362121)
@@ -372,8 +372,7 @@ fpuinitstate(void *arg __unused)
        fpu_save_area_zone = uma_zcreate("FPU_save_area",
            cpu_max_ext_state_size, NULL, NULL, NULL, NULL,
            XSAVE_AREA_ALIGN - 1, 0);
-       fpu_initialstate = malloc(cpu_max_ext_state_size, M_DEVBUF,
-           M_WAITOK | M_ZERO);
+       fpu_initialstate = uma_zalloc(fpu_save_area_zone, M_WAITOK | M_ZERO);
        if (use_xsave) {
                max_ext_n = flsl(xsave_mask);
                xsave_area_desc = malloc(max_ext_n * sizeof(struct

Modified: head/sys/i386/i386/npx.c
==============================================================================
--- head/sys/i386/i386/npx.c    Fri Jun 12 21:12:26 2020        (r362120)
+++ head/sys/i386/i386/npx.c    Fri Jun 12 21:17:56 2020        (r362121)
@@ -483,8 +483,7 @@ npxinitstate(void *arg __unused)
        fpu_save_area_zone = uma_zcreate("FPU_save_area",
            cpu_max_ext_state_size, NULL, NULL, NULL, NULL,
            XSAVE_AREA_ALIGN - 1, 0);
-       npx_initialstate = malloc(cpu_max_ext_state_size, M_DEVBUF,
-           M_WAITOK | M_ZERO);
+       npx_initialstate = uma_zalloc(fpu_save_area_zone, M_WAITOK | M_ZERO);
        if (use_xsave) {
                if (xsave_mask >> 32 != 0)
                        max_ext_n = fls(xsave_mask >> 32) + 32;
_______________________________________________
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