[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/6] x86/alternatives: adjust _apply_alternatives() to comply to Misra rule 18.2


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Wed, 7 Oct 2026 17:46:20 +0000
  • Accept-language: en-US, uk-UA, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=etNi6/tzL0jNLVy4LsgM26NsX76EYCqaVyyNtm3ZzvI=; b=DQ1KYllYZBWAPlaA89vy/ZSYn5eUe4y5hjGmQ5p44ubezXFsbdJrTqANhOOEBHOYaiTPLKdIXA+Ix9ajuDwV3Wxu9C2XWoUAmwdEgwr7QlVBD6LD94WPNEmpmKUu374at36v91A8+qtgwZvXMsjeunapS8ejChkCSpvqzPO8oxRat/ep5bkzM0JGJyKUvkwZQ7I7DsuBu+m7CLy1IduhJeErqsha9wdX5vkc6DppvZMw++5vGixCpO8uqAaTwaUewD3Rwm427ht8Ew+52Sp79FO8Ug6xTCPKOVNWljZXraGelIWS3Msd7SxoC8ATClh/xqZKEderlWxtwMuHkzyxKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GVctzl8Je3zIkFAINwci3stlEMkX6ndJ2tDkfOEzAhN1vP4JZaWKLj8LPiIPe7oNnGiTpaHk14RLPwRLxZVYskG15Cr70kUjkTOXK2NCKyfbdCnGdSyrrDOtWVeCp4y+GLylPCEx+ITRod8Xp6j7xmmygicHUODV3pWhptCmIwzJNc1ZHfhqCa/6SMhm9lZMzueJW5Rrwe6Z+2+nG7kvzQ/oJSRBNbqOkoPZ+0iU78d2xXeYxlmQ7EiMQ5GpsDzmkmHSmpNoK1LbqOSL8pwN9N/tylQHWO5tdrsqpJPZaOVCQ4FrymWfFFP/wkMAR0umOsNuEEdnAu4w+RenkD5v0w==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Delivery-date: Wed, 07 Oct 2026 17:46:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdQFsfe75+NzGtXk64qzkN3mSrm7byhs6A
  • Thread-topic: [PATCH 2/6] x86/alternatives: adjust _apply_alternatives() to comply to Misra rule 18.2


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@xxxxxxxx>
> 
> --- 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@xxxxxxxx>

BR, Dmytro.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.