From 4e2f29e8fef6d8428bed4a5c366e5cafd7b92a41 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 19 Jan 2018 02:34:40 +0100 Subject: [PATCH 12/21] spapr: Handle Decimal Floating Point (DFP) as an optional capability RH-Author: David Gibson Message-id: <20180119023442.28577-6-dgibson@redhat.com> Patchwork-id: 78672 O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 5/7] spapr: Handle Decimal Floating Point (DFP) as an optional capability Bugzilla: 1523414 RH-Acked-by: Laurent Vivier RH-Acked-by: Thomas Huth RH-Acked-by: Miroslav Rezanina From: David Gibson 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 (cherry picked from commit 2d1fb9bc8e6e78931d8e1bfeb0ed7a4d223b0480) Signed-off-by: Miroslav Rezanina Conflicts: hw/ppc/spapr.c Due to differences between upstream and downstream machine type versions. As CAP_DFP is enabled for all upstream versions, enable it for all downsteam as well. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1523414 Signed-off-by: David Gibson --- 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 0ef2af9..41cb2fa 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -575,7 +575,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, /* Advertise DFP (Decimal Floating Point) if available * 0 / no property == no DFP * 1 == 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))); } @@ -3650,7 +3650,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) mc->numa_mem_align_shift = 28; smc->has_power9_support = true; - smc->default_caps = spapr_caps(SPAPR_CAP_VSX); + smc->default_caps = spapr_caps(SPAPR_CAP_VSX | SPAPR_CAP_DFP); spapr_caps_add_properties(smc, &error_abort); } @@ -4056,7 +4056,8 @@ static void spapr_machine_rhel740_class_options(MachineClass *mc) smc->has_power9_support = false; smc->pre_2_10_has_unused_icps = true; smc->resize_hpt_default = SPAPR_RESIZE_HPT_DISABLED; - smc->default_caps = spapr_caps(SPAPR_CAP_HTM | SPAPR_CAP_VSX); + smc->default_caps = spapr_caps(SPAPR_CAP_HTM | SPAPR_CAP_VSX + | SPAPR_CAP_DFP); } DEFINE_SPAPR_MACHINE(rhel740, "rhel7.4.0", false); diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 9f901fb..2b67ac2 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -70,6 +70,16 @@ static void cap_vsx_allow(sPAPRMachineState *spapr, Error **errp) } } +static void cap_dfp_allow(sPAPRMachineState *spapr, Error **errp) +{ + PowerPCCPU *cpu = POWERPC_CPU(first_cpu); + CPUPPCState *env = &cpu->env; + + if (!(env->insns_flags2 & PPC2_DFP)) { + error_setg(errp, "DFP support not available, try cap-dfp=off"); + } +} + static sPAPRCapabilityInfo capability_table[] = { { .name = "htm", @@ -85,6 +95,13 @@ static sPAPRCapabilityInfo capability_table[] = { .allow = cap_vsx_allow, /* TODO: add cap_vsx_disallow */ }, + { + .name = "dfp", + .description = "Allow Decimal Floating Point (DFP)", + .flag = SPAPR_CAP_DFP, + .allow = cap_dfp_allow, + /* TODO: add cap_dfp_disallow */ + }, }; static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, @@ -104,6 +121,7 @@ static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, if (!ppc_check_compat(cpu, CPU_POWERPC_LOGICAL_2_06, 0, spapr->max_compat_pvr)) { caps.mask &= ~SPAPR_CAP_VSX; + caps.mask &= ~SPAPR_CAP_DFP; } return caps; diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 36f6816..df767c3 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 +/* Decimal Floating Point */ +#define SPAPR_CAP_DFP 0x0000000000000004ULL + typedef struct sPAPRCapabilities sPAPRCapabilities; struct sPAPRCapabilities { uint64_t mask; -- 1.8.3.1