mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] acpi: apei: fix the wrongly iterate generic error status block
@ 2017-08-16  8:14 Dongjiu Geng
  2017-08-16 13:55 ` Baicar, Tyler
  2017-08-17  9:25 ` Borislav Petkov
  0 siblings, 2 replies; 5+ messages in thread
From: Dongjiu Geng @ 2017-08-16  8:14 UTC (permalink / raw)
  To: tbaicar, bp, james.morse, geliangtang, andriy.shevchenko,
	tony.luck, austinwc, rjw, lenb, linux-acpi, linux-kernel,
	gengdongjiu, linuxarm, john.garry, shiju.jose, zhengqiang10,
	wangxiongfeng2
  Cc: huangshaoyu, wuquanming

The revision 0x300 generic error data entry is different
from the old version, but currently iterating through the
GHES estatus blocks does not take into account this difference.
This will lead to failure to get the right data entry if GHES
has revision 0x300 error data entry.

Update the GHES estatus iteration to properly increment using
acpi_hest_get_next, and correct the iteration termination condition
because the status block data length only includes error data length.
Clear the CPER estatus printing iteration logic to use same macro.

Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com>
CC: Tyler Baicar <tbaicar@codeaurora.org>
---
 drivers/acpi/apei/apei-internal.h |  5 -----
 drivers/firmware/efi/cper.c       | 12 ++----------
 include/acpi/ghes.h               |  5 +++++
 3 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
