[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 42/54] spapr: Handle VMX/VSX presence as an spapr c
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 42/54] spapr: Handle VMX/VSX presence as an spapr capability flag |
Date: |
Tue, 6 Feb 2018 13:15:03 -0600 |
From: David Gibson <address@hidden>
We currently have some conditionals in the spapr device tree code to decide
whether or not to advertise the availability of the VMX (aka Altivec) and
VSX vector extensions to the guest, based on whether the guest cpu has
those features.
This can lead to confusion and subtle failures on migration, since it makes
a guest visible change based only on host capabilities. We now have a
better mechanism for this, in spapr capabilities flags, which explicitly
depend on user options rather than host capabilities.
Rework the advertisement of VSX and VMX based on a new VSX capability. We
no longer bother with a conditional for VMX support, because every CPU
that's ever been supported by the pseries machine type supports VMX.
NOTE: Some userspace distributions (e.g. RHEL7.4) already rely on
availability of VSX in libc, so using cap-vsx=off may lead to a fatal
SIGILL in init.
Signed-off-by: David Gibson <address@hidden>
Reviewed-by: Greg Kurz <address@hidden>
(cherry picked from commit 2938664286499c0c30d6e455a7e2e5d3e6c3f63d)
Signed-off-by: Michael Roth <address@hidden>
---
hw/ppc/spapr.c | 20 +++++++++++---------
hw/ppc/spapr_caps.c | 25 +++++++++++++++++++++++++
include/hw/ppc/spapr.h | 3 +++
3 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 69ddc4bb23..f006662c5c 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -557,14 +557,16 @@ static void spapr_populate_cpu_dt(CPUState *cs, void
*fdt, int offset,
segs, sizeof(segs))));
}
- /* Advertise VMX/VSX (vector extensions) if available
- * 0 / no property == no vector extensions
+ /* Advertise VSX (vector extensions) if available
* 1 == VMX / Altivec available
- * 2 == VSX available */
- if (env->insns_flags & PPC_ALTIVEC) {
- uint32_t vmx = (env->insns_flags2 & PPC2_VSX) ? 2 : 1;
-
- _FDT((fdt_setprop_cell(fdt, offset, "ibm,vmx", vmx)));
+ * 2 == VSX available
+ *
+ * Only CPUs for which we create core types in spapr_cpu_core.c
+ * are possible, and all of those have VMX */
+ if (spapr_has_cap(spapr, SPAPR_CAP_VSX)) {
+ _FDT((fdt_setprop_cell(fdt, offset, "ibm,vmx", 2)));
+ } else {
+ _FDT((fdt_setprop_cell(fdt, offset, "ibm,vmx", 1)));
}
/* Advertise DFP (Decimal Floating Point) if available
@@ -3678,7 +3680,7 @@ static void spapr_machine_class_init(ObjectClass *oc,
void *data)
*/
mc->numa_mem_align_shift = 28;
- smc->default_caps = spapr_caps(0);
+ smc->default_caps = spapr_caps(SPAPR_CAP_VSX);
spapr_caps_add_properties(smc, &error_abort);
}
@@ -3760,7 +3762,7 @@ static void spapr_machine_2_11_class_options(MachineClass
*mc)
sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
spapr_machine_2_12_class_options(mc);
- smc->default_caps = spapr_caps(SPAPR_CAP_HTM);
+ smc->default_caps = spapr_caps(SPAPR_CAP_HTM | SPAPR_CAP_VSX);
SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_11);
}
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index cad40fe49a..7c855c67ad 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -57,6 +57,19 @@ static void cap_htm_allow(sPAPRMachineState *spapr, Error
**errp)
}
}
+static void cap_vsx_allow(sPAPRMachineState *spapr, Error **errp)
+{
+ PowerPCCPU *cpu = POWERPC_CPU(first_cpu);
+ CPUPPCState *env = &cpu->env;
+
+ /* Allowable CPUs in spapr_cpu_core.c should already have gotten
+ * rid of anything that doesn't do VMX */
+ g_assert(env->insns_flags & PPC_ALTIVEC);
+ if (!(env->insns_flags2 & PPC2_VSX)) {
+ error_setg(errp, "VSX support not available, try cap-vsx=off");
+ }
+}
+
static sPAPRCapabilityInfo capability_table[] = {
{
.name = "htm",
@@ -65,6 +78,13 @@ static sPAPRCapabilityInfo capability_table[] = {
.allow = cap_htm_allow,
/* TODO: add cap_htm_disallow */
},
+ {
+ .name = "vsx",
+ .description = "Allow Vector Scalar Extensions (VSX)",
+ .flag = SPAPR_CAP_VSX,
+ .allow = cap_vsx_allow,
+ /* TODO: add cap_vsx_disallow */
+ },
};
static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr,
@@ -81,6 +101,11 @@ static sPAPRCapabilities
default_caps_with_cpu(sPAPRMachineState *spapr,
caps.mask &= ~SPAPR_CAP_HTM;
}
+ if (!ppc_check_compat(cpu, CPU_POWERPC_LOGICAL_2_06,
+ 0, spapr->max_compat_pvr)) {
+ caps.mask &= ~SPAPR_CAP_VSX;
+ }
+
return caps;
}
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 985948b622..7765f3439d 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -59,6 +59,9 @@ typedef enum {
/* Hardware Transactional Memory */
#define SPAPR_CAP_HTM 0x0000000000000001ULL
+/* Vector Scalar Extensions */
+#define SPAPR_CAP_VSX 0x0000000000000002ULL
+
typedef struct sPAPRCapabilities sPAPRCapabilities;
struct sPAPRCapabilities {
uint64_t mask;
--
2.11.0
- [Qemu-stable] [PATCH 35/54] linux-user/signal.c: Rename MC_* defines, (continued)
- [Qemu-stable] [PATCH 35/54] linux-user/signal.c: Rename MC_* defines, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 29/54] linux-headers: update, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 33/54] usb-storage: Fix share-rw option parsing, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 31/54] s390x/kvm: provide stfle.81, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 34/54] spapr_pci: fix MSI/MSIX selection, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 32/54] osdep: Retry SETLK upon EINTR, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 25/54] i386: Add EPYC-IBPB CPU model, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 24/54] i386: Add new -IBRS versions of Intel CPU models, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 30/54] s390x/kvm: Handle bpb feature, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 41/54] target/ppc: Clean up probing of VMX, VSX and DFP availability on KVM, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 42/54] spapr: Handle VMX/VSX presence as an spapr capability flag,
Michael Roth <=
- [Qemu-stable] [PATCH 03/54] target/sh4: fix TCG leak during gusa sequence, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 02/54] block/iscsi: dont leave allocmap in an invalid state on UNMAP failure, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 44/54] hw/ppc/spapr_caps: Rework spapr_caps to use uint8 internal representation, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 45/54] ppc: Change Power9 compat table to support at most 8 threads/core, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 43/54] spapr: Handle Decimal Floating Point (DFP) as an optional capability, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 49/54] target/ppc/kvm: Add cap_ppc_safe_[cache/bounds_check/indirect_branch], Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 47/54] target/ppc: introduce the PPC_BIT() macro, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 48/54] target/ppc/spapr_caps: Add macro to generate spapr_caps migration vmstate, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 46/54] spapr: fix device tree properties when using compatibility mode, Michael Roth, 2018/02/06
- [Qemu-stable] [PATCH 04/54] qemu-options: Remove stray colons from output of --help, Michael Roth, 2018/02/06