* [Qemu-devel] [PATCH] bios-tables-test: handle false-positive smbios signature matches
@ 2015-03-31 18:32 Gabriel L. Somlo
2015-03-31 19:19 ` Bruce Rogers
2015-04-28 19:40 ` Gabriel L. Somlo
0 siblings, 2 replies; 4+ messages in thread
From: Gabriel L. Somlo @ 2015-03-31 18:32 UTC (permalink / raw)
To: qemu-devel
Cc: kwolf, mst, somlo, seabios, brogers, kevin, kraxel, stefanha, pbonzini
Rather than stopping at the first match for the SMBIOS signature
("_SM_") in the f-segment (0xF0000-0xFFFFF), continue scanning
until either a valid entry point table is found, or the f-segment
has been exhausted.
Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
---
tests/bios-tables-test.c | 76 ++++++++++++++++++++++++++++--------------------
1 file changed, 44 insertions(+), 32 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 735ac61..f79d89a 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -599,35 +599,15 @@ static void test_acpi_asl(test_data *data)
free_test_data(&exp_data);
}
-static void test_smbios_ep_address(test_data *data)
-{
- uint32_t off;
-
- /* find smbios entry point structure */
- for (off = 0xf0000; off < 0x100000; off += 0x10) {
- uint8_t sig[] = "_SM_";
- int i;
-
- for (i = 0; i < sizeof sig - 1; ++i) {
- sig[i] = readb(off + i);
- }
-
- if (!memcmp(sig, "_SM_", sizeof sig)) {
- break;
- }
- }
-
- g_assert_cmphex(off, <, 0x100000);
- data->smbios_ep_addr = off;
-}
-
-static void test_smbios_ep_table(test_data *data)
+static bool smbios_ep_table_ok(test_data *data)
{
struct smbios_entry_point *ep_table = &data->smbios_ep_table;
uint32_t addr = data->smbios_ep_addr;
ACPI_READ_ARRAY(ep_table->anchor_string, addr);
- g_assert(!memcmp(ep_table->anchor_string, "_SM_", 4));
+ if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
+ return false;
+ }
ACPI_READ_FIELD(ep_table->checksum, addr);
ACPI_READ_FIELD(ep_table->length, addr);
ACPI_READ_FIELD(ep_table->smbios_major_version, addr);
@@ -636,17 +616,50 @@ static void test_smbios_ep_table(test_data *data)
ACPI_READ_FIELD(ep_table->entry_point_revision, addr);
ACPI_READ_ARRAY(ep_table->formatted_area, addr);
ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr);
- g_assert(!memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5));
+ if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
+ return false;
+ }
ACPI_READ_FIELD(ep_table->intermediate_checksum, addr);
ACPI_READ_FIELD(ep_table->structure_table_length, addr);
- g_assert_cmpuint(ep_table->structure_table_length, >, 0);
+ if (ep_table->structure_table_length == 0) {
+ return false;
+ }
ACPI_READ_FIELD(ep_table->structure_table_address, addr);
ACPI_READ_FIELD(ep_table->number_of_structures, addr);
- g_assert_cmpuint(ep_table->number_of_structures, >, 0);
+ if (ep_table->number_of_structures == 0) {
+ return false;
+ }
ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr);
- g_assert(!acpi_checksum((uint8_t *)ep_table, sizeof *ep_table));
- g_assert(!acpi_checksum((uint8_t *)ep_table + 0x10,
- sizeof *ep_table - 0x10));
+ if (acpi_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
+ acpi_checksum((uint8_t *)ep_table + 0x10, sizeof *ep_table - 0x10)) {
+ return false;
+ }
+ return true;
+}
+
+static void test_smbios_entry_point(test_data *data)
+{
+ uint32_t off;
+
+ /* find smbios entry point structure */
+ for (off = 0xf0000; off < 0x100000; off += 0x10) {
+ uint8_t sig[] = "_SM_";
+ int i;
+
+ for (i = 0; i < sizeof sig - 1; ++i) {
+ sig[i] = readb(off + i);
+ }
+
+ if (!memcmp(sig, "_SM_", sizeof sig)) {
+ /* signature match, but is this a valid entry point? */
+ data->smbios_ep_addr = off;
+ if (smbios_ep_table_ok(data)) {
+ break;
+ }
+ }
+ }
+
+ g_assert_cmphex(off, <, 0x100000);
}
static inline bool smbios_single_instance(uint8_t type)
@@ -767,8 +780,7 @@ static void test_acpi_one(const char *params, test_data *data)
}
}
- test_smbios_ep_address(data);
- test_smbios_ep_table(data);
+ test_smbios_entry_point(data);
test_smbios_structs(data);
qtest_quit(global_qtest);
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] bios-tables-test: handle false-positive smbios signature matches
2015-03-31 18:32 [Qemu-devel] [PATCH] bios-tables-test: handle false-positive smbios signature matches Gabriel L. Somlo
@ 2015-03-31 19:19 ` Bruce Rogers
2015-04-28 19:40 ` Gabriel L. Somlo
1 sibling, 0 replies; 4+ messages in thread
From: Bruce Rogers @ 2015-03-31 19:19 UTC (permalink / raw)
To: Gabriel L. Somlo, qemu-devel
Cc: kwolf, mst, seabios, kevin, kraxel, stefanha, pbonzini
>>> On 3/31/2015 at 12:32 PM, "Gabriel L. Somlo" <somlo@cmu.edu> wrote:
> Rather than stopping at the first match for the SMBIOS signature
> ("_SM_") in the f-segment (0xF0000-0xFFFFF), continue scanning
> until either a valid entry point table is found, or the f-segment
> has been exhausted.
>
> Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
> ---
> tests/bios-tables-test.c | 76 ++++++++++++++++++++++++++++--------------------
> 1 file changed, 44 insertions(+), 32 deletions(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 735ac61..f79d89a 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -599,35 +599,15 @@ static void test_acpi_asl(test_data *data)
> free_test_data(&exp_data);
> }
>
> -static void test_smbios_ep_address(test_data *data)
> -{
> - uint32_t off;
> -
> - /* find smbios entry point structure */
> - for (off = 0xf0000; off < 0x100000; off += 0x10) {
> - uint8_t sig[] = "_SM_";
> - int i;
> -
> - for (i = 0; i < sizeof sig - 1; ++i) {
> - sig[i] = readb(off + i);
> - }
> -
> - if (!memcmp(sig, "_SM_", sizeof sig)) {
> - break;
> - }
> - }
> -
> - g_assert_cmphex(off, <, 0x100000);
> - data->smbios_ep_addr = off;
> -}
> -
> -static void test_smbios_ep_table(test_data *data)
> +static bool smbios_ep_table_ok(test_data *data)
> {
> struct smbios_entry_point *ep_table = &data->smbios_ep_table;
> uint32_t addr = data->smbios_ep_addr;
>
> ACPI_READ_ARRAY(ep_table->anchor_string, addr);
> - g_assert(!memcmp(ep_table->anchor_string, "_SM_", 4));
> + if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
> + return false;
> + }
> ACPI_READ_FIELD(ep_table->checksum, addr);
> ACPI_READ_FIELD(ep_table->length, addr);
> ACPI_READ_FIELD(ep_table->smbios_major_version, addr);
> @@ -636,17 +616,50 @@ static void test_smbios_ep_table(test_data *data)
> ACPI_READ_FIELD(ep_table->entry_point_revision, addr);
> ACPI_READ_ARRAY(ep_table->formatted_area, addr);
> ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr);
> - g_assert(!memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5));
> + if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
> + return false;
> + }
> ACPI_READ_FIELD(ep_table->intermediate_checksum, addr);
> ACPI_READ_FIELD(ep_table->structure_table_length, addr);
> - g_assert_cmpuint(ep_table->structure_table_length, >, 0);
> + if (ep_table->structure_table_length == 0) {
> + return false;
> + }
> ACPI_READ_FIELD(ep_table->structure_table_address, addr);
> ACPI_READ_FIELD(ep_table->number_of_structures, addr);
> - g_assert_cmpuint(ep_table->number_of_structures, >, 0);
> + if (ep_table->number_of_structures == 0) {
> + return false;
> + }
> ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr);
> - g_assert(!acpi_checksum((uint8_t *)ep_table, sizeof *ep_table));
> - g_assert(!acpi_checksum((uint8_t *)ep_table + 0x10,
> - sizeof *ep_table - 0x10));
> + if (acpi_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
> + acpi_checksum((uint8_t *)ep_table + 0x10, sizeof *ep_table - 0x10))
> {
> + return false;
> + }
> + return true;
> +}
> +
> +static void test_smbios_entry_point(test_data *data)
> +{
> + uint32_t off;
> +
> + /* find smbios entry point structure */
> + for (off = 0xf0000; off < 0x100000; off += 0x10) {
> + uint8_t sig[] = "_SM_";
> + int i;
> +
> + for (i = 0; i < sizeof sig - 1; ++i) {
> + sig[i] = readb(off + i);
> + }
> +
> + if (!memcmp(sig, "_SM_", sizeof sig)) {
> + /* signature match, but is this a valid entry point? */
> + data->smbios_ep_addr = off;
> + if (smbios_ep_table_ok(data)) {
> + break;
> + }
> + }
> + }
> +
> + g_assert_cmphex(off, <, 0x100000);
> }
>
> static inline bool smbios_single_instance(uint8_t type)
> @@ -767,8 +780,7 @@ static void test_acpi_one(const char *params, test_data
> *data)
> }
> }
>
> - test_smbios_ep_address(data);
> - test_smbios_ep_table(data);
> + test_smbios_entry_point(data);
> test_smbios_structs(data);
>
> qtest_quit(global_qtest);
I tried this out in my case which previously failed - worked great.
Thanks!
Bruce
Tested-by: Bruce Rogers <brogers@suse.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] bios-tables-test: handle false-positive smbios signature matches
2015-03-31 18:32 [Qemu-devel] [PATCH] bios-tables-test: handle false-positive smbios signature matches Gabriel L. Somlo
2015-03-31 19:19 ` Bruce Rogers
@ 2015-04-28 19:40 ` Gabriel L. Somlo
2015-04-28 19:42 ` Michael S. Tsirkin
1 sibling, 1 reply; 4+ messages in thread
From: Gabriel L. Somlo @ 2015-04-28 19:40 UTC (permalink / raw)
To: Gabriel L. Somlo; +Cc: brogers, kevin, kraxel, qemu-devel, mst
ping ?
On Tue, Mar 31, 2015 at 02:32:20PM -0400, Gabriel L. Somlo wrote:
> Rather than stopping at the first match for the SMBIOS signature
> ("_SM_") in the f-segment (0xF0000-0xFFFFF), continue scanning
> until either a valid entry point table is found, or the f-segment
> has been exhausted.
>
> Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
> ---
> tests/bios-tables-test.c | 76 ++++++++++++++++++++++++++++--------------------
> 1 file changed, 44 insertions(+), 32 deletions(-)
>
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 735ac61..f79d89a 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -599,35 +599,15 @@ static void test_acpi_asl(test_data *data)
> free_test_data(&exp_data);
> }
>
> -static void test_smbios_ep_address(test_data *data)
> -{
> - uint32_t off;
> -
> - /* find smbios entry point structure */
> - for (off = 0xf0000; off < 0x100000; off += 0x10) {
> - uint8_t sig[] = "_SM_";
> - int i;
> -
> - for (i = 0; i < sizeof sig - 1; ++i) {
> - sig[i] = readb(off + i);
> - }
> -
> - if (!memcmp(sig, "_SM_", sizeof sig)) {
> - break;
> - }
> - }
> -
> - g_assert_cmphex(off, <, 0x100000);
> - data->smbios_ep_addr = off;
> -}
> -
> -static void test_smbios_ep_table(test_data *data)
> +static bool smbios_ep_table_ok(test_data *data)
> {
> struct smbios_entry_point *ep_table = &data->smbios_ep_table;
> uint32_t addr = data->smbios_ep_addr;
>
> ACPI_READ_ARRAY(ep_table->anchor_string, addr);
> - g_assert(!memcmp(ep_table->anchor_string, "_SM_", 4));
> + if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
> + return false;
> + }
> ACPI_READ_FIELD(ep_table->checksum, addr);
> ACPI_READ_FIELD(ep_table->length, addr);
> ACPI_READ_FIELD(ep_table->smbios_major_version, addr);
> @@ -636,17 +616,50 @@ static void test_smbios_ep_table(test_data *data)
> ACPI_READ_FIELD(ep_table->entry_point_revision, addr);
> ACPI_READ_ARRAY(ep_table->formatted_area, addr);
> ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr);
> - g_assert(!memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5));
> + if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
> + return false;
> + }
> ACPI_READ_FIELD(ep_table->intermediate_checksum, addr);
> ACPI_READ_FIELD(ep_table->structure_table_length, addr);
> - g_assert_cmpuint(ep_table->structure_table_length, >, 0);
> + if (ep_table->structure_table_length == 0) {
> + return false;
> + }
> ACPI_READ_FIELD(ep_table->structure_table_address, addr);
> ACPI_READ_FIELD(ep_table->number_of_structures, addr);
> - g_assert_cmpuint(ep_table->number_of_structures, >, 0);
> + if (ep_table->number_of_structures == 0) {
> + return false;
> + }
> ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr);
> - g_assert(!acpi_checksum((uint8_t *)ep_table, sizeof *ep_table));
> - g_assert(!acpi_checksum((uint8_t *)ep_table + 0x10,
> - sizeof *ep_table - 0x10));
> + if (acpi_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
> + acpi_checksum((uint8_t *)ep_table + 0x10, sizeof *ep_table - 0x10)) {
> + return false;
> + }
> + return true;
> +}
> +
> +static void test_smbios_entry_point(test_data *data)
> +{
> + uint32_t off;
> +
> + /* find smbios entry point structure */
> + for (off = 0xf0000; off < 0x100000; off += 0x10) {
> + uint8_t sig[] = "_SM_";
> + int i;
> +
> + for (i = 0; i < sizeof sig - 1; ++i) {
> + sig[i] = readb(off + i);
> + }
> +
> + if (!memcmp(sig, "_SM_", sizeof sig)) {
> + /* signature match, but is this a valid entry point? */
> + data->smbios_ep_addr = off;
> + if (smbios_ep_table_ok(data)) {
> + break;
> + }
> + }
> + }
> +
> + g_assert_cmphex(off, <, 0x100000);
> }
>
> static inline bool smbios_single_instance(uint8_t type)
> @@ -767,8 +780,7 @@ static void test_acpi_one(const char *params, test_data *data)
> }
> }
>
> - test_smbios_ep_address(data);
> - test_smbios_ep_table(data);
> + test_smbios_entry_point(data);
> test_smbios_structs(data);
>
> qtest_quit(global_qtest);
> --
> 2.1.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] bios-tables-test: handle false-positive smbios signature matches
2015-04-28 19:40 ` Gabriel L. Somlo
@ 2015-04-28 19:42 ` Michael S. Tsirkin
0 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2015-04-28 19:42 UTC (permalink / raw)
To: Gabriel L. Somlo; +Cc: brogers, Gabriel L. Somlo, kevin, qemu-devel, kraxel
On Tue, Apr 28, 2015 at 03:40:37PM -0400, Gabriel L. Somlo wrote:
> ping ?
>
> On Tue, Mar 31, 2015 at 02:32:20PM -0400, Gabriel L. Somlo wrote:
> > Rather than stopping at the first match for the SMBIOS signature
> > ("_SM_") in the f-segment (0xF0000-0xFFFFF), continue scanning
> > until either a valid entry point table is found, or the f-segment
> > has been exhausted.
> >
> > Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
I'm curious why do you want to do this.
Can you add this info in the commmit log?
> > ---
> > tests/bios-tables-test.c | 76 ++++++++++++++++++++++++++++--------------------
> > 1 file changed, 44 insertions(+), 32 deletions(-)
> >
> > diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> > index 735ac61..f79d89a 100644
> > --- a/tests/bios-tables-test.c
> > +++ b/tests/bios-tables-test.c
> > @@ -599,35 +599,15 @@ static void test_acpi_asl(test_data *data)
> > free_test_data(&exp_data);
> > }
> >
> > -static void test_smbios_ep_address(test_data *data)
> > -{
> > - uint32_t off;
> > -
> > - /* find smbios entry point structure */
> > - for (off = 0xf0000; off < 0x100000; off += 0x10) {
> > - uint8_t sig[] = "_SM_";
> > - int i;
> > -
> > - for (i = 0; i < sizeof sig - 1; ++i) {
> > - sig[i] = readb(off + i);
> > - }
> > -
> > - if (!memcmp(sig, "_SM_", sizeof sig)) {
> > - break;
> > - }
> > - }
> > -
> > - g_assert_cmphex(off, <, 0x100000);
> > - data->smbios_ep_addr = off;
> > -}
> > -
> > -static void test_smbios_ep_table(test_data *data)
> > +static bool smbios_ep_table_ok(test_data *data)
> > {
> > struct smbios_entry_point *ep_table = &data->smbios_ep_table;
> > uint32_t addr = data->smbios_ep_addr;
> >
> > ACPI_READ_ARRAY(ep_table->anchor_string, addr);
> > - g_assert(!memcmp(ep_table->anchor_string, "_SM_", 4));
> > + if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
> > + return false;
> > + }
> > ACPI_READ_FIELD(ep_table->checksum, addr);
> > ACPI_READ_FIELD(ep_table->length, addr);
> > ACPI_READ_FIELD(ep_table->smbios_major_version, addr);
> > @@ -636,17 +616,50 @@ static void test_smbios_ep_table(test_data *data)
> > ACPI_READ_FIELD(ep_table->entry_point_revision, addr);
> > ACPI_READ_ARRAY(ep_table->formatted_area, addr);
> > ACPI_READ_ARRAY(ep_table->intermediate_anchor_string, addr);
> > - g_assert(!memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5));
> > + if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
> > + return false;
> > + }
> > ACPI_READ_FIELD(ep_table->intermediate_checksum, addr);
> > ACPI_READ_FIELD(ep_table->structure_table_length, addr);
> > - g_assert_cmpuint(ep_table->structure_table_length, >, 0);
> > + if (ep_table->structure_table_length == 0) {
> > + return false;
> > + }
> > ACPI_READ_FIELD(ep_table->structure_table_address, addr);
> > ACPI_READ_FIELD(ep_table->number_of_structures, addr);
> > - g_assert_cmpuint(ep_table->number_of_structures, >, 0);
> > + if (ep_table->number_of_structures == 0) {
> > + return false;
> > + }
> > ACPI_READ_FIELD(ep_table->smbios_bcd_revision, addr);
> > - g_assert(!acpi_checksum((uint8_t *)ep_table, sizeof *ep_table));
> > - g_assert(!acpi_checksum((uint8_t *)ep_table + 0x10,
> > - sizeof *ep_table - 0x10));
> > + if (acpi_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
> > + acpi_checksum((uint8_t *)ep_table + 0x10, sizeof *ep_table - 0x10)) {
> > + return false;
> > + }
> > + return true;
> > +}
> > +
> > +static void test_smbios_entry_point(test_data *data)
> > +{
> > + uint32_t off;
> > +
> > + /* find smbios entry point structure */
> > + for (off = 0xf0000; off < 0x100000; off += 0x10) {
> > + uint8_t sig[] = "_SM_";
> > + int i;
> > +
> > + for (i = 0; i < sizeof sig - 1; ++i) {
> > + sig[i] = readb(off + i);
> > + }
> > +
> > + if (!memcmp(sig, "_SM_", sizeof sig)) {
> > + /* signature match, but is this a valid entry point? */
> > + data->smbios_ep_addr = off;
> > + if (smbios_ep_table_ok(data)) {
> > + break;
> > + }
> > + }
> > + }
> > +
> > + g_assert_cmphex(off, <, 0x100000);
> > }
> >
> > static inline bool smbios_single_instance(uint8_t type)
> > @@ -767,8 +780,7 @@ static void test_acpi_one(const char *params, test_data *data)
> > }
> > }
> >
> > - test_smbios_ep_address(data);
> > - test_smbios_ep_table(data);
> > + test_smbios_entry_point(data);
> > test_smbios_structs(data);
> >
> > qtest_quit(global_qtest);
> > --
> > 2.1.0
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-28 19:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-31 18:32 [Qemu-devel] [PATCH] bios-tables-test: handle false-positive smbios signature matches Gabriel L. Somlo
2015-03-31 19:19 ` Bruce Rogers
2015-04-28 19:40 ` Gabriel L. Somlo
2015-04-28 19:42 ` Michael S. Tsirkin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.