diff options
author | Vipin Sharma <vipinsh@google.com> | 2021-11-09 20:44:26 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-11-11 18:56:24 +0300 |
commit | 796c83c58a494f7e88c22a02c4871173ae9c9d53 (patch) | |
tree | 56a62e0d5e797ade310b3e1c211f2d494fba931d /arch/x86/kvm/x86.c | |
parent | 329bd56ce5dc3449788de2dc078861ec6d75e457 (diff) | |
download | linux-796c83c58a494f7e88c22a02c4871173ae9c9d53.tar.xz |
KVM: Move INVPCID type check from vmx and svm to the common kvm_handle_invpcid()
Handle #GP on INVPCID due to an invalid type in the common switch
statement instead of relying on the callers (VMX and SVM) to manually
validate the type.
Unlike INVVPID and INVEPT, INVPCID is not explicitly documented to check
the type before reading the operand from memory, so deferring the
type validity check until after that point is architecturally allowed.
Signed-off-by: Vipin Sharma <vipinsh@google.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20211109174426.2350547-3-vipinsh@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 3a22aa207c73..375ef23f698b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -12510,7 +12510,8 @@ int kvm_handle_invpcid(struct kvm_vcpu *vcpu, unsigned long type, gva_t gva) return kvm_skip_emulated_instruction(vcpu); default: - BUG(); /* We have already checked above that type <= 3 */ + kvm_inject_gp(vcpu, 0); + return 1; } } EXPORT_SYMBOL_GPL(kvm_handle_invpcid); |