• Hou Wenlong's avatar
    KVM: selftests: fix triple fault if ept=0 in dirty_log_test · e5830fb1
    Hou Wenlong authored
    Commit 22f232d1 ("KVM: selftests: x86: Set supported CPUIDs on
    default VM") moved vcpu_set_cpuid into vm_create_with_vcpus, but
    dirty_log_test doesn't use it to create vm. So vcpu's CPUIDs is
    not set, the guest's pa_bits in kvm would be smaller than the
    value queried by userspace.
    
    However, the dirty track memory slot is in the highest GPA, the
    reserved bits in gpte would be set with wrong pa_bits.
    For shadow paging, page fault would fail in permission_fault and
    be injected into guest. Since guest doesn't have idt, it finally
    leads to vm_exit for triple fault.
    
    Move vcpu_set_cpuid into vm_vcpu_add_default to set supported
    CPUIDs on default vcpu, since almost all tests need it.
    
    Fixes: 22f232d1 ("KVM: selftests: x86: Set supported CPUIDs on default VM")
    Signed-off-by: default avatarHou Wenlong <houwenlong93@linux.alibaba.com>
    Message-Id: <411ea2173f89abce56fc1fca5af913ed9c5a89c9.1624351343.git.houwenlong93@linux.alibaba.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    e5830fb1
kvm_util.c 58.4 KB