Skip to contentSkip to conversation

ACPI, APEI, EINJ, limit the range of einj_param

PATCH Superseded Chen Gong 3 participants 12 messages Feb 28, 2012 – Mar 16, 2012

Subsystems (2)
lore
Share & tools
lore

Chen Gong

author
#0 lore raw

PATCH 1/1 ACPI, APEI, EINJ, limit the range of einj_param

On the platforms with ACPI4.x support, parameter extension is not always doable, which means only parameter extension is enabled, einj_param can take effect.

---
 drivers/acpi/apei/einj.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/apei/einj.c +1 -1
index 4ca087d..0323684 100644
@@ -466,7 +466,7 @@ static int __einj_error_inject(u32 type, u64 param1, u64 param2)
 		rc = apei_exec_run(&ctx, ACPI_EINJ_SET_ERROR_TYPE);
 		if (rc)
 			return rc;
-		if (einj_param) {
+		if (param_extension && einj_param) {
 			struct einj_parameter *v4param = einj_param;
 			v4param->param1 = param1;
 			v4param->param2 = param2;
Signature · 1 line
1.7.8.2.302.g17b4e
#1 lore raw
Quoted 14 lines · Chen Gong

On the platforms with ACPI4.x support, parameter extension is not always doable, which means only parameter extension is enabled, einj_param can take effect.

---
 drivers/acpi/apei/einj.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/apei/einj.c +0 -0
index 4ca087d..0323684 100644

drivers/acpi/apei/einj.c static int __einj_error_inject(u32 type, u64 param1, u64 param2) · line 472

Quoted 8 lines
drivers/acpi/apei/einj.c +1 -1
@@ -466,7 +466,7 @@ static int __einj_error_inject(u32 type, u64 param1, u64 param2)
 		rc = apei_exec_run(&ctx, ACPI_EINJ_SET_ERROR_TYPE);
 		if (rc)
 			return rc;
-		if (einj_param) {
+		if (param_extension && einj_param) {
 			struct einj_parameter *v4param = einj_param;
 			v4param->param1 = param1;
 			v4param->param2 = param2;

Good catch! It appears that is introduced when adding ACPI 5.0 parameter support. Or we can fix einj_get_parameter_address() to return NULL if param_extension is 0 and paddrv5 is 0.

Best Regards,
Huang Ying

reviewer
#2 lore raw
Quoted 2 lines

parameter support. Or we can fix einj_get_parameter_address() to return NULL if param_extension is 0 and paddrv5 is 0.

That was my intent ... but it looks like I managed to lose that in some code re-arrangement.

Perhaps (Outlook will white-space mangle, but it is only one line):

drivers/acpi/apei/einj.c +1 -1
index 4ca087d..3d3816f 100644
@@ -238,7 +238,7 @@ static void *einj_get_parameter_address(void)
 			return v5param;
 		}
 	}
-	if (paddrv4) {
+	if (param_extension && paddrv4) {
 		struct einj_parameter *v4param;
 
 		v4param = acpi_os_map_memory(paddrv4, sizeof(*v4param));
author
#3 lore raw
Quoted 15 lines · Tony
Quoted 2 lines

parameter support. Or we can fix einj_get_parameter_address() to return NULL if param_extension is 0 and paddrv5 is 0.

That was my intent ... but it looks like I managed to lose that in some code re-arrangement.

Perhaps (Outlook will white-space mangle, but it is only one line):

drivers/acpi/apei/einj.c +0 -0
index 4ca087d..3d3816f 100644

drivers/acpi/apei/einj.c static void *einj_get_parameter_address(void) · line 244

Quoted 8 lines
drivers/acpi/apei/einj.c +1 -1
@@ -238,7 +238,7 @@ static void *einj_get_parameter_address(void)
  			return v5param;
  		}
  	}
-	if (paddrv4) {
+	if (param_extension&&  paddrv4) {
  		struct einj_parameter *v4param;
 
  		v4param = acpi_os_map_memory(paddrv4, sizeof(*v4param));

After combination the opinions from Ying and Tony, the current fix is the simplest. Any other changes will make codes more complex. So I prefer to keep current style. What's your opinion?

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw
In reply to Luck, Tony
Quoted 14 lines · Tony
Quoted 2 lines

parameter support. Or we can fix einj_get_parameter_address() to return NULL if param_extension is 0 and paddrv5 is 0.

That was my intent ... but it looks like I managed to lose that in some code re-arrangement.

Perhaps (Outlook will white-space mangle, but it is only one line):

drivers/acpi/apei/einj.c +0 -0
index 4ca087d..3d3816f 100644

drivers/acpi/apei/einj.c static void *einj_get_parameter_address(void) · line 244

Quoted 8 lines
drivers/acpi/apei/einj.c +1 -1
@@ -238,7 +238,7 @@ static void *einj_get_parameter_address(void)
 			return v5param;
 		}
 	}
-	if (paddrv4) {
+	if (param_extension && paddrv4) {
 		struct einj_parameter *v4param;
 
 		v4param = acpi_os_map_memory(paddrv4, sizeof(*v4param));

Good for me. Thanks!

Best Regards,
Huang Ying

reviewer
#4 lore raw
In reply to Chen Gong
Quoted 3 lines

After combination the opinions from Ying and Tony, the current fix is the simplest. Any other changes will make codes more complex. So I prefer to keep current style. What's your opinion?

Not sure which one you mean as "the current fix" (they are both one line, adding a check for param_extension - so neither looks simpler than the other :-).

My opinion is that Ying's suggestion to make einj_get_parameter_address() return NULL is the right one.

-Tony

author
#5 lore raw
Quoted 4 lines · Tony
Quoted 3 lines

After combination the opinions from Ying and Tony, the current fix is the simplest. Any other changes will make codes more complex. So I prefer to keep current style. What's your opinion?

Quoted 9 lines

Not sure which one you mean as "the current fix" (they are both one line, adding a check for param_extension - so neither looks simpler than the other :-).

My opinion is that Ying's suggestion to make einj_get_parameter_address() return NULL is the right one.

-Tony

Sorry, here *current fix* means my patch.
I'm afraid your version as below implies some logic errors:

drivers/acpi/apei/einj.c +1 -1
index 4ca087d..3d3816f 100644
@@ -238,7 +238,7 @@ static void *einj_get_parameter_address(void)
 			return v5param;
 		}
 	}
-	if (paddrv4) {
+	if (param_extension && paddrv4) {
 		struct einj_parameter *v4param;
 
 		v4param = acpi_os_map_memory(paddrv4, sizeof(*v4param));

Because if working under ACPI4.x without param_extension support, there is possible that einj_param has meaning (maybe containing address info?), but we just ignore it under current implementation. Maybe in future we need it so I don't hope to return NULL so early. OTOH, my fix is just ignore einj_param in current logic, not very destructive.
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

reviewer
#6 lore raw
Quoted 5 lines

Because if working under ACPI4.x without param_extension support, there is possible that einj_param has meaning (maybe containing address info?), but we just ignore it under current implementation. Maybe in future we need it so I don't hope to return NULL so early. OTOH, my fix is just ignore einj_param in current logic, not very destructive.

I'm not sure that we'd ever add such extra meaning to einj_param. There aren't going to be any more updates to ACPI 4.x.

Just from a naming point of view - if we don't have the "param" extension enabled - why would "einj_param" need to be set at all?

Stopping early has other advantages:

1) We don't set up a mapping that we'll never use with:

     v4param = acpi_os_map_memory(paddrv4, sizeof (*v4param));

2) We won't uselessly dereference that mapping:

	if (v4param->reserved1 || v4param->reserved2)

-Tony

author
#7 lore raw

PATCH v2 1/1 ACPI, APEI, EINJ, limit the range of einj_param

In reply to Chen Gong

On the platforms with ACPI4.x support, parameter extension is not always doable, which means only parameter extension is enabled, einj_param can take effect.

v2->v1: stopping early in einj_get_parameter_address for einj_param

---
 drivers/acpi/apei/einj.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/apei/einj.c +1 -1
index 4ca087d..3d3816f 100644
@@ -238,7 +238,7 @@ static void *einj_get_parameter_address(void)
 			return v5param;
 		}
 	}
