kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] KVM: x86/pt: Ignore all unknown Intel PT capabilities
@ 2022-01-10  3:47 Like Xu
  2022-01-11  0:57 ` Sean Christopherson
  0 siblings, 1 reply; 6+ messages in thread
From: Like Xu @ 2022-01-10  3:47 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, Jim Mattson, Wanpeng Li, Vitaly Kuznetsov,
	Joerg Roedel, x86, kvm, linux-kernel

From: Like Xu <likexu@tencent.com>

Some of the new Intel PT capabilities (e.g. SDM Vol3, 32.2.4 Event
Tracing, it exposes details about the asynchronous events, when they are
generated, and when their corresponding software event handler completes
execution) cannot be safely and fully emulated by the KVM, especially
emulating the simultaneous writing of guest PT packets generated by
the KVM to the guest PT buffer.

For KVM, it's better to advertise currently supported features based on
the "static struct pt_cap_desc" implemented in the host PT driver and
ignore _all_ unknown features before they have been investigated one by
one and supported in a safe manner, leaving the rest as system-wide-only
tracing capabilities.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Like Xu <likexu@tencent.com>
---
v1 -> v2 Changelog:
- Be safe and ignore _all_ unknown capabilities. (Paolo)

Previous:
https://lore.kernel.org/kvm/20220106085533.84356-1-likexu@tencent.com/

 arch/x86/kvm/cpuid.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 0b920e12bb6d..439b93359848 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -901,6 +901,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
 			break;
 		}
 
+		/* It's better to be safe and ignore _all_ unknown capabilities. */
+		entry->ebx &= GENMASK(5, 0);
 		for (i = 1, max_idx = entry->eax; i <= max_idx; ++i) {
 			if (!do_host_cpuid(array, function, i))
 				goto out;
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-11  8:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10  3:47 [PATCH v2] KVM: x86/pt: Ignore all unknown Intel PT capabilities Like Xu
2022-01-11  0:57 ` Sean Christopherson
2022-01-11  4:20   ` Like Xu
2022-01-11  6:24     ` Like Xu
2022-01-11  7:59     ` Xiaoyao Li
2022-01-11  8:15       ` Like Xu

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).