1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright 2008 Michael Ellerman, IBM Corporation.
4 */
5
6#include <asm/feature-fixups.h>
7#include <asm/ppc_asm.h>
8#include <asm/synch.h>
9#include <asm/asm-compat.h>
10#include <asm/ppc-opcode.h>
11
12	.text
13
14#define globl(x)		\
15	.globl x;	\
16x:
17
18globl(ftr_fixup_test1)
19	or	1,1,1
20	or	2,2,2	/* fixup will nop out this instruction */
21	or	3,3,3
22
23globl(end_ftr_fixup_test1)
24
25globl(ftr_fixup_test1_orig)
26	or	1,1,1
27	or	2,2,2
28	or	3,3,3
29
30globl(ftr_fixup_test1_expected)
31	or	1,1,1
32	nop
33	or	3,3,3
34
35globl(ftr_fixup_test2)
36	or	1,1,1
37	or	2,2,2	/* fixup will replace this with ftr_fixup_test2_alt */
38	or	3,3,3
39
40globl(end_ftr_fixup_test2)
41
42globl(ftr_fixup_test2_orig)
43	or	1,1,1
44	or	2,2,2
45	or	3,3,3
46
47globl(ftr_fixup_test2_alt)
48	or	31,31,31
49
50globl(ftr_fixup_test2_expected)
51	or	1,1,1
52	or	31,31,31
53	or	3,3,3
54
55globl(ftr_fixup_test3)
56	or	1,1,1
57	or	2,2,2	/* fixup will fail to replace this */
58	or	3,3,3
59
60globl(end_ftr_fixup_test3)
61
62globl(ftr_fixup_test3_orig)
63	or	1,1,1
64	or	2,2,2
65	or	3,3,3
66
67globl(ftr_fixup_test3_alt)
68	or	31,31,31
69	or	31,31,31
70
71globl(ftr_fixup_test4)
72	or	1,1,1
73	or	2,2,2
74	or	2,2,2
75	or	2,2,2
76	or	2,2,2
77	or	3,3,3
78
79globl(end_ftr_fixup_test4)
80
81globl(ftr_fixup_test4_expected)
82	or	1,1,1
83	or	31,31,31
84	or	31,31,31
85	nop
86	nop
87	or	3,3,3
88
89globl(ftr_fixup_test4_orig)
90	or	1,1,1
91	or	2,2,2
92	or	2,2,2
93	or	2,2,2
94	or	2,2,2
95	or	3,3,3
96
97globl(ftr_fixup_test4_alt)
98	or	31,31,31
99	or	31,31,31
100
101
102globl(ftr_fixup_test5)
103	or	1,1,1
104BEGIN_FTR_SECTION
105	or	2,2,2
106	or	2,2,2
107	or	2,2,2
108	or	2,2,2
109	or	2,2,2
110	or	2,2,2
111	or	2,2,2
112FTR_SECTION_ELSE
1132:	b	3f
1143:	or	5,5,5
115	beq	3b
116	b	1f
117	or	6,6,6
118	b	2b
1191:	bdnz	3b
120ALT_FTR_SECTION_END(0, 1)
121	or	1,1,1
122
123globl(end_ftr_fixup_test5)
124
125globl(ftr_fixup_test5_expected)
126	or	1,1,1
1272:	b	3f
1283:	or	5,5,5
129	beq	3b
130	b	1f
131	or	6,6,6
132	b	2b
1331:	bdnz	3b
134	or	1,1,1
135
136globl(ftr_fixup_test6)
1371:	or	1,1,1
138BEGIN_FTR_SECTION
139	or	5,5,5
1402:	PPC_LCMPI	r3,0
141	beq	4f
142	blt	2b
143	b	1b
144	b	4f
145FTR_SECTION_ELSE
1462:	or	2,2,2
147	PPC_LCMPI	r3,1
148	beq	3f
149	blt	2b
150	b	3f
151	b	1b
152ALT_FTR_SECTION_END(0, 1)
1533:	or	1,1,1
154	or	2,2,2
1554:	or	3,3,3
156
157globl(end_ftr_fixup_test6)
158
159globl(ftr_fixup_test6_expected)
1601:	or	1,1,1
1612:	or	2,2,2
162	PPC_LCMPI	r3,1
163	beq	3f
164	blt	2b
165	b	3f
166	b	1b
1673:	or	1,1,1
168	or	2,2,2
169	or	3,3,3
170
171globl(ftr_fixup_test7)
172	or	1,1,1
173BEGIN_FTR_SECTION
174	or	2,2,2
175	or	2,2,2
176	or	2,2,2
177	or	2,2,2
178	or	2,2,2
179	or	2,2,2
180	or	2,2,2
181FTR_SECTION_ELSE
1822:	b	3f
1833:	or	5,5,5
184	beq	3b
185	b	1f
186	or	6,6,6
187	b	2b
188	bdnz	3b
1891:
190ALT_FTR_SECTION_END(0, 1)
191	or	1,1,1
192	or	1,1,1
193
194globl(end_ftr_fixup_test7)
195	nop
196
197globl(ftr_fixup_test7_expected)
198	or	1,1,1
1992:	b	3f
2003:	or	5,5,5
201	beq	3b
202	b	1f
203	or	6,6,6
204	b	2b
205	bdnz	3b
2061:	or	1,1,1
207
208#if 0
209/* Test that if we have a larger else case the assembler spots it and
210 * reports an error. #if 0'ed so as not to break the build normally.
211 */
212ftr_fixup_test_too_big:
213	or	1,1,1
214BEGIN_FTR_SECTION
215	or	2,2,2
216	or	2,2,2
217	or	2,2,2
218FTR_SECTION_ELSE
219	or	3,3,3
220	or	3,3,3
221	or	3,3,3
222	or	3,3,3
223ALT_FTR_SECTION_END(0, 1)
224	or	1,1,1
225#endif
226
227#define	MAKE_MACRO_TEST(TYPE)						\
228globl(ftr_fixup_test_ ##TYPE##_macros)					\
229	or	1,1,1;							\
230	/* Basic test, this section should all be nop'ed */		\
231BEGIN_##TYPE##_SECTION							\
232	or	2,2,2;							\
233	or	2,2,2;							\
234	or	2,2,2;							\
235END_##TYPE##_SECTION(0, 1)						\
236	or	1,1,1;							\
237	or	1,1,1;							\
238	/* Basic test, this section should NOT be nop'ed */		\
239BEGIN_##TYPE##_SECTION							\
240	or	2,2,2;							\
241	or	2,2,2;							\
242	or	2,2,2;							\
243END_##TYPE##_SECTION(0, 0)						\
244	or	1,1,1;							\
245	or	1,1,1;							\
246	/* Nesting test, inner section should be nop'ed */		\
247BEGIN_##TYPE##_SECTION							\
248	or	2,2,2;							\
249	or	2,2,2;							\
250BEGIN_##TYPE##_SECTION_NESTED(80)					\
251	or	3,3,3;							\
252	or	3,3,3;							\
253END_##TYPE##_SECTION_NESTED(0, 1, 80)					\
254	or	2,2,2;							\
255	or	2,2,2;							\
256END_##TYPE##_SECTION(0, 0)						\
257	or	1,1,1;							\
258	or	1,1,1;							\
259	/* Nesting test, whole section should be nop'ed */		\
260BEGIN_##TYPE##_SECTION							\
261	or	2,2,2;							\
262	or	2,2,2;							\
263BEGIN_##TYPE##_SECTION_NESTED(80)					\
264	or	3,3,3;							\
265	or	3,3,3;							\
266END_##TYPE##_SECTION_NESTED(0, 0, 80)					\
267	or	2,2,2;							\
268	or	2,2,2;							\
269END_##TYPE##_SECTION(0, 1)						\
270	or	1,1,1;							\
271	or	1,1,1;							\
272	/* Nesting test, none should be nop'ed */			\
273BEGIN_##TYPE##_SECTION							\
274	or	2,2,2;							\
275	or	2,2,2;							\
276BEGIN_##TYPE##_SECTION_NESTED(80)					\
277	or	3,3,3;							\
278	or	3,3,3;							\
279END_##TYPE##_SECTION_NESTED(0, 0, 80)					\
280	or	2,2,2;							\
281	or	2,2,2;							\
282END_##TYPE##_SECTION(0, 0)						\
283	or	1,1,1;							\
284	or	1,1,1;							\
285	/* Basic alt section test, default case should be taken */	\
286BEGIN_##TYPE##_SECTION							\
287	or	3,3,3;							\
288	or	3,3,3;							\
289	or	3,3,3;							\
290##TYPE##_SECTION_ELSE							\
291	or	5,5,5;							\
292	or	5,5,5;							\
293ALT_##TYPE##_SECTION_END(0, 0)						\
294	or	1,1,1;							\
295	or	1,1,1;							\
296	/* Basic alt section test, else case should be taken */		\
297BEGIN_##TYPE##_SECTION							\
298	or	3,3,3;							\
299	or	3,3,3;							\
300	or	3,3,3;							\
301##TYPE##_SECTION_ELSE							\
302	or	31,31,31;						\
303	or	31,31,31;						\
304	or	31,31,31;						\
305ALT_##TYPE##_SECTION_END(0, 1)						\
306	or	1,1,1;							\
307	or	1,1,1;							\
308	/* Alt with smaller else case, should be padded with nops */	\
309BEGIN_##TYPE##_SECTION							\
310	or	3,3,3;							\
311	or	3,3,3;							\
312	or	3,3,3;							\
313##TYPE##_SECTION_ELSE							\
314	or	31,31,31;						\
315ALT_##TYPE##_SECTION_END(0, 1)						\
316	or	1,1,1;							\
317	or	1,1,1;							\
318	/* Alt section with nested section in default case */		\
319	/* Default case should be taken, with nop'ed inner section */	\
320BEGIN_##TYPE##_SECTION							\
321	or	3,3,3;							\
322BEGIN_##TYPE##_SECTION_NESTED(95)					\
323	or	3,3,3;							\
324	or	3,3,3;							\
325END_##TYPE##_SECTION_NESTED(0, 1, 95)					\
326	or	3,3,3;							\
327##TYPE##_SECTION_ELSE							\
328	or	2,2,2;							\
329	or	2,2,2;							\
330ALT_##TYPE##_SECTION_END(0, 0)						\
331	or	1,1,1;							\
332	or	1,1,1;							\
333	/* Alt section with nested section in else, default taken */	\
334BEGIN_##TYPE##_SECTION							\
335	or	3,3,3;							\
336	or	3,3,3;							\
337	or	3,3,3;							\
338##TYPE##_SECTION_ELSE							\
339	or	5,5,5;							\
340BEGIN_##TYPE##_SECTION_NESTED(95)					\
341	or	3,3,3;							\
342END_##TYPE##_SECTION_NESTED(0, 1, 95)					\
343	or	5,5,5;							\
344ALT_##TYPE##_SECTION_END(0, 0)						\
345	or	1,1,1;							\
346	or	1,1,1;							\
347	/* Alt section with nested section in else, else taken & nop */	\
348BEGIN_##TYPE##_SECTION							\
349	or	3,3,3;							\
350	or	3,3,3;							\
351	or	3,3,3;							\
352##TYPE##_SECTION_ELSE							\
353	or	5,5,5;							\
354BEGIN_##TYPE##_SECTION_NESTED(95)					\
355	or	3,3,3;							\
356END_##TYPE##_SECTION_NESTED(0, 1, 95)					\
357	or	5,5,5;							\
358ALT_##TYPE##_SECTION_END(0, 1)						\
359	or	1,1,1;							\
360	or	1,1,1;							\
361	/* Feature section with nested alt section, default taken */	\
362BEGIN_##TYPE##_SECTION							\
363	or	2,2,2;							\
364BEGIN_##TYPE##_SECTION_NESTED(95)					\
365	or	1,1,1;							\
366##TYPE##_SECTION_ELSE_NESTED(95)					\
367	or	5,5,5;							\
368ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95)				\
369	or	2,2,2;							\
370END_##TYPE##_SECTION(0, 0)						\
371	or	1,1,1;							\
372	or	1,1,1;							\
373	/* Feature section with nested alt section, else taken */	\
374BEGIN_##TYPE##_SECTION							\
375	or	2,2,2;							\
376BEGIN_##TYPE##_SECTION_NESTED(95)					\
377	or	1,1,1;							\
378##TYPE##_SECTION_ELSE_NESTED(95)					\
379	or	5,5,5;							\
380ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95)				\
381	or	2,2,2;							\
382END_##TYPE##_SECTION(0, 0)						\
383	or	1,1,1;							\
384	or	1,1,1;							\
385	/* Feature section with nested alt section, all nop'ed */	\
386BEGIN_##TYPE##_SECTION							\
387	or	2,2,2;							\
388BEGIN_##TYPE##_SECTION_NESTED(95)					\
389	or	1,1,1;							\
390##TYPE##_SECTION_ELSE_NESTED(95)					\
391	or	5,5,5;							\
392ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95)				\
393	or	2,2,2;							\
394END_##TYPE##_SECTION(0, 1)						\
395	or	1,1,1;							\
396	or	1,1,1;							\
397	/* Nested alt sections, default with inner default taken */	\
398BEGIN_##TYPE##_SECTION							\
399	or	2,2,2;							\
400BEGIN_##TYPE##_SECTION_NESTED(95)					\
401	or	1,1,1;							\
402##TYPE##_SECTION_ELSE_NESTED(95)					\
403	or	5,5,5;							\
404ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95)				\
405	or	2,2,2;							\
406##TYPE##_SECTION_ELSE							\
407	or	31,31,31;						\
408BEGIN_##TYPE##_SECTION_NESTED(94)					\
409	or	5,5,5;							\
410##TYPE##_SECTION_ELSE_NESTED(94)					\
411	or	1,1,1;							\
412ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94)				\
413	or	31,31,31;						\
414ALT_##TYPE##_SECTION_END(0, 0)						\
415	or	1,1,1;							\
416	or	1,1,1;							\
417	/* Nested alt sections, default with inner else taken */	\
418BEGIN_##TYPE##_SECTION							\
419	or	2,2,2;							\
420BEGIN_##TYPE##_SECTION_NESTED(95)					\
421	or	1,1,1;							\
422##TYPE##_SECTION_ELSE_NESTED(95)					\
423	or	5,5,5;							\
424ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95)				\
425	or	2,2,2;							\
426##TYPE##_SECTION_ELSE							\
427	or	31,31,31;						\
428BEGIN_##TYPE##_SECTION_NESTED(94)					\
429	or	5,5,5;							\
430##TYPE##_SECTION_ELSE_NESTED(94)					\
431	or	1,1,1;							\
432ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94)				\
433	or	31,31,31;						\
434ALT_##TYPE##_SECTION_END(0, 0)						\
435	or	1,1,1;							\
436	or	1,1,1;							\
437	/* Nested alt sections, else with inner default taken */	\
438BEGIN_##TYPE##_SECTION							\
439	or	2,2,2;							\
440BEGIN_##TYPE##_SECTION_NESTED(95)					\
441	or	1,1,1;							\
442##TYPE##_SECTION_ELSE_NESTED(95)					\
443	or	5,5,5;							\
444ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95)				\
445	or	2,2,2;							\
446##TYPE##_SECTION_ELSE							\
447	or	31,31,31;						\
448BEGIN_##TYPE##_SECTION_NESTED(94)					\
449	or	5,5,5;							\
450##TYPE##_SECTION_ELSE_NESTED(94)					\
451	or	1,1,1;							\
452ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94)				\
453	or	31,31,31;						\
454ALT_##TYPE##_SECTION_END(0, 1)						\
455	or	1,1,1;							\
456	or	1,1,1;							\
457	/* Nested alt sections, else with inner else taken */		\
458BEGIN_##TYPE##_SECTION							\
459	or	2,2,2;							\
460BEGIN_##TYPE##_SECTION_NESTED(95)					\
461	or	1,1,1;							\
462##TYPE##_SECTION_ELSE_NESTED(95)					\
463	or	5,5,5;							\
464ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95)				\
465	or	2,2,2;							\
466##TYPE##_SECTION_ELSE							\
467	or	31,31,31;						\
468BEGIN_##TYPE##_SECTION_NESTED(94)					\
469	or	5,5,5;							\
470##TYPE##_SECTION_ELSE_NESTED(94)					\
471	or	1,1,1;							\
472ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94)				\
473	or	31,31,31;						\
474ALT_##TYPE##_SECTION_END(0, 1)						\
475	or	1,1,1;							\
476	or	1,1,1;							\
477	/* Nested alt sections, else can have large else case */	\
478BEGIN_##TYPE##_SECTION							\
479	or	2,2,2;							\
480	or	2,2,2;							\
481	or	2,2,2;							\
482	or	2,2,2;							\
483##TYPE##_SECTION_ELSE 							\
484BEGIN_##TYPE##_SECTION_NESTED(94) 					\
485	or	5,5,5;							\
486	or	5,5,5;							\
487	or	5,5,5;							\
488	or	5,5,5;							\
489##TYPE##_SECTION_ELSE_NESTED(94) 					\
490	or	1,1,1;							\
491	or	1,1,1;							\
492	or	1,1,1;							\
493	or	1,1,1;							\
494ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94)				\
495ALT_##TYPE##_SECTION_END(0, 1)						\
496	or	1,1,1;							\
497	or	1,1,1;
498
499#define	MAKE_MACRO_TEST_EXPECTED(TYPE)					\
500globl(ftr_fixup_test_ ##TYPE##_macros_expected)				\
501	or	1,1,1;							\
502	/* Basic test, this section should all be nop'ed */		\
503/* BEGIN_##TYPE##_SECTION */						\
504	nop;								\
505	nop;								\
506	nop;								\
507/* END_##TYPE##_SECTION(0, 1) */					\
508	or	1,1,1;							\
509	or	1,1,1;							\
510	/* Basic test, this section should NOT be nop'ed */		\
511/* BEGIN_##TYPE##_SECTION */						\
512	or	2,2,2;							\
513	or	2,2,2;							\
514	or	2,2,2;							\
515/* END_##TYPE##_SECTION(0, 0) */					\
516	or	1,1,1;							\
517	or	1,1,1;							\
518	/* Nesting test, inner section should be nop'ed */		\
519/* BEGIN_##TYPE##_SECTION */						\
520	or	2,2,2;							\
521	or	2,2,2;							\
522/* BEGIN_##TYPE##_SECTION_NESTED(80) */					\
523	nop;								\
524	nop;								\
525/* END_##TYPE##_SECTION_NESTED(0, 1, 80) */				\
526	or	2,2,2;							\
527	or	2,2,2;							\
528/* END_##TYPE##_SECTION(0, 0) */					\
529	or	1,1,1;							\
530	or	1,1,1;							\
531	/* Nesting test, whole section should be nop'ed */		\
532	/* NB. inner section is not nop'ed, but then entire outer is */	\
533/* BEGIN_##TYPE##_SECTION */						\
534	nop;								\
535	nop;								\
536/* BEGIN_##TYPE##_SECTION_NESTED(80) */					\
537	nop;								\
538	nop;								\
539/* END_##TYPE##_SECTION_NESTED(0, 0, 80) */				\
540	nop;								\
541	nop;								\
542/* END_##TYPE##_SECTION(0, 1) */					\
543	or	1,1,1;							\
544	or	1,1,1;							\
545	/* Nesting test, none should be nop'ed */			\
546/* BEGIN_##TYPE##_SECTION */						\
547	or	2,2,2;							\
548	or	2,2,2;							\
549/* BEGIN_##TYPE##_SECTION_NESTED(80) */					\
550	or	3,3,3;							\
551	or	3,3,3;							\
552/* END_##TYPE##_SECTION_NESTED(0, 0, 80) */				\
553	or	2,2,2;							\
554	or	2,2,2;							\
555/* END_##TYPE##_SECTION(0, 0) */					\
556	or	1,1,1;							\
557	or	1,1,1;							\
558	/* Basic alt section test, default case should be taken */	\
559/* BEGIN_##TYPE##_SECTION */						\
560	or	3,3,3;							\
561	or	3,3,3;							\
562	or	3,3,3;							\
563/* ##TYPE##_SECTION_ELSE */						\
564	/* or	5,5,5; */						\
565	/* or	5,5,5; */						\
566/* ALT_##TYPE##_SECTION_END(0, 0) */					\
567	or	1,1,1;							\
568	or	1,1,1;							\
569	/* Basic alt section test, else case should be taken */		\
570/* BEGIN_##TYPE##_SECTION */						\
571	/* or	3,3,3; */						\
572	/* or	3,3,3; */						\
573	/* or	3,3,3; */						\
574/* ##TYPE##_SECTION_ELSE */						\
575	or	31,31,31;						\
576	or	31,31,31;						\
577	or	31,31,31;						\
578/* ALT_##TYPE##_SECTION_END(0, 1) */					\
579	or	1,1,1;							\
580	or	1,1,1;							\
581	/* Alt with smaller else case, should be padded with nops */	\
582/* BEGIN_##TYPE##_SECTION */						\
583	/* or	3,3,3; */						\
584	/* or	3,3,3; */						\
585	/* or	3,3,3; */						\
586/* ##TYPE##_SECTION_ELSE */						\
587	or	31,31,31;						\
588	nop;								\
589	nop;								\
590/* ALT_##TYPE##_SECTION_END(0, 1) */					\
591	or	1,1,1;							\
592	or	1,1,1;							\
593	/* Alt section with nested section in default case */		\
594	/* Default case should be taken, with nop'ed inner section */	\
595/* BEGIN_##TYPE##_SECTION */						\
596	or	3,3,3;							\
597/* BEGIN_##TYPE##_SECTION_NESTED(95) */					\
598	nop;								\
599	nop;								\
600/* END_##TYPE##_SECTION_NESTED(0, 1, 95) */				\
601	or	3,3,3;							\
602/* ##TYPE##_SECTION_ELSE */						\
603	/* or	2,2,2; */						\
604	/* or	2,2,2; */						\
605/* ALT_##TYPE##_SECTION_END(0, 0) */					\
606	or	1,1,1;							\
607	or	1,1,1;							\
608	/* Alt section with nested section in else, default taken */	\
609/* BEGIN_##TYPE##_SECTION */						\
610	or	3,3,3;							\
611	or	3,3,3;							\
612	or	3,3,3;							\
613/* ##TYPE##_SECTION_ELSE */						\
614	/* or	5,5,5; */						\
615/* BEGIN_##TYPE##_SECTION_NESTED(95) */					\
616	/* or	3,3,3; */						\
617/* END_##TYPE##_SECTION_NESTED(0, 1, 95) */				\
618	/* or	5,5,5; */						\
619/* ALT_##TYPE##_SECTION_END(0, 0) */					\
620	or	1,1,1;							\
621	or	1,1,1;							\
622	/* Alt section with nested section in else, else taken & nop */	\
623/* BEGIN_##TYPE##_SECTION */						\
624	/* or	3,3,3; */						\
625	/* or	3,3,3; */						\
626	/* or	3,3,3; */						\
627/* ##TYPE##_SECTION_ELSE */						\
628	or	5,5,5;							\
629/* BEGIN_##TYPE##_SECTION_NESTED(95) */					\
630	nop;								\
631/* END_##TYPE##_SECTION_NESTED(0, 1, 95) */				\
632	or	5,5,5;							\
633/* ALT_##TYPE##_SECTION_END(0, 1) */					\
634	or	1,1,1;							\
635	or	1,1,1;							\
636	/* Feature section with nested alt section, default taken */	\
637/* BEGIN_##TYPE##_SECTION */						\
638	or	2,2,2;							\
639/* BEGIN_##TYPE##_SECTION_NESTED(95) */					\
640	or	1,1,1;							\
641/* ##TYPE##_SECTION_ELSE_NESTED(95) */					\
642	/* or	5,5,5; */						\
643/* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */				\
644	or	2,2,2;							\
645/* END_##TYPE##_SECTION(0, 0) */					\
646	or	1,1,1;							\
647	or	1,1,1;							\
648	/* Feature section with nested alt section, else taken */	\
649/* BEGIN_##TYPE##_SECTION */						\
650	or	2,2,2;							\
651/* BEGIN_##TYPE##_SECTION_NESTED(95) */					\
652	/* or	1,1,1; */						\
653/* ##TYPE##_SECTION_ELSE_NESTED(95) */					\
654	or	5,5,5;							\
655/* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */				\
656	or	2,2,2;							\
657/* END_##TYPE##_SECTION(0, 0) */					\
658	or	1,1,1;							\
659	or	1,1,1;							\
660	/* Feature section with nested alt section, all nop'ed */	\
661/* BEGIN_##TYPE##_SECTION */						\
662	nop;								\
663/* BEGIN_##TYPE##_SECTION_NESTED(95) */					\
664	nop;								\
665/* ##TYPE##_SECTION_ELSE_NESTED(95) */					\
666	/* or	5,5,5; */						\
667/* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */				\
668	nop;								\
669/* END_##TYPE##_SECTION(0, 1) */					\
670	or	1,1,1;							\
671	or	1,1,1;							\
672	/* Nested alt sections, default with inner default taken */	\
673/* BEGIN_##TYPE##_SECTION */						\
674	or	2,2,2;							\
675/* BEGIN_##TYPE##_SECTION_NESTED(95) */					\
676	or	1,1,1;							\
677/* ##TYPE##_SECTION_ELSE_NESTED(95) */					\
678	/* or	5,5,5; */						\
679/* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */				\
680	or	2,2,2;							\
681/* ##TYPE##_SECTION_ELSE */						\
682	/* or	31,31,31; */						\
683/* BEGIN_##TYPE##_SECTION_NESTED(94) */					\
684	/* or	5,5,5; */						\
685/* ##TYPE##_SECTION_ELSE_NESTED(94) */					\
686	/* or	1,1,1; */						\
687/* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */				\
688	/* or	31,31,31; */						\
689/* ALT_##TYPE##_SECTION_END(0, 0) */					\
690	or	1,1,1;							\
691	or	1,1,1;							\
692	/* Nested alt sections, default with inner else taken */	\
693/* BEGIN_##TYPE##_SECTION */						\
694	or	2,2,2;							\
695/* BEGIN_##TYPE##_SECTION_NESTED(95) */					\
696	/* or	1,1,1; */						\
697/* ##TYPE##_SECTION_ELSE_NESTED(95) */					\
698	or	5,5,5;							\
699/* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */				\
700	or	2,2,2;							\
701/* ##TYPE##_SECTION_ELSE */						\
702	/* or	31,31,31; */						\
703/* BEGIN_##TYPE##_SECTION_NESTED(94) */					\
704	/* or	5,5,5; */						\
705/* ##TYPE##_SECTION_ELSE_NESTED(94) */					\
706	/* or	1,1,1; */						\
707/* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */				\
708	/* or	31,31,31; */						\
709/* ALT_##TYPE##_SECTION_END(0, 0) */					\
710	or	1,1,1;							\
711	or	1,1,1;							\
712	/* Nested alt sections, else with inner default taken */	\
713/* BEGIN_##TYPE##_SECTION */						\
714	/* or	2,2,2; */						\
715/* BEGIN_##TYPE##_SECTION_NESTED(95) */					\
716	/* or	1,1,1; */						\
717/* ##TYPE##_SECTION_ELSE_NESTED(95) */					\
718	/* or	5,5,5; */						\
719/* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */				\
720	/* or	2,2,2; */						\
721/* ##TYPE##_SECTION_ELSE */						\
722	or	31,31,31;						\
723/* BEGIN_##TYPE##_SECTION_NESTED(94) */					\
724	or	5,5,5;							\
725/* ##TYPE##_SECTION_ELSE_NESTED(94) */					\
726	/* or	1,1,1; */						\
727/* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */				\
728	or	31,31,31;						\
729/* ALT_##TYPE##_SECTION_END(0, 1) */					\
730	or	1,1,1;							\
731	or	1,1,1;							\
732	/* Nested alt sections, else with inner else taken */		\
733/* BEGIN_##TYPE##_SECTION */						\
734	/* or	2,2,2; */						\
735/* BEGIN_##TYPE##_SECTION_NESTED(95) */					\
736	/* or	1,1,1; */						\
737/* ##TYPE##_SECTION_ELSE_NESTED(95) */					\
738	/* or	5,5,5; */						\
739/* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */				\
740	/* or	2,2,2; */						\
741/* ##TYPE##_SECTION_ELSE */						\
742	or	31,31,31;						\
743/* BEGIN_##TYPE##_SECTION_NESTED(94) */					\
744	/* or	5,5,5; */						\
745/* ##TYPE##_SECTION_ELSE_NESTED(94) */					\
746	or	1,1,1;							\
747/* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */				\
748	or	31,31,31;						\
749/* ALT_##TYPE##_SECTION_END(0, 1) */					\
750	or	1,1,1;							\
751	or	1,1,1;							\
752	/* Nested alt sections, else can have large else case */	\
753/* BEGIN_##TYPE##_SECTION */						\
754	/* or	2,2,2; */						\
755	/* or	2,2,2; */						\
756	/* or	2,2,2; */						\
757	/* or	2,2,2; */						\
758/* ##TYPE##_SECTION_ELSE */						\
759/* BEGIN_##TYPE##_SECTION_NESTED(94) */					\
760	/* or	5,5,5; */						\
761	/* or	5,5,5; */						\
762	/* or	5,5,5; */						\
763	/* or	5,5,5; */						\
764/* ##TYPE##_SECTION_ELSE_NESTED(94) */					\
765	or	1,1,1;							\
766	or	1,1,1;							\
767	or	1,1,1;							\
768	or	1,1,1;							\
769/* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */				\
770/* ALT_##TYPE##_SECTION_END(0, 1) */					\
771	or	1,1,1;							\
772	or	1,1,1;
773
774MAKE_MACRO_TEST(FTR);
775MAKE_MACRO_TEST_EXPECTED(FTR);
776
777#ifdef CONFIG_PPC64
778MAKE_MACRO_TEST(FW_FTR);
779MAKE_MACRO_TEST_EXPECTED(FW_FTR);
780#endif
781
782globl(lwsync_fixup_test)
7831:	or	1,1,1
784	LWSYNC
785globl(end_lwsync_fixup_test)
786
787globl(lwsync_fixup_test_expected_LWSYNC)
7881:	or	1,1,1
789	lwsync
790
791globl(lwsync_fixup_test_expected_SYNC)
7921:	or	1,1,1
793	sync
794
795globl(ftr_fixup_prefix1)
796	or	1,1,1
797	.long OP_PREFIX << 26
798	.long 0x0000000
799	or	2,2,2
800globl(end_ftr_fixup_prefix1)
801
802globl(ftr_fixup_prefix1_orig)
803	or	1,1,1
804	.long OP_PREFIX << 26
805	.long 0x0000000
806	or	2,2,2
807
808globl(ftr_fixup_prefix1_expected)
809	or	1,1,1
810	nop
811	nop
812	or	2,2,2
813
814globl(ftr_fixup_prefix2)
815	or	1,1,1
816	.long OP_PREFIX << 26
817	.long 0x0000000
818	or	2,2,2
819globl(end_ftr_fixup_prefix2)
820
821globl(ftr_fixup_prefix2_orig)
822	or	1,1,1
823	.long OP_PREFIX << 26
824	.long 0x0000000
825	or	2,2,2
826
827globl(ftr_fixup_prefix2_alt)
828	.long OP_PREFIX << 26
829	.long 0x0000001
830
831globl(ftr_fixup_prefix2_expected)
832	or	1,1,1
833	.long OP_PREFIX << 26
834	.long 0x0000001
835	or	2,2,2
836
837globl(ftr_fixup_prefix3)
838	or	1,1,1
839	.long OP_PREFIX << 26
840	.long 0x0000000
841	or	2,2,2
842	or	3,3,3
843globl(end_ftr_fixup_prefix3)
844
845globl(ftr_fixup_prefix3_orig)
846	or	1,1,1
847	.long OP_PREFIX << 26
848	.long 0x0000000
849	or	2,2,2
850	or	3,3,3
851
852globl(ftr_fixup_prefix3_alt)
853	.long OP_PREFIX << 26
854	.long 0x0000001
855	nop
856
857globl(ftr_fixup_prefix3_expected)
858	or	1,1,1
859	.long OP_PREFIX << 26
860	.long 0x0000001
861	nop
862	or	3,3,3
863