KVM: x86: Allow deflecting unknown MSR accesses to user space
authorAlexander Graf <graf@amazon.com>
Fri, 25 Sep 2020 14:34:16 +0000 (16:34 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 28 Sep 2020 11:58:04 +0000 (07:58 -0400)
commit1ae099540e8c7f1ee066b3ad45cc91f582bb1ce8
treeceaa0ec16e64a766c75b0149e42a85801eaa2ef3
parent90218e434c4118fd7bba7ea7b073e6c6454140a2
KVM: x86: Allow deflecting unknown MSR accesses to user space

MSRs are weird. Some of them are normal control registers, such as EFER.
Some however are registers that really are model specific, not very
interesting to virtualization workloads, and not performance critical.
Others again are really just windows into package configuration.

Out of these MSRs, only the first category is necessary to implement in
kernel space. Rarely accessed MSRs, MSRs that should be fine tunes against
certain CPU models and MSRs that contain information on the package level
are much better suited for user space to process. However, over time we have
accumulated a lot of MSRs that are not the first category, but still handled
by in-kernel KVM code.

This patch adds a generic interface to handle WRMSR and RDMSR from user
space. With this, any future MSR that is part of the latter categories can
be handled in user space.

Furthermore, it allows us to replace the existing "ignore_msrs" logic with
something that applies per-VM rather than on the full system. That way you
can run productive VMs in parallel to experimental ones where you don't care
about proper MSR handling.

Signed-off-by: Alexander Graf <graf@amazon.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
Message-Id: <20200925143422.21718-3-graf@amazon.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Documentation/virt/kvm/api.rst
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/emulate.c
arch/x86/kvm/x86.c
include/trace/events/kvm.h
include/uapi/linux/kvm.h