Commit d755712e authored by Liu Shixin's avatar Liu Shixin Committed by Yongqiang Liu
Browse files

dhugetlb: isolate hwpoison hugepage when release

hulk inclusion
category: bugfix
bugzilla: 46904, https://gitee.com/openeuler/kernel/issues/I6GSKP


CVE: NA

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

For a hwpoison hugetlb page, the page will be freed firstly. If succeed, it
will be dissolved and released to buddy system, then isolate the hwpoison page.

For a hwpoison hugepage belong to dynamic hugetlb, we isolate the hugepage
without dissolve it. Add a check in free_huge_page_to_dhugetlb_pool() to
isolate the hwpoison hugepage directly. And keep HUGETLB_PAGE_DTOR after free
to ensure the PageHuge() check return true in dissolve_free_huge_page().

Fixes: 0f0535e57da("dhugetlb: skip dissolve hugepage belonging to dynamic hugetlb")
Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
parent 77978cd7
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1348,8 +1348,9 @@ static void free_huge_page_to_dhugetlb_pool(struct page *page,
	}

	spin_lock(&hpool->lock);
	if (PageHWPoison(page))
		goto out;
	ClearPagePool(page);
	set_compound_page_dtor(page, NULL_COMPOUND_DTOR);
	if (!hstate_is_gigantic(h)) {
		list_add(&page->lru, &hpool->dhugetlb_2M_freelists);
		hpool->free_reserved_2M++;
@@ -1375,6 +1376,7 @@ static void free_huge_page_to_dhugetlb_pool(struct page *page,
		trace_dhugetlb_alloc_free(hpool, page, hpool->free_reserved_1G,
					  DHUGETLB_FREE_1G);
	}
out:
	spin_unlock(&hpool->lock);
	dhugetlb_pool_put(hpool);
}