@@ -118,9 +118,33 @@ void do_feature_fixups(unsigned long value, void *fixup_start, void *fixup_end)
118
118
}
119
119
120
120
#ifdef CONFIG_PPC_BOOK3S_64
121
+ static int do_patch_entry_fixups (long * start , long * end , unsigned int * instrs ,
122
+ bool do_fallback , void * fallback )
123
+ {
124
+ int i ;
125
+
126
+ for (i = 0 ; start < end ; start ++ , i ++ ) {
127
+ unsigned int * dest = (void * )start + * start ;
128
+
129
+ pr_devel ("patching dest %lx\n" , (unsigned long )dest );
130
+
131
+ // See comment in do_entry_flush_fixups() RE order of patching
132
+ if (do_fallback ) {
133
+ patch_instruction (dest , ppc_inst (instrs [0 ]));
134
+ patch_instruction (dest + 2 , ppc_inst (instrs [2 ]));
135
+ patch_branch (dest + 1 , (unsigned long )fallback , BRANCH_SET_LINK );
136
+ } else {
137
+ patch_instruction (dest + 1 , ppc_inst (instrs [1 ]));
138
+ patch_instruction (dest + 2 , ppc_inst (instrs [2 ]));
139
+ patch_instruction (dest , ppc_inst (instrs [0 ]));
140
+ }
141
+ }
142
+ return i ;
143
+ }
144
+
121
145
static void do_stf_entry_barrier_fixups (enum stf_barrier_type types )
122
146
{
123
- unsigned int instrs [3 ], * dest ;
147
+ unsigned int instrs [3 ];
124
148
long * start , * end ;
125
149
int i ;
126
150
@@ -144,23 +168,8 @@ static void do_stf_entry_barrier_fixups(enum stf_barrier_type types)
144
168
instrs [i ++ ] = PPC_RAW_ORI (_R31 , _R31 , 0 ); /* speculation barrier */
145
169
}
146
170
147
- for (i = 0 ; start < end ; start ++ , i ++ ) {
148
- dest = (void * )start + * start ;
149
-
150
- pr_devel ("patching dest %lx\n" , (unsigned long )dest );
151
-
152
- // See comment in do_entry_flush_fixups() RE order of patching
153
- if (types & STF_BARRIER_FALLBACK ) {
154
- patch_instruction (dest , ppc_inst (instrs [0 ]));
155
- patch_instruction (dest + 2 , ppc_inst (instrs [2 ]));
156
- patch_branch (dest + 1 ,
157
- (unsigned long )& stf_barrier_fallback , BRANCH_SET_LINK );
158
- } else {
159
- patch_instruction (dest + 1 , ppc_inst (instrs [1 ]));
160
- patch_instruction (dest + 2 , ppc_inst (instrs [2 ]));
161
- patch_instruction (dest , ppc_inst (instrs [0 ]));
162
- }
163
- }
171
+ i = do_patch_entry_fixups (start , end , instrs , types & STF_BARRIER_FALLBACK ,
172
+ & stf_barrier_fallback );
164
173
165
174
printk (KERN_DEBUG "stf-barrier: patched %d entry locations (%s barrier)\n" , i ,
166
175
(types == STF_BARRIER_NONE ) ? "no" :
@@ -325,7 +334,7 @@ void do_uaccess_flush_fixups(enum l1d_flush_type types)
325
334
static int __do_entry_flush_fixups (void * data )
326
335
{
327
336
enum l1d_flush_type types = * (enum l1d_flush_type * )data ;
328
- unsigned int instrs [3 ], * dest ;
337
+ unsigned int instrs [3 ];
329
338
long * start , * end ;
330
339
int i ;
331
340
@@ -375,42 +384,13 @@ static int __do_entry_flush_fixups(void *data)
375
384
376
385
start = PTRRELOC (& __start___entry_flush_fixup );
377
386
end = PTRRELOC (& __stop___entry_flush_fixup );
378
- for (i = 0 ; start < end ; start ++ , i ++ ) {
379
- dest = (void * )start + * start ;
380
-
381
- pr_devel ("patching dest %lx\n" , (unsigned long )dest );
382
-
383
- if (types == L1D_FLUSH_FALLBACK ) {
384
- patch_instruction (dest , ppc_inst (instrs [0 ]));
385
- patch_instruction (dest + 2 , ppc_inst (instrs [2 ]));
386
- patch_branch (dest + 1 ,
387
- (unsigned long )& entry_flush_fallback , BRANCH_SET_LINK );
388
- } else {
389
- patch_instruction (dest + 1 , ppc_inst (instrs [1 ]));
390
- patch_instruction (dest + 2 , ppc_inst (instrs [2 ]));
391
- patch_instruction (dest , ppc_inst (instrs [0 ]));
392
- }
393
- }
387
+ i = do_patch_entry_fixups (start , end , instrs , types == L1D_FLUSH_FALLBACK ,
388
+ & entry_flush_fallback );
394
389
395
390
start = PTRRELOC (& __start___scv_entry_flush_fixup );
396
391
end = PTRRELOC (& __stop___scv_entry_flush_fixup );
397
- for (; start < end ; start ++ , i ++ ) {
398
- dest = (void * )start + * start ;
399
-
400
- pr_devel ("patching dest %lx\n" , (unsigned long )dest );
401
-
402
- if (types == L1D_FLUSH_FALLBACK ) {
403
- patch_instruction (dest , ppc_inst (instrs [0 ]));
404
- patch_instruction (dest + 2 , ppc_inst (instrs [2 ]));
405
- patch_branch (dest + 1 ,
406
- (unsigned long )& scv_entry_flush_fallback , BRANCH_SET_LINK );
407
- } else {
408
- patch_instruction (dest + 1 , ppc_inst (instrs [1 ]));
409
- patch_instruction (dest + 2 , ppc_inst (instrs [2 ]));
410
- patch_instruction (dest , ppc_inst (instrs [0 ]));
411
- }
412
- }
413
-
392
+ i += do_patch_entry_fixups (start , end , instrs , types == L1D_FLUSH_FALLBACK ,
393
+ & scv_entry_flush_fallback );
414
394
415
395
printk (KERN_DEBUG "entry-flush: patched %d locations (%s flush)\n" , i ,
416
396
(types == L1D_FLUSH_NONE ) ? "no" :
0 commit comments