linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: "guanghui.fgh" <guanghuifeng@linux.alibaba.com>
Cc: lpieralisi@kernel.org, guohanjun@huawei.com,
	sudeep.holla@arm.com, linux-arm-kernel@lists.infradead.org,
	baolin.wang@linux.alibaba.com
Subject: Re: [PATCH] ACPI/IORT: fix IORT Reserved Memory Range node mapping error
Date: Mon, 17 Jul 2023 10:25:53 +0100	[thread overview]
Message-ID: <4718d1aef77161654bb23cdee4adbf43@kernel.org> (raw)
In-Reply-To: <f48b5d84-6c46-36a6-913a-b91dc26f7df3@linux.alibaba.com>

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-07-17  9:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17  8:38 [PATCH] ACPI/IORT: fix IORT Reserved Memory Range node mapping error Guanghui Feng
2023-07-17  8:48 ` Marc Zyngier
2023-07-17  9:03   ` guanghuifeng
2023-07-17  9:07   ` guanghui.fgh
2023-07-17  9:25     ` Marc Zyngier [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-07-17  8:42 Guanghui Feng
2023-07-17  7:57 Guanghui Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4718d1aef77161654bb23cdee4adbf43@kernel.org \
    --to=maz@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=guanghuifeng@linux.alibaba.com \
    --cc=guohanjun@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lpieralisi@kernel.org \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).