linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] acpi: fix apei related table size checking
@ 2010-07-23 17:39 Yinghai Lu
  2010-07-26  4:23 ` Bjorn Helgaas
  2010-07-26  7:41 ` Huang Ying
  0 siblings, 2 replies; 4+ messages in thread
From: Yinghai Lu @ 2010-07-23 17:39 UTC (permalink / raw)
  To: Len Brown, Huang Ying, Andi Kleen
  Cc: Stephen Rothwell, Tejun Heo, Daniel J Blueman, linux-acpi,
	linux-kernel


also check if we can find right action in apei.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/acpi/apei/apei-base.c |    5 +++++
 drivers/acpi/apei/einj.c      |    3 ++-
 drivers/acpi/apei/erst.c      |    3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

Index: linux-2.6/drivers/acpi/apei/einj.c
===================================================================
--- linux-2.6.orig/drivers/acpi/apei/einj.c
+++ linux-2.6/drivers/acpi/apei/einj.c
@@ -426,7 +426,8 @@ DEFINE_SIMPLE_ATTRIBUTE(error_inject_fop
 
 static int einj_check_table(struct acpi_table_einj *einj_tab)
 {
-	if (einj_tab->header_length != sizeof(struct acpi_table_einj))
+	if (einj_tab->header_length !=
+	    (sizeof(struct acpi_table_einj) - sizeof(einj_tab->header)))
 		return -EINVAL;
 	if (einj_tab->header.length < sizeof(struct acpi_table_einj))
 		return -EINVAL;
Index: linux-2.6/drivers/acpi/apei/erst.c
===================================================================
--- linux-2.6.orig/drivers/acpi/apei/erst.c
+++ linux-2.6/drivers/acpi/apei/erst.c
@@ -749,7 +749,8 @@ __setup("erst_disable", setup_erst_disab
 
 static int erst_check_table(struct acpi_table_erst *erst_tab)
 {
-	if (erst_tab->header_length != sizeof(struct acpi_table_erst))
+	if (erst_tab->header_length !=
+	    (sizeof(struct acpi_table_erst) - sizeof(erst_tab->header)))
 		return -EINVAL;
 	if (erst_tab->header.length < sizeof(struct acpi_table_erst))
 		return -EINVAL;
Index: linux-2.6/drivers/acpi/apei/apei-base.c
===================================================================
--- linux-2.6.orig/drivers/acpi/apei/apei-base.c
+++ linux-2.6/drivers/acpi/apei/apei-base.c
@@ -163,6 +163,7 @@ int apei_exec_run(struct apei_exec_conte
 	u32 i, ip;
 	struct acpi_whea_header *entry;
 	apei_exec_ins_func_t run;
+	bool found_action = false;
 
 	ctx->ip = 0;
 
@@ -178,6 +179,7 @@ rewind:
 		entry = &ctx->action_table[i];
 		if (entry->action != action)
 			continue;
+		found_action = true;
 		if (ip == ctx->ip) {
 			if (entry->instruction >= ctx->instructions ||
 			    !ctx->ins_table[entry->instruction].run) {
@@ -198,6 +200,9 @@ rewind:
 			goto rewind;
 	}
 
+	if (!found_action)
+		return -ENODEV;
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(apei_exec_run);

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

* Re: [PATCH] acpi: fix apei related table size checking
  2010-07-23 17:39 [PATCH] acpi: fix apei related table size checking Yinghai Lu
@ 2010-07-26  4:23 ` Bjorn Helgaas
  2010-07-26  7:13   ` Andi Kleen
  2010-07-26  7:41 ` Huang Ying
  1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2010-07-26  4:23 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Len Brown, Huang Ying, Andi Kleen, Stephen Rothwell, Tejun Heo,
	Daniel J Blueman, linux-acpi, linux-kernel

On Friday, July 23, 2010 11:39:17 am Yinghai Lu wrote:
> 
> also check if we can find right action in apei.
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>

This should be split into two patches that each fix one thing.

> ---
>  drivers/acpi/apei/apei-base.c |    5 +++++
>  drivers/acpi/apei/einj.c      |    3 ++-
>  drivers/acpi/apei/erst.c      |    3 ++-
>  3 files changed, 9 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6/drivers/acpi/apei/einj.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/apei/einj.c
> +++ linux-2.6/drivers/acpi/apei/einj.c
> @@ -426,7 +426,8 @@ DEFINE_SIMPLE_ATTRIBUTE(error_inject_fop
>  
>  static int einj_check_table(struct acpi_table_einj *einj_tab)
>  {
> -	if (einj_tab->header_length != sizeof(struct acpi_table_einj))
> +	if (einj_tab->header_length !=
> +	    (sizeof(struct acpi_table_einj) - sizeof(einj_tab->header)))
>  		return -EINVAL;
>  	if (einj_tab->header.length < sizeof(struct acpi_table_einj))
>  		return -EINVAL;
> Index: linux-2.6/drivers/acpi/apei/erst.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/apei/erst.c
> +++ linux-2.6/drivers/acpi/apei/erst.c
> @@ -749,7 +749,8 @@ __setup("erst_disable", setup_erst_disab
>  
>  static int erst_check_table(struct acpi_table_erst *erst_tab)
>  {
> -	if (erst_tab->header_length != sizeof(struct acpi_table_erst))
> +	if (erst_tab->header_length !=
> +	    (sizeof(struct acpi_table_erst) - sizeof(erst_tab->header)))
>  		return -EINVAL;
>  	if (erst_tab->header.length < sizeof(struct acpi_table_erst))
>  		return -EINVAL;
> Index: linux-2.6/drivers/acpi/apei/apei-base.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/apei/apei-base.c
> +++ linux-2.6/drivers/acpi/apei/apei-base.c
> @@ -163,6 +163,7 @@ int apei_exec_run(struct apei_exec_conte
>  	u32 i, ip;
>  	struct acpi_whea_header *entry;
>  	apei_exec_ins_func_t run;
> +	bool found_action = false;
>  
>  	ctx->ip = 0;
>  
> @@ -178,6 +179,7 @@ rewind:
>  		entry = &ctx->action_table[i];
>  		if (entry->action != action)
>  			continue;
> +		found_action = true;
>  		if (ip == ctx->ip) {
>  			if (entry->instruction >= ctx->instructions ||
>  			    !ctx->ins_table[entry->instruction].run) {
> @@ -198,6 +200,9 @@ rewind:
>  			goto rewind;
>  	}
>  
> +	if (!found_action)
> +		return -ENODEV;
> +
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(apei_exec_run);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH] acpi: fix apei related table size checking
  2010-07-26  4:23 ` Bjorn Helgaas
@ 2010-07-26  7:13   ` Andi Kleen
  0 siblings, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2010-07-26  7:13 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yinghai Lu, Len Brown, Huang Ying, Stephen Rothwell, Tejun Heo,
	Daniel J Blueman, linux-acpi, linux-kernel

  On 7/26/2010 6:23 AM, Bjorn Helgaas wrote:
> On Friday, July 23, 2010 11:39:17 am Yinghai Lu wrote:
>> also check if we can find right action in apei.
>>
>> Signed-off-by: Yinghai Lu<yinghai@kernel.org>
> This should be split into two patches that each fix one thing.

... and the description actually describe what it is supposed to fix.

-Andi


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

* Re: [PATCH] acpi: fix apei related table size checking
  2010-07-23 17:39 [PATCH] acpi: fix apei related table size checking Yinghai Lu
  2010-07-26  4:23 ` Bjorn Helgaas
@ 2010-07-26  7:41 ` Huang Ying
  1 sibling, 0 replies; 4+ messages in thread
From: Huang Ying @ 2010-07-26  7:41 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Len Brown, Andi Kleen, Stephen Rothwell, Tejun Heo,
	Daniel J Blueman, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Sat, 2010-07-24 at 01:39 +0800, Yinghai Lu wrote: 
> also check if we can find right action in apei.
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> 
> ---
>  drivers/acpi/apei/apei-base.c |    5 +++++
>  drivers/acpi/apei/einj.c      |    3 ++-
>  drivers/acpi/apei/erst.c      |    3 ++-
>  3 files changed, 9 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6/drivers/acpi/apei/einj.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/apei/einj.c
> +++ linux-2.6/drivers/acpi/apei/einj.c
> @@ -426,7 +426,8 @@ DEFINE_SIMPLE_ATTRIBUTE(error_inject_fop
>  
>  static int einj_check_table(struct acpi_table_einj *einj_tab)
>  {
> -	if (einj_tab->header_length != sizeof(struct acpi_table_einj))
> +	if (einj_tab->header_length !=
> +	    (sizeof(struct acpi_table_einj) - sizeof(einj_tab->header)))
>  		return -EINVAL;

It seems that the header_length field is not set properly by BIOS on my
testing machine which I used to develop the original code. Will try to
contact BIOS guys to make sure.

> Index: linux-2.6/drivers/acpi/apei/apei-base.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/apei/apei-base.c
> +++ linux-2.6/drivers/acpi/apei/apei-base.c
> @@ -163,6 +163,7 @@ int apei_exec_run(struct apei_exec_conte
>  	u32 i, ip;
>  	struct acpi_whea_header *entry;
>  	apei_exec_ins_func_t run;
> +	bool found_action = false;
>  
>  	ctx->ip = 0;
>  
> @@ -178,6 +179,7 @@ rewind:
>  		entry = &ctx->action_table[i];
>  		if (entry->action != action)
>  			continue;
> +		found_action = true;
>  		if (ip == ctx->ip) {
>  			if (entry->instruction >= ctx->instructions ||
>  			    !ctx->ins_table[entry->instruction].run) {
> @@ -198,6 +200,9 @@ rewind:
>  			goto rewind;
>  	}
>  
> +	if (!found_action)
> +		return -ENODEV;

-ENOENT is better here?

Best Regards,
Huang Ying



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

end of thread, other threads:[~2010-07-26  7:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-23 17:39 [PATCH] acpi: fix apei related table size checking Yinghai Lu
2010-07-26  4:23 ` Bjorn Helgaas
2010-07-26  7:13   ` Andi Kleen
2010-07-26  7:41 ` Huang Ying

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