Print this page
8956 Implement KPTI
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>


   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  *
  26  * Copyright (c) 2010, Intel Corporation.
  27  * All rights reserved.
  28  *
  29  * Copyright 2013 Joyent, Inc.  All rights reserved.
  30  */
  31 
  32 /*
  33  * This file contains the functionality that mimics the boot operations
  34  * on SPARC systems or the old boot.bin/multiboot programs on x86 systems.
  35  * The x86 kernel now does everything on its own.
  36  */
  37 
  38 #include <sys/types.h>
  39 #include <sys/bootconf.h>
  40 #include <sys/bootsvcs.h>
  41 #include <sys/bootinfo.h>
  42 #include <sys/multiboot.h>
  43 #include <sys/multiboot2.h>
  44 #include <sys/multiboot2_impl.h>
  45 #include <sys/bootvfs.h>
  46 #include <sys/bootprops.h>
  47 #include <sys/varargs.h>
  48 #include <sys/param.h>
  49 #include <sys/machparam.h>


 830 /*
 831  * Do a real mode interrupt BIOS call
 832  */
 833 typedef struct bios_regs {
 834         unsigned short ax, bx, cx, dx, si, di, bp, es, ds;
 835 } bios_regs_t;
 836 typedef int (*bios_func_t)(int, bios_regs_t *);
 837 
 838 /*ARGSUSED*/
 839 static void
 840 do_bsys_doint(bootops_t *bop, int intnum, struct bop_regs *rp)
 841 {
 842 #if defined(__xpv)
 843         prom_panic("unsupported call to BOP_DOINT()\n");
 844 #else   /* __xpv */
 845         static int firsttime = 1;
 846         bios_func_t bios_func = (bios_func_t)(void *)(uintptr_t)0x5000;
 847         bios_regs_t br;
 848 
 849         /*






 850          * The first time we do this, we have to copy the pre-packaged
 851          * low memory bios call code image into place.
 852          */
 853         if (firsttime) {
 854                 extern char bios_image[];
 855                 extern uint32_t bios_size;
 856 
 857                 bcopy(bios_image, (void *)bios_func, bios_size);
 858                 firsttime = 0;
 859         }
 860 
 861         br.ax = rp->eax.word.ax;
 862         br.bx = rp->ebx.word.bx;
 863         br.cx = rp->ecx.word.cx;
 864         br.dx = rp->edx.word.dx;
 865         br.bp = rp->ebp.word.bp;
 866         br.si = rp->esi.word.si;
 867         br.di = rp->edi.word.di;
 868         br.ds = rp->ds;
 869         br.es = rp->es;




   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  *
  26  * Copyright (c) 2010, Intel Corporation.
  27  * All rights reserved.
  28  *
  29  * Copyright 2018 Joyent, Inc.  All rights reserved.
  30  */
  31 
  32 /*
  33  * This file contains the functionality that mimics the boot operations
  34  * on SPARC systems or the old boot.bin/multiboot programs on x86 systems.
  35  * The x86 kernel now does everything on its own.
  36  */
  37 
  38 #include <sys/types.h>
  39 #include <sys/bootconf.h>
  40 #include <sys/bootsvcs.h>
  41 #include <sys/bootinfo.h>
  42 #include <sys/multiboot.h>
  43 #include <sys/multiboot2.h>
  44 #include <sys/multiboot2_impl.h>
  45 #include <sys/bootvfs.h>
  46 #include <sys/bootprops.h>
  47 #include <sys/varargs.h>
  48 #include <sys/param.h>
  49 #include <sys/machparam.h>


 830 /*
 831  * Do a real mode interrupt BIOS call
 832  */
 833 typedef struct bios_regs {
 834         unsigned short ax, bx, cx, dx, si, di, bp, es, ds;
 835 } bios_regs_t;
 836 typedef int (*bios_func_t)(int, bios_regs_t *);
 837 
 838 /*ARGSUSED*/
 839 static void
 840 do_bsys_doint(bootops_t *bop, int intnum, struct bop_regs *rp)
 841 {
 842 #if defined(__xpv)
 843         prom_panic("unsupported call to BOP_DOINT()\n");
 844 #else   /* __xpv */
 845         static int firsttime = 1;
 846         bios_func_t bios_func = (bios_func_t)(void *)(uintptr_t)0x5000;
 847         bios_regs_t br;
 848 
 849         /*
 850          * We're about to disable paging; we shouldn't be PCID enabled.
 851          */
 852         if (getcr4() & CR4_PCIDE)
 853                 prom_panic("do_bsys_doint() with PCID enabled\n");
 854 
 855         /*
 856          * The first time we do this, we have to copy the pre-packaged
 857          * low memory bios call code image into place.
 858          */
 859         if (firsttime) {
 860                 extern char bios_image[];
 861                 extern uint32_t bios_size;
 862 
 863                 bcopy(bios_image, (void *)bios_func, bios_size);
 864                 firsttime = 0;
 865         }
 866 
 867         br.ax = rp->eax.word.ax;
 868         br.bx = rp->ebx.word.bx;
 869         br.cx = rp->ecx.word.cx;
 870         br.dx = rp->edx.word.dx;
 871         br.bp = rp->ebp.word.bp;
 872         br.si = rp->esi.word.si;
 873         br.di = rp->edi.word.di;
 874         br.ds = rp->ds;
 875         br.es = rp->es;