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

From: Ankur Arora
Date: Wed Aug 30 2023 - 17:18:52 EST


Expose multi-page clearing via clear_pages().

Signed-off-by: Ankur Arora <ankur.a.arora@xxxxxxxxxx>
---
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