[PATCH] ACPI/IORT: fix IORT Reserved Memory Range node mapping error

Marc Zyngier maz at kernel.org
Mon Jul 17 02:25:53 PDT 2023


On 2023-07-17 10:07, guanghui.fgh wrote:
> 在 2023/7/17 16:48, Marc Zyngier 写道:
>> On 2023-07-17 09:38, Guanghui Feng wrote:
>>> In the ARM IORT specifications DEN 0049E.d, the recommended ID 
>>> mapping format:
>>> Field        Note Description
>>> --------------------------------
>>> Input base    The lowest value in the input range
>>> Number of IDs    The number of IDs in the range "minus" one
>>> 
>>> When there is only one id mapping in the Reserved Memory Range
>>> (RMR) node, the node filed: "Number of IDs" is zero and
>>> iort_node_get_rmr_info will not analyse id mapping. This is
>>> not in compliance with the regulations.
>>> 
>>> Signed-off-by: Guanghui Feng <guanghuifeng at linux.alibaba.com>
>>> ---
>>>  drivers/acpi/arm64/iort.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
>>> index 3631230..8427cc3 100644
>>> --- a/drivers/acpi/arm64/iort.c
>>> +++ b/drivers/acpi/arm64/iort.c
>>> @@ -1007,7 +1007,7 @@ static void iort_node_get_rmr_info(struct
>>> acpi_iort_node *node,
>>>      for (i = 0; i < node->mapping_count; i++, map++) {
>>>          struct acpi_iort_node *parent;
>>> 
>>> -        if (!map->id_count)
>>> +        if (!(map->id_count + 1))
>>>              continue;
>> 
>> struct acpi_iort_id_mapping {
>> [...]
>>      u32 id_count;        /* Number of IDs */
>> [...]
>> };
>> 
>> So the only way for id_count+1 to be 0 is when id_count==~0,
>> making the check even more buggy than it currently is.
>> 
>>          M.
> Thanks for your response.
> 
> It's true. Maybe we should use (id_count == 0xffffffff) or
> (id_count == u32(-1)) to check the mapping count.
> How about this?

That's even worse. Why do you want to check *anything*?

The correct fix is to *drop* this check altogether, and
may fix the type of num_sids as it can overflow (but that's
a separate patch).

         M.
-- 
Jazz is not dead. It just smells funny...



More information about the linux-arm-kernel mailing list