riscv: mm: define copy_user_page() as copy_page()
PATCH 1/1 riscv: mm: define copy_user_page() as copy_page()
Currently, the implementation of copy_user_page() is identical to copy_page().
Align riscv with other architectures (alpha, arc, arm64, hexagon, longarch, m68k, openrisc, s390, um, xtensa) and map copy_user_page() to copy_page() given that their implementation is identical.
In addition to following a common pattern, this centralizes the implementation. Any changes to the underlying page copy logic (e.g., for CHERI) will now automatically propagate to copy_user_page().
--- arch/riscv/include/asm/page.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/riscv/include/asm/page.h +1 -2
@@ -51,8 +51,7 @@ void clear_page(void *page);#define copy_page (to, from) memcpy((to), (from), PAGE_SIZE)#define clear_user_page (pgaddr, vaddr, page) clear_page(pgaddr) -#define copy_user_page (vto, vfrom, vaddr, topg) \ - memcpy((vto), (vfrom), PAGE_SIZE) +#define copy_user_page (vto, vfrom, vaddr, topg) copy_page(vto, vfrom)/* * Use struct definitions to apply C type checking
Signature · 1 line
2.52.0
Hello,
2026년 1월 13일 (화) 오후 10:42, Florian Schmaus <[email protected]>님이 작성:
Quoted 22 lines
Currently, the implementation of
copy_user_page()is identical tocopy_page().Align riscv with other architectures (alpha, arc, arm64, hexagon, longarch, m68k, openrisc, s390, um, xtensa) and map
copy_user_page()tocopy_page()given that their implementation is identical.In addition to following a common pattern, this centralizes the implementation. Any changes to the underlying page copy logic (e.g., for CHERI) will now automatically propagate to
copy_user_page().Signed-off-by Florian Schmaus <[email protected]>--- arch/riscv/include/asm/page.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/riscv/include/asm/page.h +0
-0
arch/riscv/include/asm/page.h void clear_page(void *page); · line 54
Quoted 6 lines
arch/riscv/include/asm/page.h +1
-2@@ -51,8 +51,7 @@ void clear_page(void *page);#define copy_page (to, from) memcpy((to), (from), PAGE_SIZE)#define clear_user_page (pgaddr, vaddr, page) clear_page(pgaddr) -#define copy_user_page (vto, vfrom, vaddr, topg) \ - memcpy((vto), (vfrom), PAGE_SIZE) +#define copy_user_page (vto, vfrom, vaddr, topg) copy_page(vto, vfrom)
Here are the observation over this patch:
1. After compiling with 'CROSS_COMPILE=riscv64-linux-gnu-' option, the following is the corresponding statement for copy_user_page() in preprocessed file.
do { do { __attribute__((__noreturn__)) extern void__compiletime_assert_333(void) __attribute__((__error__("BUILD_BUG_ON
failed: " "__same_type((vto), struct page *)"))); if (!(!(__builtin_types_compatible_p(typeof((vto)), typeof(struct page *))))) __compiletime_assert_333(); } while (0); __kunmap_atomic(vto); } while (0);
Output is the same - before/after patch: That means that the generated risc-v instruction is the same.
2. copy_user_page() is only used in dax file system (fs/dax.c)
3. With the new patch, the full compilation for all of the code happens.
BR,
Austin Kim
Quoted 11 lines
arch/riscv/include/asm/page.h +0
-1/* * Use struct definitions to apply C type checking -- 2.52.0
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv