From: Luwei Kang <luwei.kang@intel.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, tglx@linutronix.de,
mingo@redhat.com, hpa@zytor.com, x86@kernel.org,
linux-kernel@vger.kernel.org,
Chao Peng <chao.p.peng@linux.intel.com>,
Luwei Kang <luwei.kang@intel.com>
Subject: [PATCH 5/9] KVM: x86: implement intel processor trace virtualization callbacks
Date: Mon, 16 Oct 2017 20:13:20 +0800 [thread overview]
Message-ID: <1508156000-4844-1-git-send-email-luwei.kang@intel.com> (raw)
From: Chao Peng <chao.p.peng@linux.intel.com>
Implement Intel processor trace virtualization callbacks to
suppress host event in guest only mode.
Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
Signed-off-by: Luwei Kang <luwei.kang@intel.com>
---
arch/x86/kvm/vmx.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f0cae7c..28d255d 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2114,6 +2114,21 @@ static unsigned long segment_base(u16 selector)
}
#endif
+static enum pt_mode pt_mode_get(void)
+{
+ return pt_mode;
+}
+
+static bool pt_pmi(void)
+{
+ return true;
+}
+
+static struct pt_virt_ops pt_virt_ops = {
+ .get_mode = pt_mode_get,
+ .pmi = pt_pmi,
+};
+
static void vmx_save_host_state(struct kvm_vcpu *vcpu)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
@@ -6945,6 +6960,9 @@ static __init int hardware_setup(void)
!cpu_has_vmx_intel_pt() || !cpu_has_vmx_pt_use_gpa())
pt_mode = PT_MODE_SYSTEM;
+ if (pt_mode == PT_MODE_GUEST)
+ pt_register_virt_ops(&pt_virt_ops);
+
return alloc_kvm_area();
out:
@@ -6961,6 +6979,9 @@ static __exit void hardware_unsetup(void)
for (i = 0; i < VMX_BITMAP_NR; i++)
free_page((unsigned long)vmx_bitmap[i]);
+ if (pt_mode == PT_MODE_GUEST)
+ pt_unregister_virt_ops();
+
free_kvm_area();
}
--
1.8.3.1
reply other threads:[~2017-10-17 1:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1508156000-4844-1-git-send-email-luwei.kang@intel.com \
--to=luwei.kang@intel.com \
--cc=chao.p.peng@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®