From: Avi Kivity <avi@qumranet.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: "Richard W.M. Jones" <rjones@redhat.com>,
kvm-devel <kvm@vger.kernel.org>
Subject: Re: KVM: MMU: nuke shadowed pgtable pages and pte's on memslot destruction
Date: Sun, 06 Jul 2008 00:15:56 +0300 [thread overview]
Message-ID: <486FE48C.7030002@qumranet.com> (raw)
In-Reply-To: <20080705192344.GA16596@dmt.cnet>
Marcelo Tosatti wrote:
> On Sat, Jul 05, 2008 at 08:25:30PM +0300, Avi Kivity wrote:
>
>>> @@ -1955,6 +1955,22 @@ void kvm_mmu_slot_remove_write_access(st
>>> }
>>> }
>>> +int kvm_mmu_slot_has_shadowed_page(struct kvm *kvm, int slot)
>>> +{
>>> + struct kvm_mmu_page *sp;
>>> + int ret = 0;
>>> +
>>> + spin_lock(&kvm->mmu_lock);
>>> + list_for_each_entry(sp, &kvm->arch.active_mmu_pages, link) {
>>> + if (test_bit(slot, &sp->slot_bitmap)) {
>>> + ret = -EINVAL;
>>> + break;
>>> + }
>>> + }
>>> + spin_unlock(&kvm->mmu_lock);
>>> + return ret;
>>> +}
>>> +
>>>
>>>
>> I don't like the guest influencing host actions in this way. It's just
>> a guest.
>>
>> But I think it's unneeded. kvm_mmu_zap_page() will mark a root shadow
>> page invalid and force all vcpus to reload it, so all that's needed is
>> to keep the mmu spinlock held while removing the slot.
>>
>
> You're still keeping a shadowed page around with sp->gfn pointing to
> non-existant memslot. The code generally makes the assumption that
> gfn_to_memslot(gfn) on shadowed info will not fail.
>
> kvm_mmu_zap_page -> unaccount_shadowed, for example.
>
>
The page has already been zapped, so we might as well
unaccount_shadowed() on the first run. It needs to be moved until after
the reload_remote_mmus() call, though.
> The other option is to harden gfn_to_memslot() callers to handle
> failure, is that saner?
>
I don't think so.
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
next prev parent reply other threads:[~2008-07-05 21:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-04 1:06 KVM: MMU: nuke shadowed pgtable pages and pte's on memslot destruction Marcelo Tosatti
2008-07-05 17:25 ` Avi Kivity
2008-07-05 19:23 ` Marcelo Tosatti
2008-07-05 21:15 ` Avi Kivity [this message]
2008-07-07 17:31 ` Marcelo Tosatti
2008-07-07 19:58 ` Marcelo Tosatti
2008-07-10 14:42 ` Avi Kivity
2008-07-10 18:58 ` Hollis Blanchard
2008-07-10 23:49 ` Marcelo Tosatti
2008-07-11 14:48 ` Avi Kivity
2008-07-21 21:03 ` Hollis Blanchard
2008-07-21 21:34 ` Marcelo Tosatti
2008-07-21 22:22 ` Hollis Blanchard
2008-07-22 5:18 ` Avi Kivity
2008-07-10 23:54 ` Marcelo Tosatti
2008-07-11 15:09 ` 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=486FE48C.7030002@qumranet.com \
--to=avi@qumranet.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=rjones@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