ACK: [PATCH 2/2] dmi: dmicheck: add a helper function to check word min/max value

Colin Ian King colin.king at canonical.com
Thu May 11 22:12:45 UTC 2017


On 11/05/17 05:25, Alex Hung wrote:
> dmi_min_max_uint16_check is a function to check min and max
> values of a word field. This patch also adds checks for new
> fields in type 4 in spec 3.0
> 
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
>  src/dmi/dmicheck/dmicheck.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/src/dmi/dmicheck/dmicheck.c b/src/dmi/dmicheck/dmicheck.c
> index 64e9843..effa5da 100644
> --- a/src/dmi/dmicheck/dmicheck.c
> +++ b/src/dmi/dmicheck/dmicheck.c
> @@ -842,6 +842,28 @@ static void dmi_reserved_bits_check(fwts_framework *fw,
>  	}
>  }
>  
> +static void dmi_min_max_uint16_check(fwts_framework *fw,
> +	const char *table,
> +	uint32_t addr,
> +	const char *field,
> +	const fwts_dmi_header *hdr,
> +	uint8_t offset,
> +	uint16_t min,
> +	uint16_t max)
> +{
> +	uint16_t val = GET_UINT16((hdr->data) + offset);
> +	if ((val < min) || (val > max)) {
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			DMI_VALUE_OUT_OF_RANGE,
> +			"Out of range value 0x%4.4" PRIx16
> +			" (range allowed 0x%4.4" PRIx16 "..0x%4.4" PRIx16 ") "
> +			"while accessing entry '%s' @ 0x%8.8" PRIx32
> +			", field '%s', offset 0x%2.2" PRIx8,
> +			val, min, max, table, addr, field, offset);
> +		dmi_out_of_range_advice(fw, hdr->type, offset);
> +	}
> +}
> +
>  static void dmi_min_max_uint8_check(fwts_framework *fw,
>  	const char *table,
>  	uint32_t addr,
> @@ -1175,6 +1197,11 @@ static void dmicheck_entry(fwts_framework *fw,
>  			if (hdr->length < 0x28)
>  				break;
>  			dmi_reserved_bits_check(fw, table, addr, "Processor Characteristics", hdr, sizeof(uint16_t), 0x26, 8, 15);
> +			if (hdr->length < 0x30)
> +				break;
> +			dmi_min_max_uint16_check(fw, table, addr, "Core Count 2", hdr, 0x2a, 0, 0xfffe);
> +			dmi_min_max_uint16_check(fw, table, addr, "Core Enabled 2", hdr, 0x2c, 0, 0xfffe);
> +			dmi_min_max_uint16_check(fw, table, addr, "Thread Enabled 2", hdr, 0x2e, 0, 0xfffe);
>  			break;
>  
>  		case 5: /* 7.6 (Type 5 is obsolete) */
> 
Thanks Alex,

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



More information about the fwts-devel mailing list