|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/alternatives: adjust _apply_alternatives() to comply to Misra rule 18.2
commit b6326545ef0a95092882ac98921d92e012df9f21
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Oct 12 09:39:43 2026 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Oct 12 09:39:43 2026 +0200
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@xxxxxxxx>
Reviewed-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
xen/arch/x86/alternative.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c
index 80c4dc721b..a4cadd9b0b 100644
--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -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;
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |