[PATCH v2 5/9] x86/clear_page: add clear_pages()

Ankur Arora
2023-08-30T18:50:39Z

Expose multi-page clearing via clear_pages().

Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
---
arch/x86/include/asm/page_64.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
index 56f9adf0e892..1e71570ea987 100644
--- a/arch/x86/include/asm/page_64.h
+++ b/arch/x86/include/asm/page_64.h
@@ -43,9 +43,9 @@ void clear_pages_orig(void *page, unsigned int length);
void clear_pages_rep(void *page, unsigned int length);
void clear_pages_erms(void *page, unsigned int length);

-static inline void clear_page(void *page)
+static inline void clear_pages(void *page, unsigned int nsubpages)
{
- unsigned int length = PAGE_SIZE;
+ unsigned int length = nsubpages * PAGE_SIZE;
/*
* Clean up KMSAN metadata for the pages being cleared. The assembly call
* below clobbers @page, so we perform unpoisoning before it.
@@ -60,6 +60,11 @@ static inline void clear_page(void *page)
: "cc", "memory", "rax", "rcx");
}

+static inline void clear_page(void *page)
+{
+ clear_pages(page, 1);
+}
+
void copy_page(void *to, void *from);

#ifdef CONFIG_X86_5LEVEL
--
2.31.1