aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2009-02-18 08:08:58 -0500
committerAvi Kivity <avi@redhat.com>2009-03-24 05:03:09 -0400
commitfc5659c8c6b6c4e02ac354b369017c1bf231f347 (patch)
tree2bb99ec223f50f7a92e4b7db8262e7c83b4fa78e /virt
parentc807660407a695f390034e402edfe544a1d2e40c (diff)
KVM: MMU: handle compound pages in kvm_is_mmio_pfn
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 <joerg.roedel@amd.com> Acked-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 266bdaf0ce4..0ed662dc72d 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -535,8 +535,10 @@ static inline int valid_vcpu(int n)
535 535
536inline int kvm_is_mmio_pfn(pfn_t pfn) 536inline int kvm_is_mmio_pfn(pfn_t pfn)
537{ 537{
538 if (pfn_valid(pfn)) 538 if (pfn_valid(pfn)) {
539 return PageReserved(pfn_to_page(pfn)); 539 struct page *page = compound_head(pfn_to_page(pfn));
540 return PageReserved(page);
541 }
540 542
541 return true; 543 return true;
542} 544}