Print this page
re #13140 rb4270 hvm_sd module missing dependencies on scsi and cmlb
re #13166 rb4270 Check for Xen HVM even if CPUID signature returns Microsoft Hv
re #13187 rb4270 Fix Xen HVM related warnings


  82         struct xen_hvm_param xhp;
  83 
  84         xhp.domid = DOMID_SELF;
  85         xhp.index = param_id;
  86         if ((HYPERVISOR_hvm_op(HVMOP_get_param, &xhp) < 0))
  87                 return (-1);
  88         *val = xhp.value;
  89         return (0);
  90 }
  91 
  92 void
  93 xen_hvm_init(void)
  94 {
  95         struct cpuid_regs cp;
  96         uint32_t xen_signature[4], base;
  97         char *xen_str;
  98         struct xen_add_to_physmap xatp;
  99         xen_capabilities_info_t caps;
 100         pfn_t pfn;
 101         uint64_t msrval, val;

 102 
 103         if (xen_hvm_inited != 0)
 104                 return;
 105 
 106         xen_hvm_inited = 1;
 107 
 108         /*
 109          * Xen's pseudo-cpuid function returns a string representing
 110          * the Xen signature in %ebx, %ecx, and %edx.
 111          * Loop over the base values, since it may be different if
 112          * the hypervisor has hyper-v emulation switched on.
 113          *
 114          * %eax contains the maximum supported cpuid function.
 115          */
 116         for (base = 0x40000000; base < 0x40010000; base += 0x100) {
 117                 cp.cp_eax = base;
 118                 (void) __cpuid_insn(&cp);
 119                 xen_signature[0] = cp.cp_ebx;
 120                 xen_signature[1] = cp.cp_ecx;
 121                 xen_signature[2] = cp.cp_edx;


 200 
 201         /*
 202          * Allocate space for the shared_info page and tell Xen where it
 203          * is.
 204          */
 205         xen_shared_info_frame = va_to_pfn(&hypercall_shared_info_page);
 206         xatp.domid = DOMID_SELF;
 207         xatp.idx = 0;
 208         xatp.space = XENMAPSPACE_shared_info;
 209         xatp.gpfn = xen_shared_info_frame;
 210         if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp) != 0)
 211                 return;
 212 
 213         HYPERVISOR_shared_info = (void *)&hypercall_shared_info_page;
 214 
 215         /*
 216          * A working HVM tlb flush hypercall was introduced in Xen 3.3.
 217          */
 218         if (xen_major > 3 || (xen_major == 3 && xen_minor >= 3))
 219                 xen_hvm_features |= XEN_HVM_TLBFLUSH;



 220 }
 221 
 222 /*
 223  * Returns:
 224  *          -1 if a feature is not available
 225  *          1 if a boolean feature is available
 226  *          > 0 if numeric feature is available
 227  */
 228 int
 229 xpv_feature(int which)
 230 {
 231         switch (which) {
 232         case XPVF_BITS:
 233                 return (xen_bits);
 234         case XPVF_VERSION_MAJOR:
 235                 return (xen_major);
 236         case XPVF_VERSION_MINOR:
 237                 return (xen_minor);
 238         case XPVF_HYPERCALLS:
 239                 if (xen_hvm_features & XEN_HVM_HYPERCALLS)


  82         struct xen_hvm_param xhp;
  83 
  84         xhp.domid = DOMID_SELF;
  85         xhp.index = param_id;
  86         if ((HYPERVISOR_hvm_op(HVMOP_get_param, &xhp) < 0))
  87                 return (-1);
  88         *val = xhp.value;
  89         return (0);
  90 }
  91 
  92 void
  93 xen_hvm_init(void)
  94 {
  95         struct cpuid_regs cp;
  96         uint32_t xen_signature[4], base;
  97         char *xen_str;
  98         struct xen_add_to_physmap xatp;
  99         xen_capabilities_info_t caps;
 100         pfn_t pfn;
 101         uint64_t msrval, val;
 102         extern int apix_enable;
 103 
 104         if (xen_hvm_inited != 0)
 105                 return;
 106 
 107         xen_hvm_inited = 1;
 108 
 109         /*
 110          * Xen's pseudo-cpuid function returns a string representing
 111          * the Xen signature in %ebx, %ecx, and %edx.
 112          * Loop over the base values, since it may be different if
 113          * the hypervisor has hyper-v emulation switched on.
 114          *
 115          * %eax contains the maximum supported cpuid function.
 116          */
 117         for (base = 0x40000000; base < 0x40010000; base += 0x100) {
 118                 cp.cp_eax = base;
 119                 (void) __cpuid_insn(&cp);
 120                 xen_signature[0] = cp.cp_ebx;
 121                 xen_signature[1] = cp.cp_ecx;
 122                 xen_signature[2] = cp.cp_edx;


 201 
 202         /*
 203          * Allocate space for the shared_info page and tell Xen where it
 204          * is.
 205          */
 206         xen_shared_info_frame = va_to_pfn(&hypercall_shared_info_page);
 207         xatp.domid = DOMID_SELF;
 208         xatp.idx = 0;
 209         xatp.space = XENMAPSPACE_shared_info;
 210         xatp.gpfn = xen_shared_info_frame;
 211         if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp) != 0)
 212                 return;
 213 
 214         HYPERVISOR_shared_info = (void *)&hypercall_shared_info_page;
 215 
 216         /*
 217          * A working HVM tlb flush hypercall was introduced in Xen 3.3.
 218          */
 219         if (xen_major > 3 || (xen_major == 3 && xen_minor >= 3))
 220                 xen_hvm_features |= XEN_HVM_TLBFLUSH;
 221 
 222         /* FIXME Disable apix for the time being */
 223         apix_enable = 0;
 224 }
 225 
 226 /*
 227  * Returns:
 228  *          -1 if a feature is not available
 229  *          1 if a boolean feature is available
 230  *          > 0 if numeric feature is available
 231  */
 232 int
 233 xpv_feature(int which)
 234 {
 235         switch (which) {
 236         case XPVF_BITS:
 237                 return (xen_bits);
 238         case XPVF_VERSION_MAJOR:
 239                 return (xen_major);
 240         case XPVF_VERSION_MINOR:
 241                 return (xen_minor);
 242         case XPVF_HYPERCALLS:
 243                 if (xen_hvm_features & XEN_HVM_HYPERCALLS)