From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: nikunj@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com,
thuth@redhat.com, lvivier@redhat.com, qemu-ppc@nongnu.org,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC 13/17] pseries: Move CPU compatibility property to machine
Date: Wed, 9 Nov 2016 15:41:30 +1100 [thread overview]
Message-ID: <20161109044130.GF427@umbus.fritz.box> (raw)
In-Reply-To: <711cf9b0-1233-c66b-eccd-a0acfccf7e96@ozlabs.ru>
[-- Attachment #1: Type: text/plain, Size: 6158 bytes --]
On Tue, Nov 08, 2016 at 04:56:10PM +1100, Alexey Kardashevskiy wrote:
> On 08/11/16 16:26, David Gibson wrote:
> > On Fri, Nov 04, 2016 at 06:43:52PM +1100, Alexey Kardashevskiy wrote:
> >> On 30/10/16 22:12, David Gibson wrote:
> >>> Server class POWER CPUs have a "compat" property, which is used to set the
> >>> backwards compatibility mode for the processor. However, this only makes
> >>> sense for machine types which don't give the guest access to hypervisor
> >>> privilege - otherwise the compatibility level is under the guest's control.
> >>>
> >>> To reflect this, this removes the CPU 'compat' property and instead
> >>> creates a 'max-cpu-compat' property on the pseries machine. Strictly
> >>> speaking this breaks compatibility, but AFAIK the 'compat' option was
> >>> never (directly) used with -device or device_add.
> >>>
> >>> The option was used with -cpu. So, to maintain compatibility, this patch
> >>> adds a hack to the cpu option parsing to strip out any compat options
> >>> supplied with -cpu and set them on the machine property instead of the new
> >>> removed cpu property.
> >>>
> >>> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> >>> ---
> >>> hw/ppc/spapr.c | 6 +++-
> >>> hw/ppc/spapr_cpu_core.c | 47 +++++++++++++++++++++++++++--
> >>> hw/ppc/spapr_hcall.c | 2 +-
> >>> include/hw/ppc/spapr.h | 10 +++++--
> >>> target-ppc/compat.c | 65 ++++++++++++++++++++++++++++++++++++++++
> >>> target-ppc/cpu.h | 6 ++--
> >>> target-ppc/translate_init.c | 73 ---------------------------------------------
> >>> 7 files changed, 127 insertions(+), 82 deletions(-)
> >>>
> >>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> >>> index 6c78889..b983faa 100644
> >>> --- a/hw/ppc/spapr.c
> >>> +++ b/hw/ppc/spapr.c
> >>> @@ -1849,7 +1849,7 @@ static void ppc_spapr_init(MachineState *machine)
> >>> machine->cpu_model = kvm_enabled() ? "host" : smc->tcg_default_cpu;
> >>> }
> >>>
> >>> - ppc_cpu_parse_features(machine->cpu_model);
> >>> + spapr_cpu_parse_features(spapr);
> >>>
> >>> spapr_init_cpus(spapr);
> >>>
> >>> @@ -2191,6 +2191,10 @@ static void spapr_machine_initfn(Object *obj)
> >>> " place of standard EPOW events when possible"
> >>> " (required for memory hot-unplug support)",
> >>> NULL);
> >>> +
> >>> + object_property_add(obj, "max-cpu-compat", "str",
> >>> + ppc_compat_prop_get, ppc_compat_prop_set,
> >>> + NULL, &spapr->max_compat_pvr, &error_fatal);
> >>> }
> >>>
> >>> static void spapr_machine_finalizefn(Object *obj)
> >>> diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> >>> index ee5cd14..0319516 100644
> >>> --- a/hw/ppc/spapr_cpu_core.c
> >>> +++ b/hw/ppc/spapr_cpu_core.c
> >>> @@ -18,6 +18,49 @@
> >>> #include "target-ppc/mmu-hash64.h"
> >>> #include "sysemu/numa.h"
> >>>
> >>> +void spapr_cpu_parse_features(sPAPRMachineState *spapr)
> >>> +{
> >>> + /*
> >>> + * Backwards compatibility hack:
> >>> +
> >>> + * CPUs had a "compat=" property which didn't make sense for
> >>> + * anything except pseries. It was replaced by "max-cpu-compat"
> >>> + * machine option. This supports old command lines like
> >>> + * -cpu POWER8,compat=power7
> >>> + * By stripping the compat option and applying it to the machine
> >>> + * before passing it on to the cpu level parser.
> >>> + */
> >>> + gchar **inpieces, **outpieces;
> >>> + int n, i, j;
> >>> + gchar *compat_str = NULL;
> >>> + gchar *filtered_model;
> >>> +
> >>> + inpieces = g_strsplit(MACHINE(spapr)->cpu_model, ",", 0);
> >>> + n = g_strv_length(inpieces);
> >>> + outpieces = g_new0(gchar *, g_strv_length(inpieces));
> >>> +
> >>> + /* inpieces[0] is the actual model string */
> >>> + for (i = 0, j = 0; i < n; i++) {
> >>> + if (g_str_has_prefix(inpieces[i], "compat=")) {
> >>> + compat_str = inpieces[i];
> >>> + } else {
> >>> + outpieces[j++] = g_strdup(inpieces[i]);
> >>> + }
> >>> + }
> >>> +
> >>> + if (compat_str) {
> >>> + char *val = compat_str + strlen("compat=");
> >>> + object_property_set_str(OBJECT(spapr), val, "max-cpu-compat",
> >>> + &error_fatal);
> >>
> >> This part is ok.
> >>
> >>> + }
> >>> +
> >>> + filtered_model = g_strjoinv(",", outpieces);
> >>> + ppc_cpu_parse_features(filtered_model);
> >>
> >>
> >> Rather than reducing the CPU parameters string from the command line, I'd
> >> keep "dc->props = powerpc_servercpu_properties" and make them noop + warn
> >> to use the machine option instead. One day QEMU may start calling the CPU
> >> features parser itself and somebody will have to hack this thing
> >> again.
> >
> > Hrm. A deprecation message like that only works if a human is reading
> > it. Usually qemu will be invoked by libvirt and the message will
> > probably disappear into some log file to scare someone unnecessarily.
> >
> > Meanwhile, what will the actual behaviour be? Pulling the CPU's
> > property value into the machine instead would be really ugly.
> > Ignoring it would break users with existing libvirt.
>
>
> I only suggested instead of removing "compat=" from the model string,
> - pass the model as is to ppc_cpu_parse_features() with no changes;
> - change powerpc_set_compat() to print a message and do nothing else, and
> add a comment there saying why it is so.
Ah, right, now I understand. Yes, that's a good idea. It will
greatly simplify the rather hideous string mangling, too.
> > The hack above is nasty, but I'm not really seeing a better option.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-11-09 5:04 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-30 11:11 [Qemu-devel] [RFC 00/17] Clean up compatibility mode handling David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 01/17] ppc: Remove some stub POWER6 models David Gibson
2016-10-31 7:38 ` Thomas Huth
2016-10-31 8:37 ` David Gibson
2016-11-08 3:40 ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 02/17] powernv: CPU compatibility modes don't make sense for powernv David Gibson
2016-10-31 7:46 ` Thomas Huth
2016-10-31 8:38 ` David Gibson
2016-10-31 10:35 ` Greg Kurz
2016-10-30 11:11 ` [Qemu-devel] [RFC 03/17] pseries: Always use core objects for CPU construction David Gibson
2016-11-03 8:11 ` Alexey Kardashevskiy
2016-11-04 9:51 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2016-11-08 5:34 ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 04/17] pseries: Make cpu_update during CAS unconditional David Gibson
2016-11-03 8:24 ` Alexey Kardashevskiy
2016-11-04 10:45 ` Thomas Huth
2016-11-08 3:44 ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 05/17] ppc: Clean up and QOMify hypercall emulation David Gibson
2016-11-03 8:50 ` Alexey Kardashevskiy
2016-10-30 11:11 ` [Qemu-devel] [RFC 06/17] ppc: Rename cpu_version to compat_pvr David Gibson
2016-11-04 2:26 ` Alexey Kardashevskiy
2016-11-08 3:48 ` David Gibson
2016-11-04 10:51 ` Thomas Huth
2016-10-30 11:11 ` [Qemu-devel] [RFC 07/17] ppc: Rewrite ppc_set_compat() David Gibson
2016-11-04 2:57 ` Alexey Kardashevskiy
2016-11-08 3:49 ` David Gibson
2016-10-30 11:11 ` [Qemu-devel] [RFC 08/17] ppc: Rewrite ppc_get_compat_smt_threads() David Gibson
2016-11-04 3:37 ` Alexey Kardashevskiy
2016-11-08 5:13 ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 09/17] ppc: Validate compatibility modes when setting David Gibson
2016-10-31 5:55 ` Alexey Kardashevskiy
2016-10-31 8:39 ` David Gibson
2016-11-04 3:45 ` Alexey Kardashevskiy
2016-11-08 5:14 ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 10/17] pseries: Rewrite CAS PVR compatibility logic David Gibson
2016-10-31 5:00 ` Alexey Kardashevskiy
2016-10-31 5:44 ` David Gibson
2016-11-10 17:54 ` Michael Roth
2016-11-10 23:50 ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 11/17] ppc: Add ppc_set_compat_all() David Gibson
2016-11-04 4:01 ` Alexey Kardashevskiy
2016-11-08 5:18 ` David Gibson
2016-11-09 1:27 ` Alexey Kardashevskiy
2016-11-09 3:52 ` David Gibson
2016-11-09 5:18 ` Alexey Kardashevskiy
2016-11-10 3:13 ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 12/17] ppc: Migrate compatibility mode David Gibson
2016-11-04 5:58 ` Alexey Kardashevskiy
2016-11-08 5:19 ` David Gibson
2016-11-08 5:51 ` Alexey Kardashevskiy
2016-11-10 1:59 ` David Gibson
2016-11-10 23:55 ` Michael Roth
2016-11-14 1:15 ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 13/17] pseries: Move CPU compatibility property to machine David Gibson
2016-11-04 7:43 ` Alexey Kardashevskiy
2016-11-08 5:26 ` David Gibson
2016-11-08 5:56 ` Alexey Kardashevskiy
2016-11-09 4:41 ` David Gibson [this message]
2016-10-30 11:12 ` [Qemu-devel] [RFC 14/17] pseries: Reset CPU compatibility mode David Gibson
2016-11-04 7:50 ` Alexey Kardashevskiy
2016-10-30 11:12 ` [Qemu-devel] [RFC 15/17] ppc: Check that CPU model stays consistent across migration David Gibson
2016-11-04 7:54 ` Alexey Kardashevskiy
2016-11-08 5:29 ` David Gibson
2016-11-08 6:03 ` Alexey Kardashevskiy
2016-11-09 4:24 ` David Gibson
2016-11-09 6:06 ` Alexey Kardashevskiy
2016-11-09 6:40 ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 16/17] ppc: Remove counter-productive "sanity checks" in migration David Gibson
2016-11-04 5:52 ` Alexey Kardashevskiy
2016-11-08 5:31 ` David Gibson
2016-11-11 18:13 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2016-11-14 2:34 ` Alexey Kardashevskiy
2016-11-14 6:08 ` David Gibson
2016-10-30 11:12 ` [Qemu-devel] [RFC 17/17] pseries: Default to POWER8 compatibility mode David Gibson
2016-10-30 11:58 ` David Gibson
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=20161109044130.GF427@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=aik@ozlabs.ru \
--cc=lvivier@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=nikunj@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.