static void vmx_cpu_features() { feat_ctl_msr_t feat; if(!vmx_supported()) panic("vmx not supported"); rd_msr_feature_ctrl(feat); if(!feat.vmx && feat.lock) panic("vmx feature BIOS-locked: 0x%x", feat.raw); if(!feat.lock) { if(!feat.vmx) feat.vmx = 1; feat.lock = 1; wr_msr_feature_ctrl(feat); } vmx_cpu_basic_info(); vmx_cpu_proc_feat(); rd_msr_vmx_fixed_cr0(info->vm.vmx_fx_cr0); rd_msr_vmx_fixed_cr4(info->vm.vmx_fx_cr4); /* unrestricted guest */ info->vm.vmx_fx_cr0.fixed_1.raw &= ~(CR0_PG|CR0_PE); info->vm.vmx_fx_cr0.allow_1.raw |= (CR0_PG|CR0_PE); }
static void vmx_cpu_features() { feat_ctl_msr_t feat; if(!vmx_supported()) panic("vmx not supported"); rd_msr_feature_ctrl(feat); if(!feat.vmx && feat.lock) panic("vmx feature BIOS-locked: 0x%x", feat.raw); if(!feat.lock) { if(!feat.vmx) feat.vmx = 1; feat.lock = 1; wr_msr_feature_ctrl(feat); } rd_msr_vmx_basic_info(info->vm.vmx_info); debug(VMX_CPU, "vmx revision %d\n", info->vm.vmx_info.revision_id); if(info->vm.vmx_info.true_f1) { rd_msr_vmx_true_pin_ctls(info->vm.vmx_fx_pin); rd_msr_vmx_true_proc_ctls(info->vm.vmx_fx_proc); rd_msr_vmx_true_exit_ctls(info->vm.vmx_fx_exit); rd_msr_vmx_true_entry_ctls(info->vm.vmx_fx_entry); } else { rd_msr_vmx_pin_ctls(info->vm.vmx_fx_pin); rd_msr_vmx_proc_ctls(info->vm.vmx_fx_proc); rd_msr_vmx_exit_ctls(info->vm.vmx_fx_exit); rd_msr_vmx_entry_ctls(info->vm.vmx_fx_entry); } if(!vmx_allow_proc2(info->vm.vmx_fx_proc)) panic("vmx missing features (secondary proc based) !"); rd_msr_vmx_proc2_ctls(info->vm.vmx_fx_proc2); if(!vmx_allow_ept(info->vm.vmx_fx_proc2)) panic("vmx ept not supported"); if(!vmx_allow_dt(info->vm.vmx_fx_proc2)) panic("vmx desc table exiting not supported"); if(!vmx_allow_vpid(info->vm.vmx_fx_proc2)) panic("vmx vpid not supported"); if(!vmx_allow_uguest(info->vm.vmx_fx_proc2)) panic("vmx missing unrestricted guest\n"); rd_msr_vmx_ept_cap(info->vm.vmx_ept_cap); if(!info->vm.vmx_ept_cap.wb) panic("vmx ept mem type only UC"); if(!info->vm.vmx_ept_cap.pwl4) panic("unsupported page walk length"); rd_msr_vmx_fixed_cr0(info->vm.vmx_fx_cr0); rd_msr_vmx_fixed_cr4(info->vm.vmx_fx_cr4); /* unrestricted guest */ info->vm.vmx_fx_cr0.allow_0 &= ~(CR0_PG|CR0_PE); info->vm.vmx_fx_cr0.allow_1 |= (CR0_PG|CR0_PE); }