提交 c1bf5440 编写于 作者: M Min Fanlei 提交者: guzitao

sw64: kvm: fix incorrect page_ref_count() call

Sunway inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I56WV8

--------------------------------

The last page_ref_count() call will cause kernel panic if
kvm memory pool is at the end of DRAM. This patch reorders
the checks to avoid illegal atomic_read operation.
Signed-off-by: NMin Fanlei <minfanlei@wxiat.com>
Signed-off-by: NGu Zitao <guzitao@wxiat.com>
上级 aadce492
...@@ -1026,8 +1026,7 @@ static int __init sw64_kvm_pool_init(void) ...@@ -1026,8 +1026,7 @@ static int __init sw64_kvm_pool_init(void)
end_page = pfn_to_page((kvm_mem_base + kvm_mem_size - 1) >> PAGE_SHIFT); end_page = pfn_to_page((kvm_mem_base + kvm_mem_size - 1) >> PAGE_SHIFT);
p = base_page; p = base_page;
while (page_ref_count(p) == 0 && while (p <= end_page && page_ref_count(p) == 0) {
(unsigned long)p <= (unsigned long)end_page) {
set_page_count(p, 1); set_page_count(p, 1);
page_mapcount_reset(p); page_mapcount_reset(p);
SetPageReserved(p); SetPageReserved(p);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册