public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] acpi/iort: check output reference for the real used mapping
@ 2020-02-25  9:01 Guoheyi
  2020-02-25 14:57 ` Lorenzo Pieralisi
  2020-02-26  3:42 ` Hanjun Guo
  0 siblings, 2 replies; 3+ messages in thread
From: Guoheyi @ 2020-02-25  9:01 UTC (permalink / raw)
  To: devel
  Cc: wanghaibin.wang, Heyi Guo, Lorenzo Pieralisi, Hanjun Guo,
	Sudeep Holla, Rafael J. Wysocki, Len Brown, linux-acpi,
	linux-arm-kernel, linux-kernel

The function iort_node_map_id() does the sanity check against the
first mapping in the node, but not the one which we really use.

Logically we need check the mapping we use, or check every mapping in
the node. Choose the first fix for we are not firmware tester.

Signed-off-by: Heyi Guo <guoheyi@huawei.com>

---
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Hanjun Guo <guohanjun@huawei.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/acpi/arm64/iort.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index ed3d2d1a7ae9..d0fe8d673240 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -470,13 +470,6 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node,
 		map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node,
 				   node->mapping_offset);
 
-		/* Firmware bug! */
-		if (!map->output_reference) {
-			pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n",
-			       node, node->type);
-			goto fail_map;
-		}
-
 		/*
 		 * Get the special ID mapping index (if any) and skip its
 		 * associated ID map to prevent erroneous multi-stage
@@ -497,6 +490,13 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node,
 		if (i == node->mapping_count)
 			goto fail_map;
 
+		/* Firmware bug! */
+		if (!map->output_reference) {
+			pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n",
+			       node, node->type);
+			goto fail_map;
+		}
+
 		node = ACPI_ADD_PTR(struct acpi_iort_node, iort_table,
 				    map->output_reference);
 	}
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] acpi/iort: check output reference for the real used mapping
  2020-02-25  9:01 [PATCH] acpi/iort: check output reference for the real used mapping Guoheyi
@ 2020-02-25 14:57 ` Lorenzo Pieralisi
  2020-02-26  3:42 ` Hanjun Guo
  1 sibling, 0 replies; 3+ messages in thread
From: Lorenzo Pieralisi @ 2020-02-25 14:57 UTC (permalink / raw)
  To: Heyi Guo
  Cc: devel, wanghaibin.wang, Hanjun Guo, Sudeep Holla,
	Rafael J. Wysocki, Len Brown, linux-acpi, linux-arm-kernel,
	linux-kernel

On Tue, Feb 25, 2020 at 05:01:36PM +0800, Heyi Guo wrote:
> The function iort_node_map_id() does the sanity check against the
> first mapping in the node, but not the one which we really use.
> 
> Logically we need check the mapping we use, or check every mapping in
> the node. Choose the first fix for we are not firmware tester.

Yes, I agree with you, I will think about what's best to do, can
I pick up this patch and resend it on your behalf please ?

Thanks,
Lorenzo

> Signed-off-by: Heyi Guo <guoheyi@huawei.com>
> 
> ---
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Hanjun Guo <guohanjun@huawei.com>
> Cc: Sudeep Holla <sudeep.holla@arm.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/acpi/arm64/iort.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index ed3d2d1a7ae9..d0fe8d673240 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -470,13 +470,6 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node,
>  		map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node,
>  				   node->mapping_offset);
>  
> -		/* Firmware bug! */
> -		if (!map->output_reference) {
> -			pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n",
> -			       node, node->type);
> -			goto fail_map;
> -		}
> -
>  		/*
>  		 * Get the special ID mapping index (if any) and skip its
>  		 * associated ID map to prevent erroneous multi-stage
> @@ -497,6 +490,13 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node,
>  		if (i == node->mapping_count)
>  			goto fail_map;
>  
> +		/* Firmware bug! */
> +		if (!map->output_reference) {
> +			pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n",
> +			       node, node->type);
> +			goto fail_map;
> +		}
> +
>  		node = ACPI_ADD_PTR(struct acpi_iort_node, iort_table,
>  				    map->output_reference);
>  	}
> -- 
> 2.19.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] acpi/iort: check output reference for the real used mapping
  2020-02-25  9:01 [PATCH] acpi/iort: check output reference for the real used mapping Guoheyi
  2020-02-25 14:57 ` Lorenzo Pieralisi
@ 2020-02-26  3:42 ` Hanjun Guo
  1 sibling, 0 replies; 3+ messages in thread
From: Hanjun Guo @ 2020-02-26  3:42 UTC (permalink / raw)
  To: Heyi Guo, devel
  Cc: wanghaibin.wang, Lorenzo Pieralisi, Sudeep Holla,
	Rafael J. Wysocki, Len Brown, linux-acpi, linux-arm-kernel,
	linux-kernel

On 2020/2/25 17:01, Heyi Guo wrote:
> The function iort_node_map_id() does the sanity check against the
> first mapping in the node, but not the one which we really use.
> 
> Logically we need check the mapping we use, or check every mapping in
> the node. Choose the first fix for we are not firmware tester.
> 
> Signed-off-by: Heyi Guo <guoheyi@huawei.com>
> 
> ---
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Hanjun Guo <guohanjun@huawei.com>
> Cc: Sudeep Holla <sudeep.holla@arm.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/acpi/arm64/iort.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index ed3d2d1a7ae9..d0fe8d673240 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -470,13 +470,6 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node,
>  		map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node,
>  				   node->mapping_offset);
>  
> -		/* Firmware bug! */
> -		if (!map->output_reference) {
> -			pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n",
> -			       node, node->type);
> -			goto fail_map;
> -		}
> -
>  		/*
>  		 * Get the special ID mapping index (if any) and skip its
>  		 * associated ID map to prevent erroneous multi-stage
> @@ -497,6 +490,13 @@ static struct acpi_iort_node *iort_node_map_id(struct acpi_iort_node *node,
>  		if (i == node->mapping_count)
>  			goto fail_map;
>  
> +		/* Firmware bug! */
> +		if (!map->output_reference) {
> +			pr_err(FW_BUG "[node %p type %d] ID map has NULL parent reference\n",
> +			       node, node->type);
> +			goto fail_map;
> +		}

I think we can warning on the NULL parent reference when
scanning the mappings in the node, but don't bail out for
the mappings we are not using.

Thanks
Hanjun


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-26  3:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-25  9:01 [PATCH] acpi/iort: check output reference for the real used mapping Guoheyi
2020-02-25 14:57 ` Lorenzo Pieralisi
2020-02-26  3:42 ` Hanjun Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox