]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
KVM: x86: SVM: Set EMULTYPE_NO_REEXECUTE for RSM emulation
authorSean Christopherson <sean.j.christopherson@intel.com>
Thu, 29 Aug 2019 17:06:58 +0000 (14:06 -0300)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Tue, 17 Sep 2019 16:02:18 +0000 (18:02 +0200)
BugLink: https://bugs.launchpad.net/bugs/1834522
Re-execution after an emulation decode failure is only intended to
handle a case where two or vCPUs race to write a shadowed page, i.e.
we should never re-execute an instruction as part of RSM emulation.

Add a new helper, kvm_emulate_instruction_from_buffer(), to support
emulating from a pre-defined buffer.  This eliminates the last direct
call to x86_emulate_instruction() outside of kvm_mmu_page_fault(),
which means x86_emulate_instruction() can be unexported in a future
patch.

Fixes: 7607b7174405 ("KVM: SVM: install RSM intercept")
Cc: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
(cherry-picked from 35be0aded76b54a24dc8aa678a71bca22273e8d8)
Signed-off-by: Rafael David Tinoco <rafaeldtinoco@ubuntu.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/svm.c

index 11838996bd5900fa77ce55d77f1b72b0f54968d4..51d587825a59d77ea7f9343d9e46a83ec3127ad9 100644 (file)
@@ -1190,6 +1190,13 @@ static inline int emulate_instruction(struct kvm_vcpu *vcpu,
                        emulation_type | EMULTYPE_NO_REEXECUTE, NULL, 0);
 }
 
+static inline int kvm_emulate_instruction_from_buffer(struct kvm_vcpu *vcpu,
+                                                     void *insn, int insn_len)
+{
+       return x86_emulate_instruction(vcpu, 0, EMULTYPE_NO_REEXECUTE,
+                                      insn, insn_len);
+}
+
 void kvm_enable_efer_bits(u64);
 bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer);
 int kvm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr);
index 77a98268df8aec8bdf49fcdf9f1b5ca6813d5e34..779ae76c7a52d59104003f7710b23bce19e7cb78 100644 (file)
@@ -3461,8 +3461,8 @@ static int emulate_on_interception(struct vcpu_svm *svm)
 
 static int rsm_interception(struct vcpu_svm *svm)
 {
-       return x86_emulate_instruction(&svm->vcpu, 0, 0,
-                                      rsm_ins_bytes, 2) == EMULATE_DONE;
+       return kvm_emulate_instruction_from_buffer(&svm->vcpu,
+                                       rsm_ins_bytes, 2) == EMULATE_DONE;
 }
 
 static int rdpmc_interception(struct vcpu_svm *svm)