0001 .. SPDX-License-Identifier: GPL-2.0
0002
0003 Paravirtualized time support for arm64
0004 ======================================
0005
0006 Arm specification DEN0057/A defines a standard for paravirtualised time
0007 support for AArch64 guests:
0008
0009 https://developer.arm.com/docs/den0057/a
0010
0011 KVM/arm64 implements the stolen time part of this specification by providing
0012 some hypervisor service calls to support a paravirtualized guest obtaining a
0013 view of the amount of time stolen from its execution.
0014
0015 Two new SMCCC compatible hypercalls are defined:
0016
0017 * PV_TIME_FEATURES: 0xC5000020
0018 * PV_TIME_ST: 0xC5000021
0019
0020 These are only available in the SMC64/HVC64 calling convention as
0021 paravirtualized time is not available to 32 bit Arm guests. The existence of
0022 the PV_TIME_FEATURES hypercall should be probed using the SMCCC 1.1
0023 ARCH_FEATURES mechanism before calling it.
0024
0025 PV_TIME_FEATURES
0026 ============= ======== ==========
0027 Function ID: (uint32) 0xC5000020
0028 PV_call_id: (uint32) The function to query for support.
0029 Currently only PV_TIME_ST is supported.
0030 Return value: (int64) NOT_SUPPORTED (-1) or SUCCESS (0) if the relevant
0031 PV-time feature is supported by the hypervisor.
0032 ============= ======== ==========
0033
0034 PV_TIME_ST
0035 ============= ======== ==========
0036 Function ID: (uint32) 0xC5000021
0037 Return value: (int64) IPA of the stolen time data structure for this
0038 VCPU. On failure:
0039 NOT_SUPPORTED (-1)
0040 ============= ======== ==========
0041
0042 The IPA returned by PV_TIME_ST should be mapped by the guest as normal memory
0043 with inner and outer write back caching attributes, in the inner shareable
0044 domain. A total of 16 bytes from the IPA returned are guaranteed to be
0045 meaningfully filled by the hypervisor (see structure below).
0046
0047 PV_TIME_ST returns the structure for the calling VCPU.
0048
0049 Stolen Time
0050 -----------
0051
0052 The structure pointed to by the PV_TIME_ST hypercall is as follows:
0053
0054 +-------------+-------------+-------------+----------------------------+
0055 | Field | Byte Length | Byte Offset | Description |
0056 +=============+=============+=============+============================+
0057 | Revision | 4 | 0 | Must be 0 for version 1.0 |
0058 +-------------+-------------+-------------+----------------------------+
0059 | Attributes | 4 | 4 | Must be 0 |
0060 +-------------+-------------+-------------+----------------------------+
0061 | Stolen time | 8 | 8 | Stolen time in unsigned |
0062 | | | | nanoseconds indicating how |
0063 | | | | much time this VCPU thread |
0064 | | | | was involuntarily not |
0065 | | | | running on a physical CPU. |
0066 +-------------+-------------+-------------+----------------------------+
0067
0068 All values in the structure are stored little-endian.
0069
0070 The structure will be updated by the hypervisor prior to scheduling a VCPU. It
0071 will be present within a reserved region of the normal memory given to the
0072 guest. The guest should not attempt to write into this memory. There is a
0073 structure per VCPU of the guest.
0074
0075 It is advisable that one or more 64k pages are set aside for the purpose of
0076 these structures and not used for other purposes, this enables the guest to map
0077 the region using 64k pages and avoids conflicting attributes with other memory.
0078
0079 For the user space interface see Documentation/virt/kvm/devices/vcpu.rst
0080 section "3. GROUP: KVM_ARM_VCPU_PVTIME_CTRL".