* [PATCH 0/2] KVM: arm64: A few trace additions
@ 2025-03-19 11:38 Akihiko Odaki
2025-03-19 11:38 ` [PATCH 1/2] KVM: arm64: Trace values with kvm_sys_access Akihiko Odaki
2025-03-19 11:38 ` [PATCH 2/2] KVM: arm64: Trace SMC in a way similar to HVC Akihiko Odaki
0 siblings, 2 replies; 3+ messages in thread
From: Akihiko Odaki @ 2025-03-19 11:38 UTC (permalink / raw)
To: Marc Zyngier, Oliver Upton, Joey Gouly, Suzuki K Poulose,
Zenghui Yu, Catalin Marinas, Will Deacon
Cc: linux-arm-kernel, kvmarm, linux-kernel, devel, Akihiko Odaki
These are tracepoints I added during recent debugging. I hope they are
useful for others too.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
Akihiko Odaki (2):
KVM: arm64: Trace values with kvm_sys_access
KVM: arm64: Trace SMC in a way similar to HVC
arch/arm64/kvm/handle_exit.c | 3 +++
arch/arm64/kvm/sys_regs.c | 24 ++++++++++++++----------
arch/arm64/kvm/trace_handle_exit.h | 26 ++++++++++++++++++++++++--
3 files changed, 41 insertions(+), 12 deletions(-)
---
base-commit: 8098cf067a7aae92a4f293df03964bf8474faca1
change-id: 20250319-trace-80cb8d39de2e
Best regards,
--
Akihiko Odaki <akihiko.odaki@daynix.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] KVM: arm64: Trace values with kvm_sys_access
2025-03-19 11:38 [PATCH 0/2] KVM: arm64: A few trace additions Akihiko Odaki
@ 2025-03-19 11:38 ` Akihiko Odaki
2025-03-19 11:38 ` [PATCH 2/2] KVM: arm64: Trace SMC in a way similar to HVC Akihiko Odaki
1 sibling, 0 replies; 3+ messages in thread
From: Akihiko Odaki @ 2025-03-19 11:38 UTC (permalink / raw)
To: Marc Zyngier, Oliver Upton, Joey Gouly, Suzuki K Poulose,
Zenghui Yu, Catalin Marinas, Will Deacon
Cc: linux-arm-kernel, kvmarm, linux-kernel, devel, Akihiko Odaki
Tracing values written to or read from system registers.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
arch/arm64/kvm/sys_regs.c | 24 ++++++++++++++----------
arch/arm64/kvm/trace_handle_exit.h | 6 ++++--
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 14f66c7a4545..362e2758d101 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -3994,23 +3994,27 @@ static void perform_access(struct kvm_vcpu *vcpu,
struct sys_reg_params *params,
const struct sys_reg_desc *r)
{
- trace_kvm_sys_access(*vcpu_pc(vcpu), params, r);
+ bool skip;
/* Check for regs disabled by runtime config */
if (sysreg_hidden(vcpu, r)) {
kvm_inject_undefined(vcpu);
- return;
+ skip = false;
+ } else {
+ /*
+ * Not having an accessor means that we have configured a trap
+ * that we don't know how to handle. This certainly qualifies
+ * as a gross bug that should be fixed right away.
+ */
+ BUG_ON(!r->access);
+
+ /* Skip instruction if instructed so */
+ skip = r->access(vcpu, params, r);
}
- /*
- * Not having an accessor means that we have configured a trap
- * that we don't know how to handle. This certainly qualifies
- * as a gross bug that should be fixed right away.
- */
- BUG_ON(!r->access);
+ trace_kvm_sys_access(*vcpu_pc(vcpu), params, r);
- /* Skip instruction if instructed so */
- if (likely(r->access(vcpu, params, r)))
+ if (likely(skip))
kvm_incr_pc(vcpu);
}
diff --git a/arch/arm64/kvm/trace_handle_exit.h b/arch/arm64/kvm/trace_handle_exit.h
index f85415db7713..b0308d95304d 100644
--- a/arch/arm64/kvm/trace_handle_exit.h
+++ b/arch/arm64/kvm/trace_handle_exit.h
@@ -88,6 +88,7 @@ TRACE_EVENT(kvm_sys_access,
TP_STRUCT__entry(
__field(unsigned long, vcpu_pc)
+ __field(u64, regval)
__field(bool, is_write)
__field(const char *, name)
__field(u8, Op0)
@@ -99,6 +100,7 @@ TRACE_EVENT(kvm_sys_access,
TP_fast_assign(
__entry->vcpu_pc = vcpu_pc;
+ __entry->regval = params->regval;
__entry->is_write = params->is_write;
__entry->name = reg->name;
__entry->Op0 = reg->Op0;
@@ -109,10 +111,10 @@ TRACE_EVENT(kvm_sys_access,
__entry->Op2 = reg->Op2;
),
- TP_printk("PC: %lx %s (%d,%d,%d,%d,%d) %s",
+ TP_printk("PC: %lx %s (%d,%d,%d,%d,%d) %llx %s",
__entry->vcpu_pc, __entry->name ?: "UNKN",
__entry->Op0, __entry->Op1, __entry->CRn,
- __entry->CRm, __entry->Op2,
+ __entry->CRm, __entry->Op2, __entry->regval,
__entry->is_write ? "write" : "read")
);
--
2.48.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] KVM: arm64: Trace SMC in a way similar to HVC
2025-03-19 11:38 [PATCH 0/2] KVM: arm64: A few trace additions Akihiko Odaki
2025-03-19 11:38 ` [PATCH 1/2] KVM: arm64: Trace values with kvm_sys_access Akihiko Odaki
@ 2025-03-19 11:38 ` Akihiko Odaki
1 sibling, 0 replies; 3+ messages in thread
From: Akihiko Odaki @ 2025-03-19 11:38 UTC (permalink / raw)
To: Marc Zyngier, Oliver Upton, Joey Gouly, Suzuki K Poulose,
Zenghui Yu, Catalin Marinas, Will Deacon
Cc: linux-arm-kernel, kvmarm, linux-kernel, devel, Akihiko Odaki
KVM handles SMCCC calls from virtual EL2 that use the SMC instruction
since commit bd36b1a9eb5a ("KVM: arm64: nv: Handle SMCs taken from
virtual EL2"). Copy the tracepoint for HVC to the SMC handler to trace
SMCCC calls whether they come from either HVC or SMC.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
arch/arm64/kvm/handle_exit.c | 3 +++
arch/arm64/kvm/trace_handle_exit.h | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
index 512d152233ff..087880b645be 100644
--- a/arch/arm64/kvm/handle_exit.c
+++ b/arch/arm64/kvm/handle_exit.c
@@ -55,6 +55,9 @@ static int handle_hvc(struct kvm_vcpu *vcpu)
static int handle_smc(struct kvm_vcpu *vcpu)
{
+ trace_kvm_smc_arm64(*vcpu_pc(vcpu), vcpu_get_reg(vcpu, 0),
+ kvm_vcpu_hvc_get_imm(vcpu));
+
/*
* Forward this trapped smc instruction to the virtual EL2 if
* the guest has asked for it.
diff --git a/arch/arm64/kvm/trace_handle_exit.h b/arch/arm64/kvm/trace_handle_exit.h
index b0308d95304d..a3a0e0a46c60 100644
--- a/arch/arm64/kvm/trace_handle_exit.h
+++ b/arch/arm64/kvm/trace_handle_exit.h
@@ -46,6 +46,26 @@ TRACE_EVENT(kvm_hvc_arm64,
__entry->vcpu_pc, __entry->r0, __entry->imm)
);
+TRACE_EVENT(kvm_smc_arm64,
+ TP_PROTO(unsigned long vcpu_pc, unsigned long r0, unsigned long imm),
+ TP_ARGS(vcpu_pc, r0, imm),
+
+ TP_STRUCT__entry(
+ __field(unsigned long, vcpu_pc)
+ __field(unsigned long, r0)
+ __field(unsigned long, imm)
+ ),
+
+ TP_fast_assign(
+ __entry->vcpu_pc = vcpu_pc;
+ __entry->r0 = r0;
+ __entry->imm = imm;
+ ),
+
+ TP_printk("SMC at 0x%016lx (r0: 0x%016lx, imm: 0x%lx)",
+ __entry->vcpu_pc, __entry->r0, __entry->imm)
+);
+
/*
* The dreg32 name is a leftover from a distant past. This will really
* output a 64bit value...
--
2.48.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-19 11:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-19 11:38 [PATCH 0/2] KVM: arm64: A few trace additions Akihiko Odaki
2025-03-19 11:38 ` [PATCH 1/2] KVM: arm64: Trace values with kvm_sys_access Akihiko Odaki
2025-03-19 11:38 ` [PATCH 2/2] KVM: arm64: Trace SMC in a way similar to HVC Akihiko Odaki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®