Merge branch 'for-next/alternatives' into for-next/core
authorCatalin Marinas <catalin.marinas@arm.com>
Fri, 30 Sep 2022 08:18:22 +0000 (09:18 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 30 Sep 2022 08:18:22 +0000 (09:18 +0100)
* 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

1  2 
arch/arm64/include/asm/assembler.h
arch/arm64/include/asm/cpufeature.h
arch/arm64/kernel/alternative.c
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/proton-pack.c
arch/arm64/tools/cpucaps

Simple merge
Simple merge
@@@ -195,30 -193,11 +196,35 @@@ static void __nocfi __apply_alternative
        }
  }
  
-       DECLARE_BITMAP(all_capabilities, ARM64_NPATCHABLE);
 +void apply_alternatives_vdso(void)
 +{
 +      struct alt_region region;
 +      const struct elf64_hdr *hdr;
 +      const struct elf64_shdr *shdr;
 +      const struct elf64_shdr *alt;
-       bitmap_fill(all_capabilities, ARM64_NPATCHABLE);
++      DECLARE_BITMAP(all_capabilities, ARM64_NCAPS);
 +
++      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(&region, 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);
  }
Simple merge
Simple merge
Simple merge