• Sean Christopherson's avatar
    KVM: nVMX: Honor userspace MSR filter lists for nested VM-Enter/VM-Exit · 653ea448
    Sean Christopherson authored
    Synthesize a consistency check VM-Exit (VM-Enter) or VM-Abort (VM-Exit) if
    L1 attempts to load/store an MSR via the VMCS MSR lists that userspace has
    disallowed access to via an MSR filter.  Intel already disallows including
    a handful of "special" MSRs in the VMCS lists, so denying access isn't
    completely without precedent.
    
    More importantly, the behavior is well-defined _and_ can be communicated
    the end user, e.g. to the customer that owns a VM running as L1 on top of
    KVM.  On the other hand, ignoring userspace MSR filters is all but
    guaranteed to result in unexpected behavior as the access will hit KVM's
    internal state, which is likely not up-to-date.
    
    Unlike KVM-internal accesses, instruction emulation, and dedicated VMCS
    fields, the MSRs in the VMCS load/store lists are 100% guest controlled,
    thus making it all but impossible to reason about the correctness of
    ignoring the MSR filter.  And if userspace *really* wants to deny access
    to MSRs via the aforementioned scenarios, userspace can hide the
    associated feature from the guest, e.g. by disabling the PMU to prevent
    accessing PERF_GLOBAL_CTRL via its VMCS field.  But for the MSR lists, KVM
    is blindly processing MSRs; the  MSR filters are the _only_ way for
    userspace to deny access.
    
    This partially reverts commit ac8d6cad ("KVM: x86: Only do MSR
    filtering when access MSR by rdmsr/wrmsr").
    
    Cc: Hou Wenlong <houwenlong.hwl@antgroup.com>
    Cc: Jim Mattson <jmattson@google.com>
    Link: https://lore.kernel.org/r/20240722235922.3351122-1-seanjc@google.comSigned-off-by: default avatarSean Christopherson <seanjc@google.com>
    653ea448
nested.c 223 KB