target-arm queue:

* Fix KVM SVE ID register probe code
 -----BEGIN PGP SIGNATURE-----
 
 iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmLn8rwZHHBldGVyLm1h
 eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3seqD/sE4YU3qpovlyPhJJWsEFyH
 JRheAwddoj8P/ufOeJVPh85PqGH8zR6MSLSJqzz32ADrN56CFA56c0TRAoL7F6Ru
 iTibwP7hFloDxBCJIYVMZdbSw959LYADYHhdIN7UBkSryCoOC74AraUCwuYqzr9l
 jgh3lnvaH2kj5460XQQYPX4Pkf1jZIV83nhs9kh6GohhuHWtyz9UucDe8VcgMyl2
 9jn7aobLWXI1LJyWTNYJHxQacGn4HK4HbVHczDRgf9PzmjliiTltGvol+T1XGyha
 TGHXMNnMTRbWFz7LCENfEYhup5ScuZbBr5fWh4sBveodczgOActNwmFuy1sempWo
 Cnzy/rwcNREj6EXoKvUkpATKuls9rtH9U4927mesxrk9S3bRJXU4C/EgpAn3qIBZ
 1iFTgSq7eqX+BaYmG1/dtEK+vFX6mhpmKCMhQyRtSFHHibovvlANaNhOHgnPnS0m
 +Bb1pioolo31LLLxBpByOX/MxnXbG+GBnn2kmqX9MLkqamrYQq4g+ITUZcrLReId
 HmvBtYENoiXfReuvT/zRH1nBax97dKrluOgejco2bJrhiYaDgJ94jDMegdoR9mSl
 W/G3QHq18PJ5YOkrjmTn6IFjYNozLEvVqn5VwGXr6QZFxBuivAUoxOELrGULSlba
 OPTBWo2kAbJ8FvKOr3RzhQ==
 =hkV8
 -----END PGP SIGNATURE-----

Merge tag 'pull-target-arm-20220801' of https://git.linaro.org/people/pmaydell/qemu-arm into staging

target-arm queue:
 * Fix KVM SVE ID register probe code

# -----BEGIN PGP SIGNATURE-----
#
# iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAmLn8rwZHHBldGVyLm1h
# eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3seqD/sE4YU3qpovlyPhJJWsEFyH
# JRheAwddoj8P/ufOeJVPh85PqGH8zR6MSLSJqzz32ADrN56CFA56c0TRAoL7F6Ru
# iTibwP7hFloDxBCJIYVMZdbSw959LYADYHhdIN7UBkSryCoOC74AraUCwuYqzr9l
# jgh3lnvaH2kj5460XQQYPX4Pkf1jZIV83nhs9kh6GohhuHWtyz9UucDe8VcgMyl2
# 9jn7aobLWXI1LJyWTNYJHxQacGn4HK4HbVHczDRgf9PzmjliiTltGvol+T1XGyha
# TGHXMNnMTRbWFz7LCENfEYhup5ScuZbBr5fWh4sBveodczgOActNwmFuy1sempWo
# Cnzy/rwcNREj6EXoKvUkpATKuls9rtH9U4927mesxrk9S3bRJXU4C/EgpAn3qIBZ
# 1iFTgSq7eqX+BaYmG1/dtEK+vFX6mhpmKCMhQyRtSFHHibovvlANaNhOHgnPnS0m
# +Bb1pioolo31LLLxBpByOX/MxnXbG+GBnn2kmqX9MLkqamrYQq4g+ITUZcrLReId
# HmvBtYENoiXfReuvT/zRH1nBax97dKrluOgejco2bJrhiYaDgJ94jDMegdoR9mSl
# W/G3QHq18PJ5YOkrjmTn6IFjYNozLEvVqn5VwGXr6QZFxBuivAUoxOELrGULSlba
# OPTBWo2kAbJ8FvKOr3RzhQ==
# =hkV8
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 01 Aug 2022 08:35:24 AM PDT
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [full]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [full]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [full]

* tag 'pull-target-arm-20220801' of https://git.linaro.org/people/pmaydell/qemu-arm:
  target/arm: Move sve probe inside kvm >= 4.15 branch
  target/arm: Set KVM_ARM_VCPU_SVE while probing the host
  target/arm: Use kvm_arm_sve_supported in kvm_arm_get_host_cpu_features

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2022-08-01 12:00:08 -07:00
commit 0e0c2cf6de
1 changed files with 22 additions and 23 deletions

View File

@ -507,7 +507,6 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
bool sve_supported;
bool pmu_supported = false;
uint64_t features = 0;
uint64_t t;
int err;
/* Old kernels may not know about the PREFERRED_TARGET ioctl: however
@ -528,10 +527,17 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
struct kvm_vcpu_init init = { .target = -1, };
/*
* Ask for Pointer Authentication if supported. We can't play the
* SVE trick of synthesising the ID reg as KVM won't tell us
* whether we have the architected or IMPDEF version of PAuth, so
* we have to use the actual ID regs.
* Ask for SVE if supported, so that we can query ID_AA64ZFR0,
* which is otherwise RAZ.
*/
sve_supported = kvm_arm_sve_supported();
if (sve_supported) {
init.features[0] |= 1 << KVM_ARM_VCPU_SVE;
}
/*
* Ask for Pointer Authentication if supported, so that we get
* the unsanitized field values for AA64ISAR1_EL1.
*/
if (kvm_arm_pauth_supported()) {
init.features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS |
@ -673,25 +679,18 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
err |= read_sys_reg64(fdarray[2], &ahcf->isar.reset_pmcr_el0,
ARM64_SYS_REG(3, 3, 9, 12, 0));
}
}
sve_supported = ioctl(fdarray[0], KVM_CHECK_EXTENSION, KVM_CAP_ARM_SVE) > 0;
/* Add feature bits that can't appear until after VCPU init. */
if (sve_supported) {
t = ahcf->isar.id_aa64pfr0;
t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
ahcf->isar.id_aa64pfr0 = t;
/*
* There is a range of kernels between kernel commit 73433762fcae
* and f81cb2c3ad41 which have a bug where the kernel doesn't expose
* SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the VM has enabled
* SVE support, so we only read it here, rather than together with all
* the other ID registers earlier.
*/
err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0,
ARM64_SYS_REG(3, 0, 0, 4, 4));
if (sve_supported) {
/*
* There is a range of kernels between kernel commit 73433762fcae
* and f81cb2c3ad41 which have a bug where the kernel doesn't
* expose SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the VM has
* enabled SVE support, which resulted in an error rather than RAZ.
* So only read the register if we set KVM_ARM_VCPU_SVE above.
*/
err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0,
ARM64_SYS_REG(3, 0, 0, 4, 4));
}
}
kvm_arm_destroy_scratch_host_vcpu(fdarray);