Re: KVM: MMU: nuke shadowed pgtable pages and pte's on memslot destruction

Hollis Blanchard
2008-07-10T18:58:38Z

On Thu, 2008-07-10 at 17:42 +0300, Avi Kivity wrote:
>
> > During RH6.2 graphical installation the following oops is triggered:
> >
> > BUG: unable to handle kernel NULL pointer dereference at
> 0000000000000000
> > IP: [<ffffffffa00bf172>] :kvm:gfn_to_rmap+0x3e/0x61
> > Pid: 4559, comm: qemu-system-x86 Not tainted
> >
> > The problem is that KVM allows shadow pagetable entries that
> > point to a removed memslot to exist. In this case the cirrus vram
> > mapping was removed, and the NULL dereference happened during
> > kvm_set_memory_alias()'s zap_all_pages().
> >
> > So nuke all shadowed pages before memslot removal.
> >
> > Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> >
> >
> > diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
> > index a4cf4a2..76259da 100644
> > --- a/arch/ia64/kvm/kvm-ia64.c
> > +++ b/arch/ia64/kvm/kvm-ia64.c
> > @@ -1455,6 +1455,10 @@ int kvm_arch_set_memory_region(struct kvm
> *kvm,
> > return 0;
> > }
> >
> > +int kvm_arch_destroy_memory_region(struct kvm *kvm, int slot)
> > +{
> > + return 0;
> > +}
> >
> >
>
> This (and its friends) ought to be static inlines.
>
> On the other hand, don't the other arches have to flush their tlbs?
> Xiantao/Hollis? So maybe this function needs to be renamed
> kvm_flush_shadow() and implemented across the board.

Agreed, I think that's the right approach.

--
Hollis Blanchard
IBM Linux Technology Center