Message ID | 1511234517-12005-1-git-send-email-alex.hung@canonical.com |
---|---|
State | Superseded |
Headers | show |
Series | acpi: LPIT: check for monotonically increasing UID | expand |
On 21/11/17 03:21, Alex Hung wrote: > Signed-off-by: Alex Hung <alex.hung@canonical.com> > --- > src/acpi/lpit/lpit.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/src/acpi/lpit/lpit.c b/src/acpi/lpit/lpit.c > index eb4e3af..de7073c 100644 > --- a/src/acpi/lpit/lpit.c > +++ b/src/acpi/lpit/lpit.c > @@ -162,8 +162,10 @@ 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); > + uint16_t uid = 0; > > /* Stated LPI length must not be longer than what's left in the table */ > if (length < lpi_length) { > @@ -181,6 +183,16 @@ static int lpit_test1(fwts_framework *fw) > switch (*ptr) { > case 0x0: > lpit_check_type_0(fw, &length, &data, &passed); > + > + 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; > Acked-by: Colin Ian King <colin.king@canonical.com>
On 11/21/2017 11:21 AM, Alex Hung wrote: > Signed-off-by: Alex Hung <alex.hung@canonical.com> > --- > src/acpi/lpit/lpit.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/src/acpi/lpit/lpit.c b/src/acpi/lpit/lpit.c > index eb4e3af..de7073c 100644 > --- a/src/acpi/lpit/lpit.c > +++ b/src/acpi/lpit/lpit.c > @@ -162,8 +162,10 @@ 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); > + uint16_t uid = 0; > > /* Stated LPI length must not be longer than what's left in the table */ > if (length < lpi_length) { > @@ -181,6 +183,16 @@ static int lpit_test1(fwts_framework *fw) > switch (*ptr) { > case 0x0: > lpit_check_type_0(fw, &length, &data, &passed); > + > + if (uid > lpi->id && (lpi->id - uid) > 1) { not quiet sure what this does, what if uid = 0 but firmware set lpi->id = 1 first, it should be false? Ivan > + 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;
diff --git a/src/acpi/lpit/lpit.c b/src/acpi/lpit/lpit.c index eb4e3af..de7073c 100644 --- a/src/acpi/lpit/lpit.c +++ b/src/acpi/lpit/lpit.c @@ -162,8 +162,10 @@ 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); + uint16_t uid = 0; /* Stated LPI length must not be longer than what's left in the table */ if (length < lpi_length) { @@ -181,6 +183,16 @@ static int lpit_test1(fwts_framework *fw) switch (*ptr) { case 0x0: lpit_check_type_0(fw, &length, &data, &passed); + + 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;
Signed-off-by: Alex Hung <alex.hung@canonical.com> --- src/acpi/lpit/lpit.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)