@@ -689,6 +689,78 @@ static void test_lwsync_macros(void)
689689 }
690690}
691691
692+ #ifdef CONFIG_PPC64
693+ static void __init test_prefix_patching (void )
694+ {
695+ extern unsigned int ftr_fixup_prefix1 [];
696+ extern unsigned int end_ftr_fixup_prefix1 [];
697+ extern unsigned int ftr_fixup_prefix1_orig [];
698+ extern unsigned int ftr_fixup_prefix1_expected [];
699+ int size = sizeof (unsigned int ) * (end_ftr_fixup_prefix1 - ftr_fixup_prefix1 );
700+
701+ fixup .value = fixup .mask = 8 ;
702+ fixup .start_off = calc_offset (& fixup , ftr_fixup_prefix1 + 1 );
703+ fixup .end_off = calc_offset (& fixup , ftr_fixup_prefix1 + 3 );
704+ fixup .alt_start_off = fixup .alt_end_off = 0 ;
705+
706+ /* Sanity check */
707+ check (memcmp (ftr_fixup_prefix1 , ftr_fixup_prefix1_orig , size ) == 0 );
708+
709+ patch_feature_section (0 , & fixup );
710+ check (memcmp (ftr_fixup_prefix1 , ftr_fixup_prefix1_expected , size ) == 0 );
711+ check (memcmp (ftr_fixup_prefix1 , ftr_fixup_prefix1_orig , size ) != 0 );
712+ }
713+
714+ static void __init test_prefix_alt_patching (void )
715+ {
716+ extern unsigned int ftr_fixup_prefix2 [];
717+ extern unsigned int end_ftr_fixup_prefix2 [];
718+ extern unsigned int ftr_fixup_prefix2_orig [];
719+ extern unsigned int ftr_fixup_prefix2_expected [];
720+ extern unsigned int ftr_fixup_prefix2_alt [];
721+ int size = sizeof (unsigned int ) * (end_ftr_fixup_prefix2 - ftr_fixup_prefix2 );
722+
723+ fixup .value = fixup .mask = 8 ;
724+ fixup .start_off = calc_offset (& fixup , ftr_fixup_prefix2 + 1 );
725+ fixup .end_off = calc_offset (& fixup , ftr_fixup_prefix2 + 3 );
726+ fixup .alt_start_off = calc_offset (& fixup , ftr_fixup_prefix2_alt );
727+ fixup .alt_end_off = calc_offset (& fixup , ftr_fixup_prefix2_alt + 2 );
728+ /* Sanity check */
729+ check (memcmp (ftr_fixup_prefix2 , ftr_fixup_prefix2_orig , size ) == 0 );
730+
731+ patch_feature_section (0 , & fixup );
732+ check (memcmp (ftr_fixup_prefix2 , ftr_fixup_prefix2_expected , size ) == 0 );
733+ check (memcmp (ftr_fixup_prefix2 , ftr_fixup_prefix2_orig , size ) != 0 );
734+ }
735+
736+ static void __init test_prefix_word_alt_patching (void )
737+ {
738+ extern unsigned int ftr_fixup_prefix3 [];
739+ extern unsigned int end_ftr_fixup_prefix3 [];
740+ extern unsigned int ftr_fixup_prefix3_orig [];
741+ extern unsigned int ftr_fixup_prefix3_expected [];
742+ extern unsigned int ftr_fixup_prefix3_alt [];
743+ int size = sizeof (unsigned int ) * (end_ftr_fixup_prefix3 - ftr_fixup_prefix3 );
744+
745+ fixup .value = fixup .mask = 8 ;
746+ fixup .start_off = calc_offset (& fixup , ftr_fixup_prefix3 + 1 );
747+ fixup .end_off = calc_offset (& fixup , ftr_fixup_prefix3 + 4 );
748+ fixup .alt_start_off = calc_offset (& fixup , ftr_fixup_prefix3_alt );
749+ fixup .alt_end_off = calc_offset (& fixup , ftr_fixup_prefix3_alt + 3 );
750+ /* Sanity check */
751+ check (memcmp (ftr_fixup_prefix3 , ftr_fixup_prefix3_orig , size ) == 0 );
752+
753+ patch_feature_section (0 , & fixup );
754+ check (memcmp (ftr_fixup_prefix3 , ftr_fixup_prefix3_expected , size ) == 0 );
755+ patch_feature_section (0 , & fixup );
756+ check (memcmp (ftr_fixup_prefix3 , ftr_fixup_prefix3_orig , size ) != 0 );
757+ }
758+ #else
759+ static inline void test_prefix_patching (void ) {}
760+ static inline void test_prefix_alt_patching (void ) {}
761+ static inline void test_prefix_word_alt_patching (void ) {}
762+ #endif /* CONFIG_PPC64 */
763+
692764static int __init test_feature_fixups (void )
693765{
694766 printk (KERN_DEBUG "Running feature fixup self-tests ...\n" );
@@ -703,6 +775,9 @@ static int __init test_feature_fixups(void)
703775 test_cpu_macros ();
704776 test_fw_macros ();
705777 test_lwsync_macros ();
778+ test_prefix_patching ();
779+ test_prefix_alt_patching ();
780+ test_prefix_word_alt_patching ();
706781
707782 return 0 ;
708783}
0 commit comments