From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@epam.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 2/6] x86/alternatives: adjust _apply_alternatives() to comply to Misra rule 18.2
Date: Wed, 7 Oct 2026 17:46:20 +0000 [thread overview]
Message-ID: <c49923e9-a773-4d2c-ac3c-75e5168bdef7@epam.com> (raw)
In-Reply-To: <6e503818-3446-4bdc-8b65-d61169667b7a@suse.com>
On 9/9/26 15:59, Jan Beulich wrote:
> 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>
>
> --- a/xen/arch/x86/alternative.c
> +++ b/xen/arch/x86/alternative.c
> @@ -342,13 +342,13 @@ static int init_or_livepatch _apply_alte
>
> /* 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;
>
Reviewed-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
BR, Dmytro.
next prev parent reply other threads:[~2026-10-07 17:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 12:57 [PATCH 0/6] x86: address remaining rule 18.2 violations and mark clean Jan Beulich
2026-09-09 12:59 ` [PATCH 1/6] x86/PV: adjust APPEND_CALL() to comply to Misra rule 18.2 Jan Beulich
2026-10-07 16:06 ` Dmytro Prokopchuk1
2026-09-09 12:59 ` [PATCH 2/6] x86/alternatives: adjust _apply_alternatives() " Jan Beulich
2026-10-07 17:46 ` Dmytro Prokopchuk1 [this message]
2026-09-09 13:00 ` [PATCH 3/6] x86/EFI: adjust efi_multiboot2_prelude() " Jan Beulich
2026-09-09 13:54 ` Marek Marczykowski
2026-09-09 13:00 ` [PATCH 4/6] x86/cpufreq: annotate Eclair false-positives for " Jan Beulich
2026-09-09 13:01 ` [PATCH 5/6] x86/Viridian: " Jan Beulich
2026-09-09 13:13 ` Nicola Vetrini
2026-09-09 13:01 ` [PATCH 6/6] automation/Eclair: tag rules 18.1 and 18.2 as clean Jan Beulich
2026-09-22 0:14 ` Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c49923e9-a773-4d2c-ac3c-75e5168bdef7@epam.com \
--to=dmytro_prokopchuk1@epam.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.