From nobody Tue Oct 28 12:35:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1514953613960859.8278839193605; Tue, 2 Jan 2018 20:26:53 -0800 (PST) Received: from localhost ([::1]:38613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWadg-0002of-RI for importer@patchew.org; Tue, 02 Jan 2018 23:26:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWabZ-00018k-3E for qemu-devel@nongnu.org; Tue, 02 Jan 2018 23:24:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWabX-0001uL-Tc for qemu-devel@nongnu.org; Tue, 02 Jan 2018 23:24:41 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:56321) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eWabX-0001sG-I6; Tue, 02 Jan 2018 23:24:39 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3zBHrg09K7z9t3M; Wed, 3 Jan 2018 15:24:34 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1514953475; bh=1SMKLDaHfNjUowdxw/RstC/8yiqUHpfdsjfaRLJICog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xw18V6loPdErSKlBFWUYsVgTVNQwhIW0rVUHSc3r69l+gB+/kGJ+Zv4Esp4y13Eda tmxLpsz7nwb7Zp651TtVFXaCEM9Bt7MUso/kmk2rEQqpPHnLwT1xK3o6WKOV5Xpq/T qBzsQuDyYkm4XxTe7xJWbigqYjwxjOF5fCZDUppQ= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 3 Jan 2018 15:24:14 +1100 Message-Id: <20180103042419.14520-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180103042419.14520-1-david@gibson.dropbear.id.au> References: <20180103042419.14520-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 10/15] target/ppc: Clean up probing of VMX, VSX and DFP availability on KVM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, David Gibson , qemu-ppc@nongnu.org, groug@kaod.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When constructing the "host" cpu class we modify whether the VMX and VSX vector extensions and DFP (Decimal Floating Point) are available based on whether KVM can support those instructions. This can depend on policy in the host kernel as well as on the actual host cpu capabilities. However, the way we probe for this is not very nice: we explicitly check the host's device tree. That works in practice, but it's not really correct, since the device tree is a property of the host kernel's platform which we don't really know about. We get away with it because the only modern POWER platforms happen to encode VMX, VSX and DFP availability in the device tree in the same way. Arguably we should have an explicit KVM capability for this, but we haven't needed one so far. Barring specific KVM policies which don't yet exist, each of these instruction classes will be available in the guest if and only if they're available in the qemu userspace process. We can determine that from the ELF AUX vector we're supplied with. Once reworked like this, there are no more callers for kvmppc_get_vmx() and kvmppc_get_dfp() so remove them. Signed-off-by: David Gibson Reviewed-by: Greg Kurz --- target/ppc/kvm.c | 27 ++++++--------------------- target/ppc/kvm_ppc.h | 2 -- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 4664a3ce9d..518dd06e98 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2011,16 +2011,6 @@ uint64_t kvmppc_get_clockfreq(void) return kvmppc_read_int_cpu_dt("clock-frequency"); } =20 -uint32_t kvmppc_get_vmx(void) -{ - return kvmppc_read_int_cpu_dt("ibm,vmx"); -} - -uint32_t kvmppc_get_dfp(void) -{ - return kvmppc_read_int_cpu_dt("ibm,dfp"); -} - static int kvmppc_get_pvinfo(CPUPPCState *env, struct kvm_ppc_pvinfo *pvin= fo) { PowerPCCPU *cpu =3D ppc_env_get_cpu(env); @@ -2404,23 +2394,18 @@ static void alter_insns(uint64_t *word, uint64_t fl= ags, bool on) static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data) { PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); - uint32_t vmx =3D kvmppc_get_vmx(); - uint32_t dfp =3D kvmppc_get_dfp(); uint32_t dcache_size =3D kvmppc_read_int_cpu_dt("d-cache-size"); uint32_t icache_size =3D kvmppc_read_int_cpu_dt("i-cache-size"); =20 /* Now fix up the class with information we can query from the host */ pcc->pvr =3D mfpvr(); =20 - if (vmx !=3D -1) { - /* Only override when we know what the host supports */ - alter_insns(&pcc->insns_flags, PPC_ALTIVEC, vmx > 0); - alter_insns(&pcc->insns_flags2, PPC2_VSX, vmx > 1); - } - if (dfp !=3D -1) { - /* Only override when we know what the host supports */ - alter_insns(&pcc->insns_flags2, PPC2_DFP, dfp); - } + alter_insns(&pcc->insns_flags, PPC_ALTIVEC, + qemu_getauxval(AT_HWCAP) & PPC_FEATURE_HAS_ALTIVEC); + alter_insns(&pcc->insns_flags2, PPC2_VSX, + qemu_getauxval(AT_HWCAP) & PPC_FEATURE_HAS_VSX); + alter_insns(&pcc->insns_flags2, PPC2_DFP, + qemu_getauxval(AT_HWCAP) & PPC_FEATURE_HAS_DFP); =20 if (dcache_size !=3D -1) { pcc->l1_dcache_size =3D dcache_size; diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index d6be38ecaf..ecb55493cc 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -15,8 +15,6 @@ =20 uint32_t kvmppc_get_tbfreq(void); uint64_t kvmppc_get_clockfreq(void); -uint32_t kvmppc_get_vmx(void); -uint32_t kvmppc_get_dfp(void); bool kvmppc_get_host_model(char **buf); bool kvmppc_get_host_serial(char **buf); int kvmppc_get_hasidle(CPUPPCState *env); --=20 2.14.3