1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2023 Ventana Micro Systems Inc.
6 #include <linux/linkage.h>
7 #include <linux/export.h>
9 #include <asm/alternative-macros.h>
10 #include <asm/hwcap.h>
11 #include <asm/insn-def.h>
14 #define CBOZ_ALT(order, old, new) \
15 ALTERNATIVE(old, new, 0, \
16 ((order) << 16) | RISCV_ISA_EXT_ZICBOZ, \
17 CONFIG_RISCV_ISA_ZICBOZ)
19 /* void clear_page(void *page) */
20 SYM_FUNC_START(clear_page)
24 * If Zicboz isn't present, or somehow has a block
25 * size larger than 4K, then fallback to memset.
27 CBOZ_ALT(12, "j .Lno_zicboz", "nop")
29 lw a1, riscv_cboz_block_size
34 CBOZ_ALT(11, "bltu a0, a2, .Lzero_loop; ret", "nop; nop")
37 CBOZ_ALT(10, "bltu a0, a2, .Lzero_loop; ret", "nop; nop")
42 CBOZ_ALT(9, "bltu a0, a2, .Lzero_loop; ret", "nop; nop")
51 CBOZ_ALT(8, "bltu a0, a2, .Lzero_loop; ret", "nop; nop")
68 bltu a0, a2, .Lzero_loop
73 SYM_FUNC_END(clear_page)
74 EXPORT_SYMBOL(clear_page)