* [LTP] [PATCH] tracing/pt_test: TCONF if Intel PT across VMXON is not supported
@ 2025-03-15 16:01 Jan Stancek via ltp
2025-03-17 12:23 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek via ltp @ 2025-03-15 16:01 UTC (permalink / raw)
To: ltp
As noted in 1c5ac21a0e9b ("perf/x86/intel/pt: Don't die on VMXON"),
some Broadwell systems don't support Intel PT across VMXON.
If the test fails to find any events, check whether there is a
kvm_intel module loaded, and if so check for IA32_VMX_MISC[bit 14].
If this bit is 0, it's not supported. From commit mentioned above:
Intel SDM, 36.5 "Tracing post-VMXON" says that
"IA32_VMX_MISC[bit 14]" being 1 means PT can trace
post-VMXON.
Fixes: https://github.com/linux-test-project/ltp/issues/1228
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/tracing/pt_test/pt_test.c | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/testcases/kernel/tracing/pt_test/pt_test.c b/testcases/kernel/tracing/pt_test/pt_test.c
index 54011a884d20..a5a8bad7a205 100644
--- a/testcases/kernel/tracing/pt_test/pt_test.c
+++ b/testcases/kernel/tracing/pt_test/pt_test.c
@@ -14,6 +14,7 @@
*/
+#define _GNU_SOURCE
#include <sched.h>
#include <stdlib.h>
#include <stdio.h>
@@ -35,6 +36,8 @@
#define INTEL_PT_FORMAT_TSC "/sys/devices/intel_pt/format/tsc"
#define INTEL_PT_FORMAT_NRT "/sys/devices/intel_pt/format/noretcomp"
+#define MSR_IA32_VMX_MISC 0x00000485
+
//Intel PT event handle
int fde = -1;
//map head and size
@@ -102,6 +105,36 @@ static void del_map(uint64_t **buf_ev, long bufsize)
free(buf_ev);
}
+/* Some versions of Intel PT do not support tracing across VMXON */
+static int is_supported_across_vmxon(void)
+{
+ char msr_path[64];
+ int msr_fd, ret, supported;
+ uint64_t value;
+
+ sprintf(msr_path, "/dev/cpu/%d/msr", sched_getcpu());
+
+ if (access(msr_path, F_OK) != 0) {
+ tst_res(TINFO, "%s not present", msr_path);
+ tst_res(TINFO, "skipping check for INTEL PT support across VMXON");
+ return 1;
+ }
+
+ msr_fd = SAFE_OPEN(msr_path, O_RDONLY);
+ ret = pread(msr_fd, &value, sizeof(value), MSR_IA32_VMX_MISC);
+ SAFE_CLOSE(msr_fd);
+ if (ret == sizeof(value)) {
+ supported = value & (1 << 14);
+
+ tst_res(TINFO, "Intel PT %s supported across VMXON",
+ supported ? "" : "_NOT_");
+ return supported;
+ }
+
+ /* we failed on MSR read, so assume it's supported */
+ return 1;
+}
+
static void intel_pt_trace_check(void)
{
uint64_t aux_head = 0;
@@ -117,6 +150,12 @@ static void intel_pt_trace_check(void)
pmp = (struct perf_event_mmap_page *)bufm[0];
aux_head = *(volatile uint64_t *)&pmp->aux_head;
if (aux_head == 0) {
+ if ((access("/sys/module/kvm_intel", F_OK) == 0)
+ && (!is_supported_across_vmxon())) {
+ tst_brk(TCONF, "Intel PT on this system can not"
+ " run at the same time as virtualization");
+ }
+
tst_res(TFAIL, "There is no trace");
return;
}
--
2.43.5
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [LTP] [PATCH] tracing/pt_test: TCONF if Intel PT across VMXON is not supported
2025-03-15 16:01 [LTP] [PATCH] tracing/pt_test: TCONF if Intel PT across VMXON is not supported Jan Stancek via ltp
@ 2025-03-17 12:23 ` Petr Vorel
2025-03-20 11:24 ` Jan Stancek via ltp
0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2025-03-17 12:23 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp
Hi Jan,
> As noted in 1c5ac21a0e9b ("perf/x86/intel/pt: Don't die on VMXON"),
> some Broadwell systems don't support Intel PT across VMXON.
+1
> If the test fails to find any events, check whether there is a
> kvm_intel module loaded, and if so check for IA32_VMX_MISC[bit 14].
> If this bit is 0, it's not supported. From commit mentioned above:
> Intel SDM, 36.5 "Tracing post-VMXON" says that
> "IA32_VMX_MISC[bit 14]" being 1 means PT can trace
> post-VMXON.
LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
...
> static void intel_pt_trace_check(void)
> {
> uint64_t aux_head = 0;
> @@ -117,6 +150,12 @@ static void intel_pt_trace_check(void)
> pmp = (struct perf_event_mmap_page *)bufm[0];
> aux_head = *(volatile uint64_t *)&pmp->aux_head;
> if (aux_head == 0) {
> + if ((access("/sys/module/kvm_intel", F_OK) == 0)
> + && (!is_supported_across_vmxon())) {
> + tst_brk(TCONF, "Intel PT on this system can not"
> + " run at the same time as virtualization");
As we discussed at the issue, please join the string before merge.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [LTP] [PATCH] tracing/pt_test: TCONF if Intel PT across VMXON is not supported
2025-03-17 12:23 ` Petr Vorel
@ 2025-03-20 11:24 ` Jan Stancek via ltp
0 siblings, 0 replies; 3+ messages in thread
From: Jan Stancek via ltp @ 2025-03-20 11:24 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Mon, Mar 17, 2025 at 1:24 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Jan,
>
> > As noted in 1c5ac21a0e9b ("perf/x86/intel/pt: Don't die on VMXON"),
> > some Broadwell systems don't support Intel PT across VMXON.
> +1
>
> > If the test fails to find any events, check whether there is a
> > kvm_intel module loaded, and if so check for IA32_VMX_MISC[bit 14].
> > If this bit is 0, it's not supported. From commit mentioned above:
> > Intel SDM, 36.5 "Tracing post-VMXON" says that
> > "IA32_VMX_MISC[bit 14]" being 1 means PT can trace
> > post-VMXON.
>
> LGTM.
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
Pushed with the string joined.
Thanks,
Jan
>
> ...
> > static void intel_pt_trace_check(void)
> > {
> > uint64_t aux_head = 0;
> > @@ -117,6 +150,12 @@ static void intel_pt_trace_check(void)
> > pmp = (struct perf_event_mmap_page *)bufm[0];
> > aux_head = *(volatile uint64_t *)&pmp->aux_head;
> > if (aux_head == 0) {
> > + if ((access("/sys/module/kvm_intel", F_OK) == 0)
> > + && (!is_supported_across_vmxon())) {
> > + tst_brk(TCONF, "Intel PT on this system can not"
> > + " run at the same time as virtualization");
>
> As we discussed at the issue, please join the string before merge.
>
> Kind regards,
> Petr
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-20 11:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-15 16:01 [LTP] [PATCH] tracing/pt_test: TCONF if Intel PT across VMXON is not supported Jan Stancek via ltp
2025-03-17 12:23 ` Petr Vorel
2025-03-20 11:24 ` Jan Stancek via ltp
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.