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

Re: [PATCH 1/5] x86: Misra fixes for U/L suffixes


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 10 Dec 2025 23:48:51 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=jhMIduWsaFkCdEc76PVfzyk88I9YH9AxedKQH0bu3cU=; b=N0CH9p0IW+WTmYv0KcOxyRWJ6ZezbsyHQQjA31wWQL1CVoRhbj6VEFAzbnRLIjgLh5GAVqnF6ke1FxwhLXWqW2GCMsdAh3M69x95HO9X9jIgHiu7gIDJhtDaH0s9ONz0YSQk/igULcu2kEvSjNwcnGdhhMzzvVTH13oMc6xKVfnjQ5RBxdiyku3pyvzE6yk/KlkU7yfK8Knz+kEQA3gJAzT7eQV8Jr3ysMiKg4n5uQfnyKtiOuGqLoIz6RjBkplqu1z5pRxAi7uibk3sXQ331iIs8kgz+efJ6FE71y7KieBfJIYB1jP3YKdIHHO53cdQ31ovb0M/JEg+hE0etI4+mw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IA1AgH4LZXwTAazd5RsAdN00dT0uq4erPVWulxD7A6ufi29QCyjbNQQrpu8nELiWudGVOFH8FkcDsJJhD2O2Tb52Lwd97FxOIKd3E3gl3gIKIgIsgSErIvtaktW4ZCAttVOPhKUyLCeKEIf1JQ2kRuUS/6nZSbOjyUKb+cPNPWLcSikWzhrLPDc8dveDWdC300unCMbyK/2CuBJx01km8ffe63tbnG1zVhzsJA1pKedQQL50dx9WGZiZXgAD2ULxBJqHD5cjttqnq08bFjP11RwdQywFog7kONn6b3coW/ePz6YAOyQqTvlN202g0DkyXvdNeZREqSQjkBWlMGep4Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "consulting @ bugseng . com" <consulting@xxxxxxxxxxx>
  • Delivery-date: Wed, 10 Dec 2025 23:49:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 10/12/2025 8:31 pm, Nicola Vetrini wrote:
> On 2025-12-10 21:09, Nicola Vetrini wrote:
>> On 2025-12-10 19:30, Andrew Cooper wrote:
>>> diff --git a/xen/include/xen/elfstructs.h
>>> b/xen/include/xen/elfstructs.h
>>> index eb6b87a823a8..8770e7454672 100644
>>> --- a/xen/include/xen/elfstructs.h
>>> +++ b/xen/include/xen/elfstructs.h
>>> @@ -360,7 +360,7 @@ typedef struct {
>>>  } Elf64_Rela;
>>>
>>>  #define    ELF64_R_SYM(info)    ((info) >> 32)
>>> -#define    ELF64_R_TYPE(info)    ((info) & 0xFFFFFFFF)
>>> +#define    ELF64_R_TYPE(info)    ((uint32_t)(info))
>
> Actually I think this doesn't build:
>
> arch/x86/livepatch.c: In function ‘arch_livepatch_perform_rela’:
> ././include/xen/config.h:55:24: error: format ‘%lu’ expects argument
> of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’
> [-Werror=format=]
>    55 | #define XENLOG_ERR     "<0>"
>       |                        ^~~~~
> arch/x86/livepatch.c:332:20: note: in expansion of macro ‘XENLOG_ERR’
>   332 |             printk(XENLOG_ERR LIVEPATCH "%s: Unhandled
> relocation %lu\n",
>       |                    ^~~~~~~~~~
> arch/x86/livepatch.c:332:69: note: format string is defined here
>   332 |             printk(XENLOG_ERR LIVEPATCH "%s: Unhandled
> relocation %lu\n",
>      
> |                                                                   ~~^
>      
> |                                                                     |
>      
> |                                                                    
> long unsigned int
>      
> |                                                                   %u
>
> the error location is a bit unclear, but the cast is the culprit

Yeah, I spotted that just as I heading out, and ran
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2207521982
instead.

I've swapped back to using 0xFFFFFFFFU.  info ends up being long, and
the result of the expression needs to stay that way.

However, looking at the report for that, I still missed one.  I've
folded in this hunk too.

diff --git a/xen/arch/x86/pv/emulate.c b/xen/arch/x86/pv/emulate.c
index 8c44dea12330..e741e686c1af 100644
--- a/xen/arch/x86/pv/emulate.c
+++ b/xen/arch/x86/pv/emulate.c
@@ -37,7 +37,7 @@ int pv_emul_read_descriptor(unsigned int sel, const struct 
vcpu *v,
     if ( !(desc.b & _SEGMENT_L) )
     {
         *base = ((desc.a >> 16) + ((desc.b & 0xff) << 16) +
-                 (desc.b & 0xff000000));
+                 (desc.b & 0xff000000U));
         *limit = (desc.a & 0xffff) | (desc.b & 0x000f0000);
         if ( desc.b & _SEGMENT_G )
             *limit = ((*limit + 1) << 12) - 1;


~Andrew



 


Rackspace

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