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 10/17] pseries: Rewrite CAS PVR compatibility logic
Date: Mon, 31 Oct 2016 16:44:19 +1100 [thread overview]
Message-ID: <20161031054419.GP18226@umbus.fritz.box> (raw)
In-Reply-To: <6605d07b-2db6-0e07-75a6-000946c06713@ozlabs.ru>
[-- Attachment #1: Type: text/plain, Size: 5203 bytes --]
On Mon, Oct 31, 2016 at 04:00:14PM +1100, Alexey Kardashevskiy wrote:
> On 30/10/16 22:12, David Gibson wrote:
> > During boot, PAPR guests negotiate CPU model support with the
> > ibm,client-architecture-support mechanism. The logic to implement this in
> > qemu is very convoluted. This cleans it up to be cleaner, using the new
> > ppc_check_compat() call.
> >
> > The new logic for choosing a compatibility mode is:
> > 1. If the guest lists the CPU's real PVR as supported *AND* no
> > maximum compatibility mode has been requested on the command line
> > then we use "raw" mode - the CPU acts with full capabilities.
> > 2. Otherwise, we pick the most recent compatibility mode which is
> > both supported by the CPU, and is advertised as supported by the
> > guest.
> > I think the original code approximated the same thing, but it's hard to be
> > sure, and I think it had some weird edge cases.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> > hw/ppc/spapr_hcall.c | 107 +++++++++++++++++----------------------------------
> > hw/ppc/trace-events | 2 +-
> > 2 files changed, 37 insertions(+), 72 deletions(-)
> >
> > diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> > index d93f580..3bd6d06 100644
> > --- a/hw/ppc/spapr_hcall.c
> > +++ b/hw/ppc/spapr_hcall.c
> > @@ -895,98 +895,63 @@ static void do_set_compat(CPUState *cs, void *arg)
> > ppc_set_compat(cpu, s->compat_pvr, &s->err);
> > }
> >
> > -#define get_compat_level(cpuver) ( \
> > - ((cpuver) == CPU_POWERPC_LOGICAL_2_05) ? 2050 : \
> > - ((cpuver) == CPU_POWERPC_LOGICAL_2_06) ? 2060 : \
> > - ((cpuver) == CPU_POWERPC_LOGICAL_2_06_PLUS) ? 2061 : \
> > - ((cpuver) == CPU_POWERPC_LOGICAL_2_07) ? 2070 : 0)
> > -
> > -static void cas_handle_compat_cpu(PowerPCCPUClass *pcc, uint32_t pvr,
> > - unsigned max_lvl, unsigned *compat_lvl,
> > - unsigned *compat_pvr)
> > -{
> > - unsigned lvl = get_compat_level(pvr);
> > - bool is205, is206, is207;
> > -
> > - if (!lvl) {
> > - return;
> > - }
> > -
> > - /* If it is a logical PVR, try to determine the highest level */
> > - is205 = (pcc->pcr_supported & PCR_COMPAT_2_05) &&
> > - (lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_05));
> > - is206 = (pcc->pcr_supported & PCR_COMPAT_2_06) &&
> > - ((lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06)) ||
> > - (lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06_PLUS)));
> > - is207 = (pcc->pcr_supported & PCR_COMPAT_2_07) &&
> > - (lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_07));
> > -
> > - if (is205 || is206 || is207) {
> > - if (!max_lvl) {
> > - /* User did not set the level, choose the highest */
> > - if (*compat_lvl <= lvl) {
> > - *compat_lvl = lvl;
> > - *compat_pvr = pvr;
> > - }
> > - } else if (max_lvl >= lvl) {
> > - /* User chose the level, don't set higher than this */
> > - *compat_lvl = lvl;
> > - *compat_pvr = pvr;
> > - }
> > - }
> > -}
> > -
> > -static target_ulong h_client_architecture_support(PowerPCCPU *cpu_,
> > +static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
> > sPAPRMachineState *spapr,
> > target_ulong opcode,
> > target_ulong *args)
> > {
> > target_ulong list = ppc64_phys_to_real(args[0]);
> > target_ulong ov_table;
> > - PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu_);
> > CPUState *cs;
> > - bool cpu_match = false;
> > - unsigned old_compat_pvr = cpu_->compat_pvr;
> > - unsigned compat_lvl = 0, compat_pvr = 0;
> > - unsigned max_lvl = get_compat_level(cpu_->max_compat);
> > - int counter;
> > + bool explicit_match = false; /* Matched the CPU's real PVR */
> > + uint32_t max_compat = cpu->max_compat;
> > + uint32_t best_compat = 0;
> > + int i;
> > sPAPROptionVector *ov5_guest, *ov5_cas_old, *ov5_updates;
> >
> > - /* Parse PVR list */
> > - for (counter = 0; counter < 512; ++counter) {
> > + /*
> > + * We scan the supplied table of PVRs looking for two things
> > + * 1. Is our real CPU PVR in the list?
> > + * 2. What's the "best" listed logical PVR
> > + */
> > + for (i = 0; i < 512; ++i) {
> > uint32_t pvr, pvr_mask;
> >
> > - pvr_mask = ldl_be_phys(&address_space_memory, list);
> > - list += 4;
> > pvr = ldl_be_phys(&address_space_memory, list);
>
>
> LoPAPR: List-entry = 4-byte-mask : 4-byte-PVR-value
>
> This patch changes the order and "cas" fails.
Oops, yes, thanks for the catch.
--
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-10-31 5:45 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 [this message]
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
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=20161031054419.GP18226@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 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).