1f27bb139SMarc Zyngier/* 2f27bb139SMarc Zyngier * Copyright (C) 2012 ARM Ltd. 3f27bb139SMarc Zyngier * 4f27bb139SMarc Zyngier * This program is free software; you can redistribute it and/or modify 5f27bb139SMarc Zyngier * it under the terms of the GNU General Public License version 2 as 6f27bb139SMarc Zyngier * published by the Free Software Foundation. 7f27bb139SMarc Zyngier * 8f27bb139SMarc Zyngier * This program is distributed in the hope that it will be useful, 9f27bb139SMarc Zyngier * but WITHOUT ANY WARRANTY; without even the implied warranty of 10f27bb139SMarc Zyngier * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11f27bb139SMarc Zyngier * GNU General Public License for more details. 12f27bb139SMarc Zyngier * 13f27bb139SMarc Zyngier * You should have received a copy of the GNU General Public License 14f27bb139SMarc Zyngier * along with this program. If not, see <http://www.gnu.org/licenses/>. 15f27bb139SMarc Zyngier */ 16f27bb139SMarc Zyngier 17f27bb139SMarc Zyngier#include <linux/linkage.h> 18f27bb139SMarc Zyngier#include <linux/const.h> 19f27bb139SMarc Zyngier#include <asm/assembler.h> 20f27bb139SMarc Zyngier#include <asm/page.h> 2160e0a09dSAndrew Pinski#include <asm/cpufeature.h> 2260e0a09dSAndrew Pinski#include <asm/alternative.h> 23f27bb139SMarc Zyngier 24f27bb139SMarc Zyngier/* 25f27bb139SMarc Zyngier * Copy a page from src to dest (both are page aligned) 26f27bb139SMarc Zyngier * 27f27bb139SMarc Zyngier * Parameters: 28f27bb139SMarc Zyngier * x0 - dest 29f27bb139SMarc Zyngier * x1 - src 30f27bb139SMarc Zyngier */ 31f27bb139SMarc ZyngierENTRY(copy_page) 326ba3b554SMark Rutlandalternative_if ARM64_HAS_NO_HW_PREFETCH 3360e0a09dSAndrew Pinski # Prefetch two cache lines ahead. 3460e0a09dSAndrew Pinski prfm pldl1strm, [x1, #128] 3560e0a09dSAndrew Pinski prfm pldl1strm, [x1, #256] 366ba3b554SMark Rutlandalternative_else_nop_endif 3760e0a09dSAndrew Pinski 38223e23e8SWill Deacon ldp x2, x3, [x1] 39f27bb139SMarc Zyngier ldp x4, x5, [x1, #16] 40f27bb139SMarc Zyngier ldp x6, x7, [x1, #32] 41f27bb139SMarc Zyngier ldp x8, x9, [x1, #48] 42223e23e8SWill Deacon ldp x10, x11, [x1, #64] 43223e23e8SWill Deacon ldp x12, x13, [x1, #80] 44223e23e8SWill Deacon ldp x14, x15, [x1, #96] 45223e23e8SWill Deacon ldp x16, x17, [x1, #112] 46223e23e8SWill Deacon 47223e23e8SWill Deacon mov x18, #(PAGE_SIZE - 128) 48223e23e8SWill Deacon add x1, x1, #128 49223e23e8SWill Deacon1: 50223e23e8SWill Deacon subs x18, x18, #128 51223e23e8SWill Deacon 526ba3b554SMark Rutlandalternative_if ARM64_HAS_NO_HW_PREFETCH 5360e0a09dSAndrew Pinski prfm pldl1strm, [x1, #384] 546ba3b554SMark Rutlandalternative_else_nop_endif 5560e0a09dSAndrew Pinski 56223e23e8SWill Deacon stnp x2, x3, [x0] 57223e23e8SWill Deacon ldp x2, x3, [x1] 58223e23e8SWill Deacon stnp x4, x5, [x0, #16] 59223e23e8SWill Deacon ldp x4, x5, [x1, #16] 60223e23e8SWill Deacon stnp x6, x7, [x0, #32] 61223e23e8SWill Deacon ldp x6, x7, [x1, #32] 62223e23e8SWill Deacon stnp x8, x9, [x0, #48] 63223e23e8SWill Deacon ldp x8, x9, [x1, #48] 64223e23e8SWill Deacon stnp x10, x11, [x0, #64] 65223e23e8SWill Deacon ldp x10, x11, [x1, #64] 66223e23e8SWill Deacon stnp x12, x13, [x0, #80] 67223e23e8SWill Deacon ldp x12, x13, [x1, #80] 68223e23e8SWill Deacon stnp x14, x15, [x0, #96] 69223e23e8SWill Deacon ldp x14, x15, [x1, #96] 70223e23e8SWill Deacon stnp x16, x17, [x0, #112] 71223e23e8SWill Deacon ldp x16, x17, [x1, #112] 72223e23e8SWill Deacon 73223e23e8SWill Deacon add x0, x0, #128 74223e23e8SWill Deacon add x1, x1, #128 75223e23e8SWill Deacon 76223e23e8SWill Deacon b.gt 1b 77223e23e8SWill Deacon 78f27bb139SMarc Zyngier stnp x2, x3, [x0] 79f27bb139SMarc Zyngier stnp x4, x5, [x0, #16] 80f27bb139SMarc Zyngier stnp x6, x7, [x0, #32] 81f27bb139SMarc Zyngier stnp x8, x9, [x0, #48] 82223e23e8SWill Deacon stnp x10, x11, [x0, #64] 83223e23e8SWill Deacon stnp x12, x13, [x0, #80] 84223e23e8SWill Deacon stnp x14, x15, [x0, #96] 85223e23e8SWill Deacon stnp x16, x17, [x0, #112] 86223e23e8SWill Deacon 87f27bb139SMarc Zyngier ret 88f27bb139SMarc ZyngierENDPROC(copy_page) 89