Commit 897c339b authored by Jan Dakinevich's avatar Jan Dakinevich Committed by Stefan Bader

KVM: nVMX: invvpid handling improvements

BugLink: http://bugs.launchpad.net/bugs/1756866

commit bcdde302 upstream

 - Expose all invalidation types to the L1

 - Reject invvpid instruction, if L1 passed zero vpid value to single
   context invalidations
Signed-off-by: default avatarJan Dakinevich <jan.dakinevich@gmail.com>
Tested-by: default avatarLadi Prosek <lprosek@redhat.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
[jwang: port to 4.4]
Signed-off-by: default avatarJack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent d61856d7
...@@ -127,6 +127,12 @@ module_param_named(pml, enable_pml, bool, S_IRUGO); ...@@ -127,6 +127,12 @@ module_param_named(pml, enable_pml, bool, S_IRUGO);
#define VMX_MISC_EMULATED_PREEMPTION_TIMER_RATE 5 #define VMX_MISC_EMULATED_PREEMPTION_TIMER_RATE 5
#define VMX_VPID_EXTENT_SUPPORTED_MASK \
(VMX_VPID_EXTENT_INDIVIDUAL_ADDR_BIT | \
VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT | \
VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT | \
VMX_VPID_EXTENT_SINGLE_NON_GLOBAL_BIT)
/* /*
* These 2 parameters are used to config the controls for Pause-Loop Exiting: * These 2 parameters are used to config the controls for Pause-Loop Exiting:
* ple_gap: upper bound on the amount of time between two successive * ple_gap: upper bound on the amount of time between two successive
...@@ -2671,8 +2677,7 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx) ...@@ -2671,8 +2677,7 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
*/ */
if (enable_vpid) if (enable_vpid)
vmx->nested.nested_vmx_vpid_caps = VMX_VPID_INVVPID_BIT | vmx->nested.nested_vmx_vpid_caps = VMX_VPID_INVVPID_BIT |
VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT | VMX_VPID_EXTENT_SUPPORTED_MASK;
VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT;
else else
vmx->nested.nested_vmx_vpid_caps = 0; vmx->nested.nested_vmx_vpid_caps = 0;
...@@ -7444,7 +7449,8 @@ static int handle_invvpid(struct kvm_vcpu *vcpu) ...@@ -7444,7 +7449,8 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO); vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO);
type = kvm_register_readl(vcpu, (vmx_instruction_info >> 28) & 0xf); type = kvm_register_readl(vcpu, (vmx_instruction_info >> 28) & 0xf);
types = (vmx->nested.nested_vmx_vpid_caps >> 8) & 0x7; types = (vmx->nested.nested_vmx_vpid_caps &
VMX_VPID_EXTENT_SUPPORTED_MASK) >> 8;
if (type >= 32 || !(types & (1 << type))) { if (type >= 32 || !(types & (1 << type))) {
nested_vmx_failValid(vcpu, nested_vmx_failValid(vcpu,
...@@ -7466,21 +7472,27 @@ static int handle_invvpid(struct kvm_vcpu *vcpu) ...@@ -7466,21 +7472,27 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
} }
switch (type) { switch (type) {
case VMX_VPID_EXTENT_INDIVIDUAL_ADDR:
case VMX_VPID_EXTENT_SINGLE_CONTEXT: case VMX_VPID_EXTENT_SINGLE_CONTEXT:
/* case VMX_VPID_EXTENT_SINGLE_NON_GLOBAL:
* Old versions of KVM use the single-context version so we if (!vpid) {
* have to support it; just treat it the same as all-context. nested_vmx_failValid(vcpu,
*/ VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID);
skip_emulated_instruction(vcpu);
return 1;
}
break;
case VMX_VPID_EXTENT_ALL_CONTEXT: case VMX_VPID_EXTENT_ALL_CONTEXT:
__vmx_flush_tlb(vcpu, to_vmx(vcpu)->nested.vpid02);
nested_vmx_succeed(vcpu);
break; break;
default: default:
/* Trap individual address invalidation invvpid calls */ WARN_ON_ONCE(1);
BUG_ON(1); skip_emulated_instruction(vcpu);
break; return 1;
} }
__vmx_flush_tlb(vcpu, vmx->nested.vpid02);
nested_vmx_succeed(vcpu);
skip_emulated_instruction(vcpu); skip_emulated_instruction(vcpu);
return 1; return 1;
} }
......
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