[PATCH 9/8] memblock tests: add stubs required for free_reserved_area()

Mike Rapoport
2026-03-18T20:52:41Z

After moving free_reserved_area() function to mm/memblock.c memblock
tests lack stubs for several functions and macros this function calls.

Add them.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
tools/include/linux/mm.h | 1 +
tools/testing/memblock/internal.h | 28 +++++++++++++++++++++++++---
2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/tools/include/linux/mm.h b/tools/include/linux/mm.h
index 028f3faf46e7..4407d8396108 100644
--- a/tools/include/linux/mm.h
+++ b/tools/include/linux/mm.h
@@ -17,6 +17,7 @@

#define __va(x) ((void *)((unsigned long)(x)))
#define __pa(x) ((unsigned long)(x))
+#define __pa_symbol(x) ((unsigned long)(x))

#define pfn_to_page(pfn) ((void *)((pfn) * PAGE_SIZE))

diff --git a/tools/testing/memblock/internal.h b/tools/testing/memblock/internal.h
index 009b97bbdd22..7ff61172ab24 100644
--- a/tools/testing/memblock/internal.h
+++ b/tools/testing/memblock/internal.h
@@ -11,9 +11,16 @@ static int memblock_debug = 1;

#define pr_warn_ratelimited(fmt, ...) printf(fmt, ##__VA_ARGS__)

+#define K(x) ((x) << (PAGE_SHIFT-10))
+
bool mirrored_kernelcore = false;

struct page {};
+static inline void *page_address(struct page *page)
+{
+ BUG();
+ return page;
+}

void memblock_free_pages(unsigned long pfn, unsigned int order)
{
@@ -23,10 +30,25 @@ static inline void accept_memory(phys_addr_t start, unsigned long size)
{
}

-static inline unsigned long free_reserved_area(void *start, void *end,
- int poison, const char *s)
+unsigned long free_reserved_area(void *start, void *end, int poison, const char *s);
+void free_reserved_page(struct page *page);
+
+static inline bool deferred_pages_enabled(void)
+{
+ return false;
+}
+
+#define for_each_valid_pfn(pfn, start_pfn, end_pfn) \
+ for ((pfn) = (start_pfn); (pfn) < (end_pfn); (pfn)++)
+
+static inline void *kasan_reset_tag(const void *addr)
+{
+ return (void *)addr;
+}
+
+static inline bool __is_kernel(unsigned long addr)
{
- return 0;
+ return false;
}

#endif
--
2.51.0