• Sean Christopherson's avatar
    KVM: selftests: Add x86-64 support for exception fixup · 3b23054c
    Sean Christopherson authored
    Add x86-64 support for exception fixup on single instructions, without
    forcing tests to install their own fault handlers.  Use registers r9-r11
    to flag the instruction as "safe" and pass fixup/vector information,
    i.e. introduce yet another flavor of fixup (versus the kernel's in-memory
    tables and KUT's per-CPU area) to take advantage of KVM sefltests being
    64-bit only.
    
    Using only registers avoids the need to allocate fixup tables, ensure
    FS or GS base is valid for the guest, ensure memory is mapped into the
    guest, etc..., and also reduces the potential for recursive faults due to
    accessing memory.
    
    Providing exception fixup trivializes tests that just want to verify that
    an instruction faults, e.g. no need to track start/end using global
    labels, no need to install a dedicated handler, etc...
    
    Deliberately do not support #DE in exception fixup so that the fixup glue
    doesn't need to account for a fault with vector == 0, i.e. the vector can
    also indicate that a fault occurred.  KVM injects #DE only for esoteric
    emulation scenarios, i.e. there's very, very little value in testing #DE.
    Force any test that wants to generate #DEs to install its own handler(s).
    
    Use kvm_pv_test as a guinea pig for the new fixup, as it has a very
    straightforward use case of wanting to verify that RDMSR and WRMSR fault.
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Message-Id: <20220608224516.3788274-3-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    3b23054c
processor.c 35.1 KB