2 * Copyright 2008 Michael Ellerman, IBM Corporation.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
11 #include <asm/feature-fixups.h>
12 #include <asm/ppc_asm.h>
20 globl(ftr_fixup_test1)
22 or 2,2,2 /* fixup will nop out this instruction */
25 globl(end_ftr_fixup_test1)
27 globl(ftr_fixup_test1_orig)
32 globl(ftr_fixup_test1_expected)
37 globl(ftr_fixup_test2)
39 or 2,2,2 /* fixup will replace this with ftr_fixup_test2_alt */
42 globl(end_ftr_fixup_test2)
44 globl(ftr_fixup_test2_orig)
49 globl(ftr_fixup_test2_alt)
52 globl(ftr_fixup_test2_expected)
57 globl(ftr_fixup_test3)
59 or 2,2,2 /* fixup will fail to replace this */
62 globl(end_ftr_fixup_test3)
64 globl(ftr_fixup_test3_orig)
69 globl(ftr_fixup_test3_alt)
73 globl(ftr_fixup_test4)
81 globl(end_ftr_fixup_test4)
83 globl(ftr_fixup_test4_expected)
91 globl(ftr_fixup_test4_orig)
99 globl(ftr_fixup_test4_alt)
104 globl(ftr_fixup_test5)
122 ALT_FTR_SECTION_END(0, 1)
125 globl(end_ftr_fixup_test5)
127 globl(ftr_fixup_test5_expected)
138 globl(ftr_fixup_test6)
154 ALT_FTR_SECTION_END(0, 1)
159 globl(end_ftr_fixup_test6)
161 globl(ftr_fixup_test6_expected)
174 #define MAKE_MACRO_TEST(TYPE) \
175 globl(ftr_fixup_test_ ##TYPE##_macros) \
177 /* Basic test, this section should all be nop'ed */ \
178 BEGIN_##TYPE##_SECTION \
182 END_##TYPE##_SECTION(0, 1) \
185 /* Basic test, this section should NOT be nop'ed */ \
186 BEGIN_##TYPE##_SECTION \
190 END_##TYPE##_SECTION(0, 0) \
193 /* Nesting test, inner section should be nop'ed */ \
194 BEGIN_##TYPE##_SECTION \
197 BEGIN_##TYPE##_SECTION_NESTED(80) \
200 END_##TYPE##_SECTION_NESTED(0, 1, 80) \
203 END_##TYPE##_SECTION(0, 0) \
206 /* Nesting test, whole section should be nop'ed */ \
207 BEGIN_##TYPE##_SECTION \
210 BEGIN_##TYPE##_SECTION_NESTED(80) \
213 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
216 END_##TYPE##_SECTION(0, 1) \
219 /* Nesting test, none should be nop'ed */ \
220 BEGIN_##TYPE##_SECTION \
223 BEGIN_##TYPE##_SECTION_NESTED(80) \
226 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
229 END_##TYPE##_SECTION(0, 0) \
232 /* Basic alt section test, default case should be taken */ \
233 BEGIN_##TYPE##_SECTION \
237 ##TYPE##_SECTION_ELSE \
240 ALT_##TYPE##_SECTION_END(0, 0) \
243 /* Basic alt section test, else case should be taken */ \
244 BEGIN_##TYPE##_SECTION \
248 ##TYPE##_SECTION_ELSE \
252 ALT_##TYPE##_SECTION_END(0, 1) \
255 /* Alt with smaller else case, should be padded with nops */ \
256 BEGIN_##TYPE##_SECTION \
260 ##TYPE##_SECTION_ELSE \
262 ALT_##TYPE##_SECTION_END(0, 1) \
265 /* Alt section with nested section in default case */ \
266 /* Default case should be taken, with nop'ed inner section */ \
267 BEGIN_##TYPE##_SECTION \
269 BEGIN_##TYPE##_SECTION_NESTED(95) \
272 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
274 ##TYPE##_SECTION_ELSE \
277 ALT_##TYPE##_SECTION_END(0, 0) \
280 /* Alt section with nested section in else, default taken */ \
281 BEGIN_##TYPE##_SECTION \
285 ##TYPE##_SECTION_ELSE \
287 BEGIN_##TYPE##_SECTION_NESTED(95) \
289 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
291 ALT_##TYPE##_SECTION_END(0, 0) \
294 /* Alt section with nested section in else, else taken & nop */ \
295 BEGIN_##TYPE##_SECTION \
299 ##TYPE##_SECTION_ELSE \
301 BEGIN_##TYPE##_SECTION_NESTED(95) \
303 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
305 ALT_##TYPE##_SECTION_END(0, 1) \
308 /* Feature section with nested alt section, default taken */ \
309 BEGIN_##TYPE##_SECTION \
311 BEGIN_##TYPE##_SECTION_NESTED(95) \
313 ##TYPE##_SECTION_ELSE_NESTED(95) \
315 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
317 END_##TYPE##_SECTION(0, 0) \
320 /* Feature section with nested alt section, else taken */ \
321 BEGIN_##TYPE##_SECTION \
323 BEGIN_##TYPE##_SECTION_NESTED(95) \
325 ##TYPE##_SECTION_ELSE_NESTED(95) \
327 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
329 END_##TYPE##_SECTION(0, 0) \
332 /* Feature section with nested alt section, all nop'ed */ \
333 BEGIN_##TYPE##_SECTION \
335 BEGIN_##TYPE##_SECTION_NESTED(95) \
337 ##TYPE##_SECTION_ELSE_NESTED(95) \
339 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
341 END_##TYPE##_SECTION(0, 1) \
344 /* Nested alt sections, default with inner default taken */ \
345 BEGIN_##TYPE##_SECTION \
347 BEGIN_##TYPE##_SECTION_NESTED(95) \
349 ##TYPE##_SECTION_ELSE_NESTED(95) \
351 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
353 ##TYPE##_SECTION_ELSE \
355 BEGIN_##TYPE##_SECTION_NESTED(94) \
357 ##TYPE##_SECTION_ELSE_NESTED(94) \
359 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
361 ALT_##TYPE##_SECTION_END(0, 0) \
364 /* Nested alt sections, default with inner else taken */ \
365 BEGIN_##TYPE##_SECTION \
367 BEGIN_##TYPE##_SECTION_NESTED(95) \
369 ##TYPE##_SECTION_ELSE_NESTED(95) \
371 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
373 ##TYPE##_SECTION_ELSE \
375 BEGIN_##TYPE##_SECTION_NESTED(94) \
377 ##TYPE##_SECTION_ELSE_NESTED(94) \
379 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
381 ALT_##TYPE##_SECTION_END(0, 0) \
384 /* Nested alt sections, else with inner default taken */ \
385 BEGIN_##TYPE##_SECTION \
387 BEGIN_##TYPE##_SECTION_NESTED(95) \
389 ##TYPE##_SECTION_ELSE_NESTED(95) \
391 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
393 ##TYPE##_SECTION_ELSE \
395 BEGIN_##TYPE##_SECTION_NESTED(94) \
397 ##TYPE##_SECTION_ELSE_NESTED(94) \
399 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
401 ALT_##TYPE##_SECTION_END(0, 1) \
404 /* Nested alt sections, else with inner else taken */ \
405 BEGIN_##TYPE##_SECTION \
407 BEGIN_##TYPE##_SECTION_NESTED(95) \
409 ##TYPE##_SECTION_ELSE_NESTED(95) \
411 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
413 ##TYPE##_SECTION_ELSE \
415 BEGIN_##TYPE##_SECTION_NESTED(94) \
417 ##TYPE##_SECTION_ELSE_NESTED(94) \
419 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
421 ALT_##TYPE##_SECTION_END(0, 1) \
424 /* Nested alt sections, else can have large else case */ \
425 BEGIN_##TYPE##_SECTION \
430 ##TYPE##_SECTION_ELSE \
431 BEGIN_##TYPE##_SECTION_NESTED(94) \
436 ##TYPE##_SECTION_ELSE_NESTED(94) \
441 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
442 ALT_##TYPE##_SECTION_END(0, 1) \
446 #define MAKE_MACRO_TEST_EXPECTED(TYPE) \
447 globl(ftr_fixup_test_ ##TYPE##_macros_expected) \
449 /* Basic test, this section should all be nop'ed */ \
450 /* BEGIN_##TYPE##_SECTION */ \
454 /* END_##TYPE##_SECTION(0, 1) */ \
457 /* Basic test, this section should NOT be nop'ed */ \
458 /* BEGIN_##TYPE##_SECTION */ \
462 /* END_##TYPE##_SECTION(0, 0) */ \
465 /* Nesting test, inner section should be nop'ed */ \
466 /* BEGIN_##TYPE##_SECTION */ \
469 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
472 /* END_##TYPE##_SECTION_NESTED(0, 1, 80) */ \
475 /* END_##TYPE##_SECTION(0, 0) */ \
478 /* Nesting test, whole section should be nop'ed */ \
479 /* NB. inner section is not nop'ed, but then entire outer is */ \
480 /* BEGIN_##TYPE##_SECTION */ \
483 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
486 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
489 /* END_##TYPE##_SECTION(0, 1) */ \
492 /* Nesting test, none should be nop'ed */ \
493 /* BEGIN_##TYPE##_SECTION */ \
496 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
499 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
502 /* END_##TYPE##_SECTION(0, 0) */ \
505 /* Basic alt section test, default case should be taken */ \
506 /* BEGIN_##TYPE##_SECTION */ \
510 /* ##TYPE##_SECTION_ELSE */ \
513 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
516 /* Basic alt section test, else case should be taken */ \
517 /* BEGIN_##TYPE##_SECTION */ \
521 /* ##TYPE##_SECTION_ELSE */ \
525 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
528 /* Alt with smaller else case, should be padded with nops */ \
529 /* BEGIN_##TYPE##_SECTION */ \
533 /* ##TYPE##_SECTION_ELSE */ \
537 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
540 /* Alt section with nested section in default case */ \
541 /* Default case should be taken, with nop'ed inner section */ \
542 /* BEGIN_##TYPE##_SECTION */ \
544 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
547 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
549 /* ##TYPE##_SECTION_ELSE */ \
552 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
555 /* Alt section with nested section in else, default taken */ \
556 /* BEGIN_##TYPE##_SECTION */ \
560 /* ##TYPE##_SECTION_ELSE */ \
562 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
564 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
566 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
569 /* Alt section with nested section in else, else taken & nop */ \
570 /* BEGIN_##TYPE##_SECTION */ \
574 /* ##TYPE##_SECTION_ELSE */ \
576 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
578 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
580 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
583 /* Feature section with nested alt section, default taken */ \
584 /* BEGIN_##TYPE##_SECTION */ \
586 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
588 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
590 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
592 /* END_##TYPE##_SECTION(0, 0) */ \
595 /* Feature section with nested alt section, else taken */ \
596 /* BEGIN_##TYPE##_SECTION */ \
598 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
600 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
602 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
604 /* END_##TYPE##_SECTION(0, 0) */ \
607 /* Feature section with nested alt section, all nop'ed */ \
608 /* BEGIN_##TYPE##_SECTION */ \
610 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
612 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
614 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
616 /* END_##TYPE##_SECTION(0, 1) */ \
619 /* Nested alt sections, default with inner default taken */ \
620 /* BEGIN_##TYPE##_SECTION */ \
622 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
624 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
626 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
628 /* ##TYPE##_SECTION_ELSE */ \
630 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
632 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
634 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
636 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
639 /* Nested alt sections, default with inner else taken */ \
640 /* BEGIN_##TYPE##_SECTION */ \
642 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
644 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
646 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
648 /* ##TYPE##_SECTION_ELSE */ \
650 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
652 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
654 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
656 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
659 /* Nested alt sections, else with inner default taken */ \
660 /* BEGIN_##TYPE##_SECTION */ \
662 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
664 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
666 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
668 /* ##TYPE##_SECTION_ELSE */ \
670 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
672 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
674 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
676 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
679 /* Nested alt sections, else with inner else taken */ \
680 /* BEGIN_##TYPE##_SECTION */ \
682 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
684 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
686 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
688 /* ##TYPE##_SECTION_ELSE */ \
690 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
692 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
694 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
696 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
699 /* Nested alt sections, else can have large else case */ \
700 /* BEGIN_##TYPE##_SECTION */ \
705 /* ##TYPE##_SECTION_ELSE */ \
706 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
711 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
716 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
717 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
721 MAKE_MACRO_TEST(FTR);
722 MAKE_MACRO_TEST_EXPECTED(FTR);
725 MAKE_MACRO_TEST(FW_FTR);
726 MAKE_MACRO_TEST_EXPECTED(FW_FTR);