• Home
  • Raw
  • Download

Lines Matching +full:check +full:- +full:patch

1 // SPDX-License-Identifier: GPL-2.0-or-later
19 #include <asm/code-patching.h>
75 start = calc_addr(fcur, fcur->start_off); in patch_feature_section_mask()
76 end = calc_addr(fcur, fcur->end_off); in patch_feature_section_mask()
77 alt_start = calc_addr(fcur, fcur->alt_start_off); in patch_feature_section_mask()
78 alt_end = calc_addr(fcur, fcur->alt_end_off); in patch_feature_section_mask()
80 if ((alt_end - alt_start) > (end - start)) in patch_feature_section_mask()
83 if ((value & fcur->mask & mask) == (fcur->value & mask)) in patch_feature_section_mask()
112 printk("Unable to patch feature section at %p - %p" \ in do_feature_fixups_mask()
113 " with %p - %p\n", in do_feature_fixups_mask()
114 calc_addr(fcur, fcur->start_off), in do_feature_fixups_mask()
115 calc_addr(fcur, fcur->end_off), in do_feature_fixups_mask()
116 calc_addr(fcur, fcur->alt_start_off), in do_feature_fixups_mask()
117 calc_addr(fcur, fcur->alt_end_off)); in do_feature_fixups_mask()
211 printk(KERN_DEBUG "stf-barrier: patched %d entry locations (%s barrier)\n", i, in do_stf_entry_barrier_fixups()
257 printk(KERN_DEBUG "stf-barrier: patched %d exit locations (%s barrier)\n", i, in do_stf_exit_barrier_fixups()
282 * The call to the fallback entry flush, and the fallback/sync-ori exit in do_stf_barrier_fixups()
288 * The branch to mark interrupt exits non-reentrant is enabled first, in do_stf_barrier_fixups()
341 printk(KERN_DEBUG "uaccess-flush: patched %d locations (%s flush)\n", i, in do_uaccess_flush_fixups()
379 * order in which we patch instructions. That's because it's possible we could in __do_entry_flush_fixups()
383 * To make that work, when patching in the fallback flush we patch in this order: in __do_entry_flush_fixups()
384 * - the mflr (dest) in __do_entry_flush_fixups()
385 * - the mtlr (dest + 2) in __do_entry_flush_fixups()
386 * - the branch (dest + 1) in __do_entry_flush_fixups()
389 * patch the mtlr last, it's possible we could return from the branch and not in __do_entry_flush_fixups()
393 * we patch in this order: in __do_entry_flush_fixups()
394 * - the branch (dest + 1) in __do_entry_flush_fixups()
395 * - the mtlr (dest + 2) in __do_entry_flush_fixups()
396 * - the mflr (dest) in __do_entry_flush_fixups()
399 * semi-patched state. in __do_entry_flush_fixups()
412 printk(KERN_DEBUG "entry-flush: patched %d locations (%s flush)\n", i, in __do_entry_flush_fixups()
464 printk(KERN_DEBUG "rfi-flush: patched %d locations (%s flush)\n", i, in __do_rfi_flush_fixups()
514 pr_info("barrier-nospec: using ORI speculation barrier\n"); in do_barrier_nospec_fixups_range()
520 printk(KERN_DEBUG "barrier-nospec: patched %d locations\n", i); in do_barrier_nospec_fixups_range()
551 pr_info("barrier-nospec: using isync; sync as speculation barrier\n"); in do_barrier_nospec_fixups_range()
558 printk(KERN_DEBUG "barrier-nospec: patched %d locations\n", i); in do_barrier_nospec_fixups_range()
613 end = (void *)src + (__end_interrupts - _stext); in do_final_fixups()
634 *PTRRELOC(&saved_cpu_features) = spec->cpu_features; in apply_feature_fixups()
635 *PTRRELOC(&saved_mmu_features) = spec->mmu_features; in apply_feature_fixups()
638 * Apply the CPU-specific and firmware specific fixups to kernel text in apply_feature_fixups()
641 do_feature_fixups(spec->cpu_features, in apply_feature_fixups()
645 do_feature_fixups(spec->mmu_features, in apply_feature_fixups()
649 do_lwsync_fixups(spec->cpu_features, in apply_feature_fixups()
664 saved_mmu_features |= cur_cpu_spec->mmu_features & mask; in update_mmu_feature_fixups()
666 do_feature_fixups_mask(cur_cpu_spec->mmu_features, mask, in update_mmu_feature_fixups()
686 WARN(saved_cpu_features != cur_cpu_spec->cpu_features, in check_features()
688 WARN(saved_mmu_features != cur_cpu_spec->mmu_features, in check_features()
701 #define check(x) \ macro
702 if (!(x)) printk("feature-fixups: test failed at line %d\n", __LINE__);
714 return (unsigned long)p - (unsigned long)entry; in calc_offset()
723 int size = 4 * (end_ftr_fixup_test1 - ftr_fixup_test1); in test_basic_patching()
730 /* Sanity check */ in test_basic_patching()
731 check(memcmp(ftr_fixup_test1, ftr_fixup_test1_orig, size) == 0); in test_basic_patching()
733 /* Check we don't patch if the value matches */ in test_basic_patching()
735 check(memcmp(ftr_fixup_test1, ftr_fixup_test1_orig, size) == 0); in test_basic_patching()
737 /* Check we do patch if the value doesn't match */ in test_basic_patching()
739 check(memcmp(ftr_fixup_test1, ftr_fixup_test1_expected, size) == 0); in test_basic_patching()
741 /* Check we do patch if the mask doesn't match */ in test_basic_patching()
743 check(memcmp(ftr_fixup_test1, ftr_fixup_test1_orig, size) == 0); in test_basic_patching()
745 check(memcmp(ftr_fixup_test1, ftr_fixup_test1_expected, size) == 0); in test_basic_patching()
755 int size = 4 * (end_ftr_fixup_test2 - ftr_fixup_test2); in test_alternative_patching()
763 /* Sanity check */ in test_alternative_patching()
764 check(memcmp(ftr_fixup_test2, ftr_fixup_test2_orig, size) == 0); in test_alternative_patching()
766 /* Check we don't patch if the value matches */ in test_alternative_patching()
768 check(memcmp(ftr_fixup_test2, ftr_fixup_test2_orig, size) == 0); in test_alternative_patching()
770 /* Check we do patch if the value doesn't match */ in test_alternative_patching()
772 check(memcmp(ftr_fixup_test2, ftr_fixup_test2_expected, size) == 0); in test_alternative_patching()
774 /* Check we do patch if the mask doesn't match */ in test_alternative_patching()
776 check(memcmp(ftr_fixup_test2, ftr_fixup_test2_orig, size) == 0); in test_alternative_patching()
778 check(memcmp(ftr_fixup_test2, ftr_fixup_test2_expected, size) == 0); in test_alternative_patching()
787 int size = 4 * (end_ftr_fixup_test3 - ftr_fixup_test3); in test_alternative_case_too_big()
795 /* Sanity check */ in test_alternative_case_too_big()
796 check(memcmp(ftr_fixup_test3, ftr_fixup_test3_orig, size) == 0); in test_alternative_case_too_big()
799 check(patch_feature_section(0xF, &fixup) == 1); in test_alternative_case_too_big()
800 check(memcmp(ftr_fixup_test3, ftr_fixup_test3_orig, size) == 0); in test_alternative_case_too_big()
801 check(patch_feature_section(0, &fixup) == 1); in test_alternative_case_too_big()
802 check(memcmp(ftr_fixup_test3, ftr_fixup_test3_orig, size) == 0); in test_alternative_case_too_big()
803 check(patch_feature_section(~0xF, &fixup) == 1); in test_alternative_case_too_big()
804 check(memcmp(ftr_fixup_test3, ftr_fixup_test3_orig, size) == 0); in test_alternative_case_too_big()
814 int size = 4 * (end_ftr_fixup_test4 - ftr_fixup_test4); in test_alternative_case_too_small()
817 /* Check a high-bit flag */ in test_alternative_case_too_small()
818 flag = 1UL << ((sizeof(unsigned long) - 1) * 8); in test_alternative_case_too_small()
825 /* Sanity check */ in test_alternative_case_too_small()
826 check(memcmp(ftr_fixup_test4, ftr_fixup_test4_orig, size) == 0); in test_alternative_case_too_small()
828 /* Check we don't patch if the value matches */ in test_alternative_case_too_small()
830 check(memcmp(ftr_fixup_test4, ftr_fixup_test4_orig, size) == 0); in test_alternative_case_too_small()
832 /* Check we do patch if the value doesn't match */ in test_alternative_case_too_small()
834 check(memcmp(ftr_fixup_test4, ftr_fixup_test4_expected, size) == 0); in test_alternative_case_too_small()
836 /* Check we do patch if the mask doesn't match */ in test_alternative_case_too_small()
838 check(memcmp(ftr_fixup_test4, ftr_fixup_test4_orig, size) == 0); in test_alternative_case_too_small()
840 check(memcmp(ftr_fixup_test4, ftr_fixup_test4_expected, size) == 0); in test_alternative_case_too_small()
848 int size = 4 * (end_ftr_fixup_test5 - ftr_fixup_test5); in test_alternative_case_with_branch()
850 check(memcmp(ftr_fixup_test5, ftr_fixup_test5_expected, size) == 0); in test_alternative_case_with_branch()
858 int size = 4 * (end_ftr_fixup_test6 - ftr_fixup_test6); in test_alternative_case_with_external_branch()
860 check(memcmp(ftr_fixup_test6, ftr_fixup_test6_expected, size) == 0); in test_alternative_case_with_external_branch()
868 int size = 4 * (end_ftr_fixup_test7 - ftr_fixup_test7); in test_alternative_case_with_branch_to_end()
870 check(memcmp(ftr_fixup_test7, ftr_fixup_test7_expected, size) == 0); in test_alternative_case_with_branch_to_end()
877 unsigned long size = ftr_fixup_test_FTR_macros_expected - in test_cpu_macros()
881 check(memcmp(ftr_fixup_test_FTR_macros, in test_cpu_macros()
890 unsigned long size = ftr_fixup_test_FW_FTR_macros_expected - in test_fw_macros()
894 check(memcmp(ftr_fixup_test_FW_FTR_macros, in test_fw_macros()
905 unsigned long size = end_lwsync_fixup_test - in test_lwsync_macros()
909 if (cur_cpu_spec->cpu_features & CPU_FTR_LWSYNC) { in test_lwsync_macros()
910 check(memcmp(lwsync_fixup_test, in test_lwsync_macros()
913 check(memcmp(lwsync_fixup_test, in test_lwsync_macros()
925 int size = sizeof(unsigned int) * (end_ftr_fixup_prefix1 - ftr_fixup_prefix1); in test_prefix_patching()
932 /* Sanity check */ in test_prefix_patching()
933 check(memcmp(ftr_fixup_prefix1, ftr_fixup_prefix1_orig, size) == 0); in test_prefix_patching()
936 check(memcmp(ftr_fixup_prefix1, ftr_fixup_prefix1_expected, size) == 0); in test_prefix_patching()
937 check(memcmp(ftr_fixup_prefix1, ftr_fixup_prefix1_orig, size) != 0); in test_prefix_patching()
947 int size = sizeof(unsigned int) * (end_ftr_fixup_prefix2 - ftr_fixup_prefix2); in test_prefix_alt_patching()
954 /* Sanity check */ in test_prefix_alt_patching()
955 check(memcmp(ftr_fixup_prefix2, ftr_fixup_prefix2_orig, size) == 0); in test_prefix_alt_patching()
958 check(memcmp(ftr_fixup_prefix2, ftr_fixup_prefix2_expected, size) == 0); in test_prefix_alt_patching()
959 check(memcmp(ftr_fixup_prefix2, ftr_fixup_prefix2_orig, size) != 0); in test_prefix_alt_patching()
969 int size = sizeof(unsigned int) * (end_ftr_fixup_prefix3 - ftr_fixup_prefix3); in test_prefix_word_alt_patching()
976 /* Sanity check */ in test_prefix_word_alt_patching()
977 check(memcmp(ftr_fixup_prefix3, ftr_fixup_prefix3_orig, size) == 0); in test_prefix_word_alt_patching()
980 check(memcmp(ftr_fixup_prefix3, ftr_fixup_prefix3_expected, size) == 0); in test_prefix_word_alt_patching()
982 check(memcmp(ftr_fixup_prefix3, ftr_fixup_prefix3_orig, size) != 0); in test_prefix_word_alt_patching()
992 printk(KERN_DEBUG "Running feature fixup self-tests ...\n"); in test_feature_fixups()