Re: [PATCH] KVM: MMU: fix huge page adapted on non-PAE host

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 28, 2012 at 05:20:02PM +0300, Avi Kivity wrote:
> The "right thing" we should be doing is running get_page() on every
> small page within the frame (we asked for a small page but are
> opportunistrically using the pages around it, without a proper ref).
> That's a bit slow though, so we cheat.

The problem is that we're aligning the pfn. The refcount move just
follows the pfn alignment. The spte setting I think need the correct
aligned pfn that matches the hugepmd NPT/EPT alignment.

So then we're moving the pfn refcount too, otherwise
kvm_release_pfn_clean then would run on a different pfn than the one
that was returned by gup-fast.

If we would drop the refcount before calling __direct_map or use a
gup-fast that doesn't even take a pin, we wouldn't need to move the
refcount and we could only free the page (without having to do a
get_page).

> But I guess we can start with your fix.  But what about shifting mask by
> one bit?  Isn't it sufficient?
> 
> -		mask = KVM_PAGES_PER_HPAGE(level) - 1;
> +		mask = KVM_PAGES_PER_HPAGE(level);
> +		mask *= KVM_HOST_HPAGES_PER_HPAGE;
> +		mask -= 1;
> 
> This should move the reference to the right place.

The pfn passed to mmu_set_spte then would then be aligned at 4M
despite the NTP/EPT size is 2M, so I doubt it would be ok. The real
thing to check here is that the pfn passed is correct. The refcount
just follows.

Just doing s/get_page_unless_zero()/get_page()/ should work I
think. And good thing there's no chance to get this wrong by testing,
it either boots or doesn't boot.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux