Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: Specify hypercall ABI for retrieving target implementations

If the Guest requires migration to multiple targets, these hypercalls
will provide a way to retrieve the target CPU implementations from
the user space VMM.

Subsequent patch will use this to enable the associated errata.

Suggested-by: Oliver Upton <oliver.upton@linux.dev>
Suggested-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Sebastian Ott <sebott@redhat.com>
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Link: https://lore.kernel.org/r/20250221140229.12588-3-shameerali.kolothum.thodi@huawei.com
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>

authored by

Shameer Kolothum and committed by
Oliver Upton
57e5cc9b e3121298

+74
+59
Documentation/virt/kvm/arm/hypercalls.rst
··· 142 142 | | | +---------------------------------------------+ 143 143 | | | | ``INVALID_PARAMETER (-3)`` | 144 144 +---------------------+----------+----+---------------------------------------------+ 145 + 146 + ``ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID`` 147 + ------------------------------------------------------- 148 + Request the target CPU implementation version information and the number of target 149 + implementations for the Guest VM. 150 + 151 + +---------------------+-------------------------------------------------------------+ 152 + | Presence: | Optional; KVM/ARM64 Guests only | 153 + +---------------------+-------------------------------------------------------------+ 154 + | Calling convention: | HVC64 | 155 + +---------------------+----------+--------------------------------------------------+ 156 + | Function ID: | (uint32) | 0xC6000040 | 157 + +---------------------+----------+--------------------------------------------------+ 158 + | Arguments: | None | 159 + +---------------------+----------+----+---------------------------------------------+ 160 + | Return Values: | (int64) | R0 | ``SUCCESS (0)`` | 161 + | | | +---------------------------------------------+ 162 + | | | | ``NOT_SUPPORTED (-1)`` | 163 + | +----------+----+---------------------------------------------+ 164 + | | (uint64) | R1 | Bits [63:32] Reserved/Must be zero | 165 + | | | +---------------------------------------------+ 166 + | | | | Bits [31:16] Major version | 167 + | | | +---------------------------------------------+ 168 + | | | | Bits [15:0] Minor version | 169 + | +----------+----+---------------------------------------------+ 170 + | | (uint64) | R2 | Number of target implementations | 171 + | +----------+----+---------------------------------------------+ 172 + | | (uint64) | R3 | Reserved / Must be zero | 173 + +---------------------+----------+----+---------------------------------------------+ 174 + 175 + ``ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_CPUS_FUNC_ID`` 176 + ------------------------------------------------------- 177 + 178 + Request the target CPU implementation information for the Guest VM. The Guest kernel 179 + will use this information to enable the associated errata. 180 + 181 + +---------------------+-------------------------------------------------------------+ 182 + | Presence: | Optional; KVM/ARM64 Guests only | 183 + +---------------------+-------------------------------------------------------------+ 184 + | Calling convention: | HVC64 | 185 + +---------------------+----------+--------------------------------------------------+ 186 + | Function ID: | (uint32) | 0xC6000041 | 187 + +---------------------+----------+----+---------------------------------------------+ 188 + | Arguments: | (uint64) | R1 | selected implementation index | 189 + | +----------+----+---------------------------------------------+ 190 + | | (uint64) | R2 | Reserved / Must be zero | 191 + | +----------+----+---------------------------------------------+ 192 + | | (uint64) | R3 | Reserved / Must be zero | 193 + +---------------------+----------+----+---------------------------------------------+ 194 + | Return Values: | (int64) | R0 | ``SUCCESS (0)`` | 195 + | | | +---------------------------------------------+ 196 + | | | | ``INVALID_PARAMETER (-3)`` | 197 + | +----------+----+---------------------------------------------+ 198 + | | (uint64) | R1 | MIDR_EL1 of the selected implementation | 199 + | +----------+----+---------------------------------------------+ 200 + | | (uint64) | R2 | REVIDR_EL1 of the selected implementation | 201 + | +----------+----+---------------------------------------------+ 202 + | | (uint64) | R3 | AIDR_EL1 of the selected implementation | 203 + +---------------------+----------+----+---------------------------------------------+
+15
include/linux/arm-smccc.h
··· 179 179 #define ARM_SMCCC_KVM_FUNC_PKVM_RESV_62 62 180 180 #define ARM_SMCCC_KVM_FUNC_PKVM_RESV_63 63 181 181 /* End of pKVM hypercall range */ 182 + #define ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_VER 64 183 + #define ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_CPUS 65 184 + 182 185 #define ARM_SMCCC_KVM_FUNC_FEATURES_2 127 183 186 #define ARM_SMCCC_KVM_NUM_FUNCS 128 184 187 ··· 227 224 ARM_SMCCC_SMC_64, \ 228 225 ARM_SMCCC_OWNER_VENDOR_HYP, \ 229 226 ARM_SMCCC_KVM_FUNC_MMIO_GUARD) 227 + 228 + #define ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_VER_FUNC_ID \ 229 + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ 230 + ARM_SMCCC_SMC_64, \ 231 + ARM_SMCCC_OWNER_VENDOR_HYP, \ 232 + ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_VER) 233 + 234 + #define ARM_SMCCC_VENDOR_HYP_KVM_DISCOVER_IMPL_CPUS_FUNC_ID \ 235 + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ 236 + ARM_SMCCC_SMC_64, \ 237 + ARM_SMCCC_OWNER_VENDOR_HYP, \ 238 + ARM_SMCCC_KVM_FUNC_DISCOVER_IMPL_CPUS) 230 239 231 240 /* ptp_kvm counter type ID */ 232 241 #define KVM_PTP_VIRT_COUNTER 0