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>
17 globl(ftr_fixup_test1)
19 or 2,2,2 /* fixup will nop out this instruction */
22 globl(end_ftr_fixup_test1)
24 globl(ftr_fixup_test1_orig)
29 globl(ftr_fixup_test1_expected)
34 globl(ftr_fixup_test2)
36 or 2,2,2 /* fixup will replace this with ftr_fixup_test2_alt */
39 globl(end_ftr_fixup_test2)
41 globl(ftr_fixup_test2_orig)
46 globl(ftr_fixup_test2_alt)
49 globl(ftr_fixup_test2_expected)
54 globl(ftr_fixup_test3)
56 or 2,2,2 /* fixup will fail to replace this */
59 globl(end_ftr_fixup_test3)
61 globl(ftr_fixup_test3_orig)
66 globl(ftr_fixup_test3_alt)
70 globl(ftr_fixup_test4)
78 globl(end_ftr_fixup_test4)
80 globl(ftr_fixup_test4_expected)
88 globl(ftr_fixup_test4_orig)
96 globl(ftr_fixup_test4_alt)
101 globl(ftr_fixup_test5)
119 ALT_FTR_SECTION_END(0, 1)
122 globl(end_ftr_fixup_test5)
124 globl(ftr_fixup_test5_expected)
135 globl(ftr_fixup_test6)
151 ALT_FTR_SECTION_END(0, 1)
156 globl(end_ftr_fixup_test6)
158 globl(ftr_fixup_test6_expected)
170 globl(ftr_fixup_test7)
189 ALT_FTR_SECTION_END(0, 1)
193 globl(end_ftr_fixup_test7)
196 globl(ftr_fixup_test7_expected)
208 /* Test that if we have a larger else case the assembler spots it and
209 * reports an error. #if 0'ed so as not to break the build normally.
211 ftr_fixup_test_too_big:
222 ALT_FTR_SECTION_END(0, 1)
226 #define MAKE_MACRO_TEST(TYPE) \
227 globl(ftr_fixup_test_ ##TYPE##_macros) \
229 /* Basic test, this section should all be nop'ed */ \
230 BEGIN_##TYPE##_SECTION \
234 END_##TYPE##_SECTION(0, 1) \
237 /* Basic test, this section should NOT be nop'ed */ \
238 BEGIN_##TYPE##_SECTION \
242 END_##TYPE##_SECTION(0, 0) \
245 /* Nesting test, inner section should be nop'ed */ \
246 BEGIN_##TYPE##_SECTION \
249 BEGIN_##TYPE##_SECTION_NESTED(80) \
252 END_##TYPE##_SECTION_NESTED(0, 1, 80) \
255 END_##TYPE##_SECTION(0, 0) \
258 /* Nesting test, whole section should be nop'ed */ \
259 BEGIN_##TYPE##_SECTION \
262 BEGIN_##TYPE##_SECTION_NESTED(80) \
265 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
268 END_##TYPE##_SECTION(0, 1) \
271 /* Nesting test, none should be nop'ed */ \
272 BEGIN_##TYPE##_SECTION \
275 BEGIN_##TYPE##_SECTION_NESTED(80) \
278 END_##TYPE##_SECTION_NESTED(0, 0, 80) \
281 END_##TYPE##_SECTION(0, 0) \
284 /* Basic alt section test, default case should be taken */ \
285 BEGIN_##TYPE##_SECTION \
289 ##TYPE##_SECTION_ELSE \
292 ALT_##TYPE##_SECTION_END(0, 0) \
295 /* Basic alt section test, else case should be taken */ \
296 BEGIN_##TYPE##_SECTION \
300 ##TYPE##_SECTION_ELSE \
304 ALT_##TYPE##_SECTION_END(0, 1) \
307 /* Alt with smaller else case, should be padded with nops */ \
308 BEGIN_##TYPE##_SECTION \
312 ##TYPE##_SECTION_ELSE \
314 ALT_##TYPE##_SECTION_END(0, 1) \
317 /* Alt section with nested section in default case */ \
318 /* Default case should be taken, with nop'ed inner section */ \
319 BEGIN_##TYPE##_SECTION \
321 BEGIN_##TYPE##_SECTION_NESTED(95) \
324 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
326 ##TYPE##_SECTION_ELSE \
329 ALT_##TYPE##_SECTION_END(0, 0) \
332 /* Alt section with nested section in else, default taken */ \
333 BEGIN_##TYPE##_SECTION \
337 ##TYPE##_SECTION_ELSE \
339 BEGIN_##TYPE##_SECTION_NESTED(95) \
341 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
343 ALT_##TYPE##_SECTION_END(0, 0) \
346 /* Alt section with nested section in else, else taken & nop */ \
347 BEGIN_##TYPE##_SECTION \
351 ##TYPE##_SECTION_ELSE \
353 BEGIN_##TYPE##_SECTION_NESTED(95) \
355 END_##TYPE##_SECTION_NESTED(0, 1, 95) \
357 ALT_##TYPE##_SECTION_END(0, 1) \
360 /* Feature section with nested alt section, default taken */ \
361 BEGIN_##TYPE##_SECTION \
363 BEGIN_##TYPE##_SECTION_NESTED(95) \
365 ##TYPE##_SECTION_ELSE_NESTED(95) \
367 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
369 END_##TYPE##_SECTION(0, 0) \
372 /* Feature section with nested alt section, else taken */ \
373 BEGIN_##TYPE##_SECTION \
375 BEGIN_##TYPE##_SECTION_NESTED(95) \
377 ##TYPE##_SECTION_ELSE_NESTED(95) \
379 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
381 END_##TYPE##_SECTION(0, 0) \
384 /* Feature section with nested alt section, all nop'ed */ \
385 BEGIN_##TYPE##_SECTION \
387 BEGIN_##TYPE##_SECTION_NESTED(95) \
389 ##TYPE##_SECTION_ELSE_NESTED(95) \
391 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
393 END_##TYPE##_SECTION(0, 1) \
396 /* Nested alt sections, default with inner default taken */ \
397 BEGIN_##TYPE##_SECTION \
399 BEGIN_##TYPE##_SECTION_NESTED(95) \
401 ##TYPE##_SECTION_ELSE_NESTED(95) \
403 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) \
405 ##TYPE##_SECTION_ELSE \
407 BEGIN_##TYPE##_SECTION_NESTED(94) \
409 ##TYPE##_SECTION_ELSE_NESTED(94) \
411 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
413 ALT_##TYPE##_SECTION_END(0, 0) \
416 /* Nested alt sections, default with inner else taken */ \
417 BEGIN_##TYPE##_SECTION \
419 BEGIN_##TYPE##_SECTION_NESTED(95) \
421 ##TYPE##_SECTION_ELSE_NESTED(95) \
423 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
425 ##TYPE##_SECTION_ELSE \
427 BEGIN_##TYPE##_SECTION_NESTED(94) \
429 ##TYPE##_SECTION_ELSE_NESTED(94) \
431 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
433 ALT_##TYPE##_SECTION_END(0, 0) \
436 /* Nested alt sections, else with inner default taken */ \
437 BEGIN_##TYPE##_SECTION \
439 BEGIN_##TYPE##_SECTION_NESTED(95) \
441 ##TYPE##_SECTION_ELSE_NESTED(95) \
443 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
445 ##TYPE##_SECTION_ELSE \
447 BEGIN_##TYPE##_SECTION_NESTED(94) \
449 ##TYPE##_SECTION_ELSE_NESTED(94) \
451 ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) \
453 ALT_##TYPE##_SECTION_END(0, 1) \
456 /* Nested alt sections, else with inner else taken */ \
457 BEGIN_##TYPE##_SECTION \
459 BEGIN_##TYPE##_SECTION_NESTED(95) \
461 ##TYPE##_SECTION_ELSE_NESTED(95) \
463 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) \
465 ##TYPE##_SECTION_ELSE \
467 BEGIN_##TYPE##_SECTION_NESTED(94) \
469 ##TYPE##_SECTION_ELSE_NESTED(94) \
471 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
473 ALT_##TYPE##_SECTION_END(0, 1) \
476 /* Nested alt sections, else can have large else case */ \
477 BEGIN_##TYPE##_SECTION \
482 ##TYPE##_SECTION_ELSE \
483 BEGIN_##TYPE##_SECTION_NESTED(94) \
488 ##TYPE##_SECTION_ELSE_NESTED(94) \
493 ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) \
494 ALT_##TYPE##_SECTION_END(0, 1) \
498 #define MAKE_MACRO_TEST_EXPECTED(TYPE) \
499 globl(ftr_fixup_test_ ##TYPE##_macros_expected) \
501 /* Basic test, this section should all be nop'ed */ \
502 /* BEGIN_##TYPE##_SECTION */ \
506 /* END_##TYPE##_SECTION(0, 1) */ \
509 /* Basic test, this section should NOT be nop'ed */ \
510 /* BEGIN_##TYPE##_SECTION */ \
514 /* END_##TYPE##_SECTION(0, 0) */ \
517 /* Nesting test, inner section should be nop'ed */ \
518 /* BEGIN_##TYPE##_SECTION */ \
521 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
524 /* END_##TYPE##_SECTION_NESTED(0, 1, 80) */ \
527 /* END_##TYPE##_SECTION(0, 0) */ \
530 /* Nesting test, whole section should be nop'ed */ \
531 /* NB. inner section is not nop'ed, but then entire outer is */ \
532 /* BEGIN_##TYPE##_SECTION */ \
535 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
538 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
541 /* END_##TYPE##_SECTION(0, 1) */ \
544 /* Nesting test, none should be nop'ed */ \
545 /* BEGIN_##TYPE##_SECTION */ \
548 /* BEGIN_##TYPE##_SECTION_NESTED(80) */ \
551 /* END_##TYPE##_SECTION_NESTED(0, 0, 80) */ \
554 /* END_##TYPE##_SECTION(0, 0) */ \
557 /* Basic alt section test, default case should be taken */ \
558 /* BEGIN_##TYPE##_SECTION */ \
562 /* ##TYPE##_SECTION_ELSE */ \
565 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
568 /* Basic alt section test, else case should be taken */ \
569 /* BEGIN_##TYPE##_SECTION */ \
573 /* ##TYPE##_SECTION_ELSE */ \
577 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
580 /* Alt with smaller else case, should be padded with nops */ \
581 /* BEGIN_##TYPE##_SECTION */ \
585 /* ##TYPE##_SECTION_ELSE */ \
589 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
592 /* Alt section with nested section in default case */ \
593 /* Default case should be taken, with nop'ed inner section */ \
594 /* BEGIN_##TYPE##_SECTION */ \
596 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
599 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
601 /* ##TYPE##_SECTION_ELSE */ \
604 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
607 /* Alt section with nested section in else, default taken */ \
608 /* BEGIN_##TYPE##_SECTION */ \
612 /* ##TYPE##_SECTION_ELSE */ \
614 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
616 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
618 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
621 /* Alt section with nested section in else, else taken & nop */ \
622 /* BEGIN_##TYPE##_SECTION */ \
626 /* ##TYPE##_SECTION_ELSE */ \
628 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
630 /* END_##TYPE##_SECTION_NESTED(0, 1, 95) */ \
632 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
635 /* Feature section with nested alt section, default taken */ \
636 /* BEGIN_##TYPE##_SECTION */ \
638 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
640 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
642 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
644 /* END_##TYPE##_SECTION(0, 0) */ \
647 /* Feature section with nested alt section, else taken */ \
648 /* BEGIN_##TYPE##_SECTION */ \
650 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
652 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
654 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
656 /* END_##TYPE##_SECTION(0, 0) */ \
659 /* Feature section with nested alt section, all nop'ed */ \
660 /* BEGIN_##TYPE##_SECTION */ \
662 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
664 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
666 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
668 /* END_##TYPE##_SECTION(0, 1) */ \
671 /* Nested alt sections, default with inner default taken */ \
672 /* BEGIN_##TYPE##_SECTION */ \
674 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
676 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
678 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 95) */ \
680 /* ##TYPE##_SECTION_ELSE */ \
682 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
684 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
686 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
688 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
691 /* Nested alt sections, default with inner else taken */ \
692 /* BEGIN_##TYPE##_SECTION */ \
694 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
696 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
698 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
700 /* ##TYPE##_SECTION_ELSE */ \
702 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
704 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
706 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
708 /* ALT_##TYPE##_SECTION_END(0, 0) */ \
711 /* Nested alt sections, else with inner default taken */ \
712 /* BEGIN_##TYPE##_SECTION */ \
714 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
716 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
718 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
720 /* ##TYPE##_SECTION_ELSE */ \
722 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
724 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
726 /* ALT_##TYPE##_SECTION_END_NESTED(0, 0, 94) */ \
728 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
731 /* Nested alt sections, else with inner else taken */ \
732 /* BEGIN_##TYPE##_SECTION */ \
734 /* BEGIN_##TYPE##_SECTION_NESTED(95) */ \
736 /* ##TYPE##_SECTION_ELSE_NESTED(95) */ \
738 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 95) */ \
740 /* ##TYPE##_SECTION_ELSE */ \
742 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
744 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
746 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
748 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
751 /* Nested alt sections, else can have large else case */ \
752 /* BEGIN_##TYPE##_SECTION */ \
757 /* ##TYPE##_SECTION_ELSE */ \
758 /* BEGIN_##TYPE##_SECTION_NESTED(94) */ \
763 /* ##TYPE##_SECTION_ELSE_NESTED(94) */ \
768 /* ALT_##TYPE##_SECTION_END_NESTED(0, 1, 94) */ \
769 /* ALT_##TYPE##_SECTION_END(0, 1) */ \
773 MAKE_MACRO_TEST(FTR);
774 MAKE_MACRO_TEST_EXPECTED(FTR);
777 MAKE_MACRO_TEST(FW_FTR);
778 MAKE_MACRO_TEST_EXPECTED(FW_FTR);
781 globl(lwsync_fixup_test)
784 globl(end_lwsync_fixup_test)
786 globl(lwsync_fixup_test_expected_LWSYNC)
790 globl(lwsync_fixup_test_expected_SYNC)