From 92e7fc0251da026f756f648fea5639cfdd746fff Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Fri, 22 Mar 2024 09:28:08 -0400 Subject: [PATCH] Fix: build kvm probe on EL 8.4+ The lower value of the EL range, 240.15.1, corresponds to the first import of EL r8 kernels into Rocky Linux's kernel staging repo. The change may have been introduced in an earlier RHEL 8 kernel, prior to the history of imports into Rocky. Change-Id: Icefe472d43e28cc09746e9e046b12299609ebab1 Signed-off-by: Kienan Stewart Signed-off-by: Mathieu Desnoyers --- include/instrumentation/events/arch/x86/kvm/mmutrace.h | 6 ++++-- include/instrumentation/events/arch/x86/kvm/trace.h | 9 ++++++--- src/probes/Kbuild | 3 ++- src/probes/lttng-probe-kvm-x86-mmu.c | 6 ++++-- src/probes/lttng-probe-kvm-x86.c | 3 ++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/include/instrumentation/events/arch/x86/kvm/mmutrace.h b/include/instrumentation/events/arch/x86/kvm/mmutrace.h index 4107b6ef..45b621d6 100644 --- a/include/instrumentation/events/arch/x86/kvm/mmutrace.h +++ b/include/instrumentation/events/arch/x86/kvm/mmutrace.h @@ -133,7 +133,8 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_mmu_page_class, kvm_mmu_prepare_zap_page, TP_ARGS(sp) ) -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0)) +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0) || \ + LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0)) LTTNG_TRACEPOINT_EVENT_MAP( mark_mmio_spte, @@ -205,7 +206,8 @@ LTTNG_TRACEPOINT_EVENT_MAP( ctf_integer(int, ret, ret) ) ) -#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0)) +#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0) || \ + LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0)) LTTNG_TRACEPOINT_EVENT_MAP( fast_page_fault, diff --git a/include/instrumentation/events/arch/x86/kvm/trace.h b/include/instrumentation/events/arch/x86/kvm/trace.h index 0bccea06..3cf18de8 100644 --- a/include/instrumentation/events/arch/x86/kvm/trace.h +++ b/include/instrumentation/events/arch/x86/kvm/trace.h @@ -179,7 +179,8 @@ LTTNG_TRACEPOINT_EVENT_CODE_MAP(kvm_exit, kvm_x86_exit, TP_code_post() ) -#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0)) +#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0) || \ + LTTNG_RHEL_KERNEL_RANGE(4,18,0,240,0,0, 4,19,0,0,0,0)) LTTNG_TRACEPOINT_EVENT_CODE_MAP(kvm_exit, kvm_x86_exit, TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa), TP_ARGS(exit_reason, vcpu, isa), @@ -544,7 +545,8 @@ LTTNG_TRACEPOINT_EVENT_MAP(kvm_emulate_insn, kvm_x86_emulate_insn, TP_ARGS(vcpu, failed), TP_FIELDS( -#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(5,7,0)) +#if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(5,7,0) && \ + !LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0)) ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt._eip - (vcpu->arch.emulate_ctxt.fetch.ptr - vcpu->arch.emulate_ctxt.fetch.data)) @@ -553,7 +555,8 @@ LTTNG_TRACEPOINT_EVENT_MAP(kvm_emulate_insn, kvm_x86_emulate_insn, vcpu->arch.emulate_ctxt.fetch.data) ctf_array(__u8, insn, vcpu->arch.emulate_ctxt.fetch.data, 15) ctf_integer(__u8, flags, kei_decode_mode(vcpu->arch.emulate_ctxt.mode)) -#elif (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(5,18,0)) +#elif (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(5,18,0) || \ + LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0)) ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt->_eip - (vcpu->arch.emulate_ctxt->fetch.ptr - vcpu->arch.emulate_ctxt->fetch.data)) diff --git a/src/probes/Kbuild b/src/probes/Kbuild index bac90c3a..c4273e01 100644 --- a/src/probes/Kbuild +++ b/src/probes/Kbuild @@ -55,7 +55,8 @@ ifneq ($(CONFIG_KVM),) kvm_dep_emulate_wildcard = $(wildcard $(kvm_dep_emulate)) kvm_dep_emulate_check = $(shell \ if [ \( $(VERSION) -ge 6 \ - -o \( $(VERSION) -eq 5 -a $(PATCHLEVEL) -eq 7 \) \) -a \ + -o \( $(VERSION) -eq 5 -a $(PATCHLEVEL) -eq 7 \) \ + -o \( $(VERSION) -eq 4 -a $(PATCHLEVEL) -eq 18 -a $(RHEL_API_VERSION) -ge 2400000 \) \) -a \ -z "$(kvm_dep_emulate_wildcard)" ] ; then \ echo "warn" ; \ else \ diff --git a/src/probes/lttng-probe-kvm-x86-mmu.c b/src/probes/lttng-probe-kvm-x86-mmu.c index a77f49b5..7901b734 100644 --- a/src/probes/lttng-probe-kvm-x86-mmu.c +++ b/src/probes/lttng-probe-kvm-x86-mmu.c @@ -20,14 +20,16 @@ */ #include -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0)) +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0) || \ + LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0)) #include <../../arch/x86/kvm/mmu/mmu_internal.h> #include <../../arch/x86/kvm/mmu/mmutrace.h> #else #include <../../arch/x86/kvm/mmutrace.h> #endif -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0)) +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,10,0) || \ + LTTNG_RHEL_KERNEL_RANGE(4,18,0,305,0,0, 4,19,0,0,0,0)) #include <../arch/x86/kvm/mmu.h> #include <../arch/x86/kvm/mmu/spte.h> #endif diff --git a/src/probes/lttng-probe-kvm-x86.c b/src/probes/lttng-probe-kvm-x86.c index be9e2ad0..f2767bb5 100644 --- a/src/probes/lttng-probe-kvm-x86.c +++ b/src/probes/lttng-probe-kvm-x86.c @@ -12,7 +12,8 @@ #include #include -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,7,0)) +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,7,0) || \ + LTTNG_RHEL_KERNEL_RANGE(4,18,0,240,15,1, 4,19,0,0,0,0)) #include #endif -- 2.34.1