Skip to content

Commit

Permalink
KVM: MMU: handle compound pages in kvm_is_mmio_pfn
Browse files Browse the repository at this point in the history
The function kvm_is_mmio_pfn is called before put_page is called on a
page by KVM. This is a problem when when this function is called on some
struct page which is part of a compund page. It does not test the
reserved flag of the compound page but of the struct page within the
compount page. This is a problem when KVM works with hugepages allocated
at boot time. These pages have the reserved bit set in all tail pages.
Only the flag in the compount head is cleared. KVM would not put such a
page which results in a memory leak.

Signed-off-by: Joerg Roedel <[email protected]>
Acked-by: Marcelo Tosatti <[email protected]>
Signed-off-by: Avi Kivity <[email protected]>
  • Loading branch information
Joerg Roedel authored and avikivity committed Mar 24, 2009
1 parent c807660 commit fc5659c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,10 @@ static inline int valid_vcpu(int n)

inline int kvm_is_mmio_pfn(pfn_t pfn)
{
if (pfn_valid(pfn))
return PageReserved(pfn_to_page(pfn));
if (pfn_valid(pfn)) {
struct page *page = compound_head(pfn_to_page(pfn));
return PageReserved(page);
}

return true;
}
Expand Down

0 comments on commit fc5659c

Please sign in to comment.