Commit 62cc6b9d authored by David Matlack's avatar David Matlack Committed by Paolo Bonzini

KVM: nVMX: support restore of VMX capability MSRs

The VMX capability MSRs advertise the set of features the KVM virtual
CPU can support. This set of features varies across different host CPUs
and KVM versions. This patch aims to addresses both sources of
differences, allowing VMs to be migrated across CPUs and KVM versions
without guest-visible changes to these MSRs. Note that cross-KVM-
version migration is only supported from this point forward.

When the VMX capability MSRs are restored, they are audited to check
that the set of features advertised are a subset of what KVM and the
CPU support.

Since the VMX capability MSRs are read-only, they do not need to be on
the default MSR save/restore lists. The userspace hypervisor can set
the values of these MSRs or read them from KVM at VCPU creation time,
and restore the same value after every save/restore.
Signed-off-by: default avatarDavid Matlack <dmatlack@google.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent 0115f9cb
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define VMX_H #define VMX_H
#include <linux/bitops.h>
#include <linux/types.h> #include <linux/types.h>
#include <uapi/asm/vmx.h> #include <uapi/asm/vmx.h>
...@@ -111,6 +112,36 @@ ...@@ -111,6 +112,36 @@
#define VMX_MISC_SAVE_EFER_LMA 0x00000020 #define VMX_MISC_SAVE_EFER_LMA 0x00000020
#define VMX_MISC_ACTIVITY_HLT 0x00000040 #define VMX_MISC_ACTIVITY_HLT 0x00000040
static inline u32 vmx_basic_vmcs_revision_id(u64 vmx_basic)
{
return vmx_basic & GENMASK_ULL(30, 0);
}
static inline u32 vmx_basic_vmcs_size(u64 vmx_basic)
{
return (vmx_basic & GENMASK_ULL(44, 32)) >> 32;
}
static inline int vmx_misc_preemption_timer_rate(u64 vmx_misc)
{
return vmx_misc & VMX_MISC_PREEMPTION_TIMER_RATE_MASK;
}
static inline int vmx_misc_cr3_count(u64 vmx_misc)
{
return (vmx_misc & GENMASK_ULL(24, 16)) >> 16;
}
static inline int vmx_misc_max_msr(u64 vmx_misc)
{
return (vmx_misc & GENMASK_ULL(27, 25)) >> 25;
}
static inline int vmx_misc_mseg_revid(u64 vmx_misc)
{
return (vmx_misc & GENMASK_ULL(63, 32)) >> 32;
}
/* VMCS Encodings */ /* VMCS Encodings */
enum vmcs_field { enum vmcs_field {
VIRTUAL_PROCESSOR_ID = 0x00000000, VIRTUAL_PROCESSOR_ID = 0x00000000,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment