From: Gleb Natapov <gleb@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm <kvm@vger.kernel.org>, Paolo Bonzini <pbonzini@redhat.com>,
Ulrich Obergfell <uobergfe@redhat.com>
Subject: Re: KVM: MMU: make kvm_mmu_available_pages robust against n_used_mmu_pages > n_max_mmu_pages
Date: Wed, 13 Mar 2013 11:46:20 +0200 [thread overview]
Message-ID: <20130313094619.GH11223@redhat.com> (raw)
In-Reply-To: <20130313013642.GA20722@amt.cnet>
On Tue, Mar 12, 2013 at 10:36:43PM -0300, Marcelo Tosatti wrote:
>
> As noticed by Ulrich Obergfell <uobergfe@redhat.com>, the mmu
> counters are for beancounting purposes only - so n_used_mmu_pages and
> n_max_mmu_pages could be relaxed (example: before f0f5933a1626c8df7b),
> resulting in n_used_mmu_pages > n_max_mmu_pages.
>
> Make code robust against n_used_mmu_pages > n_max_mmu_pages.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
Applied, thanks.
> diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
> index 6987108..3b1ad00 100644
> --- a/arch/x86/kvm/mmu.h
> +++ b/arch/x86/kvm/mmu.h
> @@ -57,8 +57,11 @@ int kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context);
>
> static inline unsigned int kvm_mmu_available_pages(struct kvm *kvm)
> {
> - return kvm->arch.n_max_mmu_pages -
> - kvm->arch.n_used_mmu_pages;
> + if (kvm->arch.n_max_mmu_pages > kvm->arch.n_used_mmu_pages)
> + return kvm->arch.n_max_mmu_pages -
> + kvm->arch.n_used_mmu_pages;
> +
> + return 0;
> }
>
> static inline void kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
--
Gleb.
prev parent reply other threads:[~2013-03-13 9:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-13 1:36 KVM: MMU: make kvm_mmu_available_pages robust against n_used_mmu_pages > n_max_mmu_pages Marcelo Tosatti
2013-03-13 5:17 ` Xiao Guangrong
2013-03-13 9:46 ` Gleb Natapov [this message]
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=20130313094619.GH11223@redhat.com \
--to=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=uobergfe@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.