From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH RFC] KVM: MMU: Don't use RCU for lockless shadow walking
Date: Tue, 24 Apr 2012 17:54:56 +0800 [thread overview]
Message-ID: <4F967870.6080806@linux.vnet.ibm.com> (raw)
In-Reply-To: <4F96703F.4000607@redhat.com>
On 04/24/2012 05:19 PM, Avi Kivity wrote:
>>> Turned out to be simpler than expected. However, I think there's a problem
>>> with make_all_cpus_request() possible reading an incorrect vcpu->cpu.
>>
>>
>> It seems possible.
>>
>> Can we fix it by reading vcpu->cpu when the vcpu is in GUEST_MODE or
>> EXITING_GUEST_MODE (IIRC, in these modes, interrupt is disabled)?
>>
>> Like:
>>
>> if (kvm_vcpu_exiting_guest_mode(vcpu) != OUTSIDE_GUEST_MODE)
>> cpumask_set_cpu(vcpu->cpu, cpus);
>
> I think it is actually okay. We are only vulnerable if lockless shadow
> walk started during prepare_zap_page(), and extends past
> kvm_flush_remote_tlbs(), yes? But in that case, vcpu->cpu is stable
> since local_irq_disable() kills preemption.
>
This case can happen?
VCPU 0 VCPU 1
kvm_for_each_vcpu(i, vcpu, kvm) {
kvm_make_request(req, vcpu);
VCPU1 is running on CPU 1 out of guest mode
cpu = vcpu->cpu;
/* Set ->requests bit before we read ->mode */
smp_mb();
if (cpus != NULL && cpu != -1 && cpu != me &&
VCPU1 is scheduled to CPU 2, and running in
guest mode
kvm_vcpu_exiting_guest_mode(vcpu) != OUTSIDE_GUEST_MODE)
cpumask_set_cpu(cpu, cpus);
}
VCPU 0 send IPI to CPU1, but actually, VCPU1 is running on CPU 2.
next prev parent reply other threads:[~2012-04-24 9:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-23 16:16 [PATCH RFC] KVM: MMU: Don't use RCU for lockless shadow walking Avi Kivity
2012-04-24 1:17 ` Marcelo Tosatti
2012-04-24 9:24 ` Avi Kivity
2012-05-14 12:41 ` Avi Kivity
2012-04-24 6:37 ` Xiao Guangrong
2012-04-24 9:19 ` Avi Kivity
2012-04-24 9:23 ` Avi Kivity
2012-04-24 9:54 ` Xiao Guangrong [this message]
2012-04-24 10:02 ` Avi Kivity
2012-04-24 10:05 ` Xiao Guangrong
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=4F967870.6080806@linux.vnet.ibm.com \
--to=xiaoguangrong@linux.vnet.ibm.com \
--cc=avi@redhat.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;
as well as URLs for NNTP newsgroup(s).