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;