From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
To: Andrea Bolognani <abologna@redhat.com>, qemu-ppc@nongnu.org
Cc: paulus@ozlabs.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au
Subject: Re: [Qemu-devel] [Qemu-ppc] [QEMU-PPC] [RFC 1/3] hw/ppc/spapr_caps: Rework spapr_caps to use uint8 internal representation
Date: Wed, 10 Jan 2018 11:19:33 +1100 [thread overview]
Message-ID: <1515543573.1993.10.camel@gmail.com> (raw)
In-Reply-To: <1515499621.3287.17.camel@redhat.com>
On Tue, 2018-01-09 at 13:07 +0100, Andrea Bolognani wrote:
> On Tue, 2018-01-09 at 20:21 +1100, Suraj Jitindar Singh wrote:
> [...]
> > +static void cap_htm_allow(sPAPRMachineState *spapr, uint8_t val,
> > Error **errp)
> > +{
> > + if (!val) {
> > + /* TODO: We don't support disabling htm yet */
> > + return;
> > + }
> > if (tcg_enabled()) {
> > error_setg(errp,
> > - "No Transactional Memory support in TCG, try
> > cap-htm=off");
> > + "No Transactional Memory support in TCG, try
> > cap-htm=0");
> > } else if (kvm_enabled() && !kvmppc_has_cap_htm()) {
> > error_setg(errp,
> > -"KVM implementation does not support Transactional Memory, try
> > cap-htm=off"
> > +"KVM implementation does not support Transactional Memory, try
> > cap-htm=0"
> > );
> > }
> > }
>
> Changing the command-line interface from off/on to 0/1 seems
> unnecessary, given that broken/workaround/fixed are used for the
> capabilities you introduce later in the series. off/on look much
> better IMHO.
These are booleans so they have to be "on"/"off" anyway... 0/1 doesn't
work. My bad :/ I'll fix the message.
>
> [...]
> > -static bool spapr_caps_needed(void *opaque)
> > -{
> > - sPAPRMachineState *spapr = opaque;
> > -
> > - return (spapr->forced_caps.mask != 0) || (spapr-
> > >forbidden_caps.mask != 0);
> > -}
> > -
> > /* This has to be called from the top-level spapr post_load, not
> > the
> > * caps specific one. Otherwise it wouldn't be called when the
> > source
> > * caps are all defaults, which could still conflict with
> > overridden
> > * caps on the destination */
> > int spapr_caps_post_migration(sPAPRMachineState *spapr)
> > {
> > - uint64_t allcaps = 0;
> > int i;
> > bool ok = true;
> > sPAPRCapabilities dstcaps = spapr->effective_caps;
> > sPAPRCapabilities srccaps;
> >
> > srccaps = default_caps_with_cpu(spapr, first_cpu);
> > - srccaps.mask |= spapr->mig_forced_caps.mask;
> > - srccaps.mask &= ~spapr->mig_forbidden_caps.mask;
> > + for (i = 0; i < SPAPR_CAP_NUM; i++) {
> > + if (spapr->mig_caps.caps[i] & SPAPR_CAP_CMD_LINE) {
> > + srccaps.caps[i] = spapr->mig_caps.caps[i] &
> > ~SPAPR_CAP_CMD_LINE;
> > + }
> > + }
> >
> > - for (i = 0; i < ARRAY_SIZE(capability_table); i++) {
> > + for (i = 0; i < SPAPR_CAP_NUM; i++) {
> > sPAPRCapabilityInfo *info = &capability_table[i];
> >
> > - allcaps |= info->flag;
> > -
> > - if ((srccaps.mask & info->flag) && !(dstcaps.mask & info-
> > >flag)) {
> > - error_report("cap-%s=on in incoming stream, but off in
> > destination",
> > - info->name);
> > + if (srccaps.caps[i] > dstcaps.caps[i]) {
> > + error_report("cap-%s higher level (%d) in incoming
> > stream than on destination (%d)",
> > + info->name, srccaps.caps[i],
> > dstcaps.caps[i]);
> > ok = false;
> > }
> >
> > - if (!(srccaps.mask & info->flag) && (dstcaps.mask & info-
> > >flag)) {
> > - warn_report("cap-%s=off in incoming stream, but on in
> > destination",
> > - info->name);
> > + if (srccaps.caps[i] < dstcaps.caps[i]) {
> > + warn_report("cap-%s lower level (%d) in incoming
> > stream than on destination (%d)",
> > + info->name, srccaps.caps[i],
> > dstcaps.caps[i]);
> > }
> > }
>
> These numeric comparisons make me feel very uneasy :)
>
> What if we need to add more possible values down the line? Should
> there be at least some room between existing values to avoid painting
> ourselves in a corner? Eg. instead of using 0/1/2 use 20/40/60...
>
> You clearly know more about the problem than I do, so feel free to
> dismiss all of the above... I thought I would bring up my worries
> just in case :)
For these capabilities I think we're ok to keep it as 0/1/2. In the
event we need a bigger range another capability can be added with other
possible values which was the whole point of introducing this generic
framework. The basic idea is the receiving side must always support a
higher "level" than the source.
With these new capabilities it's more likely we'll have to add an
entirly new one than require more possible values. :)
It could even be possible to have a per capability comparison function
to confirm compatibility in future. But again thats an exercise for
when/if more complex capabilities are added.
>
next prev parent reply other threads:[~2018-01-10 0:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 9:21 [Qemu-devel] [QEMU-PPC] [RFC 0/3] target/ppc: Rework spapr_caps Suraj Jitindar Singh
2018-01-09 9:21 ` [Qemu-devel] [QEMU-PPC] [RFC 1/3] hw/ppc/spapr_caps: Rework spapr_caps to use uint8 internal representation Suraj Jitindar Singh
2018-01-09 11:13 ` [Qemu-devel] [Qemu-ppc] " Murilo Opsfelder Araújo
2018-01-10 0:21 ` Suraj Jitindar Singh
2018-01-09 12:07 ` Andrea Bolognani
2018-01-10 0:19 ` Suraj Jitindar Singh [this message]
2018-01-10 2:51 ` David Gibson
2018-01-10 4:13 ` [Qemu-devel] " David Gibson
2018-01-12 2:19 ` Suraj Jitindar Singh
2018-01-09 9:21 ` [Qemu-devel] [QEMU-PPC] [RFC 2/3] hw/spapr/spapr_caps: Add new caps safe_[cache/bounds_check/indirect_branch] Suraj Jitindar Singh
2018-01-09 11:15 ` [Qemu-devel] [Qemu-ppc] " Murilo Opsfelder Araújo
2018-01-10 0:25 ` Suraj Jitindar Singh
2018-01-09 12:02 ` [Qemu-devel] " joserz
2018-01-10 0:23 ` Suraj Jitindar Singh
2018-01-10 4:54 ` David Gibson
2018-01-09 9:21 ` [Qemu-devel] [QEMU-PPC] [RFC 3/3] target/ppc: Add H-Call H_GET_CPU_CHARACTERISTICS Suraj Jitindar Singh
2018-01-09 11:19 ` [Qemu-devel] [Qemu-ppc] " Murilo Opsfelder Araújo
2018-01-10 0:26 ` Suraj Jitindar Singh
2018-01-10 5:02 ` [Qemu-devel] " 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=1515543573.1993.10.camel@gmail.com \
--to=sjitindarsingh@gmail.com \
--cc=abologna@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=paulus@ozlabs.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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).