From b41a7537a4c154acbb8680000c77553d8cb0ff72 Mon Sep 17 00:00:00 2001 From: Prakruthi Deepak Heragu Date: Mon, 24 Feb 2025 15:02:59 -0800 Subject: [PATCH] ANDROID: gunyah: vcpu_mgr: Add trace_hooks in the gunyah_vcpu driver As QTVMs use Gunyah emulated watchdog instead of vcpu_stall detector, provide trace_hooks to manage the watchdog of the QTVM. Bug: 399219478 Change-Id: I6ec8a0236835dcc20c66681a747eae09c0c1a32d Signed-off-by: Prakruthi Deepak Heragu --- drivers/android/vendor_hooks.c | 3 +++ drivers/virt/gunyah/gunyah_vcpu.c | 8 ++++++++ include/trace/hooks/gunyah.h | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 include/trace/hooks/gunyah.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index e19675951d4e..8dfd45a3643f 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -160,6 +161,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpuidle_psci_enter); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpuidle_psci_exit); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpufreq_transition); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_gic_v3_set_affinity); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_gh_before_vcpu_run); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_gh_after_vcpu_run); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_proc_transaction_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_select_special_worklist); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sync_txn_recvd); diff --git a/drivers/virt/gunyah/gunyah_vcpu.c b/drivers/virt/gunyah/gunyah_vcpu.c index f4a8ab7c4bf4..d61934a32690 100644 --- a/drivers/virt/gunyah/gunyah_vcpu.c +++ b/drivers/virt/gunyah/gunyah_vcpu.c @@ -16,6 +16,7 @@ #include "vm_mgr.h" #include +#include #define MAX_VCPU_NAME 20 /* gh-vcpu:strlen(U32::MAX)+NUL */ @@ -259,6 +260,7 @@ static int gunyah_vcpu_run(struct gunyah_vcpu *vcpu) unsigned long resume_data[3] = { 0 }; enum gunyah_error gunyah_error; int ret = 0; + u32 vcpu_id; if (!vcpu->f) return -ENODEV; @@ -271,6 +273,7 @@ static int gunyah_vcpu_run(struct gunyah_vcpu *vcpu) goto out; } + vcpu_id = vcpu->ticket.label; switch (vcpu->state) { case GUNYAH_VCPU_RUN_STATE_UNKNOWN: if (vcpu->ghvm->vm_status != GUNYAH_RM_VM_STATUS_RUNNING) { @@ -308,10 +311,15 @@ static int gunyah_vcpu_run(struct gunyah_vcpu *vcpu) goto out; } + trace_android_rvh_gh_before_vcpu_run(vcpu->ghvm->vmid, vcpu_id); gh_guest_accounting_enter(); gunyah_error = gunyah_hypercall_vcpu_run( vcpu->rsc->capid, resume_data, &vcpu_run_resp); gh_guest_accounting_exit(); + trace_android_rvh_gh_after_vcpu_run(vcpu->ghvm->vmid, + vcpu_id, gunyah_error, + (const struct gunyah_hypercall_vcpu_run_resp *)&vcpu_run_resp); + if (gunyah_error == GUNYAH_ERROR_OK) { memset(resume_data, 0, sizeof(resume_data)); switch (vcpu_run_resp.state) { diff --git a/include/trace/hooks/gunyah.h b/include/trace/hooks/gunyah.h new file mode 100644 index 000000000000..695fec27c93f --- /dev/null +++ b/include/trace/hooks/gunyah.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM gunyah +#define TRACE_INCLUDE_PATH trace/hooks +#if !defined(_TRACE_HOOK_GUNYAH_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_GUNYAH_H +#include +struct gunyah_hypercall_vcpu_run_resp; + +DECLARE_RESTRICTED_HOOK(android_rvh_gh_before_vcpu_run, + TP_PROTO(u16 vmid, u32 vcpu_id), + TP_ARGS(vmid, vcpu_id), 1); +DECLARE_RESTRICTED_HOOK(android_rvh_gh_after_vcpu_run, + TP_PROTO(u16 vmid, u32 vcpu_id, int hcall_ret, + const struct gunyah_hypercall_vcpu_run_resp *resp), + TP_ARGS(vmid, vcpu_id, hcall_ret, resp), 1); + +#endif /* _TRACE_HOOK_GUNYAH_H */ +/* This part must be outside protection */ +#include