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

Re: [XEN PATCH 12/13] xen/x86: fixed violations of MISRA C:2012 Rule 7.2


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 21 Jun 2023 09:17:56 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=4lmfqkE7JwZA88CjxHCFIroKkc6gZDlIKTmkKWfd4JI=; b=IhihtXxpXzlaA1KsURVFFpsWNu2YFdpGP4GhVoEyaMpxegLrLqxFiZVbfg4oIuXLpH6h8lMjW9ocZHy1sVaXHXxzTFffkw9gf8uMYiaWlKvtUZUiqES46UoUX/fRhsxI+qCqm0e0yo8ZcjCNGKiqDjwUziymSC3ME2N3GhKVGac93B8HYj3DG6zBxbjoAk3RV0CD9eBVNcI404sJVFTINTU6NO8ui9xPh6fxAmerHadihjE1AtJo0AbnCWs01DpcbLQwmji7uTGuq4jAYdeHC4m/sxKOt9hcYBWc4leZPQlJnbBxQNzZAoZnwWd0MoBbKW+mec50BRjHx84RwL2TZQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QpyxFcUsHLmzgXgedxw7irf7JmkUXikwMuYAIjqNw3SXWmHIN39C0cXp/tqmPfROQdFu18I5Mu25eA28U1sudXTnEefLPKSHHXrBwZBcV1WjjxU599cwaV4gm4xotJeGOok4msOIm7JQMiuo4aES5+mEQ/4nHqXuVhBOWmdiyBunWxmg39fI5GEbuHvXYRRX8ec3nUiAls+e8LFk7UY/Y4WPQlZ9Ih49FnDlK/vBUJKWNTRhyVaJl9kX+MhRN/spCvRybCEZfDnY6T5VHJSal41xi2ZyRrrYCw/ZV0NP42Wjly8CskazLQ3s/9ulznAVYOupWFqLYNnGxBEM6gXEgw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, consulting@xxxxxxxxxxx, Gianluca Luparini <gianluca.luparini@xxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Xenia Ragiadakou <Xenia.Ragiadakou@xxxxxxx>, Ayan Kumar <ayan.kumar.halder@xxxxxxx>, Simone Ballarin <simone.ballarin@xxxxxxxxxxx>
  • Delivery-date: Wed, 21 Jun 2023 07:18:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

First of all - please trim replies.

On 20.06.2023 23:23, Stefano Stabellini wrote:
> On Tue, 20 Jun 2023, Simone Ballarin wrote:
>> --- a/xen/arch/x86/percpu.c
>> +++ b/xen/arch/x86/percpu.c
>> @@ -12,7 +12,7 @@ unsigned long __per_cpu_offset[NR_CPUS];
>>   * possible #PF at (NULL + a little) which has security implications in the
>>   * context of PV guests.
>>   */
>> -#define INVALID_PERCPU_AREA (0x8000000000000000L - (long)__per_cpu_start)
>> +#define INVALID_PERCPU_AREA (0x8000000000000000UL - (long)__per_cpu_start)
>>  #define PERCPU_ORDER get_order_from_bytes(__per_cpu_data_end - 
>> __per_cpu_start)
> 
> Hi Jan, should this be ULL?

Not really, no - we're 64-bit only. Furthermore the expression is
about addresses, which correspond to "unsigned long" in our world.

>> --- a/xen/include/public/arch-x86/xen-x86_64.h
>> +++ b/xen/include/public/arch-x86/xen-x86_64.h
>> @@ -53,10 +53,10 @@
>>  #define FLAT_USER_SS32 FLAT_RING3_SS32
>>  #define FLAT_USER_SS   FLAT_USER_SS64
>>  
>> -#define __HYPERVISOR_VIRT_START 0xFFFF800000000000
>> -#define __HYPERVISOR_VIRT_END   0xFFFF880000000000
>> -#define __MACH2PHYS_VIRT_START  0xFFFF800000000000
>> -#define __MACH2PHYS_VIRT_END    0xFFFF804000000000
>> +#define __HYPERVISOR_VIRT_START 0xFFFF800000000000U
>> +#define __HYPERVISOR_VIRT_END   0xFFFF880000000000U
>> +#define __MACH2PHYS_VIRT_START  0xFFFF800000000000U
>> +#define __MACH2PHYS_VIRT_END    0xFFFF804000000000U
> 
> Also here ULL?

UL yes, but as above I don't think ULL is good to use for addresses.
That said, things are a little less clear in the public headers: In
principle it could be a goal for them to be usable on foreign
architectures (say e.g. a 32-bit tool stack, or an analysis tool
which can be run without being on the original host architecture) as
well.

Furthermore, open-coded use of ULL would make this no-longer-C89.
If anything, it would then need to be UINT64_C(), yet even that would
grow our public header dependencies on C99-like infrastructure being
available (right now we only require certain stdint.h-like types;
Arm alone, interestingly, also uses PRIx64 and PRIu64, which may be
kind of unavoidable there).

Jan



 


Rackspace

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