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

Re: [PATCH 09/14] ACPI: address a Misra rule 11.8 violation in Arm code


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Tue, 22 Sep 2026 21:18:31 +0000
  • Accept-language: en-US
  • 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=A4KMALGWBREel2hCxC00aazS8xleixzBvLDh+8W/RgE=; b=K97b5qW54Cp+nHodS47Lmh/VcRvzkvfA6yIqbkd6a9s4VyGPIXtBi0Z3JdhE/NFQMk0qIN4/Z9EE6znLJIgg7Mk5Ma36Qwmfo9UzQpGyNxiOw9mZcpfhrP5f6R4cnd6B1xCLWLn5b+czBs6BCtvfv5+ue8Hee+Z2U6L2Hj6pR9LjQ8Ily6N5+xm7VE3LvbID2GzoDm3cAkn7L7tknSHU7OcvytlKl29dyBuWHDcOuf2lwsq1m3DhuWqbYGLNdgoW9PZzxsqWOWJtKixccjJakANlKIRxA9+IqTKF2TPgqpiiIualz9SJnk8No9Mdco67UTfrkH43P0eaysLZB3h/2w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h/NGHD1RMZYhDVs3/TftudDlvnxmAG5Qz2vqOJ8wWJnDNTzogxcI3CXa3RdjZln6gN/CHC8UWkAXSRtr/5dGiiXyD7xcrf2iHE4DwJlH1v1tI/WRP2PGc79YJvWMTqUkTHn31QzOCr5Ahf9Z72V36ky7kFH51O1HP49CNA5td1mRuD+5g68p3TJuTDxFwrD5G8mNRYlNqWGgpuWjBwpSo6tBOlpfiD94PECr9X5A3PsvSId3T/pig1U5B9/6jtWCCgyvhRBOaUhfiQNbEp0czTAKmOJ6lFet4IzsyeYZimg6zYrSbl9PBrjGyTZlOMZJCj3gZ1gTq9iCb+n4K2s8kQ==
  • 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: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Tue, 22 Sep 2026 21:18:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdOqUePUfY0zBPU0K0F/hx5odMHA==
  • Thread-topic: [PATCH 09/14] ACPI: address a Misra rule 11.8 violation in Arm code

Hi Jan,

Sorry for the late reply

Jan Beulich <jbeulich@xxxxxxxx> writes:

> On 22.09.2026 12:57, Volodymyr Babchuk wrote:
>> Jan Beulich <jbeulich@xxxxxxxx> writes:
>>> On 22.09.2026 03:38, Volodymyr Babchuk wrote:
>>>> Jan Beulich <jbeulich@xxxxxxxx> writes:
>>>>> Outside of drivers/acpi/tables/ (which is excluded from Eclair reporting
>>>>> for dubious reasons), arch/arm/acpi/domain_build.c is the only user of
>>>>> ACPI_COMPARE_NAME(). Make the macro const correct, at the expense of
>>>>> introducing a "const" variant of ACPI_CAST_PTR(), and at the expense of
>>>>
>>>> I think you can avoid adding ACPI_CAST_PTR() by providing a const
>>>> type. Like this:
>>>>
>>>> +#define ACPI_COMPARE_NAME(a, b)         (*ACPI_CAST_PTR (const u32, a) == 
>>>> \
>>>> +                                         *ACPI_CAST_PTR (const u32, b))
>>>
>>> I don't think so. You did notice ...
>>>
>>>>> --- a/xen/include/acpi/acmacros.h
>>>>> +++ b/xen/include/acpi/acmacros.h
>>>>> @@ -103,6 +103,7 @@
>>>>>   * Pointer manipulation
>>>>>   */
>>>>>  #define ACPI_CAST_PTR(t, p)             ((t *) (acpi_uintptr_t) (p))
>>>>> +#define ACPI_CAST_CPTR(t, p)            ((const t *) (const 
>>>>> acpi_uintptr_t) (p))
>>>
>>> ... this, I assume. On the surface it looks odd, because one would expect
>>> acpi_uintptr_t to be a scalar type, like uintptr_t is. But it isn't:
>>>
>>> #ifndef acpi_uintptr_t
>>> #define acpi_uintptr_t                  void *
>>> #endif
>> 
>> Well, that was unexpected. Talk about principle of least surprise...
>> 
>>> The only alternative I see (somewhat more risky overall) would be to
>>> introduce
>>>
>>> #define acpi_uintptr_t                  uintptr_t
>> 
>> What are the risks? I'd really prefer to have fewer gotchas in the code.
>
> It hides casting away of const-ness. Right here we would like that, yet in
> the general case I think we don't. Otoh Linux switched to the above in the
> 5.18 dev cycle.

... but for different reason. clang complained about pointer
subtraction with a null pointer. This does not fired in Xen because we
are not using ACPI_PTR_DIFF() yet. But, if we are going to use it, we'll
face the same problem.

So, if we are already touching this parts, maybe it is better port that
Linux patch ([1]) and use const types as I suggested?


[1] https://lore.kernel.org/linux-acpi/20210927121338.938994-1-arnd@xxxxxxxxxx, 

-- 
WBR, Volodymyr


 


Rackspace

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