@@ -1873,6 +1873,7 @@ Parameters: struct kvm_one_reg (in)
18731873Returns: 0 on success, negative value on failure
18741874Errors:
18751875 ENOENT: no such register
1876+ EPERM: register access forbidden for architecture-dependent reasons
18761877 EINVAL: other errors, such as bad size encoding for a known register
18771878
18781879struct kvm_one_reg {
@@ -2127,13 +2128,20 @@ Specifically:
21272128 0x6030 0000 0010 004c SPSR_UND 64 spsr[KVM_SPSR_UND]
21282129 0x6030 0000 0010 004e SPSR_IRQ 64 spsr[KVM_SPSR_IRQ]
21292130 0x6060 0000 0010 0050 SPSR_FIQ 64 spsr[KVM_SPSR_FIQ]
2130- 0x6040 0000 0010 0054 V0 128 fp_regs.vregs[0]
2131- 0x6040 0000 0010 0058 V1 128 fp_regs.vregs[1]
2131+ 0x6040 0000 0010 0054 V0 128 fp_regs.vregs[0] (*)
2132+ 0x6040 0000 0010 0058 V1 128 fp_regs.vregs[1] (*)
21322133 ...
2133- 0x6040 0000 0010 00d0 V31 128 fp_regs.vregs[31]
2134+ 0x6040 0000 0010 00d0 V31 128 fp_regs.vregs[31] (*)
21342135 0x6020 0000 0010 00d4 FPSR 32 fp_regs.fpsr
21352136 0x6020 0000 0010 00d5 FPCR 32 fp_regs.fpcr
21362137
2138+ (*) These encodings are not accepted for SVE-enabled vcpus. See
2139+ KVM_ARM_VCPU_INIT.
2140+
2141+ The equivalent register content can be accessed via bits [127:0] of
2142+ the corresponding SVE Zn registers instead for vcpus that have SVE
2143+ enabled (see below).
2144+
21372145arm64 CCSIDR registers are demultiplexed by CSSELR value:
21382146 0x6020 0000 0011 00 <csselr:8>
21392147
@@ -2143,6 +2151,61 @@ arm64 system registers have the following id bit patterns:
21432151arm64 firmware pseudo-registers have the following bit pattern:
21442152 0x6030 0000 0014 <regno:16>
21452153
2154+ arm64 SVE registers have the following bit patterns:
2155+ 0x6080 0000 0015 00 <n:5> <slice:5> Zn bits[2048*slice + 2047 : 2048*slice]
2156+ 0x6050 0000 0015 04 <n:4> <slice:5> Pn bits[256*slice + 255 : 256*slice]
2157+ 0x6050 0000 0015 060 <slice:5> FFR bits[256*slice + 255 : 256*slice]
2158+ 0x6060 0000 0015 ffff KVM_REG_ARM64_SVE_VLS pseudo-register
2159+
2160+ Access to slices beyond the maximum vector length configured for the
2161+ vcpu (i.e., where 16 * slice >= max_vq (**)) will fail with ENOENT.
2162+
2163+ These registers are only accessible on vcpus for which SVE is enabled.
2164+ See KVM_ARM_VCPU_INIT for details.
2165+
2166+ In addition, except for KVM_REG_ARM64_SVE_VLS, these registers are not
2167+ accessible until the vcpu's SVE configuration has been finalized
2168+ using KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE). See KVM_ARM_VCPU_INIT
2169+ and KVM_ARM_VCPU_FINALIZE for more information about this procedure.
2170+
2171+ KVM_REG_ARM64_SVE_VLS is a pseudo-register that allows the set of vector
2172+ lengths supported by the vcpu to be discovered and configured by
2173+ userspace. When transferred to or from user memory via KVM_GET_ONE_REG
2174+ or KVM_SET_ONE_REG, the value of this register is of type __u64[8], and
2175+ encodes the set of vector lengths as follows:
2176+
2177+ __u64 vector_lengths[8];
2178+
2179+ if (vq >= SVE_VQ_MIN && vq <= SVE_VQ_MAX &&
2180+ ((vector_lengths[(vq - 1) / 64] >> ((vq - 1) % 64)) & 1))
2181+ /* Vector length vq * 16 bytes supported */
2182+ else
2183+ /* Vector length vq * 16 bytes not supported */
2184+
2185+ (**) The maximum value vq for which the above condition is true is
2186+ max_vq. This is the maximum vector length available to the guest on
2187+ this vcpu, and determines which register slices are visible through
2188+ this ioctl interface.
2189+
2190+ (See Documentation/arm64/sve.txt for an explanation of the "vq"
2191+ nomenclature.)
2192+
2193+ KVM_REG_ARM64_SVE_VLS is only accessible after KVM_ARM_VCPU_INIT.
2194+ KVM_ARM_VCPU_INIT initialises it to the best set of vector lengths that
2195+ the host supports.
2196+
2197+ Userspace may subsequently modify it if desired until the vcpu's SVE
2198+ configuration is finalized using KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE).
2199+
2200+ Apart from simply removing all vector lengths from the host set that
2201+ exceed some value, support for arbitrarily chosen sets of vector lengths
2202+ is hardware-dependent and may not be available. Attempting to configure
2203+ an invalid set of vector lengths via KVM_SET_ONE_REG will fail with
2204+ EINVAL.
2205+
2206+ After the vcpu's SVE configuration is finalized, further attempts to
2207+ write this register will fail with EPERM.
2208+
21462209
21472210MIPS registers are mapped using the lower 32 bits. The upper 16 of that is
21482211the register group type:
@@ -2197,6 +2260,7 @@ Parameters: struct kvm_one_reg (in and out)
21972260Returns: 0 on success, negative value on failure
21982261Errors:
21992262 ENOENT: no such register
2263+ EPERM: register access forbidden for architecture-dependent reasons
22002264 EINVAL: other errors, such as bad size encoding for a known register
22012265
22022266This ioctl allows to receive the value of a single register implemented
@@ -2690,6 +2754,33 @@ Possible features:
26902754 - KVM_ARM_VCPU_PMU_V3: Emulate PMUv3 for the CPU.
26912755 Depends on KVM_CAP_ARM_PMU_V3.
26922756
2757+ - KVM_ARM_VCPU_SVE: Enables SVE for the CPU (arm64 only).
2758+ Depends on KVM_CAP_ARM_SVE.
2759+ Requires KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
2760+
2761+ * After KVM_ARM_VCPU_INIT:
2762+
2763+ - KVM_REG_ARM64_SVE_VLS may be read using KVM_GET_ONE_REG: the
2764+ initial value of this pseudo-register indicates the best set of
2765+ vector lengths possible for a vcpu on this host.
2766+
2767+ * Before KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
2768+
2769+ - KVM_RUN and KVM_GET_REG_LIST are not available;
2770+
2771+ - KVM_GET_ONE_REG and KVM_SET_ONE_REG cannot be used to access
2772+ the scalable archietctural SVE registers
2773+ KVM_REG_ARM64_SVE_ZREG(), KVM_REG_ARM64_SVE_PREG() or
2774+ KVM_REG_ARM64_SVE_FFR;
2775+
2776+ - KVM_REG_ARM64_SVE_VLS may optionally be written using
2777+ KVM_SET_ONE_REG, to modify the set of vector lengths available
2778+ for the vcpu.
2779+
2780+ * After KVM_ARM_VCPU_FINALIZE(KVM_ARM_VCPU_SVE):
2781+
2782+ - the KVM_REG_ARM64_SVE_VLS pseudo-register is immutable, and can
2783+ no longer be written using KVM_SET_ONE_REG.
26932784
269427854.83 KVM_ARM_PREFERRED_TARGET
26952786
@@ -3904,6 +3995,41 @@ number of valid entries in the 'entries' array, which is then filled.
39043995'index' and 'flags' fields in 'struct kvm_cpuid_entry2' are currently reserved,
39053996userspace should not expect to get any particular value there.
39063997
3998+ 4.119 KVM_ARM_VCPU_FINALIZE
3999+
4000+ Capability: KVM_CAP_ARM_SVE
4001+ Architectures: arm, arm64
4002+ Type: vcpu ioctl
4003+ Parameters: int feature (in)
4004+ Returns: 0 on success, -1 on error
4005+ Errors:
4006+ EPERM: feature not enabled, needs configuration, or already finalized
4007+ EINVAL: unknown feature
4008+
4009+ Recognised values for feature:
4010+ arm64 KVM_ARM_VCPU_SVE
4011+
4012+ Finalizes the configuration of the specified vcpu feature.
4013+
4014+ The vcpu must already have been initialised, enabling the affected feature, by
4015+ means of a successful KVM_ARM_VCPU_INIT call with the appropriate flag set in
4016+ features[].
4017+
4018+ For affected vcpu features, this is a mandatory step that must be performed
4019+ before the vcpu is fully usable.
4020+
4021+ Between KVM_ARM_VCPU_INIT and KVM_ARM_VCPU_FINALIZE, the feature may be
4022+ configured by use of ioctls such as KVM_SET_ONE_REG. The exact configuration
4023+ that should be performaned and how to do it are feature-dependent.
4024+
4025+ Other calls that depend on a particular feature being finalized, such as
4026+ KVM_RUN, KVM_GET_REG_LIST, KVM_GET_ONE_REG and KVM_SET_ONE_REG, will fail with
4027+ -EPERM unless the feature has already been finalized by means of a
4028+ KVM_ARM_VCPU_FINALIZE call.
4029+
4030+ See KVM_ARM_VCPU_INIT for details of vcpu features that require finalization
4031+ using this ioctl.
4032+
390740335. The kvm_run structure
39084034------------------------
39094035
0 commit comments