blob: d1091b5ee5da9ae508416d48dd5c31b0b3992d85 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Paul Mackerras14cf11a2005-09-26 16:04:21 +10002/*
Mark Nelson57dda6e2008-08-22 14:39:00 +10003 * Copyright (C) 2008 Mark Nelson, IBM Corp.
Paul Mackerras14cf11a2005-09-26 16:04:21 +10004 */
Anton Blanchardd988f0e2011-05-08 21:18:38 +00005#include <asm/page.h>
Paul Mackerras14cf11a2005-09-26 16:04:21 +10006#include <asm/processor.h>
7#include <asm/ppc_asm.h>
Mark Nelson57dda6e2008-08-22 14:39:00 +10008#include <asm/asm-offsets.h>
Al Viro9445aa12016-01-13 23:33:46 -05009#include <asm/export.h>
Christophe Leroy2c86cd12018-07-05 16:25:01 +000010#include <asm/feature-fixups.h>
Mark Nelson57dda6e2008-08-22 14:39:00 +100011
12 .section ".toc","aw"
13PPC64_CACHES:
14 .tc ppc64_caches[TC],ppc64_caches
15 .section ".text"
16
Anton Blanchard2ac7b012014-06-05 08:04:39 +100017_GLOBAL_TOC(copy_page)
Anton Blanchardfde69282012-05-29 19:33:12 +000018BEGIN_FTR_SECTION
Anton Blanchardd988f0e2011-05-08 21:18:38 +000019 lis r5,PAGE_SIZE@h
Anton Blanchardfde69282012-05-29 19:33:12 +000020FTR_SECTION_ELSE
Nicholas Piggin15a32042018-02-21 05:08:26 +100021#ifdef CONFIG_PPC_BOOK3S_64
Anton Blanchardb1576fe2014-02-04 16:04:35 +110022 b copypage_power7
Nicholas Piggin15a32042018-02-21 05:08:26 +100023#endif
Anton Blanchardfde69282012-05-29 19:33:12 +000024ALT_FTR_SECTION_END_IFCLR(CPU_FTR_VMX_COPY)
Anton Blanchardd988f0e2011-05-08 21:18:38 +000025 ori r5,r5,PAGE_SIZE@l
Mark Nelson57dda6e2008-08-22 14:39:00 +100026BEGIN_FTR_SECTION
27 ld r10,PPC64_CACHES@toc(r2)
Benjamin Herrenschmidtbd067f82017-01-08 17:31:45 -060028 lwz r11,DCACHEL1LOGBLOCKSIZE(r10) /* log2 of cache block size */
29 lwz r12,DCACHEL1BLOCKSIZE(r10) /* get cache block size */
Mark Nelson57dda6e2008-08-22 14:39:00 +100030 li r9,0
31 srd r8,r5,r11
32
33 mtctr r8
Anton Blanchard3cd980d2009-10-18 01:23:28 +000034.Lsetup:
Mark Nelson57dda6e2008-08-22 14:39:00 +100035 dcbt r9,r4
36 dcbz r9,r3
37 add r9,r9,r12
Anton Blanchard3cd980d2009-10-18 01:23:28 +000038 bdnz .Lsetup
Mark Nelson57dda6e2008-08-22 14:39:00 +100039END_FTR_SECTION_IFSET(CPU_FTR_CP_USE_DCBTZ)
Paul Mackerras14cf11a2005-09-26 16:04:21 +100040 addi r3,r3,-8
Mark Nelson57dda6e2008-08-22 14:39:00 +100041 srdi r8,r5,7 /* page is copied in 128 byte strides */
42 addi r8,r8,-1 /* one stride copied outside loop */
43
44 mtctr r8
45
46 ld r5,0(r4)
47 ld r6,8(r4)
48 ld r7,16(r4)
49 ldu r8,24(r4)
501: std r5,8(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100051 std r6,16(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000052 ld r9,8(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100053 ld r10,16(r4)
54 std r7,24(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100055 std r8,32(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000056 ld r11,24(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100057 ld r12,32(r4)
58 std r9,40(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100059 std r10,48(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000060 ld r5,40(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100061 ld r6,48(r4)
62 std r11,56(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100063 std r12,64(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000064 ld r7,56(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100065 ld r8,64(r4)
66 std r5,72(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100067 std r6,80(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000068 ld r9,72(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100069 ld r10,80(r4)
70 std r7,88(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100071 std r8,96(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000072 ld r11,88(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100073 ld r12,96(r4)
74 std r9,104(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100075 std r10,112(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000076 ld r5,104(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100077 ld r6,112(r4)
78 std r11,120(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100079 stdu r12,128(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000080 ld r7,120(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100081 ldu r8,128(r4)
Paul Mackerras14cf11a2005-09-26 16:04:21 +100082 bdnz 1b
Mark Nelson57dda6e2008-08-22 14:39:00 +100083
84 std r5,8(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100085 std r6,16(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000086 ld r9,8(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100087 ld r10,16(r4)
88 std r7,24(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100089 std r8,32(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000090 ld r11,24(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100091 ld r12,32(r4)
92 std r9,40(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100093 std r10,48(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000094 ld r5,40(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100095 ld r6,48(r4)
96 std r11,56(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +100097 std r12,64(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +000098 ld r7,56(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +100099 ld r8,64(r4)
100 std r5,72(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +1000101 std r6,80(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +0000102 ld r9,72(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +1000103 ld r10,80(r4)
104 std r7,88(r3)
Mark Nelson57dda6e2008-08-22 14:39:00 +1000105 std r8,96(r3)
Anton Blanchard63e6c5b2010-02-10 18:07:54 +0000106 ld r11,88(r4)
Mark Nelson57dda6e2008-08-22 14:39:00 +1000107 ld r12,96(r4)
108 std r9,104(r3)
109 std r10,112(r3)
110 std r11,120(r3)
111 std r12,128(r3)
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000112 blr
Al Viro9445aa12016-01-13 23:33:46 -0500113EXPORT_SYMBOL(copy_page)