bool vcpu_handle_msr_read(void);
bool vcpu_handle_msr_write(void);
+void vcpu_handle_cpuid(void);
+
bool vcpu_handle_xsetbv(void);
void vcpu_reset(bool hard_reset);
vmcb->general1_intercepts |= GENERAL1_INTERCEPT_NMI;
vmcb->general1_intercepts |= GENERAL1_INTERCEPT_CR0_SEL_WRITE;
+ vmcb->general1_intercepts |= GENERAL1_INTERCEPT_CPUID;
vmcb->general1_intercepts |= GENERAL1_INTERCEPT_IOIO_PROT;
vmcb->general1_intercepts |= GENERAL1_INTERCEPT_MSR_PROT;
vmcb->general1_intercepts |= GENERAL1_INTERCEPT_SHUTDOWN_EVT;
if (svm_handle_cr(cpu_data))
goto vmentry;
break;
+ case VMEXIT_CPUID:
+ vcpu_handle_cpuid();
+ goto vmentry;
case VMEXIT_MSR:
cpu_data->stats[JAILHOUSE_CPU_STAT_VMEXITS_MSR]++;
if (!vmcb->exitinfo1)
return true;
}
+void vcpu_handle_cpuid(void)
+{
+ union registers *guest_regs = &this_cpu_data()->guest_regs;
+
+ this_cpu_data()->stats[JAILHOUSE_CPU_STAT_VMEXITS_CPUID]++;
+
+ /* clear upper 32 bits of the involved registers */
+ guest_regs->rax &= 0xffffffff;
+ guest_regs->rbx &= 0xffffffff;
+ guest_regs->rcx &= 0xffffffff;
+ guest_regs->rdx &= 0xffffffff;
+
+ cpuid((u32 *)&guest_regs->rax, (u32 *)&guest_regs->rbx,
+ (u32 *)&guest_regs->rcx, (u32 *)&guest_regs->rdx);
+
+ vcpu_skip_emulated_instruction(X86_INST_LEN_CPUID);
+}
+
bool vcpu_handle_xsetbv(void)
{
union registers *guest_regs = &this_cpu_data()->guest_regs;
vmcs_write64(GUEST_RIP, vmcs_read64(GUEST_RIP) + inst_len);
}
-static void vmx_handle_cpuid(union registers *guest_regs)
-{
- this_cpu_data()->stats[JAILHOUSE_CPU_STAT_VMEXITS_CPUID]++;
-
- /* clear upper 32 bits of the involved registers */
- guest_regs->rax &= 0xffffffff;
- guest_regs->rbx &= 0xffffffff;
- guest_regs->rcx &= 0xffffffff;
- guest_regs->rdx &= 0xffffffff;
-
- cpuid((u32 *)&guest_regs->rax, (u32 *)&guest_regs->rbx,
- (u32 *)&guest_regs->rcx, (u32 *)&guest_regs->rdx);
-
- vcpu_skip_emulated_instruction(X86_INST_LEN_CPUID);
-}
-
static void update_efer(void)
{
unsigned long efer = vmcs_read64(GUEST_IA32_EFER);
iommu_check_pending_faults(cpu_data);
return;
case EXIT_REASON_CPUID:
- vmx_handle_cpuid(&cpu_data->guest_regs);
+ vcpu_handle_cpuid();
return;
case EXIT_REASON_VMCALL:
vcpu_handle_hypercall();