mbox series

[0/3] KVM: x86: Fix Intel PT Host/Guest mode when host tracing also

Message ID 20240906130026.10705-1-adrian.hunter@intel.com (mailing list archive)
Headers show
Series KVM: x86: Fix Intel PT Host/Guest mode when host tracing also | expand

Message

Adrian Hunter Sept. 6, 2024, 1 p.m. UTC
Hi

There is a long-standing problem whereby running Intel PT on host and guest
in Host/Guest mode, causes VM-Entry failure.

The motivation for this patch set is to provide a fix for stable kernels
prior to the advent of the "Mediated Passthrough vPMU" patch set:

	https://lore.kernel.org/kvm/20240801045907.4010984-1-mizhang@google.com/

which would render a large part of the fix unnecessary but likely not be
suitable for backport to stable due to its size and complexity.

Ideally, this patch set would be applied before "Mediated Passthrough vPMU"

Note that the fix does not conflict with "Mediated Passthrough vPMU", it
is just that "Mediated Passthrough vPMU" will make the code to stop and
restart Intel PT unnecessary.


Adrian Hunter (3):
      KVM: x86: Fix Intel PT IA32_RTIT_CTL MSR validation
      KVM: x86: Fix Intel PT Host/Guest mode when host tracing also
      KVM: selftests: Add guest Intel PT test

 arch/x86/events/intel/pt.c                         | 131 ++++++-
 arch/x86/events/intel/pt.h                         |  10 +
 arch/x86/include/asm/intel_pt.h                    |   4 +
 arch/x86/kvm/vmx/vmx.c                             |  26 +-
 arch/x86/kvm/vmx/vmx.h                             |   1 -
 tools/testing/selftests/kvm/Makefile               |   1 +
 .../selftests/kvm/include/x86_64/processor.h       |   1 +
 tools/testing/selftests/kvm/x86_64/intel_pt.c      | 381 +++++++++++++++++++++
 8 files changed, 532 insertions(+), 23 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/intel_pt.c

base-commit: d45aab436cf06544abeeffc607110f559a3af3b4


Regards
Adrian

Comments

Zhenyu Wang Sept. 10, 2024, 6:02 a.m. UTC | #1
Add Mingwei.

On 2024.09.06 16:00:23 +0300, Adrian Hunter wrote:
> Hi
> 
> There is a long-standing problem whereby running Intel PT on host and guest
> in Host/Guest mode, causes VM-Entry failure.
> 
> The motivation for this patch set is to provide a fix for stable kernels
> prior to the advent of the "Mediated Passthrough vPMU" patch set:
> 
> 	https://lore.kernel.org/kvm/20240801045907.4010984-1-mizhang@google.com/
> 
> which would render a large part of the fix unnecessary but likely not be
> suitable for backport to stable due to its size and complexity.
> 
> Ideally, this patch set would be applied before "Mediated Passthrough vPMU"
> 
> Note that the fix does not conflict with "Mediated Passthrough vPMU", it
> is just that "Mediated Passthrough vPMU" will make the code to stop and
> restart Intel PT unnecessary.
>

With mediated passthrough vPMU, we could enable PT pmu's PERF_PMU_CAP_PASSTHROUGH_VPMU
capability like core pmu, then perf guest helper could handle any host PT events
during VM entry/exit as well like core perf events. The benefit is general perf interface
to handle like others. But it would be sure to depend on passthrough vPMU be enabled,
not as this to fix in case w/o that.

I have local patches to work against passthrough vPMU, but like passthrough vPMU
to be settled down first. With Adrian's change, it could be also possible to decouple
the dependency, so may support in both cases with or w/o passthrough vPMU enabled. 

