Print this page
13275 bhyve needs richer INIT/SIPI support
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Approved by: Gordon Ross <gordon.w.ross@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/bhyve/spinup_ap.c
          +++ new/usr/src/cmd/bhyve/spinup_ap.c
↓ open down ↓ 48 lines elided ↑ open up ↑
  49   49  #include <machine/vmm.h>
  50   50  #include <vmmapi.h>
  51   51  
  52   52  #include <stdio.h>
  53   53  #include <stdlib.h>
  54   54  #include <assert.h>
  55   55  
  56   56  #include "bhyverun.h"
  57   57  #include "spinup_ap.h"
  58   58  
       59 +#ifdef __FreeBSD__
  59   60  static void
  60   61  spinup_ap_realmode(struct vmctx *ctx, int newcpu, uint64_t *rip)
  61   62  {
  62   63          int vector, error;
  63   64          uint16_t cs;
  64   65          uint64_t desc_base;
  65   66          uint32_t desc_limit, desc_access;
  66   67  
  67   68          vector = *rip >> PAGE_SHIFT;
  68   69          *rip = 0;
↓ open down ↓ 25 lines elided ↑ open up ↑
  94   95          int error;
  95   96  
  96   97          assert(newcpu != 0);
  97   98          assert(newcpu < guest_ncpus);
  98   99  
  99  100          error = vcpu_reset(ctx, newcpu);
 100  101          assert(error == 0);
 101  102  
 102  103          fbsdrun_set_capabilities(ctx, newcpu);
 103  104  
 104      -#ifdef __FreeBSD__
 105  105          /*
 106  106           * Enable the 'unrestricted guest' mode for 'newcpu'.
 107  107           *
 108  108           * Set up the processor state in power-on 16-bit mode, with the CS:IP
 109  109           * init'd to the specified low-mem 4K page.
 110  110           */
 111  111          error = vm_set_capability(ctx, newcpu, VM_CAP_UNRESTRICTED_GUEST, 1);
 112  112          assert(error == 0);
 113      -#else
 114      -        /* Unrestricted Guest is always enabled on illumos */
 115      -#endif
 116  113  
 117  114          spinup_ap_realmode(ctx, newcpu, &rip);
 118  115  
 119      -#ifdef __FreeBSD__
 120  116          fbsdrun_addcpu(ctx, vcpu, newcpu, rip);
 121      -#else
 122      -        fbsdrun_addcpu(ctx, vcpu, newcpu, rip, false);
 123      -#endif
 124  117  
 125  118          return (newcpu);
 126  119  }
      120 +#else /* __FreeBSD__ */
      121 +void
      122 +spinup_halted_ap(struct vmctx *ctx, int newcpu)
      123 +{
      124 +        int error;
      125 +
      126 +        assert(newcpu != 0);
      127 +        assert(newcpu < guest_ncpus);
      128 +
      129 +        error = vcpu_reset(ctx, newcpu);
      130 +        assert(error == 0);
      131 +
      132 +        fbsdrun_set_capabilities(ctx, newcpu);
      133 +
      134 +        error = vm_set_run_state(ctx, newcpu, VRS_HALT, 0);
      135 +        assert(error == 0);
      136 +
      137 +        fbsdrun_addcpu(ctx, newcpu, 0, false);
      138 +}
      139 +#endif /* __FreeBSD__ */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX