18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2012 ARM Ltd. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <linux/linkage.h> 78c2ecf20Sopenharmony_ci#include <linux/const.h> 88c2ecf20Sopenharmony_ci#include <asm/assembler.h> 98c2ecf20Sopenharmony_ci#include <asm/page.h> 108c2ecf20Sopenharmony_ci#include <asm/cpufeature.h> 118c2ecf20Sopenharmony_ci#include <asm/alternative.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Copy a page from src to dest (both are page aligned) 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * Parameters: 178c2ecf20Sopenharmony_ci * x0 - dest 188c2ecf20Sopenharmony_ci * x1 - src 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ciSYM_FUNC_START_PI(copy_page) 218c2ecf20Sopenharmony_cialternative_if ARM64_HAS_NO_HW_PREFETCH 228c2ecf20Sopenharmony_ci // Prefetch three cache lines ahead. 238c2ecf20Sopenharmony_ci prfm pldl1strm, [x1, #128] 248c2ecf20Sopenharmony_ci prfm pldl1strm, [x1, #256] 258c2ecf20Sopenharmony_ci prfm pldl1strm, [x1, #384] 268c2ecf20Sopenharmony_cialternative_else_nop_endif 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci ldp x2, x3, [x1] 298c2ecf20Sopenharmony_ci ldp x4, x5, [x1, #16] 308c2ecf20Sopenharmony_ci ldp x6, x7, [x1, #32] 318c2ecf20Sopenharmony_ci ldp x8, x9, [x1, #48] 328c2ecf20Sopenharmony_ci ldp x10, x11, [x1, #64] 338c2ecf20Sopenharmony_ci ldp x12, x13, [x1, #80] 348c2ecf20Sopenharmony_ci ldp x14, x15, [x1, #96] 358c2ecf20Sopenharmony_ci ldp x16, x17, [x1, #112] 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci add x0, x0, #256 388c2ecf20Sopenharmony_ci add x1, x1, #128 398c2ecf20Sopenharmony_ci1: 408c2ecf20Sopenharmony_ci tst x0, #(PAGE_SIZE - 1) 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cialternative_if ARM64_HAS_NO_HW_PREFETCH 438c2ecf20Sopenharmony_ci prfm pldl1strm, [x1, #384] 448c2ecf20Sopenharmony_cialternative_else_nop_endif 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci stnp x2, x3, [x0, #-256] 478c2ecf20Sopenharmony_ci ldp x2, x3, [x1] 488c2ecf20Sopenharmony_ci stnp x4, x5, [x0, #16 - 256] 498c2ecf20Sopenharmony_ci ldp x4, x5, [x1, #16] 508c2ecf20Sopenharmony_ci stnp x6, x7, [x0, #32 - 256] 518c2ecf20Sopenharmony_ci ldp x6, x7, [x1, #32] 528c2ecf20Sopenharmony_ci stnp x8, x9, [x0, #48 - 256] 538c2ecf20Sopenharmony_ci ldp x8, x9, [x1, #48] 548c2ecf20Sopenharmony_ci stnp x10, x11, [x0, #64 - 256] 558c2ecf20Sopenharmony_ci ldp x10, x11, [x1, #64] 568c2ecf20Sopenharmony_ci stnp x12, x13, [x0, #80 - 256] 578c2ecf20Sopenharmony_ci ldp x12, x13, [x1, #80] 588c2ecf20Sopenharmony_ci stnp x14, x15, [x0, #96 - 256] 598c2ecf20Sopenharmony_ci ldp x14, x15, [x1, #96] 608c2ecf20Sopenharmony_ci stnp x16, x17, [x0, #112 - 256] 618c2ecf20Sopenharmony_ci ldp x16, x17, [x1, #112] 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci add x0, x0, #128 648c2ecf20Sopenharmony_ci add x1, x1, #128 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci b.ne 1b 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci stnp x2, x3, [x0, #-256] 698c2ecf20Sopenharmony_ci stnp x4, x5, [x0, #16 - 256] 708c2ecf20Sopenharmony_ci stnp x6, x7, [x0, #32 - 256] 718c2ecf20Sopenharmony_ci stnp x8, x9, [x0, #48 - 256] 728c2ecf20Sopenharmony_ci stnp x10, x11, [x0, #64 - 256] 738c2ecf20Sopenharmony_ci stnp x12, x13, [x0, #80 - 256] 748c2ecf20Sopenharmony_ci stnp x14, x15, [x0, #96 - 256] 758c2ecf20Sopenharmony_ci stnp x16, x17, [x0, #112 - 256] 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci ret 788c2ecf20Sopenharmony_ciSYM_FUNC_END_PI(copy_page) 798c2ecf20Sopenharmony_ciEXPORT_SYMBOL(copy_page) 80