Skip to content

Commit

Permalink
KVM: VMX: Set EDX at INIT with CPUID.0x1, Family-Model-Stepping
Browse files Browse the repository at this point in the history
Set EDX at RESET/INIT based on the userspace-defined CPUID model when
possible, i.e. when CPUID.0x1.EAX is defind by userspace.  At RESET/INIT,
all CPUs that support CPUID set EDX to the FMS enumerated in
CPUID.0x1.EAX.  If no CPUID match is found, fall back to KVM's default
of 0x600 (Family '6'), which is the least awful approximation of KVM's
virtual CPU model.

Fixes: 6aa8b73 ("[PATCH] kvm: userspace interface")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210713163324.627647-5-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
sean-jc authored and bonzini committed Aug 2, 2021
1 parent 4f117ce commit 2a24be7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion arch/x86/kvm/vmx/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -4394,14 +4394,19 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
struct msr_data apic_base_msr;
u32 eax, dummy;
u64 cr0;

vmx->rmode.vm86_active = 0;
vmx->spec_ctrl = 0;

vmx->msr_ia32_umwait_control = 0;

vmx->vcpu.arch.regs[VCPU_REGS_RDX] = get_rdx_init_val();
eax = 1;
if (!kvm_cpuid(vcpu, &eax, &dummy, &dummy, &dummy, true))
eax = get_rdx_init_val();
kvm_rdx_write(vcpu, eax);

vmx->hv_deadline_tsc = -1;
kvm_set_cr8(vcpu, 0);

Expand Down

0 comments on commit 2a24be7

Please sign in to comment.