public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Joerg Roedel <joerg.roedel@amd.com>
Cc: Avi Kivity <avi@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] kvm mmu: handle compound pages in kvm_is_mmio_pfn
Date: Wed, 18 Feb 2009 15:10:02 -0300	[thread overview]
Message-ID: <20090218181002.GD25719@amt.cnet> (raw)
In-Reply-To: <1234962540-7131-2-git-send-email-joerg.roedel@amd.com>



BTW some page bits are erroneously transferred to the struct page's
within the compound page. We've got away with that so far because
these bits (such as dirty and accessed) are not used by the limited
hugetlb/hugetlbfs implementation ATM.

Acked-by: Marcelo Tosatti <mtosatti@redhat.com>

On Wed, Feb 18, 2009 at 02:08:58PM +0100, Joerg Roedel wrote:
> 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>
> ---
>  virt/kvm/kvm_main.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 266bdaf..0ed662d 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -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;
>  }


  reply	other threads:[~2009-02-18 18:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-18 13:08 [PATCH 0/3] KVM SoftMMU fixes Joerg Roedel
2009-02-18 13:08 ` [PATCH 1/3] kvm mmu: handle compound pages in kvm_is_mmio_pfn Joerg Roedel
2009-02-18 18:10   ` Marcelo Tosatti [this message]
2009-02-18 13:08 ` [PATCH 2/3] kvm mmu: remove redundant check in mmu_set_spte Joerg Roedel
2009-02-18 18:38   ` Marcelo Tosatti
2009-02-18 13:09 ` [PATCH 3/3] kvm mmu: alloc shadow pages with __GFP_ZERO Joerg Roedel
2009-02-18 13:47   ` Avi Kivity
2009-02-18 13:54     ` Joerg Roedel
2009-02-18 14:03       ` Avi Kivity
2009-02-18 14:10         ` Joerg Roedel
2009-02-18 14:14           ` Avi Kivity
2009-02-18 18:42       ` Marcelo Tosatti

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=20090218181002.GD25719@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=joerg.roedel@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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