From: Jesse <jdutton@neuraliq.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH]: pointer to vmcs getting lost
Date: Fri, 01 Aug 2008 16:36:03 -0700 [thread overview]
Message-ID: <48939DE3.5070504@neuraliq.com> (raw)
In-Reply-To: <20080801232411.GA3486@dmt.cnet>
Thanks for the feedback. Comments inline.
Marcelo Tosatti wrote:
> Hi Jesse,
>
> On Fri, Aug 01, 2008 at 03:18:52PM -0700, Jesse wrote:
>
>> Greetings,
>>
>> I noticed a race condition when running two guests simultaneously and
>> debugging both guests (on 64-bit intel cpus). Periodically I would get
>> errors from the vmread, vmwrite, or vmresume instructions. Some research
>> revealed that these errors were being caused by having an invalid vmcs
>> loaded. Further, I found that the vmcs is a per_cpu variable, which I
>> believe means that any reference to it is invalid after a context
>> switch. (Corrections appreciated). This means that the vmcs must be
>> reloaded each time the process is switched to.
>>
>
> The preempt notifiers will do that for you.
>
Right, but they won't call VMPTRLD. For some reason this matters (for
intel chips), even if the variable ends up back in the same place, as
far as I can tell.
>
>> The patch below fixed the
>> problem for me.
>>
>> This patch does three things.
>> 1. Extends the critical section in __vcpu_run to include the handling of
>> vmexits, where many of the vmread/writes occur.
>> 2. Perform a vcpu_load after we enter the critical section, and after we
>> return from kvm_resched.
>> 3. Move the call to kvm_guest_debug_pre into the critical section
>> (because it calls vmread/write).
>>
>
> Wouldnt it suffice to move ->guest_debug_pre into the non preemptable
> section? http://article.gmane.org/gmane.comp.emulators.kvm.devel/20244
>
Excellent. I hadn't seen that patch yet. However, many of the
vmreads/vmwrites that failed in my testing were in the exit handlers.
And a calling VMPTRLD (in vcpu_load) explicitly on entering the critical
section secures any other vmcs concurrency problems.
> I haven't tested that patch though.
>
>
next prev parent reply other threads:[~2008-08-01 23:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-01 22:18 [PATCH]: pointer to vmcs getting lost Jesse
2008-08-01 23:24 ` Marcelo Tosatti
2008-08-01 23:36 ` Jesse [this message]
2008-08-02 16:31 ` Marcelo Tosatti
2008-08-03 0:11 ` Jesse
2008-08-11 11:48 ` Avi Kivity
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=48939DE3.5070504@neuraliq.com \
--to=jdutton@neuraliq.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.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