Commit 3b778094 authored by Oliver Upton's avatar Oliver Upton Committed by Marc Zyngier
Browse files

KVM: arm64: Remove debug tracepoints



The debug tracepoints are a useless firehose of information that track
implementation detail rather than well-defined events. These are going
to be rather difficult to uphold now that the implementation is getting
redone, so throw them out instead of bending over backwards.

Tested-by: default avatarJames Clark <james.clark@linaro.org>
Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20241219224116.3941496-10-oliver.upton@linux.dev


[maz: fixed compilation after trace-ectomy]
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 58db67e9
Loading
Loading
Loading
Loading
+0 −34
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
#include <asm/kvm_arm.h>
#include <asm/kvm_emulate.h>

#include "trace.h"

/*
 * save/restore_guest_debug_regs
@@ -35,10 +34,6 @@ static void save_guest_debug_regs(struct kvm_vcpu *vcpu)
	u64 val = vcpu_read_sys_reg(vcpu, MDSCR_EL1);

	vcpu->arch.guest_debug_preserved.mdscr_el1 = val;

	trace_kvm_arm_set_dreg32("Saved MDSCR_EL1",
				vcpu->arch.guest_debug_preserved.mdscr_el1);

	vcpu->arch.guest_debug_preserved.pstate_ss =
					(*vcpu_cpsr(vcpu) & DBG_SPSR_SS);
}
@@ -49,9 +44,6 @@ static void restore_guest_debug_regs(struct kvm_vcpu *vcpu)

	vcpu_write_sys_reg(vcpu, val, MDSCR_EL1);

	trace_kvm_arm_set_dreg32("Restored MDSCR_EL1",
				vcpu_read_sys_reg(vcpu, MDSCR_EL1));

	if (vcpu->arch.guest_debug_preserved.pstate_ss)
		*vcpu_cpsr(vcpu) |= DBG_SPSR_SS;
	else
@@ -110,8 +102,6 @@ static void kvm_arm_setup_mdcr_el2(struct kvm_vcpu *vcpu)
		write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2);

	preempt_enable();

	trace_kvm_arm_set_dreg32("MDCR_EL2", vcpu->arch.mdcr_el2);
}

/**
@@ -158,8 +148,6 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
{
	unsigned long mdscr;

	trace_kvm_arm_setup_debug(vcpu, vcpu->guest_debug);

	kvm_arm_setup_mdcr_el2(vcpu);

	/* Check if we need to use the debug registers. */
@@ -209,8 +197,6 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
			vcpu_write_sys_reg(vcpu, mdscr, MDSCR_EL1);
		}

		trace_kvm_arm_set_dreg32("SPSR_EL2", *vcpu_cpsr(vcpu));

		/*
		 * HW Breakpoints and watchpoints
		 *
@@ -228,14 +214,6 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
			vcpu->arch.debug_ptr = &vcpu->arch.external_debug_state;
			vcpu_set_flag(vcpu, DEBUG_DIRTY);

			trace_kvm_arm_set_regset("BKPTS", get_num_brps(),
						&vcpu->arch.debug_ptr->dbg_bcr[0],
						&vcpu->arch.debug_ptr->dbg_bvr[0]);

			trace_kvm_arm_set_regset("WAPTS", get_num_wrps(),
						&vcpu->arch.debug_ptr->dbg_wcr[0],
						&vcpu->arch.debug_ptr->dbg_wvr[0]);

		/*
		 * The OS Lock blocks debug exceptions in all ELs when it is
		 * enabled. If the guest has enabled the OS Lock, constrain its
@@ -257,14 +235,10 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
	/* If KDE or MDE are set, perform a full save/restore cycle. */
	if (vcpu_read_sys_reg(vcpu, MDSCR_EL1) & (DBG_MDSCR_KDE | DBG_MDSCR_MDE))
		vcpu_set_flag(vcpu, DEBUG_DIRTY);

	trace_kvm_arm_set_dreg32("MDSCR_EL1", vcpu_read_sys_reg(vcpu, MDSCR_EL1));
}

void kvm_arm_clear_debug(struct kvm_vcpu *vcpu)
{
	trace_kvm_arm_clear_debug(vcpu->guest_debug);

	/*
	 * Restore the guest's debug registers if we were using them.
	 */
@@ -286,14 +260,6 @@ void kvm_arm_clear_debug(struct kvm_vcpu *vcpu)
		 */
		if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW) {
			kvm_arm_reset_debug_ptr(vcpu);

			trace_kvm_arm_set_regset("BKPTS", get_num_brps(),
						&vcpu->arch.debug_ptr->dbg_bcr[0],
						&vcpu->arch.debug_ptr->dbg_bvr[0]);

			trace_kvm_arm_set_regset("WAPTS", get_num_wrps(),
						&vcpu->arch.debug_ptr->dbg_wcr[0],
						&vcpu->arch.debug_ptr->dbg_wvr[0]);
		}
	}
}
+0 −11
Original line number Diff line number Diff line
@@ -657,8 +657,6 @@ static bool trap_debug_regs(struct kvm_vcpu *vcpu,
		vcpu_set_flag(vcpu, DEBUG_DIRTY);

	kvm_debug_set_guest_ownership(vcpu);
	trace_trap_reg(__func__, r->reg, p->is_write, p->regval);

	return true;
}