-	if (paddrv4) {
+	if (param_extension && paddrv4) {
 		struct einj_parameter *v4param;
 
 		v4param = acpi_os_map_memory(paddrv4, sizeof(*v4param));
Signature · 1 line
1.7.8.2.302.g17b4e
author
#8 lore raw
Quoted 16 lines · Chen Gong

On the platforms with ACPI4.x support, parameter extension is not always doable, which means only parameter extension is enabled, einj_param can take effect.

v2->v1: stopping early in einj_get_parameter_address for einj_param

---
  drivers/acpi/apei/einj.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/apei/einj.c +0 -0
index 4ca087d..3d3816f 100644

drivers/acpi/apei/einj.c static void *einj_get_parameter_address(void) · line 244

Quoted 8 lines
drivers/acpi/apei/einj.c +1 -1
@@ -238,7 +238,7 @@ static void *einj_get_parameter_address(void)
  			return v5param;
  		}
  	}
-	if (paddrv4) {
+	if (param_extension&&  paddrv4) {
  		struct einj_parameter *v4param;
 
  		v4param = acpi_os_map_memory(paddrv4, sizeof(*v4param));

Hi, Len

Any comment for this?

reviewer Acked-by
#9 lore raw

Review

Quoted 2 lines
(quoted diff) +1 -1
-	if (paddrv4) {
+	if (param_extension&&  paddrv4) {

looks like needs a space moved from after the "&&" to before it. But otherwise:

author
#10 lore raw
Quoted 6 lines · Tony

Review

Quoted 2 lines
(quoted diff) +1 -1
-	if (paddrv4) {
+	if (param_extension&&   paddrv4) {

looks like needs a space moved from after the "&&" to before it. But otherwise:

Not sure why because my patch looks good. Maybe my mail client does something --
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html