Skip to content

Commit 67ca664

Browse files
committed
vmx: move Hypervisor HV_VMX_CAP_* query to per-vCPU setup
Signed-off-by: David Scott <dave@recoil.org>
1 parent 8702deb commit 67ca664

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

src/lib/vmm/intel/vmx.c

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -496,60 +496,6 @@ vmx_init(void)
496496
xhyve_abort("hv_vm_create unknown error %d\n", error);
497497
}
498498

499-
/* Check support for primary processor-based VM-execution controls */
500-
error = vmx_set_ctlreg(HV_VMX_CAP_PROCBASED,
501-
PROCBASED_CTLS_ONE_SETTING,
502-
PROCBASED_CTLS_ZERO_SETTING, &procbased_ctls);
503-
if (error) {
504-
printf("vmx_init: processor does not support desired primary "
505-
"processor-based controls\n");
506-
return (error);
507-
}
508-
509-
/* Clear the processor-based ctl bits that are set on demand */
510-
procbased_ctls &= ~PROCBASED_CTLS_WINDOW_SETTING;
511-
512-
/* Check support for secondary processor-based VM-execution controls */
513-
error = vmx_set_ctlreg(HV_VMX_CAP_PROCBASED2,
514-
PROCBASED_CTLS2_ONE_SETTING,
515-
PROCBASED_CTLS2_ZERO_SETTING, &procbased_ctls2);
516-
if (error) {
517-
printf("vmx_init: processor does not support desired secondary "
518-
"processor-based controls\n");
519-
return (error);
520-
}
521-
522-
/* Check support for pin-based VM-execution controls */
523-
error = vmx_set_ctlreg(HV_VMX_CAP_PINBASED,
524-
PINBASED_CTLS_ONE_SETTING,
525-
PINBASED_CTLS_ZERO_SETTING, &pinbased_ctls);
526-
if (error) {
527-
printf("vmx_init: processor does not support desired "
528-
"pin-based controls\n");
529-
return (error);
530-
}
531-
532-
/* Check support for VM-exit controls */
533-
error = vmx_set_ctlreg(HV_VMX_CAP_EXIT,
534-
VM_EXIT_CTLS_ONE_SETTING,
535-
VM_EXIT_CTLS_ZERO_SETTING,
536-
&exit_ctls);
537-
if (error) {
538-
printf("vmx_init: processor does not support desired "
539-
"exit controls\n");
540-
return (error);
541-
}
542-
543-
/* Check support for VM-entry controls */
544-
error = vmx_set_ctlreg(HV_VMX_CAP_ENTRY,
545-
VM_ENTRY_CTLS_ONE_SETTING, VM_ENTRY_CTLS_ZERO_SETTING,
546-
&entry_ctls);
547-
if (error) {
548-
printf("vmx_init: processor does not support desired "
549-
"entry controls\n");
550-
return (error);
551-
}
552-
553499
/*
554500
* Check support for optional features by testing them
555501
* as individual bits
@@ -649,6 +595,60 @@ vmx_vcpu_init(void *arg, int vcpuid) {
649595

650596
vmx_msr_guest_init(vmx, vcpuid);
651597

598+
/* Check support for primary processor-based VM-execution controls */
599+
error = vmx_set_ctlreg(HV_VMX_CAP_PROCBASED,
600+
PROCBASED_CTLS_ONE_SETTING,
601+
PROCBASED_CTLS_ZERO_SETTING, &procbased_ctls);
602+
if (error) {
603+
printf("vmx_init: processor does not support desired primary "
604+
"processor-based controls\n");
605+
return (error);
606+
}
607+
608+
/* Clear the processor-based ctl bits that are set on demand */
609+
procbased_ctls &= ~PROCBASED_CTLS_WINDOW_SETTING;
610+
611+
/* Check support for secondary processor-based VM-execution controls */
612+
error = vmx_set_ctlreg(HV_VMX_CAP_PROCBASED2,
613+
PROCBASED_CTLS2_ONE_SETTING,
614+
PROCBASED_CTLS2_ZERO_SETTING, &procbased_ctls2);
615+
if (error) {
616+
printf("vmx_init: processor does not support desired secondary "
617+
"processor-based controls\n");
618+
return (error);
619+
}
620+
621+
/* Check support for pin-based VM-execution controls */
622+
error = vmx_set_ctlreg(HV_VMX_CAP_PINBASED,
623+
PINBASED_CTLS_ONE_SETTING,
624+
PINBASED_CTLS_ZERO_SETTING, &pinbased_ctls);
625+
if (error) {
626+
printf("vmx_init: processor does not support desired "
627+
"pin-based controls\n");
628+
return (error);
629+
}
630+
631+
/* Check support for VM-exit controls */
632+
error = vmx_set_ctlreg(HV_VMX_CAP_EXIT,
633+
VM_EXIT_CTLS_ONE_SETTING,
634+
VM_EXIT_CTLS_ZERO_SETTING,
635+
&exit_ctls);
636+
if (error) {
637+
printf("vmx_init: processor does not support desired "
638+
"exit controls\n");
639+
return (error);
640+
}
641+
642+
/* Check support for VM-entry controls */
643+
error = vmx_set_ctlreg(HV_VMX_CAP_ENTRY,
644+
VM_ENTRY_CTLS_ONE_SETTING, VM_ENTRY_CTLS_ZERO_SETTING,
645+
&entry_ctls);
646+
if (error) {
647+
printf("vmx_init: processor does not support desired "
648+
"entry controls\n");
649+
return (error);
650+
}
651+
652652
vmcs_write(vcpuid, VMCS_PIN_BASED_CTLS, pinbased_ctls);
653653
vmcs_write(vcpuid, VMCS_PRI_PROC_BASED_CTLS, procbased_ctls);
654654
vmcs_write(vcpuid, VMCS_SEC_PROC_BASED_CTLS, procbased_ctls2);

0 commit comments

Comments
 (0)