index 6e9f14c0a71b..cb4126051f62 100644
--- a/drivers/acpi/apei/apei-internal.h
+++ b/drivers/acpi/apei/apei-internal.h
@@ -120,11 +120,6 @@ int apei_exec_collect_resources(struct apei_exec_context *ctx,
 struct dentry;
 struct dentry *apei_get_debugfs_dir(void);
 
-#define apei_estatus_for_each_section(estatus, section)			\
-	for (section = (struct acpi_hest_generic_data *)(estatus + 1);	\
-	     (void *)section - (void *)estatus < estatus->data_length;	\
-	     section = (void *)(section+1) + section->error_data_length)
-
 static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus)
 {
 	if (estatus->raw_data_length)
diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index 48a8f69da42a..bf3672a81e49 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -606,7 +606,6 @@ void cper_estatus_print(const char *pfx,
 			const struct acpi_hest_generic_status *estatus)
 {
 	struct acpi_hest_generic_data *gdata;
-	unsigned int data_len;
 	int sec_no = 0;
 	char newpfx[64];
 	__u16 severity;
@@ -617,14 +616,10 @@ void cper_estatus_print(const char *pfx,
 		       "It has been corrected by h/w "
 		       "and requires no further action");
 	printk("%s""event severity: %s\n", pfx, cper_severity_str(severity));
-	data_len = estatus->data_length;
-	gdata = (struct acpi_hest_generic_data *)(estatus + 1);
 	snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP);
 
-	while (data_len >= acpi_hest_get_size(gdata)) {
+	apei_estatus_for_each_section(estatus, gdata) {
 		cper_estatus_print_section(newpfx, gdata, sec_no);
-		data_len -= acpi_hest_get_record_size(gdata);
-		gdata = acpi_hest_get_next(gdata);
 		sec_no++;
 	}
 }
@@ -653,15 +648,12 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
 	if (rc)
 		return rc;
 	data_len = estatus->data_length;
-	gdata = (struct acpi_hest_generic_data *)(estatus + 1);
 
-	while (data_len >= acpi_hest_get_size(gdata)) {
+	apei_estatus_for_each_section(estatus, gdata) {
 		gedata_len = acpi_hest_get_error_length(gdata);
 		if (gedata_len > data_len - acpi_hest_get_size(gdata))
 			return -EINVAL;
-
 		data_len -= acpi_hest_get_record_size(gdata);
-		gdata = acpi_hest_get_next(gdata);
 	}
 	if (data_len)
 		return -EINVAL;
diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h
index 9f26e01186ae..9061c5c743b3 100644
--- a/include/acpi/ghes.h
+++ b/include/acpi/ghes.h
@@ -113,6 +113,11 @@ static inline void *acpi_hest_get_next(struct acpi_hest_generic_data *gdata)
 	return (void *)(gdata) + acpi_hest_get_record_size(gdata);
 }
 
+#define apei_estatus_for_each_section(estatus, section)			\
+	for (section = (struct acpi_hest_generic_data *)(estatus + 1);	\
+	     (void *)section - (void *)(estatus + 1) < estatus->data_length; \
+	     section = acpi_hest_get_next(section))
+
 int ghes_notify_sea(void);
 
 #endif /* GHES_H */
-- 
2.14.0

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

* Re: [PATCH v3] acpi: apei: fix the wrongly iterate generic error status block
  2017-08-16  8:14 [PATCH v3] acpi: apei: fix the wrongly iterate generic error status block Dongjiu Geng
@ 2017-08-16 13:55 ` Baicar, Tyler
  2017-08-17  3:09   ` gengdongjiu
  2017-08-17  9:25 ` Borislav Petkov
  1 sibling, 1 reply; 5+ messages in thread
From: Baicar, Tyler @ 2017-08-16 13:55 UTC (permalink / raw)
  To: Dongjiu Geng, bp, james.morse, geliangtang, andriy.shevchenko,
	tony.luck, austinwc, rjw, lenb, linux-acpi, linux-kernel,
	linuxarm, john.garry, shiju.jose, zhengqiang10, wangxiongfeng2
  Cc: huangshaoyu, wuquanming

On 8/16/2017 2:14 AM, Dongjiu Geng wrote:
> The revision 0x300 generic error data entry is different
> from the old version, but currently iterating through the
> GHES estatus blocks does not take into account this difference.
> This will lead to failure to get the right data entry if GHES
> has revision 0x300 error data entry.
>
> Update the GHES estatus iteration to properly increment using
> acpi_hest_get_next, and correct the iteration termination condition
> because the status block data length only includes error data length.
> Clear the CPER estatus printing iteration logic to use same macro.
>
> Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com>
> CC: Tyler Baicar <tbaicar@codeaurora.org>
Tested-by: Tyler Baicar <tbaicar@codeaurora.org>

Works good for me!

Thanks,
Tyler
> ---
>   drivers/acpi/apei/apei-internal.h |  5 -----
>   drivers/firmware/efi/cper.c       | 12 ++----------
>   include/acpi/ghes.h               |  5 +++++
>   3 files changed, 7 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
> index 6e9f14c0a71b..cb4126051f62 100644
> --- a/drivers/acpi/apei/apei-internal.h
> +++ b/drivers/acpi/apei/apei-internal.h
> @@ -120,11 +120,6 @@ int apei_exec_collect_resources(struct apei_exec_context *ctx,
>   struct dentry;
>   struct dentry *apei_get_debugfs_dir(void);
>   
> -#define apei_estatus_for_each_section(estatus, section)			\
> -	for (section = (struct acpi_hest_generic_data *)(estatus + 1);	\
> -	     (void *)section - (void *)estatus < estatus->data_length;	\
> -	     section = (void *)(section+1) + section->error_data_length)
> -
>   static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus)
>   {
>   	if (estatus->raw_data_length)
> diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
> index 48a8f69da42a..bf3672a81e49 100644
> --- a/drivers/firmware/efi/cper.c
> +++ b/drivers/firmware/efi/cper.c
> @@ -606,7 +606,6 @@ void cper_estatus_print(const char *pfx,
>   			const struct acpi_hest_generic_status *estatus)
>   {
>   	struct acpi_hest_generic_data *gdata;
> -	unsigned int data_len;
>   	int sec_no = 0;
>   	char newpfx[64];
>   	__u16 severity;
> @@ -617,14 +616,10 @@ void cper_estatus_print(const char *pfx,
>   		       "It has been corrected by h/w "
>   		       "and requires no further action");
>   	printk("%s""event severity: %s\n", pfx, cper_severity_str(severity));
> -	data_len = estatus->data_length;
> -	gdata = (struct acpi_hest_generic_data *)(estatus + 1);
>   	snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP);
>   
> -	while (data_len >= acpi_hest_get_size(gdata)) {
> +	apei_estatus_for_each_section(estatus, gdata) {
>   		cper_estatus_print_section(newpfx, gdata, sec_no);
> -		data_len -= acpi_hest_get_record_size(gdata);
> -		gdata = acpi_hest_get_next(gdata);
>   		sec_no++;
>   	}
>   }
> @@ -653,15 +648,12 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
>   	if (rc)
>   		return rc;
>   	data_len = estatus->data_length;
> -	gdata = (struct acpi_hest_generic_data *)(estatus + 1);
>   
> -	while (data_len >= acpi_hest_get_size(gdata)) {
> +	apei_estatus_for_each_section(estatus, gdata) {
>   		gedata_len = acpi_hest_get_error_length(gdata);
>   		if (gedata_len > data_len - acpi_hest_get_size(gdata))
>   			return -EINVAL;
> -
>   		data_len -= acpi_hest_get_record_size(gdata);
> -		gdata = acpi_hest_get_next(gdata);
>   	}
>   	if (data_len)
>   		return -EINVAL;
> diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h
> index 9f26e01186ae..9061c5c743b3 100644
> --- a/include/acpi/ghes.h
> +++ b/include/acpi/ghes.h
> @@ -113,6 +113,11 @@ static inline void *acpi_hest_get_next(struct acpi_hest_generic_data *gdata)
>   	return (void *)(gdata) + acpi_hest_get_record_size(gdata);
>   }
>   
> +#define apei_estatus_for_each_section(estatus, section)			\
> +	for (section = (struct acpi_hest_generic_data *)(estatus + 1);	\
> +	     (void *)section - (void *)(estatus + 1) < estatus->data_length; \
> +	     section = acpi_hest_get_next(section))
> +
>   int ghes_notify_sea(void);
>   
>   #endif /* GHES_H */

-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

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

* Re: [PATCH v3] acpi: apei: fix the wrongly iterate generic error status block
  2017-08-16 13:55 ` Baicar, Tyler
@ 2017-08-17  3:09   ` gengdongjiu
  0 siblings, 0 replies; 5+ messages in thread
From: gengdongjiu @ 2017-08-17  3:09 UTC (permalink / raw)
  To: Baicar, Tyler, bp, james.morse, geliangtang, andriy.shevchenko,
	tony.luck, austinwc, rjw, lenb, linux-acpi, linux-kernel,
	linuxarm, john.garry, shiju.jose, zhengqiang10, wangxiongfeng2,
	will.deacon, zjzhang, catalin.marinas
  Cc: huangshaoyu, wuquanming

CC Will and Jonathan


On 2017/8/16 21:55, Baicar, Tyler wrote:
> On 8/16/2017 2:14 AM, Dongjiu Geng wrote:
>> The revision 0x300 generic error data entry is different
>> from the old version, but currently iterating through the
>> GHES estatus blocks does not take into account this difference.
>> This will lead to failure to get the right data entry if GHES
>> has revision 0x300 error data entry.
>>
>> Update the GHES estatus iteration to properly increment using
>> acpi_hest_get_next, and correct the iteration termination condition
>> because the status block data length only includes error data length.
>> Clear the CPER estatus printing iteration logic to use same macro.
>>
>> Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com>
>> CC: Tyler Baicar <tbaicar@codeaurora.org>
> Tested-by: Tyler Baicar <tbaicar@codeaurora.org>
> 
> Works good for me!
> 
> Thanks,
> Tyler
>> ---
>>   drivers/acpi/apei/apei-internal.h |  5 -----
>>   drivers/firmware/efi/cper.c       | 12 ++----------
>>   include/acpi/ghes.h               |  5 +++++
>>   3 files changed, 7 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
>> index 6e9f14c0a71b..cb4126051f62 100644
>> --- a/drivers/acpi/apei/apei-internal.h
>> +++ b/drivers/acpi/apei/apei-internal.h
>> @@ -120,11 +120,6 @@ int apei_exec_collect_resources(struct apei_exec_context *ctx,
>>   struct dentry;
>>   struct dentry *apei_get_debugfs_dir(void);
>>   -#define apei_estatus_for_each_section(estatus, section)            \
>> -    for (section = (struct acpi_hest_generic_data *)(estatus + 1);    \
>> -         (void *)section - (void *)estatus < estatus->data_length;    \
>> -         section = (void *)(section+1) + section->error_data_length)
>> -
>>   static inline u32 cper_estatus_len(struct acpi_hest_generic_status *estatus)
>>   {
>>       if (estatus->raw_data_length)
>> diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
>> index 48a8f69da42a..bf3672a81e49 100644
>> --- a/drivers/firmware/efi/cper.c
>> +++ b/drivers/firmware/efi/cper.c
>> @@ -606,7 +606,6 @@ void cper_estatus_print(const char *pfx,
>>               const struct acpi_hest_generic_status *estatus)
>>   {
>>       struct acpi_hest_generic_data *gdata;
>> -    unsigned int data_len;
>>       int sec_no = 0;
>>       char newpfx[64];
>>       __u16 severity;
>> @@ -617,14 +616,10 @@ void cper_estatus_print(const char *pfx,
>>                  "It has been corrected by h/w "
>>                  "and requires no further action");
>>       printk("%s""event severity: %s\n", pfx, cper_severity_str(severity));
>> -    data_len = estatus->data_length;
>> -    gdata = (struct acpi_hest_generic_data *)(estatus + 1);
>>       snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP);
>>   -    while (data_len >= acpi_hest_get_size(gdata)) {
>> +    apei_estatus_for_each_section(estatus, gdata) {
>>           cper_estatus_print_section(newpfx, gdata, sec_no);
>> -        data_len -= acpi_hest_get_record_size(gdata);
>> -        gdata = acpi_hest_get_next(gdata);
>>           sec_no++;
>>       }
>>   }
>> @@ -653,15 +648,12 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
>>       if (rc)
>>           return rc;
>>       data_len = estatus->data_length;
>> -    gdata = (struct acpi_hest_generic_data *)(estatus + 1);
>>   -    while (data_len >= acpi_hest_get_size(gdata)) {
>> +    apei_estatus_for_each_section(estatus, gdata) {
>>           gedata_len = acpi_hest_get_error_length(gdata);
>>           if (gedata_len > data_len - acpi_hest_get_size(gdata))
>>               return -EINVAL;
>> -
>>           data_len -= acpi_hest_get_record_size(gdata);
>> -        gdata = acpi_hest_get_next(gdata);
>>       }
>>       if (data_len)
>>           return -EINVAL;
>> diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h
>> index 9f26e01186ae..9061c5c743b3 100644
>> --- a/include/acpi/ghes.h
>> +++ b/include/acpi/ghes.h
>> @@ -113,6 +113,11 @@ static inline void *acpi_hest_get_next(struct acpi_hest_generic_data *gdata)
>>       return (void *)(gdata) + acpi_hest_get_record_size(gdata);
>>   }
>>   +#define apei_estatus_for_each_section(estatus, section)            \
>> +    for (section = (struct acpi_hest_generic_data *)(estatus + 1);    \
>> +         (void *)section - (void *)(estatus + 1) < estatus->data_length; \
>> +         section = acpi_hest_get_next(section))
>> +
>>   int ghes_notify_sea(void);
>>     #endif /* GHES_H */
> 

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

* Re: [PATCH v3] acpi: apei: fix the wrongly iterate generic error status block
  2017-08-16  8:14 [PATCH v3] acpi: apei: fix the wrongly iterate generic error status block Dongjiu Geng
  2017-08-16 13:55 ` Baicar, Tyler
@ 2017-08-17  9:25 ` Borislav Petkov
  2017-08-17 10:45   ` gengdongjiu
  1 sibling, 1 reply; 5+ messages in thread
From: Borislav Petkov @ 2017-08-17  9:25 UTC (permalink / raw)
  To: Dongjiu Geng
  Cc: tbaicar, james.morse, geliangtang, andriy.shevchenko, tony.luck,
	austinwc, rjw, lenb, linux-acpi, linux-kernel, linuxarm,
	john.garry, shiju.jose, zhengqiang10, wangxiongfeng2,
	huangshaoyu, wuquanming

On Wed, Aug 16, 2017 at 04:14:50PM +0800, Dongjiu Geng wrote:
> The revision 0x300 generic error data entry is different
> from the old version, but currently iterating through the
> GHES estatus blocks does not take into account this difference.
> This will lead to failure to get the right data entry if GHES
> has revision 0x300 error data entry.
> 
> Update the GHES estatus iteration to properly increment using

			  iteration macro

> acpi_hest_get_next, and correct the iteration termination condition

Please end function names with parentheses.

> because the status block data length only includes error data length.

<---- newline here.

> Clear the CPER estatus printing iteration logic to use same macro.

s/Clear ... /Convert ... to the same macro./

> 
> Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com>
> CC: Tyler Baicar <tbaicar@codeaurora.org>
> ---
>  drivers/acpi/apei/apei-internal.h |  5 -----
>  drivers/firmware/efi/cper.c       | 12 ++----------
>  include/acpi/ghes.h               |  5 +++++
>  3 files changed, 7 insertions(+), 15 deletions(-)

With those addressed you can add:

Reviewed-by: Borislav Petkov <bp@suse.de>

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

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

* Re: [PATCH v3] acpi: apei: fix the wrongly iterate generic error status block
  2017-08-17  9:25 ` Borislav Petkov
@ 2017-08-17 10:45   ` gengdongjiu
  0 siblings, 0 replies; 5+ messages in thread
From: gengdongjiu @ 2017-08-17 10:45 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: tbaicar, james.morse, geliangtang, andriy.shevchenko, tony.luck,
	austinwc, rjw, lenb, linux-acpi, linux-kernel, linuxarm,
	john.garry, shiju.jose, zhengqiang10, wangxiongfeng2,
	huangshaoyu, wuquanming

Borislav,
  thanks for the review,

On 2017/8/17 17:25, Borislav Petkov wrote:
> On Wed, Aug 16, 2017 at 04:14:50PM +0800, Dongjiu Geng wrote:
>> The revision 0x300 generic error data entry is different
>> from the old version, but currently iterating through the
>> GHES estatus blocks does not take into account this difference.
>> This will lead to failure to get the right data entry if GHES
>> has revision 0x300 error data entry.
>>
>> Update the GHES estatus iteration to properly increment using
> 			  iteration macro
> 
>> acpi_hest_get_next, and correct the iteration termination condition
> Please end function names with parentheses.
> 
>> because the status block data length only includes error data length.
> <---- newline here.
> 
>> Clear the CPER estatus printing iteration logic to use same macro.
> s/Clear ... /Convert ... to the same macro./
> 
>> Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com>
>> CC: Tyler Baicar <tbaicar@codeaurora.org>
>> ---
>>  drivers/acpi/apei/apei-internal.h |  5 -----
>>  drivers/firmware/efi/cper.c       | 12 ++----------
>>  include/acpi/ghes.h               |  5 +++++
>>  3 files changed, 7 insertions(+), 15 deletions(-)
> With those addressed you can add:
  Ok, I will add.

> 
> Reviewed-by: Borislav Petkov <bp@suse.de>
> 
> -- 

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

end of thread, other threads:[~2017-08-17 10:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-16  8:14 [PATCH v3] acpi: apei: fix the wrongly iterate generic error status block Dongjiu Geng
2017-08-16 13:55 ` Baicar, Tyler
2017-08-17  3:09   ` gengdongjiu
2017-08-17  9:25 ` Borislav Petkov
2017-08-17 10:45   ` gengdongjiu

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

all inboxes | Powered by JetHome®