未验证 提交 e25d3df9 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!1625 Fix host zero page refcount overflow caused by kvm

Merge Pull Request from: @ci-robot 
 
PR sync from: Lei Chen <lei.chen@smartx.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/YBB4FWVDSAGSXOH4VTUKE6MMDOJWYADW/ 
v2:
1. using full commit id instead of abbrevation
2. fix wrong mainline tag

Sean Christopherson (1):
  KVM: Don't set Accessed/Dirty bits for ZERO_PAGE

Zhuang Yanying (1):
  KVM: fix overflow of zero page refcount with ksm running


-- 
2.34.1
 
https://gitee.com/openeuler/kernel/issues/I7PQPE?from=project-issue 
 
Link:https://gitee.com/openeuler/kernel/pulls/1625 

Reviewed-by: Kevin Zhu <zhukeqian1@huawei.com> 
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> 
......@@ -170,6 +170,7 @@ bool kvm_is_reserved_pfn(kvm_pfn_t pfn)
*/
if (pfn_valid(pfn))
return PageReserved(pfn_to_page(pfn)) &&
!is_zero_pfn(pfn) &&
!kvm_is_zone_device_pfn(pfn);
return true;
......@@ -1844,20 +1845,28 @@ void kvm_release_pfn_dirty(kvm_pfn_t pfn)
}
EXPORT_SYMBOL_GPL(kvm_release_pfn_dirty);
void kvm_set_pfn_dirty(kvm_pfn_t pfn)
static bool kvm_is_ad_tracked_pfn(kvm_pfn_t pfn)
{
if (!kvm_is_reserved_pfn(pfn) && !kvm_is_zone_device_pfn(pfn)) {
struct page *page = pfn_to_page(pfn);
if (!pfn_valid(pfn))
return false;
if (!PageReserved(page))
SetPageDirty(page);
}
/*
* Per page-flags.h, pages tagged PG_reserved "should in general not be
* touched (e.g. set dirty) except by its owner".
*/
return !PageReserved(pfn_to_page(pfn));
}
void kvm_set_pfn_dirty(kvm_pfn_t pfn)
{
if (kvm_is_ad_tracked_pfn(pfn))
SetPageDirty(pfn_to_page(pfn));
}
EXPORT_SYMBOL_GPL(kvm_set_pfn_dirty);
void kvm_set_pfn_accessed(kvm_pfn_t pfn)
{
if (!kvm_is_reserved_pfn(pfn) && !kvm_is_zone_device_pfn(pfn))
if (kvm_is_ad_tracked_pfn(pfn))
mark_page_accessed(pfn_to_page(pfn));
}
EXPORT_SYMBOL_GPL(kvm_set_pfn_accessed);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册