kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Edmondson <david.edmondson@oracle.com>
To: linux-kernel@vger.kernel.org
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Sean Christopherson <seanjc@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Joerg Roedel <joro@8bytes.org>,
	Wanpeng Li <wanpengli@tencent.com>,
	Borislav Petkov <bp@alien8.de>, Jim Mattson <jmattson@google.com>,
	Ingo Molnar <mingo@redhat.com>,
	Joao Martins <joao.m.martins@oracle.com>,
	David Edmondson <david.edmondson@oracle.com>
Subject: [PATCH 2/6] KVM: x86: pass emulation_reason to handle_emulation_failure()
Date: Mon, 12 Apr 2021 14:09:33 +0100	[thread overview]
Message-ID: <20210412130938.68178-3-david.edmondson@oracle.com> (raw)
In-Reply-To: <20210412130938.68178-1-david.edmondson@oracle.com>

From: Joao Martins <joao.m.martins@oracle.com>

Make the emulation_reason available up stack when reporting an
emulation failure.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
 arch/x86/kvm/x86.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 87e76f3aee64..b9225012ebd2 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7119,7 +7119,8 @@ void kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip)
 }
 EXPORT_SYMBOL_GPL(kvm_inject_realmode_interrupt);
 
-static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type)
+static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type,
+				    int emulation_reason)
 {
 	++vcpu->stat.insn_emulation_fail;
 	trace_kvm_emulate_insn_failed(vcpu);
@@ -7132,7 +7133,8 @@ static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type)
 	if (emulation_type & EMULTYPE_SKIP) {
 		vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
 		vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
-		vcpu->run->internal.ndata = 0;
+		vcpu->run->internal.data[0] = emulation_reason;
+		vcpu->run->internal.ndata = 1;
 		return 0;
 	}
 
@@ -7141,7 +7143,8 @@ static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type)
 	if (!is_guest_mode(vcpu) && static_call(kvm_x86_get_cpl)(vcpu) == 0) {
 		vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
 		vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
-		vcpu->run->internal.ndata = 0;
+		vcpu->run->internal.data[0] = emulation_reason;
+		vcpu->run->internal.ndata = 1;
 		return 0;
 	}
 
@@ -7490,7 +7493,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
 				inject_emulated_exception(vcpu);
 				return 1;
 			}
-			return handle_emulation_failure(vcpu, emulation_type);
+			return handle_emulation_failure(vcpu, emulation_type,
+							emulation_reason);
 		}
 	}
 
@@ -7547,7 +7551,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
 					emulation_type))
 			return 1;
 
-		return handle_emulation_failure(vcpu, emulation_type);
+		return handle_emulation_failure(vcpu, emulation_type,
+						emulation_reason);
 	}
 
 	if (ctxt->have_exception) {
-- 
2.30.2


  parent reply	other threads:[~2021-04-12 13:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 13:09 [PATCH 0/6] KVM: x86: Make the cause of instruction emulation available to user-space David Edmondson
2021-04-12 13:09 ` [PATCH 1/6] KVM: x86: add an emulation_reason to x86_emulate_instruction() David Edmondson
2021-04-12 13:09 ` David Edmondson [this message]
2021-04-12 13:09 ` [PATCH 3/6] KVM: x86: add emulation_reason to kvm_emulate_instruction() David Edmondson
2021-04-12 13:09 ` [PATCH 4/6] KVM: x86: pass a proper reason " David Edmondson
2021-04-12 13:09 ` [PATCH 5/6] KVM: SVM: pass a proper reason in kvm_emulate_instruction() David Edmondson
2021-04-12 16:04   ` Sean Christopherson
2021-04-13 10:53     ` David Edmondson
2021-04-13 18:45       ` Aaron Lewis
2021-04-14 12:25         ` David Edmondson
2021-04-12 13:09 ` [PATCH 6/6] KVM: VMX: " David Edmondson
2021-04-12 18:34 ` [PATCH 0/6] KVM: x86: Make the cause of instruction emulation available to user-space Jim Mattson
2021-04-13 10:54   ` David Edmondson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210412130938.68178-3-david.edmondson@oracle.com \
    --to=david.edmondson@oracle.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joao.m.martins@oracle.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).