Print this page
9723 provide support for VMM's GDT handling
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/ia32/os/desctbls.c
          +++ new/usr/src/uts/intel/ia32/os/desctbls.c
↓ open down ↓ 1282 lines elided ↑ open up ↑
1283 1283          init_tss();
1284 1284          CPU->cpu_tss = ktss0;
1285 1285          init_ldt();
1286 1286  
1287 1287          /* Stash this so that the NMI,MCE,#DF and KDI handlers can use it. */
1288 1288          kpti_safe_cr3 = (uint64_t)getcr3();
1289 1289  }
1290 1290  
1291 1291  #endif  /* __xpv */
1292 1292  
     1293 +#ifndef __xpv
1293 1294  /*
     1295 + * As per Intel Vol 3 27.5.2, the GDTR limit is reset to 64Kb on a VM exit, so
     1296 + * we have to manually fix it up ourselves.
     1297 + *
     1298 + * The caller may still need to make sure that it can't go off-CPU with the
     1299 + * incorrect limit, before calling this (such as disabling pre-emption).
     1300 + */
     1301 +void
     1302 +reset_gdtr_limit(void)
     1303 +{
     1304 +        ulong_t flags = intr_clear();
     1305 +        desctbr_t gdtr;
     1306 +
     1307 +        rd_gdtr(&gdtr);
     1308 +        gdtr.dtr_limit = (sizeof (user_desc_t) * NGDT) - 1;
     1309 +        wr_gdtr(&gdtr);
     1310 +
     1311 +        intr_restore(flags);
     1312 +}
     1313 +#endif /* __xpv */
     1314 +
     1315 +/*
1294 1316   * In the early kernel, we need to set up a simple GDT to run on.
1295 1317   *
1296 1318   * XXPV Can dboot use this too?  See dboot_gdt.s
1297 1319   */
1298 1320  void
1299 1321  init_boot_gdt(user_desc_t *bgdt)
1300 1322  {
1301 1323  #if defined(__amd64)
1302 1324          set_usegd(&bgdt[GDT_B32DATA], SDP_LONG, NULL, -1, SDT_MEMRWA, SEL_KPL,
1303 1325              SDP_PAGES, SDP_OP32);
↓ open down ↓ 120 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX