From patchwork Fri Nov 19 10:21:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 12693115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C34FC433EF for ; Fri, 19 Nov 2021 10:23:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CCDFE61B27 for ; Fri, 19 Nov 2021 10:23:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CCDFE61B27 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vA1hhnHVK5j+MtDZ7Kf1rjYTrtKhToaLEoDkpeIfB8I=; b=v760zzVD+xInY4 wwYRC8hgyltDuLXfB0ZXxAnDw0g0Dd46u5KLzB34k0H+Rnay2TsECgeGRZsoXYZoHfCwj8+QIyOby 9l24yrYaCVnHQ2SeFgHRw78LqwfN74oifSZWRLQXDosHjTyFm8OIpxDngfDhgyKX4r26vIHEZs63z csJ1ruDEmbftONX4Vvtc1osABF1nfuCm1nUfDSKsWjJe1dwdzHrcOFEVfP7KVhm8YI2hm5pIXNAu+ 0ojYf9zYnABTLFJKPr+dTAvdZB8zv4roGFWWVg6aFHo3Ur/bT9jwLyHhTzRfp3Mq6NVgELbPoGLHF WLZ6E0tEKfeiN9uUeUAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mo12A-00A5ti-5s; Fri, 19 Nov 2021 10:22:18 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mo11h-00A5kF-OT for linux-arm-kernel@lists.infradead.org; Fri, 19 Nov 2021 10:21:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637317307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mX5jcuznSuqa2Xcuiv4jYmRlfngakhSaRM4ITDtNgjs=; b=SnPIKWOWW7qPOimXc3cq6JJntsCfvh85N4ntd62/z8rwYvSiMvov5zXK9GN0jVXwcUDfHz hbVn5VslzYR8q/KzApmaWBV3cHSHxTOHc/v6RnIAsVKqAhzJvIPH61o5YNPX0TeEyvOiZI 3oJ27yREnVwXD5TtYdDSDTHswcajZ+Q= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-184-Q4H4po4qO0GTr6XEYOwdRA-1; Fri, 19 Nov 2021 05:21:45 -0500 X-MC-Unique: Q4H4po4qO0GTr6XEYOwdRA-1 Received: by mail-wm1-f70.google.com with SMTP id n16-20020a05600c3b9000b003331973fdbbso4534404wms.0 for ; Fri, 19 Nov 2021 02:21:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mX5jcuznSuqa2Xcuiv4jYmRlfngakhSaRM4ITDtNgjs=; b=PcV1VCPgYgPn8+bCtXFHEKyxshgJSOrMGI0MQr5vp27Kdyq8VjT2++7lEW+H6nBPOc cSWY1SChGZJ1nttf3JyrdpXCPro1LrHYKWOKLmxmXv7rKMpNSOXbX9+6ZWk3kYIWgoxr p3kGYzFwyOyYMxxSCkbXnJVigS+WelN9sRVorI48F5C1yWIMpoGdAwHv1d0HYNRp7VMS dol0WDRY/TKkg1hgmuiYHntVjOlsPur+etr15VxCpizGGymVzuMxakLtL4U5+3fbjg08 cF3DMe2t4jhBPa+s5N5fy7J9Z611hxKKZg2iOFi15Lj7f+rz2Ywmm9ahUXVOl/QUyT/8 9wdQ== X-Gm-Message-State: AOAM530ob4Qwd967TQYbRnnlEbybi8RTrsN/PnbIfFz4XhF/XTj7AL53 gb6jMf4Ghs5MbOEY1K8Y+rrHGIN8h+wyrKRPRbEU9j5etkVicot5+9u5D64sfmneBu9zzNk7fLa 4/sSF/y1KftCv/I4NO03e5ou7h3bqpmN0iAUO9q2MdF/boDJzHf+V1p66kWjq+jUedXUaHcC7hu wzgKiE1e+TLRM= X-Received: by 2002:a5d:4909:: with SMTP id x9mr5932219wrq.313.1637317304344; Fri, 19 Nov 2021 02:21:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeQnWOxgbNOebQdl80w1DTmX2lRjG3ogVnSnid0ngmyFfrhWmSZI2Hfqqy5HB4Ucb0MKfToQ== X-Received: by 2002:a5d:4909:: with SMTP id x9mr5932181wrq.313.1637317304102; Fri, 19 Nov 2021 02:21:44 -0800 (PST) Received: from vian.redhat.com ([2a0c:5a80:3c10:3400:3c70:6643:6e71:7eae]) by smtp.gmail.com with ESMTPSA id k27sm14336026wms.41.2021.11.19.02.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 02:21:43 -0800 (PST) From: Nicolas Saenz Julienne To: linux-arm-kernel@lists.infradead.org, maz@kernel.org, rostedt@goodmis.org Cc: james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, nsaenzju@redhat.com, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, mingo@redhat.com, mtosatti@redhat.com, nilal@redhat.com Subject: [RFC PATCH 1/2] arm64/tracing: add cntvct based trace clock Date: Fri, 19 Nov 2021 11:21:17 +0100 Message-Id: <20211119102117.22304-2-nsaenzju@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211119102117.22304-1-nsaenzju@redhat.com> References: <20211119102117.22304-1-nsaenzju@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=nsaenzju@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211119_022149_920589_D8718647 X-CRM114-Status: GOOD ( 16.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a new arm64-specific trace clock using the cntvct register, similar to x64-tsc. This gives us: - A clock that is relatively fast (1GHz on armv8.6, 1-50MHz otherwise), monotonic, and resilient to low power modes. - It can be used to correlate events across cpus as well as across hypervisor and guests. By using arch_timer_read_counter() we make sure that armv8.6 cpus use the less expensive CNTVCTSS_EL0, which cannot be accessed speculatively. Signed-off-by: Nicolas Saenz Julienne --- arch/arm64/include/asm/trace_clock.h | 12 ++++++++++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/trace_clock.c | 12 ++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/trace_clock.h create mode 100644 arch/arm64/kernel/trace_clock.c diff --git a/arch/arm64/include/asm/trace_clock.h b/arch/arm64/include/asm/trace_clock.h new file mode 100644 index 000000000000..ce4a66d63108 --- /dev/null +++ b/arch/arm64/include/asm/trace_clock.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_ARM64_TRACE_CLOCK_H +#define _ASM_ARM64_TRACE_CLOCK_H + +#include + +extern u64 notrace trace_clock_arm64_cntvct(void); + +# define ARCH_TRACE_CLOCKS \ + { trace_clock_arm64_cntvct, "cntvct", .in_ns = 0 }, + +#endif /* _ASM_ARM64_TRACE_CLOCK_H */ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 88b3e2a21408..ec9180f0ac90 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,7 +29,7 @@ obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ cpufeature.o alternative.o cacheinfo.o \ smp.o smp_spin_table.o topology.o smccc-call.o \ syscall.o proton-pack.o idreg-override.o idle.o \ - patching.o + patching.o trace_clock.o targets += efi-entry.o diff --git a/arch/arm64/kernel/trace_clock.c b/arch/arm64/kernel/trace_clock.c new file mode 100644 index 000000000000..fe1315f368cb --- /dev/null +++ b/arch/arm64/kernel/trace_clock.c @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * arm64 trace clocks + */ +#include + +#include + +u64 notrace trace_clock_arm64_cntvct(void) +{ + return arch_timer_read_counter(); +} From patchwork Fri Nov 19 10:21:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 12693114 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CA10C433F5 for ; Fri, 19 Nov 2021 10:23:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 54DEE61B6F for ; Fri, 19 Nov 2021 10:23:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 54DEE61B6F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=L8JoYsQo/KOllon+CtUxq+1Hcgr+pFDINRSz7q9vK+I=; b=W4hIrXeEi6TZqd gJRRZemqKojWDBnSBnLZmkiS2MYVMsZpzKJ1c+E93iOMVf9PadJj2Gjqjmulo6Wt0akdHEVcAXT0X Fb1JvE0FgsTd8MQzkVoX7Pmmr+eDMNF2FmNRCrzVLwSRgzsdJkCb3asEY9OfVE7SkVQu3uZFz8/Ro CRfbHqwrS0zmPxrnqImv/LM3GtQroI7JFjGwcyGnYK2tadO5kKPl9GYgdo59h6VWFI2LIwq4kSsFO NkgXjFGkYF6zrMzC5nqemuDN+IzDiTZ/G0jJtU/hjevkjykRq+z+mgl754NT7DKQ4bpdTu6vfqVeI n5eU1y8RTvZoHe7BR24w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mo11z-00A5rL-9q; Fri, 19 Nov 2021 10:22:07 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mo11h-00A5l7-NU for linux-arm-kernel@lists.infradead.org; Fri, 19 Nov 2021 10:21:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637317308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ct7CtyToJccif4yM7473FLAuHcnDcJ5KfOy6FoPwk00=; b=B561OfNcT50arC7paI6BW10CY8WjbM9Cb/6cY/8Hyy41rCFIOdnfMpiIOKrn4nDyBJElzg +AoZ0ZvGr3G4Qm/FqmqSADE74McCXg/4pfJ81acPxN6OYdZOAW5H//BEJk090heDdzLjLZ mrotMh0HZ3XFwAD+CSrJQhdSwCPmxqg= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-296-_QpJaKnyNv6iDPdJ3oPspQ-1; Fri, 19 Nov 2021 05:21:47 -0500 X-MC-Unique: _QpJaKnyNv6iDPdJ3oPspQ-1 Received: by mail-wm1-f69.google.com with SMTP id 138-20020a1c0090000000b00338bb803204so3098290wma.1 for ; Fri, 19 Nov 2021 02:21:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ct7CtyToJccif4yM7473FLAuHcnDcJ5KfOy6FoPwk00=; b=mv2bOlaHYT/TIA8wcpWxAHve2c2c5n3gHg49CiT2efNAut4JT03CqOl/b7SjZUvNHz igQvz0E1QoLySuUnITb8B3UxLpV4t8hvXvCtrcXrIYnQGxC7uO6KNuPpF+fL/qUSWoOg hPf8x1hqL4A7CauHyhmAVarUGAEulteyKjST+WO0QZEMvH0prCKFxUTwiRG7DT8yFs6g vNe5l9YY0WY7vlvBl9Zx3XXTaRWrmanJamECFr3MwfYjYI2t2C1dyklZkwJLGXcLATkU ehKW9JAmIuUKtYrBQ4OBHcplTghmex0ZWSQwdUpYL8oCZAN1HzgLvkfb9iGALMB4GXWg Bs3A== X-Gm-Message-State: AOAM532B8ctC6iFRRdz7f+mO2A37lwx/3th0XS+cL29vKDAtaJrN6P5f I+uhXfYHTftLOTFg8X/kLIsCYwWEusxHSy7CulFvzPpd5hUclG/N7sNE7LRLWhnxKqaHd72rVnD bhmq2LF8YmWRyeiVDpNj0DAN4JYlYzXG5D2GpwK4T3Qk8bhwiohV1e9CIfr9AIqVG7KS1VPPNlN ZPS3fNJYwCTjE= X-Received: by 2002:a1c:6a0e:: with SMTP id f14mr5372835wmc.58.1637317305304; Fri, 19 Nov 2021 02:21:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIUdO9kJGSkL5mvaE1u7YqQr35Qw1TrQUV/WROHnbGRLAbqb5SG0+IyiEIxSlskLareoN6zA== X-Received: by 2002:a1c:6a0e:: with SMTP id f14mr5372797wmc.58.1637317305056; Fri, 19 Nov 2021 02:21:45 -0800 (PST) Received: from vian.redhat.com ([2a0c:5a80:3c10:3400:3c70:6643:6e71:7eae]) by smtp.gmail.com with ESMTPSA id k27sm14336026wms.41.2021.11.19.02.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 02:21:44 -0800 (PST) From: Nicolas Saenz Julienne To: linux-arm-kernel@lists.infradead.org, maz@kernel.org, rostedt@goodmis.org Cc: james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, nsaenzju@redhat.com, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, mingo@redhat.com, mtosatti@redhat.com, nilal@redhat.com Subject: [RFC PATCH 2/2] KVM: arm64: export cntvoff in debugfs Date: Fri, 19 Nov 2021 11:21:18 +0100 Message-Id: <20211119102117.22304-3-nsaenzju@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211119102117.22304-1-nsaenzju@redhat.com> References: <20211119102117.22304-1-nsaenzju@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=nsaenzju@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211119_022149_864484_599BEA7F X-CRM114-Status: GOOD ( 19.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org While using cntvct as the raw clock for tracing, it's possible to synchronize host/guest traces just by knowing the virtual offset applied to the guest's virtual counter. This is also the case on x86 when TSC is available. The offset is exposed in debugfs as 'tsc-offset' on a per vcpu basis. So let's implement the same for arm64. Signed-off-by: Nicolas Saenz Julienne --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/arch_timer.c | 2 +- arch/arm64/kvm/debugfs.c | 25 +++++++++++++++++++++++++ include/kvm/arm_arch_timer.h | 3 +++ 5 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 arch/arm64/kvm/debugfs.c diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 2a5f7f38006f..130534c9079e 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -29,6 +29,7 @@ #include #define __KVM_HAVE_ARCH_INTC_INITIALIZED +#define __KVM_HAVE_ARCH_VCPU_DEBUGFS #define KVM_HALT_POLL_NS_DEFAULT 500000 diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile index 989bb5dad2c8..17be7cf770f2 100644 --- a/arch/arm64/kvm/Makefile +++ b/arch/arm64/kvm/Makefile @@ -14,7 +14,7 @@ kvm-y := $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o \ $(KVM)/vfio.o $(KVM)/irqchip.o $(KVM)/binary_stats.o \ arm.o mmu.o mmio.o psci.o perf.o hypercalls.o pvtime.o \ inject_fault.o va_layout.o handle_exit.o \ - guest.o debug.o reset.o sys_regs.o \ + guest.o debug.o debugfs.o reset.o sys_regs.o \ vgic-sys-reg-v3.o fpsimd.o pmu.o \ arch_timer.o trng.o\ vgic/vgic.o vgic/vgic-init.o \ diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index 3df67c127489..ee69387f7fb6 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -82,7 +82,7 @@ u64 timer_get_cval(struct arch_timer_context *ctxt) } } -static u64 timer_get_offset(struct arch_timer_context *ctxt) +u64 timer_get_offset(struct arch_timer_context *ctxt) { struct kvm_vcpu *vcpu = ctxt->vcpu; diff --git a/arch/arm64/kvm/debugfs.c b/arch/arm64/kvm/debugfs.c new file mode 100644 index 000000000000..f0f5083ea8d4 --- /dev/null +++ b/arch/arm64/kvm/debugfs.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2021 Red Hat Inc. + */ + +#include +#include + +#include + +static int vcpu_get_cntv_offset(void *data, u64 *val) +{ + struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data; + + *val = timer_get_offset(vcpu_vtimer(vcpu)); + + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(vcpu_cntvoff_fops, vcpu_get_cntv_offset, NULL, "%lld\n"); + +void kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry) +{ + debugfs_create_file("cntvoff", 0444, debugfs_dentry, vcpu, &vcpu_cntvoff_fops); +} diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h index 51c19381108c..de0cd9be825c 100644 --- a/include/kvm/arm_arch_timer.h +++ b/include/kvm/arm_arch_timer.h @@ -106,4 +106,7 @@ void kvm_arm_timer_write_sysreg(struct kvm_vcpu *vcpu, u32 timer_get_ctl(struct arch_timer_context *ctxt); u64 timer_get_cval(struct arch_timer_context *ctxt); +/* Nedded for debugfs */ +u64 timer_get_offset(struct arch_timer_context *ctxt); + #endif