From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8185E746C for ; Thu, 16 Feb 2023 14:31:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4270DC433EF; Thu, 16 Feb 2023 14:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676557889; bh=QqKWnxVCmWjaRHHpFhF9lvt+Kt1/5o5W5NIuE4VWNwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBVBIVKxfN+otxuDh6tjITGWlD2qZDMmlePf2P+zsLwLtBZNJml2UZXr9wo/KzhfD +DLAftqcKO6kMhOlxQELU7as2b7dfitiOvkVwlY10gpOBFJFZPHS6sIuU6AE+V5RYt pVv+G9Sk34MHxhtlqfNthRXYV6d+lnZRLOkQyZVzprLW7rYrfV2Rd4E4UezXAA04FW W1uo3lEp0Hh/Qbo3JiraAVfgDlNBoRfdUwUUjgHwIjgpYxS+DJDtlE7RIVJZDW/Gz0 5j+AQZjL6T7Ch/3llwQjP97zZBhI8X3ThnLoq5JGtoCH9cyU9OoK1yt9IcWC5DUA7y vqMnS8MLWR9Iw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pSf8v-00AuwB-OE; Thu, 16 Feb 2023 14:21:49 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Ricardo Koller , Simon Veith , dwmw2@infradead.org Subject: [PATCH 11/16] KVM: arm64: Document KVM_ARM_SET_CNT_OFFSETS and co Date: Thu, 16 Feb 2023 14:21:18 +0000 Message-Id: <20230216142123.2638675-12-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216142123.2638675-1-maz@kernel.org> References: <20230216142123.2638675-1-maz@kernel.org> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, ricarkol@google.com, sveith@amazon.de, dwmw2@infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Add some basic documentation on the effects of KVM_ARM_SET_CNT_OFFSETS. Signed-off-by: Marc Zyngier --- Documentation/virt/kvm/api.rst | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 0a67cb738013..bdd361fd90f4 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -5937,6 +5937,53 @@ delivery must be provided via the "reg_aen" struct. The "pad" and "reserved" fields may be used for future extensions and should be set to 0s by userspace. +4.138 KVM_ARM_SET_CNT_OFFSETS +----------------------------- + +:Capability: KVM_CAP_COUNTER_OFFSETS +:Architectures: arm64 +:Type: vm ioctl +:Parameters: struct kvm_arm_counter_offsets (in) +:Returns: 0 on success, <0 on error + +This capability indicates that userspace is able to apply a set of +VM-wide offsets to the virtual and physical counters as viewed by the +guest using the KVM_ARM_SET_CNT_OFFSETS ioctl and the following data +structure: + + struct kvm_arm_counter_offsets { + __u64 virtual_offset; + __u64 physical_offset; + + #define KVM_COUNTER_SET_VOFFSET_FLAG (1UL << 0) + #define KVM_COUNTER_SET_POFFSET_FLAG (1UL << 1) + + __u64 flags; + __u64 reserved; + }; + +Each of the two offsets describe a number of counter cycles that are +subtracted from the corresponding counter (similar to the effects of +the CNTVOFF_EL2 and CNTPOFF_EL2 system registers). For each offset +that userspace wishes to change, it must set the corresponding flag in +the "flag" field. These values always apply to all vcpus (already +created or created after this ioctl) in this VM. + +It is userspace's responsibility to compute the offsets based, for +example, on previous values of the guest counters. + +With nested virtualisation, the virtual offset as no effect on the +execution of the guest, and the nested hypervisor is responsible for +the offset that is presented to its own guests. + +Any flag value that isn't described here, or any value other than 0 +for the "reserved" field may result in an error being returned. + +Note that using this ioctl results in KVM ignoring subsequent +userspace writes to the CNTVCT_EL0 and CNTPCT_EL0 registers using the +SET_ONE_REG interface. No error will be returned, but the resulting +offset will not be applied. + 5. The kvm_run structure ======================== -- 2.34.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AA555C61DA4 for ; Thu, 16 Feb 2023 14:34:27 +0000 (UTC) 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=5yHtwpG0hrUJj039YcIGgY36LHYe3inPcw1qGThGIPo=; b=XWBoNWCys+pdzR WuUknbRtpcbAdSUO4fYARZKYB/9rK9O6Wiq5/7T5krEIqjcUrkHr2XGZ3apeAbW8AoEJAZc6vVVmE 3k9Yd4TbGGHMNh/FoQ1T7MDuP6gbYHhUIFQKASVhnMJAew+rdxr46HSZN0UumAxtVke4nT9vRN8wj mVoHuYdTdUFDlbs+tgGUxYlDBjfcCtGdzOjCyqdrd2x18mXDC4yeBhxc+Q9eJbmauGCfmyldisHM/ aEhL1yX/FymQxpunpswxrCEHJUVNpginsr0XUMunlqnP8ACRtjffUz+eOMRWuQ0C4CKw3Svog2MoV UXvWwrCuznnP2wmvWfUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSfJz-00Aeuw-8D; Thu, 16 Feb 2023 14:33:15 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSfII-00Ae5F-A0 for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2023 14:31:32 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D2D5661411; Thu, 16 Feb 2023 14:31:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4270DC433EF; Thu, 16 Feb 2023 14:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676557889; bh=QqKWnxVCmWjaRHHpFhF9lvt+Kt1/5o5W5NIuE4VWNwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBVBIVKxfN+otxuDh6tjITGWlD2qZDMmlePf2P+zsLwLtBZNJml2UZXr9wo/KzhfD +DLAftqcKO6kMhOlxQELU7as2b7dfitiOvkVwlY10gpOBFJFZPHS6sIuU6AE+V5RYt pVv+G9Sk34MHxhtlqfNthRXYV6d+lnZRLOkQyZVzprLW7rYrfV2Rd4E4UezXAA04FW W1uo3lEp0Hh/Qbo3JiraAVfgDlNBoRfdUwUUjgHwIjgpYxS+DJDtlE7RIVJZDW/Gz0 5j+AQZjL6T7Ch/3llwQjP97zZBhI8X3ThnLoq5JGtoCH9cyU9OoK1yt9IcWC5DUA7y vqMnS8MLWR9Iw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pSf8v-00AuwB-OE; Thu, 16 Feb 2023 14:21:49 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Ricardo Koller , Simon Veith , dwmw2@infradead.org Subject: [PATCH 11/16] KVM: arm64: Document KVM_ARM_SET_CNT_OFFSETS and co Date: Thu, 16 Feb 2023 14:21:18 +0000 Message-Id: <20230216142123.2638675-12-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216142123.2638675-1-maz@kernel.org> References: <20230216142123.2638675-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, ricarkol@google.com, sveith@amazon.de, dwmw2@infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230216_063130_516456_68E16666 X-CRM114-Status: GOOD ( 17.94 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add some basic documentation on the effects of KVM_ARM_SET_CNT_OFFSETS. Signed-off-by: Marc Zyngier --- Documentation/virt/kvm/api.rst | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 0a67cb738013..bdd361fd90f4 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -5937,6 +5937,53 @@ delivery must be provided via the "reg_aen" struct. The "pad" and "reserved" fields may be used for future extensions and should be set to 0s by userspace. +4.138 KVM_ARM_SET_CNT_OFFSETS +----------------------------- + +:Capability: KVM_CAP_COUNTER_OFFSETS +:Architectures: arm64 +:Type: vm ioctl +:Parameters: struct kvm_arm_counter_offsets (in) +:Returns: 0 on success, <0 on error + +This capability indicates that userspace is able to apply a set of +VM-wide offsets to the virtual and physical counters as viewed by the +guest using the KVM_ARM_SET_CNT_OFFSETS ioctl and the following data +structure: + + struct kvm_arm_counter_offsets { + __u64 virtual_offset; + __u64 physical_offset; + + #define KVM_COUNTER_SET_VOFFSET_FLAG (1UL << 0) + #define KVM_COUNTER_SET_POFFSET_FLAG (1UL << 1) + + __u64 flags; + __u64 reserved; + }; + +Each of the two offsets describe a number of counter cycles that are +subtracted from the corresponding counter (similar to the effects of +the CNTVOFF_EL2 and CNTPOFF_EL2 system registers). For each offset +that userspace wishes to change, it must set the corresponding flag in +the "flag" field. These values always apply to all vcpus (already +created or created after this ioctl) in this VM. + +It is userspace's responsibility to compute the offsets based, for +example, on previous values of the guest counters. + +With nested virtualisation, the virtual offset as no effect on the +execution of the guest, and the nested hypervisor is responsible for +the offset that is presented to its own guests. + +Any flag value that isn't described here, or any value other than 0 +for the "reserved" field may result in an error being returned. + +Note that using this ioctl results in KVM ignoring subsequent +userspace writes to the CNTVCT_EL0 and CNTPCT_EL0 registers using the +SET_ONE_REG interface. No error will be returned, but the resulting +offset will not be applied. + 5. The kvm_run structure ======================== -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel