1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright 2008 Michael Ellerman, IBM Corporation.
6 #include <asm/feature-fixups.h>
7 #include <asm/ppc_asm.h>
9 #include <asm/asm-compat.h>
10 #include <asm/ppc-opcode.h>
18 globl(ftr_fixup_test1)
20 or 2,2,2 /* fixup will nop out this instruction */
23 globl(end_ftr_fixup_test1)
25 globl(ftr_fixup_test1_orig)
30 globl(ftr_fixup_test1_expected)
35 globl(ftr_fixup_test2)
37 or 2,2,2 /* fixup will replace this with ftr_fixup_test2_alt */
40 globl(end_ftr_fixup_test2)
42 globl(ftr_fixup_test2_orig)
47 globl(ftr_fixup_test2_alt)
50 globl(ftr_fixup_test2_expected)
55 globl(ftr_fixup_test3)
57 or 2,2,2 /* fixup will fail to replace this */
60 globl(end_ftr_fixup_test3)
62 globl(ftr_fixup_test3_orig)
67 globl(ftr_fixup_test3_alt)
71 globl(ftr_fixup_test4)
79 globl(end_ftr_fixup_test4)
81 globl(ftr_fixup_test4_expected)
89 globl(ftr_fixup_test4_orig)
97 globl(ftr_fixup_test4_alt)
102 globl(ftr_fixup_test5)
120 ALT_FTR_SECTION_END(0, 1)
123 globl(end_ftr_fixup_test5)
125 globl(ftr_fixup_test5_expected)
136 globl(ftr_fixup_test6)
152 ALT_FTR_SECTION_END(0, 1)
157 globl(end_ftr_fixup_test6)
159 globl(ftr_fixup_test6_expected)
171 globl(ftr_fixup_test7)
190 ALT_FTR_SECTION_END(0, 1)
194 globl(end_ftr_fixup_test7)
197 globl(ftr_fixup_test7_expected)
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.
212 ftr_fixup_test_too_big:
223 ALT_FTR_SECTION_END(0, 1)
227 #define MAKE_MACRO_TEST(TYPE) \
228 globl(ftr_fixup_test_ ##TYPE##_macros) \
230 /* Basic test, this section should all be nop'ed */ \
231 BEGIN_##TYPE##_SECTION \
235 END_##TYPE##_SECTION(0, 1) \
238 /* Basic test, this section should NOT be nop'ed */ \
239 BEGIN_##TYPE##_SECTION \
243 END_##TYPE##_SECTION(0, 0) \
246 /* Nesting test, inner section should be nop'ed */ \
247 BEGIN_##TYPE##_SECTION \
250 BEGIN_##TYPE##_SECTION_NESTED(80) \
253 END_##TYPE##_SECTION_NESTED(0, 1, 80) \
256 END_##TYPE##_SECTION(0, 0) \
259 /* Nesting test, whole section should be nop'ed */ \
260 BEGIN_##TYPE##_SECTION \
263 BEGIN_##TYPE##_SECTION_NESTED(80) \
266 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
269 END_##TYPE##_SECTION(0, 1) \
272 /* Nesting test, none should be nop'ed */ \
273 BEGIN_##TYPE##_SECTION \
276 BEGIN_##TYPE##_SECTION_NESTED(80) \
279 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
282 END_##TYPE##_SECTION(0, 0) \
285 /* Basic alt section test, default case should be taken */ \
286 BEGIN_##TYPE##_SECTION \
290 ##TYPE##_SECTION_ELSE \
293 ALT_##TYPE##_SECTION_END(0, 0) \
296 /* Basic alt section test, else case should be taken */ \
297 BEGIN_##TYPE##_SECTION \
301 ##TYPE##_SECTION_ELSE \
305 ALT_##TYPE##_SECTION_END(0, 1) \
308 /* Alt with smaller else case, should be padded with nops */ \
309 BEGIN_##TYPE##_SECTION \
313 ##TYPE##_SECTION_ELSE \
315 ALT_##TYPE##_SECTION_END(0, 1) \
318 /* Alt section with nested section in default case */ \
319 /* Default case should be taken, with nop'ed inner section */ \
320 BEGIN_##TYPE##_SECTION \
322 BEGIN_##TYPE##_SECTION_NESTED(95) \
325 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
327 ##TYPE##_SECTION_ELSE \
330 ALT_##TYPE##_SECTION_END(0, 0) \
333 /* Alt section with nested section in else, default taken */ \
334 BEGIN_##TYPE##_SECTION \
338 ##TYPE##_SECTION_ELSE \
340 BEGIN_##TYPE##_SECTION_NESTED(95) \
342 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
344 ALT_##TYPE##_SECTION_END(0, 0) \
347 /* Alt section with nested section in else, else taken & nop */ \
348 BEGIN_##TYPE##_SECTION \
352 ##TYPE##_SECTION_ELSE \
354 BEGIN_##TYPE##_SECTION_NESTED(95) \
356 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
358 ALT_##TYPE##_SECTION_END(0, 1) \
361 /* Feature section with nested alt section, default taken */ \
362 BEGIN_##TYPE##_SECTION \
364 BEGIN_##TYPE##_SECTION_NESTED(95) \
366 ##TYPE##_SECTION_ELSE_NESTED(95) \
368 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
370 END_##TYPE##_SECTION(0, 0) \
373 /* Feature section with nested alt section, else taken */ \
374 BEGIN_##TYPE##_SECTION \
376 BEGIN_##TYPE##_SECTION_NESTED(95) \
378 ##TYPE##_SECTION_ELSE_NESTED(95) \
380 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
382 END_##TYPE##_SECTION(0, 0) \
385 /* Feature section with nested alt section, all nop'ed */ \
386 BEGIN_##TYPE##_SECTION \
388 BEGIN_##TYPE##_SECTION_NESTED(95) \
390 ##TYPE##_SECTION_ELSE_NESTED(95) \
392 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
394 END_##TYPE##_SECTION(0, 1) \
397 /* Nested alt sections, default with inner default taken */ \
398 BEGIN_##TYPE##_SECTION \
400 BEGIN_##TYPE##_SECTION_NESTED(95) \
402 ##TYPE##_SECTION_ELSE_NESTED(95) \
404 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
406 ##TYPE##_SECTION_ELSE \
408 BEGIN_##TYPE##_SECTION_NESTED(94) \
410 ##TYPE##_SECTION_ELSE_NESTED(94) \
412 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
414 ALT_##TYPE##_SECTION_END(0, 0) \
417 /* Nested alt sections, default with inner else taken */ \
418 BEGIN_##TYPE##_SECTION \
420 BEGIN_##TYPE##_SECTION_NESTED(95) \
422 ##TYPE##_SECTION_ELSE_NESTED(95) \
424 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
426 ##TYPE##_SECTION_ELSE \
428 BEGIN_##TYPE##_SECTION_NESTED(94) \
430 ##TYPE##_SECTION_ELSE_NESTED(94) \
432 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
434 ALT_##TYPE##_SECTION_END(0, 0) \
437 /* Nested alt sections, else with inner default taken */ \
438 BEGIN_##TYPE##_SECTION \
440 BEGIN_##TYPE##_SECTION_NESTED(95) \
442 ##TYPE##_SECTION_ELSE_NESTED(95) \
444 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
446 ##TYPE##_SECTION_ELSE \
448 BEGIN_##TYPE##_SECTION_NESTED(94) \
450 ##TYPE##_SECTION_ELSE_NESTED(94) \
452 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
454 ALT_##TYPE##_SECTION_END(0, 1) \
457 /* Nested alt sections, else with inner else taken */ \
458 BEGIN_##TYPE##_SECTION \
460 BEGIN_##TYPE##_SECTION_NESTED(95) \
462 ##TYPE##_SECTION_ELSE_NESTED(95) \
464 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
466 ##TYPE##_SECTION_ELSE \
468 BEGIN_##TYPE##_SECTION_NESTED(94) \
470 ##TYPE##_SECTION_ELSE_NESTED(94) \
472 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
474 ALT_##TYPE##_SECTION_END(0, 1) \
477 /* Nested alt sections, else can have large else case */ \
478 BEGIN_##TYPE##_SECTION \
483 ##TYPE##_SECTION_ELSE \
484 BEGIN_##TYPE##_SECTION_NESTED(94) \
489 ##TYPE##_SECTION_ELSE_NESTED(94) \
494 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
495 ALT_##TYPE##_SECTION_END(0, 1) \
499 #define MAKE_MACRO_TEST_EXPECTED(TYPE) \
500 globl(ftr_fixup_test_ ##TYPE##_macros_expected) \
502 /* Basic test, this section should all be nop'ed */ \
503 /* BEGIN_##TYPE##_SECTION */ \
507 /* END_##TYPE##_SECTION(0, 1) */ \
510 /* Basic test, this section should NOT be nop'ed */ \
511 /* BEGIN_##TYPE##_SECTION */ \
515 /* END_##TYPE##_SECTION(0, 0) */ \
518 /* Nesting test, inner section should be nop'ed */ \
519 /* BEGIN_##TYPE##_SECTION */ \
522 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
525 /* END_##TYPE##_SECTION_NESTED(0, 1, 80) */ \
528 /* END_##TYPE##_SECTION(0, 0) */ \
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 */ \
536 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
539 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
542 /* END_##TYPE##_SECTION(0, 1) */ \
545 /* Nesting test, none should be nop'ed */ \
546 /* BEGIN_##TYPE##_SECTION */ \
549 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
552 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
555 /* END_##TYPE##_SECTION(0, 0) */ \
558 /* Basic alt section test, default case should be taken */ \
559 /* BEGIN_##TYPE##_SECTION */ \
563 /* ##TYPE##_SECTION_ELSE */ \
566 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
569 /* Basic alt section test, else case should be taken */ \
570 /* BEGIN_##TYPE##_SECTION */ \
574 /* ##TYPE##_SECTION_ELSE */ \
578 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
581 /* Alt with smaller else case, should be padded with nops */ \
582 /* BEGIN_##TYPE##_SECTION */ \
586 /* ##TYPE##_SECTION_ELSE */ \
590 /* ALT_##TYPE##_SECTION_END(0, 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 */ \
597 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
600 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
602 /* ##TYPE##_SECTION_ELSE */ \
605 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
608 /* Alt section with nested section in else, default taken */ \
609 /* BEGIN_##TYPE##_SECTION */ \
613 /* ##TYPE##_SECTION_ELSE */ \
615 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
617 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
619 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
622 /* Alt section with nested section in else, else taken & nop */ \
623 /* BEGIN_##TYPE##_SECTION */ \
627 /* ##TYPE##_SECTION_ELSE */ \
629 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
631 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
633 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
636 /* Feature section with nested alt section, default taken */ \
637 /* BEGIN_##TYPE##_SECTION */ \
639 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
641 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
643 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
645 /* END_##TYPE##_SECTION(0, 0) */ \
648 /* Feature section with nested alt section, else taken */ \
649 /* BEGIN_##TYPE##_SECTION */ \
651 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
653 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
655 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
657 /* END_##TYPE##_SECTION(0, 0) */ \
660 /* Feature section with nested alt section, all nop'ed */ \
661 /* BEGIN_##TYPE##_SECTION */ \
663 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
665 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
667 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
669 /* END_##TYPE##_SECTION(0, 1) */ \
672 /* Nested alt sections, default with inner default taken */ \
673 /* BEGIN_##TYPE##_SECTION */ \
675 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
677 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
679 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
681 /* ##TYPE##_SECTION_ELSE */ \
683 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
685 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
687 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
689 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
692 /* Nested alt sections, default with inner else taken */ \
693 /* BEGIN_##TYPE##_SECTION */ \
695 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
697 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
699 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
701 /* ##TYPE##_SECTION_ELSE */ \
703 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
705 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
707 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
709 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
712 /* Nested alt sections, else with inner default taken */ \
713 /* BEGIN_##TYPE##_SECTION */ \
715 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
717 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
719 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
721 /* ##TYPE##_SECTION_ELSE */ \
723 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
725 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
727 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
729 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
732 /* Nested alt sections, else with inner else taken */ \
733 /* BEGIN_##TYPE##_SECTION */ \
735 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
737 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
739 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
741 /* ##TYPE##_SECTION_ELSE */ \
743 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
745 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
747 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
749 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
752 /* Nested alt sections, else can have large else case */ \
753 /* BEGIN_##TYPE##_SECTION */ \
758 /* ##TYPE##_SECTION_ELSE */ \
759 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
764 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
769 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
770 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
774 MAKE_MACRO_TEST(FTR);
775 MAKE_MACRO_TEST_EXPECTED(FTR);
778 MAKE_MACRO_TEST(FW_FTR);
779 MAKE_MACRO_TEST_EXPECTED(FW_FTR);
782 globl(lwsync_fixup_test)
785 globl(end_lwsync_fixup_test)
787 globl(lwsync_fixup_test_expected_LWSYNC)
791 globl(lwsync_fixup_test_expected_SYNC)
795 globl(ftr_fixup_prefix1)
797 .long OP_PREFIX << 26
800 globl(end_ftr_fixup_prefix1)
802 globl(ftr_fixup_prefix1_orig)
804 .long OP_PREFIX << 26
808 globl(ftr_fixup_prefix1_expected)
814 globl(ftr_fixup_prefix2)
816 .long OP_PREFIX << 26
819 globl(end_ftr_fixup_prefix2)
821 globl(ftr_fixup_prefix2_orig)
823 .long OP_PREFIX << 26
827 globl(ftr_fixup_prefix2_alt)
828 .long OP_PREFIX << 26
831 globl(ftr_fixup_prefix2_expected)
833 .long OP_PREFIX << 26
837 globl(ftr_fixup_prefix3)
839 .long OP_PREFIX << 26
843 globl(end_ftr_fixup_prefix3)
845 globl(ftr_fixup_prefix3_orig)
847 .long OP_PREFIX << 26
852 globl(ftr_fixup_prefix3_alt)
853 .long OP_PREFIX << 26
857 globl(ftr_fixup_prefix3_expected)
859 .long OP_PREFIX << 26