diff mbox

kvm x86: release time_page on vcpu destruction

Message ID 1235574511-4571-1-git-send-email-joerg.roedel@amd.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Joerg Roedel Feb. 25, 2009, 3:08 p.m. UTC
Not releasing the time_page causes a leak of that page or the compound
page it is situated in.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kvm/x86.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Comments

Marcelo Tosatti Feb. 25, 2009, 4:13 p.m. UTC | #1
On Wed, Feb 25, 2009 at 04:08:31PM +0100, Joerg Roedel wrote:
> Not releasing the time_page causes a leak of that page or the compound
> page it is situated in.
> 
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> ---
>  arch/x86/kvm/x86.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 8ca100a..a1ecec5 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -4159,6 +4159,11 @@ EXPORT_SYMBOL_GPL(kvm_put_guest_fpu);
>  
>  void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
>  {
> +	if (vcpu->arch.time_page) {
> +		kvm_release_page_dirty(vcpu->arch.time_page);
> +		vcpu->arch.time_page = NULL;
> +	}
> +
>  	kvm_x86_ops->vcpu_free(vcpu);
>  }

Looks good.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity Feb. 26, 2009, 9:54 a.m. UTC | #2
Joerg Roedel wrote:
> Not releasing the time_page causes a leak of that page or the compound
> page it is situated in.
>   

Applied, thanks.
diff mbox

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8ca100a..a1ecec5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4159,6 +4159,11 @@  EXPORT_SYMBOL_GPL(kvm_put_guest_fpu);
 
 void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
 {
+	if (vcpu->arch.time_page) {
+		kvm_release_page_dirty(vcpu->arch.time_page);
+		vcpu->arch.time_page = NULL;
+	}
+
 	kvm_x86_ops->vcpu_free(vcpu);
 }