qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Jason J. Herne" <jjherne@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Subject: Re: [Qemu-devel] [PATCH 7/7] KVM regsync: Fix do_kvm_cpu_synchronize_state data integrity issue
Date: Thu, 03 Jan 2013 13:48:59 -0500	[thread overview]
Message-ID: <50E5D29B.6060804@linux.vnet.ibm.com> (raw)
In-Reply-To: <133FEF92-3C4F-48C8-BF67-E50066EEEF45@suse.de>

On 01/03/2013 08:56 AM, Alexander Graf wrote:
>> static void do_kvm_cpu_synchronize_state(void *_args)
>> >{
>> >     struct kvm_cpu_syncstate_args *args = _args;
>> >+    CPUArchState *env = args->env;
>> >+    int register_level = args->register_level;
>> >
> This probably becomes more readable if we explicitly revert back to unsynced state first:
>
> /* Write back local modifications at our current level */
> if (register_level > env->kvm_vcpu_dirty) {
>      kvm_arch_put_registers(...);
>      env->kvm_vcpu_dirty = 0;
> }
>
> and then do the sync we are requested to do:
>
> if (!env->kvm_vcpu_dirty) {
>      ...
> }

I agree, but only if we add a second conditional to the if 1st statement 
  as such:

if (args->env->kvm_vcpu_dirty && register_level > env->kvm_vcpu_dirty)

This is to cover the case where the caller is asking for register level 
"1" and we're already dirty at level "2". In this case, nothing should 
happen and we'll need the "args->env->kvm_vcpu_dirty" to ensure that is 
the case.

static void do_kvm_cpu_synchronize_state(void *_args)
{
     struct kvm_cpu_syncstate_args *args = _args;
     CPUArchState *env = args->env;
     int register_level = args->register_level;

     /* Write back local modifications at our current level */
     if (args->env->kvm_vcpu_dirty && register_level > 
env->kvm_vcpu_dirty) {
         kvm_arch_put_registers(env, env->kvm_vcpu_dirty);
         env->kvm_vcpu_dirty = 0;
     }

     if (!args->env->kvm_vcpu_dirty) {
         kvm_arch_get_registers(env, register_level);
         env->kvm_vcpu_dirty = register_level;
     }
}

Do you agree?  Thanks for your time. :)

-- 
-- Jason J. Herne (jjherne@linux.vnet.ibm.com)

  reply	other threads:[~2013-01-03 18:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21 13:56 [Qemu-devel] [PATCH 7/7] KVM regsync: Fix do_kvm_cpu_synchronize_state data integrity issue Jason J. Herne
2013-01-03 13:56 ` Alexander Graf
2013-01-03 18:48   ` Jason J. Herne [this message]
2013-01-03 19:09     ` Alexander Graf
2013-01-04  1:38       ` Marcelo Tosatti
2013-01-04  4:22         ` Bhushan Bharat-R65777
2013-01-04  8:40           ` Alexander Graf
2013-01-04  8:57             ` Bhushan Bharat-R65777
2013-01-04  9:01               ` Alexander Graf
2013-01-04 10:23             ` Bhushan Bharat-R65777
2013-01-04 10:29               ` Alexander Graf
2013-01-04 10:32                 ` Bhushan Bharat-R65777
2013-01-04 10:36                   ` Alexander Graf
2013-01-04 11:01                     ` Bhushan Bharat-R65777
2013-01-04 11:03                       ` Alexander Graf
2013-01-04 15:25                         ` Jason J. Herne
2013-01-04 16:27                           ` Alexander Graf
2013-01-04 17:39                             ` Jason J. Herne
2013-01-06 14:43                               ` Bhushan Bharat-R65777
2013-01-07 15:43                             ` Jason J. Herne
2013-01-07 15:49                               ` Alexander Graf
2013-01-07 18:19                                 ` Jason J. Herne
2013-01-07 18:42                                   ` Alexander Graf

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=50E5D29B.6060804@linux.vnet.ibm.com \
    --to=jjherne@linux.vnet.ibm.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=qemu-devel@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).