From: Catalin Marinas Date: Fri, 30 Sep 2022 08:18:22 +0000 (+0100) Subject: Merge branch 'for-next/alternatives' into for-next/core X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c704cf27a1adc5fa40fb8e40b5617bdca889a419;p=linux.git Merge branch 'for-next/alternatives' into for-next/core * for-next/alternatives: : Alternatives (code patching) improvements arm64: fix the build with binutils 2.27 arm64: avoid BUILD_BUG_ON() in alternative-macros arm64: alternatives: add shared NOP callback arm64: alternatives: add alternative_has_feature_*() arm64: alternatives: have callbacks take a cap arm64: alternatives: make alt_region const arm64: alternatives: hoist print out of __apply_alternatives() arm64: alternatives: proton-pack: prepare for cap changes arm64: alternatives: kvm: prepare for cap changes arm64: cpufeature: make cpus_have_cap() noinstr-safe --- c704cf27a1adc5fa40fb8e40b5617bdca889a419 diff --cc arch/arm64/kernel/alternative.c index a97775963f356,5a904d4e98eab..64045e3ef03a9 --- a/arch/arm64/kernel/alternative.c +++ b/arch/arm64/kernel/alternative.c @@@ -195,30 -193,11 +196,35 @@@ static void __nocfi __apply_alternative } } +void apply_alternatives_vdso(void) +{ + struct alt_region region; + const struct elf64_hdr *hdr; + const struct elf64_shdr *shdr; + const struct elf64_shdr *alt; - DECLARE_BITMAP(all_capabilities, ARM64_NPATCHABLE); ++ DECLARE_BITMAP(all_capabilities, ARM64_NCAPS); + - bitmap_fill(all_capabilities, ARM64_NPATCHABLE); ++ bitmap_fill(all_capabilities, ARM64_NCAPS); + + hdr = (struct elf64_hdr *)vdso_start; + shdr = (void *)hdr + hdr->e_shoff; + alt = find_section(hdr, shdr, ".altinstructions"); + if (!alt) + return; + + region = (struct alt_region){ + .begin = (void *)hdr + alt->sh_offset, + .end = (void *)hdr + alt->sh_offset + alt->sh_size, + }; + + __apply_alternatives(®ion, false, &all_capabilities[0]); +} + + static const struct alt_region kernel_alternatives = { + .begin = (struct alt_instr *)__alt_instructions, + .end = (struct alt_instr *)__alt_instructions_end, + }; + /* * We might be patching the stop_machine state machine, so implement a * really simple polling protocol here. @@@ -252,7 -227,8 +254,9 @@@ static int __apply_alternatives_multi_s void __init apply_alternatives_all(void) { + pr_info("applying system-wide alternatives\n"); + + apply_alternatives_vdso(); /* better not try code patching on a live SMP system */ stop_machine(__apply_alternatives_multi_stop, NULL, cpu_online_mask); }