浏览代码

KVM: x86: Merge EMULTYPE_RETRY and EMULTYPE_ALLOW_REEXECUTE

retry_instruction() and reexecute_instruction() are a package deal,
i.e. there is no scenario where one is allowed and the other is not.
Merge their controlling emulation type flags to enforce this in code.
Name the combined flag EMULTYPE_ALLOW_RETRY to make it abundantly
clear that we are allowing re{try,execute} to occur, as opposed to
explicitly requesting retry of a previously failed instruction.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Sean Christopherson 7 年之前
父节点
当前提交
384bf2218e
共有 3 个文件被更改,包括 6 次插入7 次删除
  1. 3 4
      arch/x86/include/asm/kvm_host.h
  2. 1 1
      arch/x86/kvm/mmu.c
  3. 2 2
      arch/x86/kvm/x86.c

+ 3 - 4
arch/x86/include/asm/kvm_host.h

@@ -1237,10 +1237,9 @@ enum emulation_result {
 #define EMULTYPE_NO_DECODE	    (1 << 0)
 #define EMULTYPE_NO_DECODE	    (1 << 0)
 #define EMULTYPE_TRAP_UD	    (1 << 1)
 #define EMULTYPE_TRAP_UD	    (1 << 1)
 #define EMULTYPE_SKIP		    (1 << 2)
 #define EMULTYPE_SKIP		    (1 << 2)
-#define EMULTYPE_RETRY		    (1 << 3)
-#define EMULTYPE_ALLOW_REEXECUTE    (1 << 4)
-#define EMULTYPE_NO_UD_ON_FAIL	    (1 << 5)
-#define EMULTYPE_VMWARE		    (1 << 6)
+#define EMULTYPE_ALLOW_RETRY	    (1 << 3)
+#define EMULTYPE_NO_UD_ON_FAIL	    (1 << 4)
+#define EMULTYPE_VMWARE		    (1 << 5)
 int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2,
 int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2,
 			    int emulation_type, void *insn, int insn_len);
 			    int emulation_type, void *insn, int insn_len);
 
 

+ 1 - 1
arch/x86/kvm/mmu.c

@@ -5217,7 +5217,7 @@ static int make_mmu_pages_available(struct kvm_vcpu *vcpu)
 int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
 int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
 		       void *insn, int insn_len)
 		       void *insn, int insn_len)
 {
 {
-	int r, emulation_type = EMULTYPE_RETRY | EMULTYPE_ALLOW_REEXECUTE;
+	int r, emulation_type = EMULTYPE_ALLOW_RETRY;
 	enum emulation_result er;
 	enum emulation_result er;
 	bool direct = vcpu->arch.mmu.direct_map;
 	bool direct = vcpu->arch.mmu.direct_map;
 
 

+ 2 - 2
arch/x86/kvm/x86.c

@@ -5870,7 +5870,7 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2,
 	gpa_t gpa = cr2;
 	gpa_t gpa = cr2;
 	kvm_pfn_t pfn;
 	kvm_pfn_t pfn;
 
 
-	if (!(emulation_type & EMULTYPE_ALLOW_REEXECUTE))
+	if (!(emulation_type & EMULTYPE_ALLOW_RETRY))
 		return false;
 		return false;
 
 
 	if (!vcpu->arch.mmu.direct_map) {
 	if (!vcpu->arch.mmu.direct_map) {
@@ -5958,7 +5958,7 @@ static bool retry_instruction(struct x86_emulate_ctxt *ctxt,
 	 */
 	 */
 	vcpu->arch.last_retry_eip = vcpu->arch.last_retry_addr = 0;
 	vcpu->arch.last_retry_eip = vcpu->arch.last_retry_addr = 0;
 
 
-	if (!(emulation_type & EMULTYPE_RETRY))
+	if (!(emulation_type & EMULTYPE_ALLOW_RETRY))
 		return false;
 		return false;
 
 
 	if (x86_page_table_writing_insn(ctxt))
 	if (x86_page_table_writing_insn(ctxt))