All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Razvan Cojocaru <rcojocaru@bitdefender.com>
Cc: tim@xen.org, wei.liu2@citrix.com, george.dunlap@eu.citrix.com,
	andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com,
	George Dunlap <george.dunlap@citrix.com>,
	xen-devel@lists.xen.org, paul.durrant@citrix.com,
	david.vrabel@citrix.com, keir@xen.org
Subject: Re: [for-4.7] x86/emulate: synchronize LOCKed instruction emulation
Date: Wed, 04 May 2016 07:42:00 -0600	[thread overview]
Message-ID: <572A184802000078000E8947@prv-mh.provo.novell.com> (raw)
In-Reply-To: <958968d2-881b-0de1-3844-80a283c46df0@bitdefender.com>

>>> On 04.05.16 at 13:32, <rcojocaru@bitdefender.com> wrote:
> But while implementing a stub that falls back to the actual LOCK CMPXCHG
> and replacing hvm_copy_to_guest_virt() with it would indeed be an
> improvement (with the added advantage of being able to treat
> non-emulated LOCK CMPXCHG cases), I don't understand how that would
> solve the read-modify-write atomicity problem.
> 
> AFAICT, this would only solve the write problem. Assuming we have VCPU1
> and VCPU2 emulating a LOCKed instruction expecting rmw atomicity, the
> stub alone would not prevent this:
> 
> VCPU1: read, modify
> VCPU2: read, modify, write
> VCPU1: write

I'm not sure I follow what you mean here: Does the above represent
what the guest does, or what the hypervisor does as steps to emulate
a _single_ guest instruction? In the former case, I don't see what
you're after. And in the latter case I don't understand why you think
using CMPXCHG instead of WRITE wouldn't help.

Jan

> Moreover, since reads and writes are not synchronized, it would be
> possible for VCPU2's read to occur while VCPU1 writes, and VCPU1 could
> read part of the old data + part of the new data.
> 
> So the problem originally addressed by the patch would still need to be
> addressed like that: with a read / write lock covering all the relevant
> parts of x86_emulate(). Unless I'm mistaken, the stub part is only
> needed to make sure that CMPXCHG alone does not race when a VCPU
> emulates and another does not.
> 
> 
> Thanks,
> Razvan




_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-05-04 13:42 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13 12:26 [for-4.7] x86/emulate: synchronize LOCKed instruction emulation Razvan Cojocaru
2016-04-14  4:35 ` Jan Beulich
2016-04-14  5:56   ` Razvan Cojocaru
2016-04-14  6:09     ` Juergen Gross
2016-04-14  6:31       ` Razvan Cojocaru
2016-04-14  7:46         ` Juergen Gross
2016-04-14  8:01           ` Andrew Cooper
2016-04-14  8:18             ` Juergen Gross
2016-04-14  8:25               ` Razvan Cojocaru
2016-04-14  8:07     ` Andrew Cooper
2016-04-14  8:09       ` Razvan Cojocaru
2016-04-14  9:08     ` Razvan Cojocaru
2016-04-14 15:33       ` Jan Beulich
2016-04-14 15:44     ` Jan Beulich
2016-04-14 16:00       ` Razvan Cojocaru
2016-04-14 16:11         ` Jan Beulich
2016-04-14  8:51   ` Razvan Cojocaru
2016-04-14 15:31     ` Jan Beulich
2016-04-14 15:40       ` Razvan Cojocaru
2016-04-14 10:35 ` David Vrabel
2016-04-14 11:43   ` Razvan Cojocaru
2016-04-14 15:40     ` Jan Beulich
2016-04-14 15:45       ` Razvan Cojocaru
2016-04-14 16:08         ` Jan Beulich
2016-04-18 12:14           ` Razvan Cojocaru
2016-04-18 16:45             ` Jan Beulich
2016-04-19 11:01               ` Razvan Cojocaru
2016-04-19 16:35                 ` Jan Beulich
2016-04-26 16:03                   ` George Dunlap
2016-04-26 17:23                     ` Razvan Cojocaru
2016-04-26 17:39                       ` Andrew Cooper
2016-04-27  6:25                         ` Jan Beulich
2016-04-27  7:36                           ` Andrew Cooper
2016-04-27  6:22                       ` Jan Beulich
2016-04-27  7:14                         ` Razvan Cojocaru
2016-05-03 14:20                           ` Razvan Cojocaru
2016-05-03 14:30                             ` Jan Beulich
2016-05-03 14:41                               ` Razvan Cojocaru
2016-05-03 15:13                                 ` Jan Beulich
2016-05-04 11:32                                   ` Razvan Cojocaru
2016-05-04 13:42                                     ` Jan Beulich [this message]
2016-05-05  9:25                                       ` Razvan Cojocaru
2016-05-05 16:38                                         ` Jan Beulich
2016-04-14 15:45       ` Andrew Cooper
2016-04-14 16:09         ` Jan Beulich
2016-05-13 15:27 ` Wei Liu
2016-05-13 15:51   ` Jan Beulich

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=572A184802000078000E8947@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=keir@xen.org \
    --cc=paul.durrant@citrix.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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 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.