Skip to content

Commit 6a74584

Browse files
Steven PriceMarc Zyngier
authored andcommitted
KVM: arm64: Document PV-time interface
Introduce a paravirtualization interface for KVM/arm64 based on the "Arm Paravirtualized Time for Arm-Base Systems" specification DEN 0057A. This only adds the details about "Stolen Time" as the details of "Live Physical Time" have not been fully agreed. User space can specify a reserved area of memory for the guest and inform KVM to populate the memory with information on time that the host kernel has stolen from the guest. A hypercall interface is provided for the guest to interrogate the hypervisor's support for this interface and the location of the shared memory structures. Signed-off-by: Steven Price <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent dcac930 commit 6a74584

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

Documentation/virt/kvm/arm/pvtime.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
Paravirtualized time support for arm64
4+
======================================
5+
6+
Arm specification DEN0057/A defines a standard for paravirtualised time
7+
support for AArch64 guests:
8+
9+
https://developer.arm.com/docs/den0057/a
10+
11+
KVM/arm64 implements the stolen time part of this specification by providing
12+
some hypervisor service calls to support a paravirtualized guest obtaining a
13+
view of the amount of time stolen from its execution.
14+
15+
Two new SMCCC compatible hypercalls are defined:
16+
17+
* PV_TIME_FEATURES: 0xC5000020
18+
* PV_TIME_ST: 0xC5000021
19+
20+
These are only available in the SMC64/HVC64 calling convention as
21+
paravirtualized time is not available to 32 bit Arm guests. The existence of
22+
the PV_FEATURES hypercall should be probed using the SMCCC 1.1 ARCH_FEATURES
23+
mechanism before calling it.
24+
25+
PV_TIME_FEATURES
26+
============= ======== ==========
27+
Function ID: (uint32) 0xC5000020
28+
PV_call_id: (uint32) The function to query for support.
29+
Currently only PV_TIME_ST is supported.
30+
Return value: (int64) NOT_SUPPORTED (-1) or SUCCESS (0) if the relevant
31+
PV-time feature is supported by the hypervisor.
32+
============= ======== ==========
33+
34+
PV_TIME_ST
35+
============= ======== ==========
36+
Function ID: (uint32) 0xC5000021
37+
Return value: (int64) IPA of the stolen time data structure for this
38+
VCPU. On failure:
39+
NOT_SUPPORTED (-1)
40+
============= ======== ==========
41+
42+
The IPA returned by PV_TIME_ST should be mapped by the guest as normal memory
43+
with inner and outer write back caching attributes, in the inner shareable
44+
domain. A total of 16 bytes from the IPA returned are guaranteed to be
45+
meaningfully filled by the hypervisor (see structure below).
46+
47+
PV_TIME_ST returns the structure for the calling VCPU.
48+
49+
Stolen Time
50+
-----------
51+
52+
The structure pointed to by the PV_TIME_ST hypercall is as follows:
53+
54+
+-------------+-------------+-------------+----------------------------+
55+
| Field | Byte Length | Byte Offset | Description |
56+
+=============+=============+=============+============================+
57+
| Revision | 4 | 0 | Must be 0 for version 1.0 |
58+
+-------------+-------------+-------------+----------------------------+
59+
| Attributes | 4 | 4 | Must be 0 |
60+
+-------------+-------------+-------------+----------------------------+
61+
| Stolen time | 8 | 8 | Stolen time in unsigned |
62+
| | | | nanoseconds indicating how |
63+
| | | | much time this VCPU thread |
64+
| | | | was involuntarily not |
65+
| | | | running on a physical CPU. |
66+
+-------------+-------------+-------------+----------------------------+
67+
68+
All values in the structure are stored little-endian.
69+
70+
The structure will be updated by the hypervisor prior to scheduling a VCPU. It
71+
will be present within a reserved region of the normal memory given to the
72+
guest. The guest should not attempt to write into this memory. There is a
73+
structure per VCPU of the guest.
74+
75+
It is advisable that one or more 64k pages are set aside for the purpose of
76+
these structures and not used for other purposes, this enables the guest to map
77+
the region using 64k pages and avoids conflicting attributes with other memory.
78+
79+
For the user space interface see Documentation/virt/kvm/devices/vcpu.txt
80+
section "3. GROUP: KVM_ARM_VCPU_PVTIME_CTRL".

Documentation/virt/kvm/devices/vcpu.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,17 @@ time to use the number provided for a given timer, overwriting any previously
6060
configured values on other VCPUs. Userspace should configure the interrupt
6161
numbers on at least one VCPU after creating all VCPUs and before running any
6262
VCPUs.
63+
64+
3. GROUP: KVM_ARM_VCPU_PVTIME_CTRL
65+
Architectures: ARM64
66+
67+
3.1 ATTRIBUTE: KVM_ARM_VCPU_PVTIME_IPA
68+
Parameters: 64-bit base address
69+
Returns: -ENXIO: Stolen time not implemented
70+
-EEXIST: Base address already set for this VCPU
71+
-EINVAL: Base address not 64 byte aligned
72+
73+
Specifies the base address of the stolen time structure for this VCPU. The
74+
base address must be 64 byte aligned and exist within a valid guest memory
75+
region. See Documentation/virt/kvm/arm/pvtime.txt for more information
76+
including the layout of the stolen time structure.

0 commit comments

Comments
 (0)