All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hou Wenlong" <houwenlong.hwl@antgroup.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] KVM: x86: Add missing trace points for RDMSR/WRMSR in emulator path
Date: Thu, 28 Jul 2022 16:25:05 +0800	[thread overview]
Message-ID: <f7d395b60eb7e6dcc149ba39d86f9296bd81b0ac.1658913543.git.houwenlong.hwl@antgroup.com> (raw)
In-Reply-To: <cover.1658913543.git.houwenlong.hwl@antgroup.com>

Since the RDMSR/WRMSR emulation uses a sepearte emualtor interface,
the trace points for RDMSR/WRMSR can be added in emulator path like
normal path.

Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
---
 arch/x86/kvm/x86.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8df89b9c212f..6e45b20ce9a4 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7908,12 +7908,16 @@ static int emulator_get_msr_with_filter(struct x86_emulate_ctxt *ctxt,
 	int r;
 
 	r = kvm_get_msr_with_filter(vcpu, msr_index, pdata);
-	if (r) {
+	if (!r) {
+		trace_kvm_msr_read(msr_index, *pdata);
+	} else {
 		if (kvm_msr_user_space(vcpu, msr_index, KVM_EXIT_X86_RDMSR, 0,
-				       complete_emulated_rdmsr, r))
+				       complete_emulated_rdmsr, r)) {
 			r = X86EMUL_IO_NEEDED;
-		else
+		} else {
+			trace_kvm_msr_read_ex(msr_index);
 			r = X86EMUL_UNHANDLEABLE;
+		}
 	}
 
 	return r;
@@ -7926,12 +7930,16 @@ static int emulator_set_msr_with_filter(struct x86_emulate_ctxt *ctxt,
 	int r;
 
 	r = kvm_set_msr_with_filter(vcpu, msr_index, data);
-	if (r > 0) {
+	if (!r) {
+		trace_kvm_msr_write(msr_index, data);
+	} else if (r > 0) {
 		if (kvm_msr_user_space(vcpu, msr_index, KVM_EXIT_X86_WRMSR, data,
-				       complete_emulated_msr_access, r))
+				       complete_emulated_msr_access, r)) {
 			r = X86EMUL_IO_NEEDED;
-		else
+		} else {
+			trace_kvm_msr_write_ex(msr_index, data);
 			r = X86EMUL_UNHANDLEABLE;
+		}
 	}
 
 	return r;
-- 
2.31.1


  parent reply	other threads:[~2022-07-28  8:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28  8:25 [PATCH 0/2] Add missing trace points in emulator path Hou Wenlong
2022-07-28  8:25 ` [PATCH 1/2] KVM: x86: Return emulator error if RDMSR/WRMSR emulation failed Hou Wenlong
2022-08-30 18:44   ` Sean Christopherson
2022-08-31  3:17     ` Hou Wenlong
2022-07-28  8:25 ` Hou Wenlong [this message]
2022-08-30 19:05   ` [PATCH 2/2] KVM: x86: Add missing trace points for RDMSR/WRMSR in emulator path Sean Christopherson

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=f7d395b60eb7e6dcc149ba39d86f9296bd81b0ac.1658913543.git.houwenlong.hwl@antgroup.com \
    --to=houwenlong.hwl@antgroup.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.