From: Greg KH <gregkh@linuxfoundation.org>
To: Zhuang Yanying <ann.zhuangyanying@huawei.com>
Cc: tv@lio96.de, stable@vger.kernel.org, pbonzini@redhat.com,
LinFeng <linfeng23@huawei.com>
Subject: Re: [PATCH 2/2] KVM: special handling of zero_page in some flows
Date: Mon, 30 Mar 2020 15:40:47 +0200 [thread overview]
Message-ID: <20200330134047.GB332213@kroah.com> (raw)
In-Reply-To: <1585575162-37912-3-git-send-email-ann.zhuangyanying@huawei.com>
On Mon, Mar 30, 2020 at 09:32:42PM +0800, Zhuang Yanying wrote:
> From: LinFeng <linfeng23@huawei.com>
>
> Just adding !is_zero_page() to kvm_is_reserved_pfn() is too
> rough. According to commit:e433e83bc3("KVM: MMU: Do not treat
> ZONE_DEVICE pages as being reserved"), special handling in some
> other flows is also need by zero_page, if not treat zero_page as
> being reserved.
>
> Signed-off-by: LinFeng <linfeng23@huawei.com>
> Signed-off-by: Zhuang Yanying <ann.zhuangyanying@huawei.com>
> ---
> arch/x86/kvm/mmu.c | 2 ++
> virt/kvm/kvm_main.c | 6 +++---
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index d9c7e986b4e4..63155e67abf7 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -2826,6 +2826,7 @@ static void transparent_hugepage_adjust(struct kvm_vcpu *vcpu,
> * here.
> */
> if (!is_error_noslot_pfn(pfn) && !kvm_is_reserved_pfn(pfn) &&
> + !is_zero_pfn(pfn) &&
> level == PT_PAGE_TABLE_LEVEL &&
> PageTransCompoundMap(pfn_to_page(pfn)) &&
> !mmu_gfn_lpage_is_disallowed(vcpu, gfn, PT_DIRECTORY_LEVEL)) {
> @@ -4788,6 +4789,7 @@ static bool kvm_mmu_zap_collapsible_spte(struct kvm *kvm,
> */
> if (sp->role.direct &&
> !kvm_is_reserved_pfn(pfn) &&
> + !is_zero_pfn(pfn) &&
> PageTransCompoundMap(pfn_to_page(pfn))) {
> drop_spte(kvm, sptep);
> need_tlb_flush = 1;
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index d49cdd6ca883..ddc8c2a6e206 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1658,7 +1658,7 @@ static struct page *kvm_pfn_to_page(kvm_pfn_t pfn)
> if (is_error_noslot_pfn(pfn))
> return KVM_ERR_PTR_BAD_PAGE;
>
> - if (kvm_is_reserved_pfn(pfn)) {
> + if (kvm_is_reserved_pfn(pfn) && is_zero_pfn(pfn)) {
> WARN_ON(1);
> return KVM_ERR_PTR_BAD_PAGE;
> }
> @@ -1717,7 +1717,7 @@ static void kvm_release_pfn_dirty(kvm_pfn_t pfn)
>
> void kvm_set_pfn_dirty(kvm_pfn_t pfn)
> {
> - if (!kvm_is_reserved_pfn(pfn)) {
> + if (!kvm_is_reserved_pfn(pfn) && !is_zero_pfn(pfn)) {
> struct page *page = pfn_to_page(pfn);
>
> if (!PageReserved(page))
> @@ -1728,7 +1728,7 @@ EXPORT_SYMBOL_GPL(kvm_set_pfn_dirty);
>
> void kvm_set_pfn_accessed(kvm_pfn_t pfn)
> {
> - if (!kvm_is_reserved_pfn(pfn))
> + if (!kvm_is_reserved_pfn(pfn) && !is_zero_pfn(pfn))
> mark_page_accessed(pfn_to_page(pfn));
> }
> EXPORT_SYMBOL_GPL(kvm_set_pfn_accessed);
> --
> 2.23.0
>
>
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
next prev parent reply other threads:[~2020-03-30 13:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-26 17:43 proposing 7df003c85218b5f for v5.5.y, v5.4.y, 4.19.y, v4.14.y, v4.9.y Thomas Voegtle
2020-03-26 18:04 ` Paolo Bonzini
2020-03-26 20:08 ` Thomas Voegtle
2020-03-26 20:15 ` Paolo Bonzini
2020-03-27 7:54 ` Greg KH
2020-03-30 13:32 ` [PATCH 0/2] KVM: fix overflow of zero page refcount with ksm running Zhuang Yanying
2020-03-30 13:32 ` [PATCH 1/2] " Zhuang Yanying
2020-03-30 13:40 ` Greg KH
2020-03-30 13:32 ` [PATCH 2/2] KVM: special handling of zero_page in some flows Zhuang Yanying
2020-03-30 13:40 ` Greg KH [this message]
2020-03-30 13:40 ` [PATCH 0/2] KVM: fix overflow of zero page refcount with ksm running Greg KH
-- strict thread matches above, loose matches on Subject: below --
2020-04-01 12:50 Zhuang Yanying
2020-04-01 12:50 ` [PATCH 2/2] KVM: special handling of zero_page in some flows Zhuang Yanying
2020-04-01 13:00 ` Greg KH
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=20200330134047.GB332213@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=ann.zhuangyanying@huawei.com \
--cc=linfeng23@huawei.com \
--cc=pbonzini@redhat.com \
--cc=stable@vger.kernel.org \
--cc=tv@lio96.de \
/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;
as well as URLs for NNTP newsgroup(s).