linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86/pt: Do not advertise Intel PT Event Trace capability
@ 2022-01-06  8:55 Like Xu
  2022-01-07 18:18 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Like Xu @ 2022-01-06  8:55 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, Jim Mattson, Wanpeng Li, Vitaly Kuznetsov,
	Joerg Roedel, Thomas Gleixner, x86, kvm, linux-kernel

From: Like Xu <likexu@tencent.com>

The Inte PT Event Trace capability (Intel SDM Vol3, 32.2.4 Event Tracing)
is a new CPU feature that "exposes details about the asynchronous events,
when they are generated, and when their corresponding software event
handler completes execution".

It is not possible for KVM to emulate all events including interrupts,
VM exits, VM entries, INIT, SIPI events and etc. for guests and to
emulate the simultaneous writing of Control Flow Events and Event Data
packets generated by the KVM to the guest PT buffer.

For KVM, it is best not to advertise the Event Trace feature and just
let it be a system-wide-only tracing capability.

Signed-off-by: Like Xu <likexu@tencent.com>
---
Off topic, other new PT features such as "PSB and PMI Preservation Supported"
and "TNT disable" are under investigation or awaiting host support to move on.

 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..1028c57377e9 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;
 		}
 
+		/* Not advertise Event Trace capability due to endless emulation */
+		entry->ebx &= ~BIT(7);
 		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] 2+ messages in thread

* Re: [PATCH] KVM: x86/pt: Do not advertise Intel PT Event Trace capability
  2022-01-06  8:55 [PATCH] KVM: x86/pt: Do not advertise Intel PT Event Trace capability Like Xu
@ 2022-01-07 18:18 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2022-01-07 18:18 UTC (permalink / raw)
  To: Like Xu
  Cc: Sean Christopherson, Jim Mattson, Wanpeng Li, Vitaly Kuznetsov,
	Joerg Roedel, Thomas Gleixner, x86, kvm, linux-kernel

On 1/6/22 09:55, Like Xu wrote:
> From: Like Xu <likexu@tencent.com>
> 
> The Inte PT Event Trace capability (Intel SDM Vol3, 32.2.4 Event Tracing)
> is a new CPU feature that "exposes details about the asynchronous events,
> when they are generated, and when their corresponding software event
> handler completes execution".
> 
> It is not possible for KVM to emulate all events including interrupts,
> VM exits, VM entries, INIT, SIPI events and etc. for guests and to
> emulate the simultaneous writing of Control Flow Events and Event Data
> packets generated by the KVM to the guest PT buffer.
> 
> For KVM, it is best not to advertise the Event Trace feature and just
> let it be a system-wide-only tracing capability.
> 
> Signed-off-by: Like Xu <likexu@tencent.com>
> ---
> Off topic, other new PT features such as "PSB and PMI Preservation Supported"
> and "TNT disable" are under investigation or awaiting host support to move on.

Yeah, I think it's better to be safe and ignore _all_ unknown capabilities.

Paolo

>   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..1028c57377e9 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;
>   		}
>   
> +		/* Not advertise Event Trace capability due to endless emulation */
> +		entry->ebx &= ~BIT(7);
>   		for (i = 1, max_idx = entry->eax; i <= max_idx; ++i) {
>   			if (!do_host_cpuid(array, function, i))
>   				goto out;


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

end of thread, other threads:[~2022-01-07 18:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06  8:55 [PATCH] KVM: x86/pt: Do not advertise Intel PT Event Trace capability Like Xu
2022-01-07 18:18 ` Paolo Bonzini

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