qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yu Ning <yu.ning@linux.intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Vincent Palatin <vpalatin@chromium.org>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Stefan Weil <sw@weilnetz.de>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v5 3/4] Plumb the HAXM-based hardware acceleration support
Date: Mon, 9 Jan 2017 14:17:43 +0800	[thread overview]
Message-ID: <7e2bab8d-fcb4-c861-c1b5-f85c5df674b6@linux.intel.com> (raw)
In-Reply-To: <61d18d9c-32f1-983f-c237-3c28d31e2f23@redhat.com>



On 1/6/2017 5:38, Paolo Bonzini wrote:
>
> On 05/01/2017 15:01, Paolo Bonzini wrote:
>>
>> In fact there is a race anyway:
>>
>>          if (cpu->exit_request) {
>>              ret = 1;
>>              break;
>>          }
>> 					cpu->exit_request
>> 					SuspendThread
>> 					ResumeThread
>>          hax_vcpu_interrupt(env);
>>          qemu_mutex_unlock_iothread();
>>          hax_ret = hax_vcpu_run(vcpu);
>>
>> and the same race is true for QueueUserAPC.  It's rare enough that I
>> guess we can accept the patches with just a FIXME comment, but...  Yu
>> Ning, can you tell us what user_event_pending is for? :)  My hunch is
>> that we should call hax_raise_event after setting cpu->exit_request, like
>>
>> 	hax_raise_event();
>> 	/* write user_event_pending before exit_request */
>> 	smp_wmb();
>> 	cpu->exit_request = 1;
>> 	SuspendThread/ResumeThread
>> 		(or QueueUserAPC)
>>
>> and in the hax thread:
>>
>>          if (cpu->exit_request) {
>> 	    cpu->hax_vcpu->tunnel->user_event_pending = 0;
>>              ret = 1;
>>              break;
>>          }
>>
>>          hax_vcpu_interrupt(env);
>>          qemu_mutex_unlock_iothread();
>>
>> 	/* read exit_request before user_event_pending */
>> 	smp_rmb();
>>          hax_ret = hax_vcpu_run(vcpu);
>>
>> but I would like some more official documentation than my own reverse
>> engineering of the brain of whoever wrote the interface (I have not
>> looked at the HAXM driver binary).

Unfortunately, user_event_pending was introduced in 2011 without proper 
documentation, so I guess even the original author might not have an 
answer now (even if I could find him).  I need more time to analyze the 
HAXM driver code to understand what it's about.  Please feel free to add 
a FIXME for now.

But one thing I've noticed is that the Darwin driver does not test or 
reset this flag properly - it will remain 1 after the first 
hax_raise_event() call.  So removing user_event_pending from the QEMU 
side should not affect Mac.

  parent reply	other threads:[~2017-01-09  6:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19 16:24 [Qemu-devel] [PATCH v5 0/4] Add HAX support Vincent Palatin
2016-12-19 16:24 ` [Qemu-devel] [PATCH v5 1/4] kvm: move cpu synchronization code Vincent Palatin
2016-12-19 16:24 ` [Qemu-devel] [PATCH v5 2/4] target-i386: Add Intel HAX files Vincent Palatin
2016-12-19 16:24 ` [Qemu-devel] [PATCH v5 3/4] Plumb the HAXM-based hardware acceleration support Vincent Palatin
2016-12-22  9:57   ` Paolo Bonzini
2017-01-05 13:50     ` Vincent Palatin
2017-01-05 14:01       ` Paolo Bonzini
2017-01-05 21:38         ` Paolo Bonzini
2017-01-06 14:08           ` Vincent Palatin
2017-01-09 13:03             ` Paolo Bonzini
2017-01-09 16:54               ` Vincent Palatin
2017-01-09  6:17           ` Yu Ning [this message]
2016-12-19 16:24 ` [Qemu-devel] [PATCH v5 4/4] hax: add Darwin support Vincent Palatin
2016-12-22  9:49   ` Paolo Bonzini
2017-01-05 13:50     ` Vincent Palatin

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=7e2bab8d-fcb4-c861-c1b5-f85c5df674b6@linux.intel.com \
    --to=yu.ning@linux.intel.com \
    --cc=ehabkost@redhat.com \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    --cc=vpalatin@chromium.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).