qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Jiri Denemark <jdenemar@redhat.com>,
	"Collin L . Walling" <walling@linux.vnet.ibm.com>,
	Richard Henderson <rth@twiddle.net>,
	"Jason J . Herne" <jjherne@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH for-2.9 v2 1/2] i386: Replace uint32_t* with FeatureWord on feature getter/setter
Date: Tue, 28 Mar 2017 12:25:57 +0200	[thread overview]
Message-ID: <20170328122557.6e958e83@Igors-MacBook-Pro.local> (raw)
In-Reply-To: <20170327144815.8043-2-ehabkost@redhat.com>

On Mon, 27 Mar 2017 11:48:14 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> Instead of passing a pointer to the feature property getter and
> setter functions, pass a FeatureWord enum so they can perform
> other actions related to the feature flag.
> 
> This will be used to add a new "user_features" field to keep
> track of features that were explicitly set by the user.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  target/i386/cpu.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 7aa762245a..feefa5b8a4 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -3692,15 +3692,17 @@ static void x86_cpu_unrealizefn(DeviceState *dev, Error **errp)
>  }
>  
>  typedef struct BitProperty {
> -    uint32_t *ptr;
> +    FeatureWord w;
>      uint32_t mask;
>  } BitProperty;
>  
>  static void x86_cpu_get_bit_prop(Object *obj, Visitor *v, const char *name,
>                                   void *opaque, Error **errp)
>  {
> +    X86CPU *cpu = X86_CPU(obj);
>      BitProperty *fp = opaque;
> -    bool value = (*fp->ptr & fp->mask) == fp->mask;
> +    uint32_t f = cpu->env.features[fp->w];
> +    bool value = (f & fp->mask) == fp->mask;
>      visit_type_bool(v, name, &value, errp);
>  }
>  
> @@ -3708,6 +3710,7 @@ static void x86_cpu_set_bit_prop(Object *obj, Visitor *v, const char *name,
>                                   void *opaque, Error **errp)
>  {
>      DeviceState *dev = DEVICE(obj);
> +    X86CPU *cpu = X86_CPU(obj);
>      BitProperty *fp = opaque;
>      Error *local_err = NULL;
>      bool value;
> @@ -3724,9 +3727,9 @@ static void x86_cpu_set_bit_prop(Object *obj, Visitor *v, const char *name,
>      }
>  
>      if (value) {
> -        *fp->ptr |= fp->mask;
> +        cpu->env.features[fp->w] |= fp->mask;
>      } else {
> -        *fp->ptr &= ~fp->mask;
> +        cpu->env.features[fp->w] &= ~fp->mask;
>      }
>  }
>  
> @@ -3745,7 +3748,7 @@ static void x86_cpu_release_bit_prop(Object *obj, const char *name,
>   */
>  static void x86_cpu_register_bit_prop(X86CPU *cpu,
>                                        const char *prop_name,
> -                                      uint32_t *field,
> +                                      FeatureWord w,
>                                        int bitnr)
>  {
>      BitProperty *fp;
> @@ -3755,11 +3758,11 @@ static void x86_cpu_register_bit_prop(X86CPU *cpu,
>      op = object_property_find(OBJECT(cpu), prop_name, NULL);
>      if (op) {
>          fp = op->opaque;
> -        assert(fp->ptr == field);
> +        assert(fp->w == w);
>          fp->mask |= mask;
>      } else {
>          fp = g_new0(BitProperty, 1);
> -        fp->ptr = field;
> +        fp->w = w;
>          fp->mask = mask;
>          object_property_add(OBJECT(cpu), prop_name, "bool",
>                              x86_cpu_get_bit_prop,
> @@ -3787,7 +3790,7 @@ static void x86_cpu_register_feature_bit_props(X86CPU *cpu,
>      /* aliases don't use "|" delimiters anymore, they are registered
>       * manually using object_property_add_alias() */
>      assert(!strchr(name, '|'));
> -    x86_cpu_register_bit_prop(cpu, name, &cpu->env.features[w], bitnr);
> +    x86_cpu_register_bit_prop(cpu, name, w, bitnr);
>  }
>  
>  static GuestPanicInformation *x86_cpu_get_crash_info(CPUState *cs)

  reply	other threads:[~2017-03-28 10:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27 14:48 [Qemu-devel] [PATCH for-2.9 v2 0/2] i386: Don't override -cpu options on -cpu host/max Eduardo Habkost
2017-03-27 14:48 ` [Qemu-devel] [PATCH for-2.9 v2 1/2] i386: Replace uint32_t* with FeatureWord on feature getter/setter Eduardo Habkost
2017-03-28 10:25   ` Igor Mammedov [this message]
2017-03-27 14:48 ` [Qemu-devel] [PATCH for-2.9 v2 2/2] i386: Don't override -cpu options on -cpu host/max Eduardo Habkost
2017-03-28 10:31   ` Igor Mammedov
2017-03-28 12:46 ` [Qemu-devel] [PATCH for-2.9 v2 0/2] " Jiri Denemark

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=20170328122557.6e958e83@Igors-MacBook-Pro.local \
    --to=imammedo@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jdenemar@redhat.com \
    --cc=jjherne@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=walling@linux.vnet.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).