ACK: [PATCH][V2] acpi: LPIT: check for monotonically increasing UID

Colin Ian King colin.king at canonical.com
Tue Jan 23 08:57:17 UTC 2018


On 23/01/18 02:19, Alex Hung wrote:
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
>  src/acpi/lpit/lpit.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/src/acpi/lpit/lpit.c b/src/acpi/lpit/lpit.c
> index 73665b8..4ad7322 100644
> --- a/src/acpi/lpit/lpit.c
> +++ b/src/acpi/lpit/lpit.c
> @@ -143,6 +143,7 @@ static int lpit_test1(fwts_framework *fw)
>  	uint8_t *data;
>  	bool passed = true;
>  	uint32_t length;
> +	uint16_t uid = 0, init_id = 0;
>  	fwts_acpi_table_lpit *lpit = (fwts_acpi_table_lpit *)table->data;
>  
>  	if (table->length < sizeof(fwts_acpi_table_lpit)) {
> @@ -162,6 +163,7 @@ static int lpit_test1(fwts_framework *fw)
>  
>  	/* Got enough data to be able to inspect the initial 2 x 32 bit words.. */
>  	while (length > 8) {
> +		fwts_acpi_table_lpit_c_state *lpi = (fwts_acpi_table_lpit_c_state *)data;
>  		uint32_t *ptr = (uint32_t *)data;
>  		uint32_t lpi_length = *(ptr + 1);
>  
> @@ -181,6 +183,27 @@ static int lpit_test1(fwts_framework *fw)
>  		switch (*ptr) {
>  		case 0x0:
>  			lpit_check_type_0(fw, &length, &data, &passed);
> +
> +			/* check lpi->id starts from zero */
> +			if (init_id == 0 && lpi->id != 0) {
> +				passed = false;
> +				fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +					"LPITNativeCStateBadUID",
> +					"Unique ID of Native C-state based LPI  "
> +					"structure must start from zero");
> +			} else
> +				init_id = 1;
> +
> +			/* check lpi->id increases monotonically */
> +			if (uid > lpi->id || (lpi->id - uid) > 1) {
> +				passed = false;
> +				fwts_failed(fw, LOG_LEVEL_CRITICAL,
> +					"LPITNativeCStateBadUID",
> +					"Unique ID of Native C-state based LPI  "
> +					"structure must be a zero-based monotonically "
> +					"increasing value");
> +			}
> +			uid = lpi->id;
>  			break;
>  		default:
>  			passed = false;
> 

Makes sense,

Acked-by: Colin Ian King <colin.king at canonical.com>



More information about the fwts-devel mailing list