From: Greg Kurz <groug@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: surajjs@au1.ibm.com, lvivier@redhat.com, qemu-ppc@nongnu.org,
qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com,
abologna@redhat.com
Subject: Re: [Qemu-devel] [PATCH 5/6] spapr: Handle VMX/VSX presence as an spapr capability flag
Date: Mon, 18 Dec 2017 12:47:52 +0100 [thread overview]
Message-ID: <20171218124752.6d4f127c@bahia.lan> (raw)
In-Reply-To: <20171218092024.21645-6-david@gibson.dropbear.id.au>
On Mon, 18 Dec 2017 20:20:23 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:
> 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 <david@gibson.dropbear.id.au>
> ---
Reviewed-by: Greg Kurz <groug@kaod.org>
> 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 86fc83f9c2..693dd6f7b3 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
> @@ -3832,7 +3834,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);
> }
>
> @@ -3914,7 +3916,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 a8c726a88b..da066aec8f 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 5c85f39c3b..148a03d189 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;
next prev parent reply other threads:[~2017-12-18 11:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-18 9:20 [Qemu-devel] [PATCH 0/6] spapr: Add optional capabilities David Gibson
2017-12-18 9:20 ` [Qemu-devel] [PATCH 1/6] spapr: Capabilities infrastructure David Gibson
2017-12-18 9:58 ` Greg Kurz
2017-12-18 10:15 ` David Gibson
2017-12-18 9:20 ` [Qemu-devel] [PATCH 2/6] spapr: Treat Hardware Transactional Memory (HTM) as an optional capability David Gibson
2017-12-18 11:10 ` Greg Kurz
2017-12-19 0:35 ` David Gibson
2017-12-18 9:20 ` [Qemu-devel] [PATCH 3/6] spapr: Validate capabilities on migration David Gibson
2017-12-18 11:31 ` Greg Kurz
2017-12-18 9:20 ` [Qemu-devel] [PATCH 4/6] target/ppc: Clean up probing of VMX, VSX and DFP availability on KVM David Gibson
2017-12-18 11:45 ` Greg Kurz
2017-12-18 9:20 ` [Qemu-devel] [PATCH 5/6] spapr: Handle VMX/VSX presence as an spapr capability flag David Gibson
2017-12-18 11:47 ` Greg Kurz [this message]
2017-12-18 9:20 ` [Qemu-devel] [PATCH 6/6] spapr: Handle Decimal Floating Point (DFP) as an optional capability David Gibson
2017-12-18 11:51 ` Greg Kurz
2017-12-19 0:37 ` [Qemu-devel] [PATCH 0/6] spapr: Add optional capabilities David Gibson
2017-12-20 22:32 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171218124752.6d4f127c@bahia.lan \
--to=groug@kaod.org \
--cc=abologna@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=surajjs@au1.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).