Print this page
    
15254 %ymm registers not restored after signal handler
15367 x86 getfpregs() summons corrupting %xmm ghosts
15333 want x86 /proc xregs support (libc_db, libproc, mdb, etc.)
15336 want libc functions for extended ucontext_t
15334 want ps_lwphandle-specific reg routines
15328 FPU_CW_INIT mistreats reserved bit
15335 i86pc fpu_subr.c isn't really platform-specific
15332 setcontext(2) isn't actually noreturn
15331 need <sys/stdalign.h>
Change-Id: I7060aa86042dfb989f77fc3323c065ea2eafa9ad
Conflicts:
    usr/src/uts/common/fs/proc/prcontrol.c
    usr/src/uts/intel/os/archdep.c
    usr/src/uts/intel/sys/ucontext.h
    usr/src/uts/intel/syscall/getcontext.c
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/lib/libc/i386/fp/fpstart.c
          +++ new/usr/src/lib/libc/i386/fp/fpstart.c
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  
    | 
      ↓ open down ↓ | 
    23 lines elided | 
    
      ↑ open up ↑ | 
  
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*
  28   28   *      Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.
  29   29   *      Copyright (c) 1988 AT&T
  30   30   *        All Rights Reserved
  31   31   */
  32   32  
  33   33  /*
       34 + * Copyright 2023 Oxide Computer Company
       35 + */
       36 +
       37 +/*
  34   38   * Establish the default settings for the floating-point state for a C language
  35   39   * program:
  36   40   *      rounding mode           -- round to nearest default by OS,
  37   41   *      exceptions enabled      -- all masked
  38   42   *      sticky bits             -- all clear by default by OS.
  39   43   *      precision control       -- double extended
  40   44   * Set _fp_hw according to what floating-point hardware is available.
  41   45   * Set _sse_hw according to what SSE hardware is available.
  42   46   * Set __flt_rounds according to the rounding mode.
  43   47   */
  44   48  
  45   49  #pragma weak _fpstart = __fpstart
  46   50  
  47   51  #include        "lint.h"
  48   52  #include        <sys/types.h>
  49   53  #include        <sys/sysi86.h>  /* for SI86FPHW/SI86FPSTART definitions */
  50   54  #include        <sys/fp.h>      /* for FPU_CW_INIT and SSE_MXCSR_INIT */
       55 +#include        <upanic.h>
  51   56  
  52   57  extern int      __fltrounds();
  53   58  
  54   59  int     _fp_hw;                 /* default: bss: 0 == no hardware */
  55   60  int     _sse_hw;                /* default: bss: 0 == no sse */
  56   61  int     __flt_rounds;           /* ANSI rounding mode */
  57   62  
       63 +#define UPANIC_MSG      "32-bit FPU init failed!"
       64 +
  58   65  void
  59   66  __fpstart()
  60   67  {
  61   68          /*
  62   69           * query OS for HW status and ensure the x87 and (optional)
  63   70           * SSE control words are (will be) set correctly.
  64   71           */
  65   72          if ((_sse_hw = sysi86(SI86FPSTART,
  66   73              &_fp_hw, FPU_CW_INIT, SSE_MXCSR_INIT)) == -1) {
  67      -                extern void _putcw();
  68      -
  69   74                  /*
  70      -                 * (fallback to old syscall on old kernels)
       75 +                 * Because the system only supports a 64-bit kernel, the above
       76 +                 * should always work (we assume it does in 64-bit libc). If it
       77 +                 * should fail, we upanic. Note, because the FPU state is
       78 +                 * unknown, we use a static message below and don't rely upon
       79 +                 * strlen(), but rather constant time lengths.
  71   80                   */
  72      -                _sse_hw = 0;
  73      -                (void) sysi86(SI86FPHW, &_fp_hw);
  74      -                _putcw(0x133f);
       81 +                upanic(UPANIC_MSG, sizeof (UPANIC_MSG));
  75   82          }
  76   83  
  77   84          /*
  78   85           * At this point the x87 fp environment that has been (or more
  79   86           * hopefully, will be) established by the kernel is:
  80   87           *
  81   88           * affine infinity      0x1000
  82   89           * round to nearest     0x0000
  83   90           * 64-bit doubles       0x0300
  84   91           * precision, underflow, overflow, zero-divide, denorm, invalid masked
  85   92           *                      0x003f
  86   93           *
  87   94           * which conforms to the 4th edition i386 ABI definition.
  88   95           *
  89   96           * Additionally, if we have SSE hardware, we've also masked all
  90   97           * the same traps, and have round to nearest.
  91   98           */
  92   99  
  93  100          __flt_rounds = 1;       /* ANSI way of saying round-to-nearest */
  94  101  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX