From nobody Tue Oct 28 01:56:31 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 1516156110459121.41258671812307; Tue, 16 Jan 2018 18:28:30 -0800 (PST) Received: from localhost ([::1]:55865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebdSn-00017V-LF for importer@patchew.org; Tue, 16 Jan 2018 21:28:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebdQK-0007rY-1I for qemu-devel@nongnu.org; Tue, 16 Jan 2018 21:25:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebdQI-0001JI-5C for qemu-devel@nongnu.org; Tue, 16 Jan 2018 21:25:55 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:45363) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebdQH-0001Gz-Qz; Tue, 16 Jan 2018 21:25:54 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3zLrY518Xpz9sNc; Wed, 17 Jan 2018 13:25:44 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1516155945; bh=aCqmymGO576qENI/gp2k043LLchW9JXQoT5nNwEOsr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ph/qSc0OfvQeIZetiHNFl5XaC70wjbaD5S4rpSTC8/zY2iaOqgWMoqN+xWbTp7WHA qDKiFsfs0jZ+GpE9ktj0CnMBcyQGUaIFUncjuXXRHpRc0EJJGDBUp0G0j0MgcjplCm ATvKitnzx29FJxWNB8ehELIr//QknHyScXxhO2Lw= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 17 Jan 2018 13:25:10 +1100 Message-Id: <20180117022525.31767-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180117022525.31767-1-david@gibson.dropbear.id.au> References: <20180117022525.31767-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 07/22] spapr: Handle Decimal Floating Point (DFP) as an optional capability 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, surajjs@au1.ibm.com, joserz@linux.vnet.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson 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" Decimal Floating Point has been available on POWER7 and later (server) cpus. However, it can be disabled on the hypervisor, meaning that it's not available to guests. We currently handle this by conditionally advertising DFP support in the device tree depending on whether the guest CPU model supports it - which can also depend on what's allowed in the host for -cpu host. That can lead to confusion on migration, since host properties are silently affecting guest visible properties. This patch handles it by treating it as an optional capability for the pseries machine type. Signed-off-by: David Gibson Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 7 ++++--- hw/ppc/spapr_caps.c | 18 ++++++++++++++++++ include/hw/ppc/spapr.h | 3 +++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index eca9f11c91..d1acfe8858 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -572,7 +572,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *f= dt, int offset, /* Advertise DFP (Decimal Floating Point) if available * 0 / no property =3D=3D no DFP * 1 =3D=3D DFP available */ - if (env->insns_flags2 & PPC2_DFP) { + if (spapr_has_cap(spapr, SPAPR_CAP_DFP)) { _FDT((fdt_setprop_cell(fdt, offset, "ibm,dfp", 1))); } =20 @@ -3834,7 +3834,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) */ mc->numa_mem_align_shift =3D 28; =20 - smc->default_caps =3D spapr_caps(SPAPR_CAP_VSX); + smc->default_caps =3D spapr_caps(SPAPR_CAP_VSX | SPAPR_CAP_DFP); spapr_caps_add_properties(smc, &error_abort); } =20 @@ -3916,7 +3916,8 @@ static void spapr_machine_2_11_class_options(MachineC= lass *mc) sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); =20 spapr_machine_2_12_class_options(mc); - smc->default_caps =3D spapr_caps(SPAPR_CAP_HTM | SPAPR_CAP_VSX); + smc->default_caps =3D spapr_caps(SPAPR_CAP_HTM | SPAPR_CAP_VSX + | SPAPR_CAP_DFP); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_11); } =20 diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 7c855c67ad..9d070a306c 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -70,6 +70,16 @@ static void cap_vsx_allow(sPAPRMachineState *spapr, Erro= r **errp) } } =20 +static void cap_dfp_allow(sPAPRMachineState *spapr, Error **errp) +{ + PowerPCCPU *cpu =3D POWERPC_CPU(first_cpu); + CPUPPCState *env =3D &cpu->env; + + if (!(env->insns_flags2 & PPC2_DFP)) { + error_setg(errp, "DFP support not available, try cap-dfp=3Doff"); + } +} + static sPAPRCapabilityInfo capability_table[] =3D { { .name =3D "htm", @@ -85,6 +95,13 @@ static sPAPRCapabilityInfo capability_table[] =3D { .allow =3D cap_vsx_allow, /* TODO: add cap_vsx_disallow */ }, + { + .name =3D "dfp", + .description =3D "Allow Decimal Floating Point (DFP)", + .flag =3D SPAPR_CAP_DFP, + .allow =3D cap_dfp_allow, + /* TODO: add cap_dfp_disallow */ + }, }; =20 static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, @@ -104,6 +121,7 @@ static sPAPRCapabilities default_caps_with_cpu(sPAPRMac= hineState *spapr, if (!ppc_check_compat(cpu, CPU_POWERPC_LOGICAL_2_06, 0, spapr->max_compat_pvr)) { caps.mask &=3D ~SPAPR_CAP_VSX; + caps.mask &=3D ~SPAPR_CAP_DFP; } =20 return caps; diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 148a03d189..26ac17e641 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -62,6 +62,9 @@ typedef enum { /* Vector Scalar Extensions */ #define SPAPR_CAP_VSX 0x0000000000000002ULL =20 +/* Decimal Floating Point */ +#define SPAPR_CAP_DFP 0x0000000000000004ULL + typedef struct sPAPRCapabilities sPAPRCapabilities; struct sPAPRCapabilities { uint64_t mask; --=20 2.14.3