> 
> Adrian Hunter (3):
>       KVM: x86: Fix Intel PT IA32_RTIT_CTL MSR validation
>       KVM: x86: Fix Intel PT Host/Guest mode when host tracing also
>       KVM: selftests: Add guest Intel PT test
> 
>  arch/x86/events/intel/pt.c                         | 131 ++++++-
>  arch/x86/events/intel/pt.h                         |  10 +
>  arch/x86/include/asm/intel_pt.h                    |   4 +
>  arch/x86/kvm/vmx/vmx.c                             |  26 +-
>  arch/x86/kvm/vmx/vmx.h                             |   1 -
>  tools/testing/selftests/kvm/Makefile               |   1 +
>  .../selftests/kvm/include/x86_64/processor.h       |   1 +
>  tools/testing/selftests/kvm/x86_64/intel_pt.c      | 381 +++++++++++++++++++++
>  8 files changed, 532 insertions(+), 23 deletions(-)
>  create mode 100644 tools/testing/selftests/kvm/x86_64/intel_pt.c
> 
> base-commit: d45aab436cf06544abeeffc607110f559a3af3b4
> 
> 
> Regards
> Adrian
>
Adrian Hunter Sept. 26, 2024, 2:05 p.m. UTC | #2
On 6/09/24 16:00, Adrian Hunter wrote:
> Hi
> 
> There is a long-standing problem whereby running Intel PT on host and guest
> in Host/Guest mode, causes VM-Entry failure.
> 
> The motivation for this patch set is to provide a fix for stable kernels
> prior to the advent of the "Mediated Passthrough vPMU" patch set:
> 
> 	https://lore.kernel.org/kvm/20240801045907.4010984-1-mizhang@google.com/
> 
> which would render a large part of the fix unnecessary but likely not be
> suitable for backport to stable due to its size and complexity.
> 
> Ideally, this patch set would be applied before "Mediated Passthrough vPMU"
> 
> Note that the fix does not conflict with "Mediated Passthrough vPMU", it
> is just that "Mediated Passthrough vPMU" will make the code to stop and
> restart Intel PT unnecessary.

Any comments?

> 
> 
> Adrian Hunter (3):
>       KVM: x86: Fix Intel PT IA32_RTIT_CTL MSR validation
>       KVM: x86: Fix Intel PT Host/Guest mode when host tracing also
>       KVM: selftests: Add guest Intel PT test
> 
>  arch/x86/events/intel/pt.c                         | 131 ++++++-
>  arch/x86/events/intel/pt.h                         |  10 +
>  arch/x86/include/asm/intel_pt.h                    |   4 +
>  arch/x86/kvm/vmx/vmx.c                             |  26 +-
>  arch/x86/kvm/vmx/vmx.h                             |   1 -
>  tools/testing/selftests/kvm/Makefile               |   1 +
>  .../selftests/kvm/include/x86_64/processor.h       |   1 +
>  tools/testing/selftests/kvm/x86_64/intel_pt.c      | 381 +++++++++++++++++++++
>  8 files changed, 532 insertions(+), 23 deletions(-)
>  create mode 100644 tools/testing/selftests/kvm/x86_64/intel_pt.c
> 
> base-commit: d45aab436cf06544abeeffc607110f559a3af3b4
> 
> 
> Regards
> Adrian
Adrian Hunter Oct. 4, 2024, 4:59 p.m. UTC | #3
On 26/09/24 17:05, Adrian Hunter wrote:
> On 6/09/24 16:00, Adrian Hunter wrote:
>> Hi
>>
>> There is a long-standing problem whereby running Intel PT on host and guest
>> in Host/Guest mode, causes VM-Entry failure.
>>
>> The motivation for this patch set is to provide a fix for stable kernels
>> prior to the advent of the "Mediated Passthrough vPMU" patch set:
>>
>> 	https://lore.kernel.org/kvm/20240801045907.4010984-1-mizhang@google.com/
>>
>> which would render a large part of the fix unnecessary but likely not be
>> suitable for backport to stable due to its size and complexity.
>>
>> Ideally, this patch set would be applied before "Mediated Passthrough vPMU"
>>
>> Note that the fix does not conflict with "Mediated Passthrough vPMU", it
>> is just that "Mediated Passthrough vPMU" will make the code to stop and
>> restart Intel PT unnecessary.
> 
> Any comments?

Any comments?

> 
>>
>>
>> Adrian Hunter (3):
>>       KVM: x86: Fix Intel PT IA32_RTIT_CTL MSR validation
>>       KVM: x86: Fix Intel PT Host/Guest mode when host tracing also
>>       KVM: selftests: Add guest Intel PT test
>>
>>  arch/x86/events/intel/pt.c                         | 131 ++++++-
>>  arch/x86/events/intel/pt.h                         |  10 +
>>  arch/x86/include/asm/intel_pt.h                    |   4 +
>>  arch/x86/kvm/vmx/vmx.c                             |  26 +-
>>  arch/x86/kvm/vmx/vmx.h                             |   1 -
>>  tools/testing/selftests/kvm/Makefile               |   1 +
>>  .../selftests/kvm/include/x86_64/processor.h       |   1 +
>>  tools/testing/selftests/kvm/x86_64/intel_pt.c      | 381 +++++++++++++++++++++
>>  8 files changed, 532 insertions(+), 23 deletions(-)
>>  create mode 100644 tools/testing/selftests/kvm/x86_64/intel_pt.c
>>
>> base-commit: d45aab436cf06544abeeffc607110f559a3af3b4
>>
>>
>> Regards
>> Adrian
>