BUG_ON(ret);
}
-int apply_alternatives(void *start, size_t length)
+int apply_alternatives(const struct alt_instr *start, const struct alt_instr *end)
{
const struct alt_region region = {
.begin = start,
- .end = start + length,
+ .end = end,
};
return __apply_alternatives(®ion);
* APs have less capabilities than the boot processor are not handled.
* Tough. Make sure you disable such features by hand.
*/
-void init_or_livepatch apply_alternatives_nocheck(struct alt_instr *start, struct alt_instr *end)
+void init_or_livepatch apply_alternatives(const struct alt_instr *start,
+ const struct alt_instr *end)
{
- struct alt_instr *a;
+ const struct alt_instr *a;
u8 *instr, *replacement;
u8 insnbuf[MAX_PATCH_LEN];
* This routine is called with local interrupt disabled and used during
* bootup.
*/
-void __init apply_alternatives(struct alt_instr *start, struct alt_instr *end)
-{
- unsigned long cr0 = read_cr0();
-
- ASSERT(!local_irq_is_enabled());
-
- /* Disable WP to allow application of alternatives to read-only pages. */
- write_cr0(cr0 & ~X86_CR0_WP);
-
- apply_alternatives_nocheck(start, end);
-
- /* Reinstate WP. */
- write_cr0(cr0);
-}
-
void __init alternative_instructions(void)
{
nmi_callback_t *saved_nmi_callback;
+ unsigned long cr0 = read_cr0();
arch_init_ideal_nops();
* expect a machine check to cause undue problems during to code
* patching.
*/
+ ASSERT(!local_irq_is_enabled());
+
+ /* Disable WP to allow application of alternatives to read-only pages. */
+ write_cr0(cr0 & ~X86_CR0_WP);
+
apply_alternatives(__alt_instructions, __alt_instructions_end);
+ /* Reinstate WP. */
+ write_cr0(cr0);
+
set_nmi_callback(saved_nmi_callback);
}
return -EINVAL;
}
}
- apply_alternatives_nocheck(start, end);
+ apply_alternatives(start, end);
}
sec = livepatch_elf_sec_by_name(elf, ".ex_table");
#define ALT_REPL_PTR(a) __ALT_PTR(a, alt_offset)
void __init apply_alternatives_all(void);
-int apply_alternatives(void *start, size_t length);
+int apply_alternatives(const struct alt_instr *start, const struct alt_instr *end);
#define ALTINSTR_ENTRY(feature) \
" .word 661b - .\n" /* label */ \
#define ALT_ORIG_PTR(a) __ALT_PTR(a, instr_offset)
#define ALT_REPL_PTR(a) __ALT_PTR(a, repl_offset)
-/* Similar to apply_alternatives except it can be run with IRQs enabled. */
-extern void apply_alternatives_nocheck(struct alt_instr *start,
- struct alt_instr *end);
-extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
+/* Similar to alternative_instructions except it can be run with IRQs enabled. */
+extern void apply_alternatives(const struct alt_instr *start,
+ const struct alt_instr *end);
extern void alternative_instructions(void);
#define OLDINSTR(oldinstr) "661:\n\t" oldinstr "\n662:\n"