All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 1/2] intel_bios_reader: Read the child device size from VBT
@ 2015-03-25 18:36 ville.syrjala
  2015-03-25 18:36 ` [PATCH i-g-t 2/2] intel_bios_reader: Don't explode looking for the devid ville.syrjala
  0 siblings, 1 reply; 2+ messages in thread
From: ville.syrjala @ 2015-03-25 18:36 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

New stuff has been added to the end of the child device block at various
times, so using a hardcoded size for the block is a bad idea.
Fortunately the size of the block is listed in the VBT just before the
blocks themselves, so grab it from there.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tools/intel_bios.h        | 2 +-
 tools/intel_bios_reader.c | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/intel_bios.h b/tools/intel_bios.h
index aedc5fc..64e723d 100644
--- a/tools/intel_bios.h
+++ b/tools/intel_bios.h
@@ -269,7 +269,7 @@ struct bdb_general_definitions {
 	 * TV and LVDS are missing, so be careful when interpreting
 	 * [4] and [5].
 	 */
-	struct child_device_config devices[0];
+	uint8_t devices[0];
 	/* may be another device block here on some platforms */
 } __attribute__ ((packed));
 
diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 4fa47a9..641cb38 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -338,7 +338,6 @@ static void dump_child_device(struct child_device_config *child)
 static void dump_general_definitions(const struct bdb_block *block)
 {
 	struct bdb_general_definitions *defs = block->data;
-	struct child_device_config *child;
 	int i;
 	int child_device_num;
 
@@ -351,9 +350,11 @@ static void dump_general_definitions(const struct bdb_block *block)
 	printf("\tBoot display type: 0x%02x%02x\n", defs->boot_display[1],
 	       defs->boot_display[0]);
 	printf("\tTV data block present: %s\n", YESNO(tv_present));
-	child_device_num = (block->size - sizeof(*defs)) / sizeof(*child);
+	printf("\tChild device size: %d\n", defs->child_dev_size);
+	child_device_num = (block->size - sizeof(*defs)) /
+		defs->child_dev_size;
 	for (i = 0; i < child_device_num; i++)
-		dump_child_device(&defs->devices[i]);
+		dump_child_device((void*)&defs->devices[i * defs->child_dev_size]);
 }
 
 static void dump_child_devices(const struct bdb_block *block)
-- 
2.0.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH i-g-t 2/2] intel_bios_reader: Don't explode looking for the devid
  2015-03-25 18:36 [PATCH i-g-t 1/2] intel_bios_reader: Read the child device size from VBT ville.syrjala
@ 2015-03-25 18:36 ` ville.syrjala
  0 siblings, 0 replies; 2+ messages in thread
From: ville.syrjala @ 2015-03-25 18:36 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Check that the offset where expect to find the device id is withing the
BIOS image, instead of accessing whatever (if anything) happens to be
there.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tools/intel_bios_reader.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 641cb38..c5fc777 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -1052,11 +1052,14 @@ err:
 
 
 static int
-get_device_id(unsigned char *bios)
+get_device_id(unsigned char *bios, int size)
 {
     int device;
     int offset = (bios[0x19] << 8) + bios[0x18];
 
+    if (offset + 7 >= size)
+	return -1;
+
     if (bios[offset] != 'P' ||
 	bios[offset+1] != 'C' ||
 	bios[offset+2] != 'I' ||
@@ -1296,7 +1299,7 @@ int main(int argc, char **argv)
 	printf("\n");
 
 	if (devid == -1)
-	    devid = get_device_id(VBIOS);
+	    devid = get_device_id(VBIOS, size);
 	if (devid == -1)
 	    printf("Warning: could not find PCI device ID!\n");
 
-- 
2.0.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2015-03-25 18:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-25 18:36 [PATCH i-g-t 1/2] intel_bios_reader: Read the child device size from VBT ville.syrjala
2015-03-25 18:36 ` [PATCH i-g-t 2/2] intel_bios_reader: Don't explode looking for the devid ville.syrjala

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.