Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp495176lqb; Wed, 29 May 2024 01:47:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXehIBw6lerOVSnJmn++8JoQniHthja0S02Y0K5LHzalW5fk8b5/rhcrD+RE77eST4sm+MSgNnZmzGRq5s6vjo9IgJsHmkKFbvzScXSoA== X-Google-Smtp-Source: AGHT+IFkd4+9H8bw0apMLdTzWtPuAgL1Ivw84Tfmuyepm2rMPkJVAxB4zQ4UYtfgn/sPVtGaCayR X-Received: by 2002:a05:6122:1819:b0:4df:4b7f:6009 with SMTP id 71dfb90a1353d-4e4f02939afmr14767148e0c.8.1716972425959; Wed, 29 May 2024 01:47:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716972425; cv=pass; d=google.com; s=arc-20160816; b=BHG5nqECi0GmeBFk5kSpNQBszinw2fkO9xmMoPzTBKo0BNeoKhHo1tm5FZuXkP4kFD S5Przoh6h1I47W3Tq5JfMFA72Kf2p+Ms5OMFzUmJwTAyq0Y9aepl14qkAHRlR4FWrebU SIAAmSXsHYB58nJ7PO0HJAjVhpmZ+lnLtaxF/EmpE/uy2mX4ZTzCPC5iUNt4+EEzV5Nz 7DKLgWjP0r33fPUpv1jUQn4/4k7cyxr6I+5n3zoLdwYIsO257yBG9rpx1sM884nIMaGN IP99rH4imPCKb6R+QuhoEOkiftUtBIPB5/D2vOzHmKD4eCME7YfgQ2Zc72df0gLJd6Ag q17w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fWn1mnxuGDWLsH0K63lEv6ghtIitI4mKpUWd5Cueyhk=; fh=cDzgObpEUqFkc2dvEIaGTqwg1K/iGGXMvzMpzGqsyUk=; b=rw5NusSLmw78vMq7/9UjG36Cxgez4ua/a+kO4z656hI9L4yUKslN96Wj08put0D+XJ JnQwzoK3Pkfa4v5Cet+BCDdYwsFIvrR38i/5FEm0h1ClE5rXndQR8LN6wX44pYz8XtfA kwmYBSVTtc8IgUSZIsyCPGYxLi5CjthOf9YqTR9jQhyxRLCHP3emYLbgQj7IHpHct7uR Wl4MrWn+iGl1A/eon8AJDW78Ii8VKacTZxX6E33msuhvafywGJq2ktmjNCXaIxheExrT y6WL69TIRFoPWC/mPJVZDZGJ5AYlhlauig+oDGQOyn5VGFsNrrq6OPJ5iGhyxj2iijej miDg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Sa8ibUlR; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-193774-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193774-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794abd15ed0si1190950585a.370.2024.05.29.01.47.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 01:47:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193774-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=Sa8ibUlR; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-193774-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193774-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9CD6B1C21563 for ; Wed, 29 May 2024 08:47:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A748418130B; Wed, 29 May 2024 08:43:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Sa8ibUlR" Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57323168C30; Wed, 29 May 2024 08:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716972176; cv=none; b=YulJ2h7vXsumHCDv1qbG7/E8Zw+GyHqeAXm6eKEmGanKn8SLxHp3cNwkw8I9O1Bh4C3ui0TY1GCNCBUpg6PcZIQoZNYI208t9PYf3LtslHot7B+S8ZdsKs4S7cfWUj0s1vAyWBUEskLMQHtZqQqns27TXZG7Y87EtOat/qJ6QUw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716972176; c=relaxed/simple; bh=SqFqxkxMziT4lajTt+DcHCCFQBTQSTWhPMfdmQH0YCc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rRGXLR7TV8Z2X4oRFsA0xEVmoEoo46TJ3BP96A7bN/3SWsgXllMFJUwIhG15IMnf+/RlHKi6/IzvWMRyN1mPzEdlnPKE1p0wOjCQBB6r0E49mjWNFSCiga8MqlJMA9i5tZzb9afCpXp3xIia+V6a35AiFLyydFeTuV6ddSJgmcY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=Sa8ibUlR; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 6b3069141d9711ef8c37dd7afa272265-20240529 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=fWn1mnxuGDWLsH0K63lEv6ghtIitI4mKpUWd5Cueyhk=; b=Sa8ibUlRY/o1CBCTF4BsQXIG4FxlNdE5JKB6g9p5Z9KYnHkmy4BcI5Lpw1M6gIW3xJah0jmAz5GdG29seLCu9xprlOvAbLEQ5eiOi7W6DlpCkBYtqYTVF0/YqoF6hFMVy1GPn3Q0GgQtIIft4HfarqCkfd+iEaYNn+dRMs8MUms=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.39,REQID:f96f3073-c52b-4f9b-b7e9-8e28ec274d2c,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:393d96e,CLOUDID:dbf35b93-e2c0-40b0-a8fe-7c7e47299109,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 6b3069141d9711ef8c37dd7afa272265-20240529 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 929388137; Wed, 29 May 2024 16:42:44 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 29 May 2024 16:42:42 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 29 May 2024 16:42:42 +0800 From: Liju-clr Chen To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , "Catalin Marinas" , Will Deacon , "Steven Rostedt" , Masami Hiramatsu , Mathieu Desnoyers , Richard Cochran , Matthias Brugger , AngeloGioacchino Del Regno , Liju-clr Chen , Yingshiuan Pan , Ze-yu Wang CC: , , , , , , , David Bradil , Trilok Soni , Shawn Hsiao , PeiLun Suei , Chi-shen Yeh , Kevenny Hsieh , Liju-clr Chen Subject: [PATCH v11 20/21] virt: geniezone: Add tracing support for hyp call and vcpu exit_reason Date: Wed, 29 May 2024 16:42:38 +0800 Message-ID: <20240529084239.11478-21-liju-clr.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240529084239.11478-1-liju-clr.chen@mediatek.com> References: <20240529084239.11478-1-liju-clr.chen@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--12.057800-8.000000 X-TMASE-MatchedRID: tpf4JaSfoco9S3IiQd+eNcNrWpY804TGLoYOuiLW+uVh2fnHe1cil1mB Y2oLO+3hkVOFsc3HEGn8I8AIZZ2s3pSL8e/MGApZKy67dnbJjn4WnD2CPybLCsXhke5ra0593AG yPNT+2TGM0+ypVXg5IEzyp2gK85W+VJTV35UngiMVglQa/gMvfIfsPVs/8Vw6SSUXkvSVAdwluI Iv8IIdTRyagBEJyc4yUvgoj+bRd81VY7t+zwxALh3EEAbn+GRbwx0jRRxcQfPxCQaCt6X8bibLS tTV0GSXiOUo3zIx595/jtPF2D6Mdii34jbc8Vq/ngIgpj8eDcAZ1CdBJOsoY8RB0bsfrpPIXzYx eQR1DvvSxITrGtEBWVyPrCJBz1RPIZaK+J7yt4S+BDbLKQc376AAPLN8oQEA X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--12.057800-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 465F3C0EDEB7861008F875B1ACDD7EABE5C35490C3BD40BED4378716F628A8212000:8 X-MTK: N From: Yi-De Wu Add tracepoints for hypervisor calls and VCPU exit reasons in GenieZone driver. It aids performance debugging by providing more information about hypervisor operations and VCPU behavior. Command Usage: echo geniezone:* >> /sys/kernel/tracing/set_event echo 1 > /sys/kernel/tracing/tracing_on echo 0 > /sys/kernel/tracing/tracing_on cat /sys/kernel/tracing/trace For example: crosvm_vcpu0-4874 [007] ..... 94.757349: mtk_hypcall_enter: id=0xfb001005 crosvm_vcpu0-4874 [007] ..... 94.760902: mtk_hypcall_leave: id=0xfb001005 invalid=0 crosvm_vcpu0-4874 [007] ..... 94.760902: mtk_vcpu_exit: vcpu exit_reason=IRQ(0x92920003) This example tracks a hypervisor function call by an ID (`0xbb001005`) from initiation to termination, which is supported (invalid=0). A vCPU exit is triggered by an Interrupt Request (IRQ) (exit reason: 0x92920003). /* VM exit reason */ enum { GZVM_EXIT_UNKNOWN = 0x92920000, GZVM_EXIT_MMIO = 0x92920001, GZVM_EXIT_HYPERCALL = 0x92920002, GZVM_EXIT_IRQ = 0x92920003, GZVM_EXIT_EXCEPTION = 0x92920004, GZVM_EXIT_DEBUG = 0x92920005, GZVM_EXIT_FAIL_ENTRY = 0x92920006, GZVM_EXIT_INTERNAL_ERROR = 0x92920007, GZVM_EXIT_SYSTEM_EVENT = 0x92920008, GZVM_EXIT_SHUTDOWN = 0x92920009, GZVM_EXIT_GZ = 0x9292000a, }; Signed-off-by: Liju-clr Chen Signed-off-by: Yi-De Wu --- arch/arm64/geniezone/vm.c | 4 ++ drivers/virt/geniezone/gzvm_vcpu.c | 3 ++ include/trace/events/geniezone.h | 84 ++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 include/trace/events/geniezone.h diff --git a/arch/arm64/geniezone/vm.c b/arch/arm64/geniezone/vm.c index 62ffb415354c..618de2ff9471 100644 --- a/arch/arm64/geniezone/vm.c +++ b/arch/arm64/geniezone/vm.c @@ -7,6 +7,8 @@ #include #include +#define CREATE_TRACE_POINTS +#include #include #include #include "gzvm_arch_common.h" @@ -44,11 +46,13 @@ int gzvm_hypcall_wrapper(unsigned long a0, unsigned long a1, .a6 = a6, .a7 = a7, }; + trace_mtk_hypcall_enter(a0); arm_smccc_1_2_hvc(&args, &res_1_2); res->a0 = res_1_2.a0; res->a1 = res_1_2.a1; res->a2 = res_1_2.a2; res->a3 = res_1_2.a3; + trace_mtk_hypcall_leave(a0, (res->a0 != ERR_NOT_SUPPORTED) ? 0 : 1); return gzvm_err_to_errno(res->a0); } diff --git a/drivers/virt/geniezone/gzvm_vcpu.c b/drivers/virt/geniezone/gzvm_vcpu.c index 8741088de479..28bd690e4b7c 100644 --- a/drivers/virt/geniezone/gzvm_vcpu.c +++ b/drivers/virt/geniezone/gzvm_vcpu.c @@ -10,6 +10,8 @@ #include #include #include + +#include #include /* maximum size needed for holding an integer */ @@ -103,6 +105,7 @@ static long gzvm_vcpu_run(struct gzvm_vcpu *vcpu, void __user *argp) while (!need_userspace && !signal_pending(current)) { gzvm_arch_vcpu_run(vcpu, &exit_reason); + trace_mtk_vcpu_exit(exit_reason); switch (exit_reason) { case GZVM_EXIT_MMIO: diff --git a/include/trace/events/geniezone.h b/include/trace/events/geniezone.h new file mode 100644 index 000000000000..4fffd826ba67 --- /dev/null +++ b/include/trace/events/geniezone.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2023 MediaTek Inc. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM geniezone + +#define _TRACE_GENIEZONE_H + +#include +#include + +#define GZVM_EXIT_REASONS \ +EM(UNKNOWN)\ +EM(MMIO)\ +EM(HYPERCALL)\ +EM(IRQ)\ +EM(EXCEPTION)\ +EM(DEBUG)\ +EM(FAIL_ENTRY)\ +EM(INTERNAL_ERROR)\ +EM(SYSTEM_EVENT)\ +EM(SHUTDOWN)\ +EMe(GZ) + +#undef EM +#undef EMe +#define EM(a) TRACE_DEFINE_ENUM(GZVM_EXIT_##a); +#define EMe(a) TRACE_DEFINE_ENUM(GZVM_EXIT_##a); + +GZVM_EXIT_REASONS + +#undef EM +#undef EMe + +#define EM(a) { GZVM_EXIT_##a, #a }, +#define EMe(a) { GZVM_EXIT_##a, #a } + +TRACE_EVENT(mtk_hypcall_enter, + TP_PROTO(unsigned long id), + + TP_ARGS(id), + + TP_STRUCT__entry(__field(unsigned long, id)), + + TP_fast_assign(__entry->id = id;), + + TP_printk("id=0x%lx", __entry->id) +); + +TRACE_EVENT(mtk_hypcall_leave, + TP_PROTO(unsigned long id, unsigned long invalid), + + TP_ARGS(id, invalid), + + TP_STRUCT__entry(__field(unsigned long, id) + __field(unsigned long, invalid) + ), + + TP_fast_assign(__entry->id = id; + __entry->invalid = invalid; + ), + + TP_printk("id=0x%lx invalid=%lu", __entry->id, __entry->invalid) +); + +TRACE_EVENT(mtk_vcpu_exit, + TP_PROTO(unsigned long exit_reason), + + TP_ARGS(exit_reason), + + TP_STRUCT__entry(__field(unsigned long, exit_reason)), + + TP_fast_assign(__entry->exit_reason = exit_reason;), + + TP_printk("vcpu exit_reason=%s(0x%lx)", + __print_symbolic(__entry->exit_reason, GZVM_EXIT_REASONS), + __entry->exit_reason) + +); + +/* This part must be outside protection */ +#include -- 2.18.0