Skip to content

Commit f0616ab

Browse files
reijiw-kvmctmarinas
authored andcommitted
arm64: clear_page() shouldn't use DC ZVA when DCZID_EL0.DZP == 1
Currently, clear_page() uses DC ZVA instruction unconditionally. But it should make sure that DCZID_EL0.DZP, which indicates whether or not use of DC ZVA instruction is prohibited, is zero when using the instruction. Use STNP instead when DCZID_EL0.DZP == 1. Fixes: f27bb13 ("arm64: Miscellaneous library functions") Signed-off-by: Reiji Watanabe <[email protected]> Reviewed-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent d58071a commit f0616ab

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/arm64/lib/clear_page.S

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
SYM_FUNC_START_PI(clear_page)
1818
mrs x1, dczid_el0
19+
tbnz x1, #4, 2f /* Branch if DC ZVA is prohibited */
1920
and w1, w1, #0xf
2021
mov x2, #4
2122
lsl x1, x2, x1
@@ -25,5 +26,14 @@ SYM_FUNC_START_PI(clear_page)
2526
tst x0, #(PAGE_SIZE - 1)
2627
b.ne 1b
2728
ret
29+
30+
2: stnp xzr, xzr, [x0]
31+
stnp xzr, xzr, [x0, #16]
32+
stnp xzr, xzr, [x0, #32]
33+
stnp xzr, xzr, [x0, #48]
34+
add x0, x0, #64
35+
tst x0, #(PAGE_SIZE - 1)
36+
b.ne 2b
37+
ret
2838
SYM_FUNC_END_PI(clear_page)
2939
EXPORT_SYMBOL(clear_page)

0 commit comments

Comments
 (0)