@@ -711,8 +709,6 @@ static bool trap_bvr(struct kvm_vcpu *vcpu,
	else
		dbg_to_reg(vcpu, p, rd, dbg_reg);

	trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);

	return true;
}

@@ -748,8 +744,6 @@ static bool trap_bcr(struct kvm_vcpu *vcpu,
	else
		dbg_to_reg(vcpu, p, rd, dbg_reg);

	trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);

	return true;
}

@@ -785,9 +779,6 @@ static bool trap_wvr(struct kvm_vcpu *vcpu,
	else
		dbg_to_reg(vcpu, p, rd, dbg_reg);

	trace_trap_reg(__func__, rd->CRm, p->is_write,
		vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm]);

	return true;
}

@@ -823,8 +814,6 @@ static bool trap_wcr(struct kvm_vcpu *vcpu,
	else
		dbg_to_reg(vcpu, p, rd, dbg_reg);

	trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);

	return true;
}

+0 −75
Original line number Diff line number Diff line
@@ -46,38 +46,6 @@ TRACE_EVENT(kvm_hvc_arm64,
		  __entry->vcpu_pc, __entry->r0, __entry->imm)
);

TRACE_EVENT(kvm_arm_setup_debug,
	TP_PROTO(struct kvm_vcpu *vcpu, __u32 guest_debug),
	TP_ARGS(vcpu, guest_debug),

	TP_STRUCT__entry(
		__field(struct kvm_vcpu *, vcpu)
		__field(__u32, guest_debug)
	),

	TP_fast_assign(
		__entry->vcpu = vcpu;
		__entry->guest_debug = guest_debug;
	),

	TP_printk("vcpu: %p, flags: 0x%08x", __entry->vcpu, __entry->guest_debug)
);

TRACE_EVENT(kvm_arm_clear_debug,
	TP_PROTO(__u32 guest_debug),
	TP_ARGS(guest_debug),

	TP_STRUCT__entry(
		__field(__u32, guest_debug)
	),

	TP_fast_assign(
		__entry->guest_debug = guest_debug;
	),

	TP_printk("flags: 0x%08x", __entry->guest_debug)
);

/*
 * The dreg32 name is a leftover from a distant past. This will really
 * output a 64bit value...
@@ -99,49 +67,6 @@ TRACE_EVENT(kvm_arm_set_dreg32,
	TP_printk("%s: 0x%llx", __entry->name, __entry->value)
);

TRACE_DEFINE_SIZEOF(__u64);

TRACE_EVENT(kvm_arm_set_regset,
	TP_PROTO(const char *type, int len, __u64 *control, __u64 *value),
	TP_ARGS(type, len, control, value),
	TP_STRUCT__entry(
		__field(const char *, name)
		__field(int, len)
		__array(u64, ctrls, 16)
		__array(u64, values, 16)
	),
	TP_fast_assign(
		__entry->name = type;
		__entry->len = len;
		memcpy(__entry->ctrls, control, len << 3);
		memcpy(__entry->values, value, len << 3);
	),
	TP_printk("%d %s CTRL:%s VALUE:%s", __entry->len, __entry->name,
		__print_array(__entry->ctrls, __entry->len, sizeof(__u64)),
		__print_array(__entry->values, __entry->len, sizeof(__u64)))
);

TRACE_EVENT(trap_reg,
	TP_PROTO(const char *fn, int reg, bool is_write, u64 write_value),
	TP_ARGS(fn, reg, is_write, write_value),

	TP_STRUCT__entry(
		__field(const char *, fn)
		__field(int, reg)
		__field(bool, is_write)
		__field(u64, write_value)
	),

	TP_fast_assign(
		__entry->fn = fn;
		__entry->reg = reg;
		__entry->is_write = is_write;
		__entry->write_value = write_value;
	),

	TP_printk("%s %s reg %d (0x%016llx)", __entry->fn,  __entry->is_write?"write to":"read from", __entry->reg, __entry->write_value)
);

TRACE_EVENT(kvm_handle_sys_reg,
	TP_PROTO(unsigned long hsr),
	TP_ARGS(hsr),