mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/alternatives: adjust _apply_alternatives() to comply to Misra rule 18.2
While avoiding casts would be preferable here, the subtraction ends up violating "Subtraction between pointers shall only be applied to pointers that address elements of the same array". Use long arithmetic instead. No functional change intended. Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
This commit is contained in:
1 parent
6c98c5368f
commit
b6326545ef
1 file changed
+2
-2
@@ -342,13 +342,13 @@ static int init_or_livepatch _apply_alternatives(struct alt_instr *start,
|
||||
|
||||
/* 0xe8/0xe9 are relative branches; fix the offset. */
|
||||
if ( a->repl_len >= 5 && (*buf & 0xfe) == 0xe8 )
|
||||
*(int32_t *)(buf + 1) += repl - orig;
|
||||
*(int32_t *)(buf + 1) += (long)repl - (long)orig;
|
||||
else if ( IS_ENABLED(CONFIG_RETURN_THUNK) &&
|
||||
a->repl_len > 5 && buf[a->repl_len - 5] == 0xe9 &&
|
||||
((long)repl + a->repl_len +
|
||||
*(int32_t *)(buf + a->repl_len - 4) ==
|
||||
(long)__x86_return_thunk) )
|
||||
*(int32_t *)(buf + a->repl_len - 4) += repl - orig;
|
||||
*(int32_t *)(buf + a->repl_len - 4) += (long)repl - (long)orig;
|
||||
|
||||
a->priv = 1;
|
||||
|
||||
|
||||