Skip to contentSkip to conversation

nvbios: Fix reading of ram_restrict_group_count.

PATCH In review Christian Costa 2 participants 4 messages Aug 30, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvbios: Fix reading of ram_restrict_group_count.

The entry offset was use instead of the data it points to. Probably a regression.
The files showing script parsing errors has been reduced from 410 to 6 with the database of 505 vbios.

---
 nvbios/mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
nvbios/mem.c +2 -2
index 81f2d1b..e4797e3 100644
@@ -232,11 +232,11 @@ envy_bios_parse_bit_M (struct envy_bios *bios, struct envy_bios_bit_entry *bit)
 
 	if (bit->version == 1) {
 		if (bit->t_len >= 5) {
-			bios_u8(bios, bit->offset+2, &ram_restrict_group_count);
+			bios_u8(bios, bit->t_offset+2, &ram_restrict_group_count);
 		}
 	} else if (bit->version == 2) {
 		if (bit->t_len >= 3) {
-			bios_u8(bios, bit->offset, &ram_restrict_group_count);
+			bios_u8(bios, bit->t_offset, &ram_restrict_group_count);
 		}
 	}
 
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 1409418318-31648-1-git-send-email-titan.costa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/1 nvbios: Truncate nb of entries to avoid displaying garbage

We return an error but this does not prevent the display so just make sure only valid data are printed.

---
 nvbios/mem.c | 1 +
 1 file changed, 1 insertion(+)
nvbios/mem.c +1 -0
index e4797e3..00f5cd5 100644
@@ -112,6 +112,7 @@ envy_bios_parse_mem_train (struct envy_bios *bios) {
 		entry->offset = mt->offset + mt->hlen + ((mt->rlen + mt->subentries * mt->subentrylen) * i);
 		err |= bios_u8(bios, entry->offset, &entry->u00);
 		if (mt->subentries > sizeof(entry->subentry)) {
+			mt->subentries = sizeof(entry->subentry);
 			ENVY_BIOS_ERR("Error when parsing mem train: subentries = %d > %lu\n", mt->subentries, sizeof(entry->subentry));
 			return -EFAULT;
 		}
Signature · 1 line
1.9.1
#3 lore raw

PATCH 1/1 nvamemtiming: Make deep mode take range into account and treat range end as included

In reply to a message not in the archive
---
 nva/set_timings.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
nva/set_timings.c +4 -4
index 7376486..6cd831c 100644
@@ -448,14 +448,14 @@ deep_dump(struct nvamemtiming_conf *conf)
 	if (conf->range.start == (unsigned char) -1)
 		conf->range.start = 0;
 	if (conf->range.end == (unsigned char) -1)
-		conf->range.end = conf->vbios.timing_entry_length;
+		conf->range.end = conf->vbios.timing_entry_length - 1;
 
 	fprintf(stderr, "Deep mode: Will iterate between %i and %i\n", conf->range.start, conf->range.end);
 
 	launch(conf, outf, 0, NO_COLOR);
 
 	/* iterate through the vbios timing values */
-	for (i = 0; i < conf->vbios.timing_entry_length; i++) {
+	for (i = conf->range.start; i <= conf->range.end; i++) {
 		uint8_t orig = conf->vbios.data[conf->vbios.timing_entry_offset + i];
 
 		if (timing_value_types[i] == VALUE ||
@@ -506,14 +506,14 @@ shallow_dump(struct nvamemtiming_conf *conf)
 	if (conf->range.start == (unsigned char) -1)
 		conf->range.start = 0;
 	if (conf->range.end == (unsigned char) -1)
-		conf->range.end = conf->vbios.timing_entry_length;
+		conf->range.end = conf->vbios.timing_entry_length - 1;
 
 	fprintf(stderr, "Shallow mode: Will iterate between %i and %i\n", conf->range.start, conf->range.end);
 
 	launch(conf, outf, 0, NO_COLOR);
 
 	/* iterate through the vbios timing values */
-	for (i = conf->range.start; i < conf->range.end; i++) {
+	for (i = conf->range.start; i <= conf->range.end; i++) {
 		uint8_t orig = conf->vbios.data[conf->vbios.timing_entry_offset + i];
 
 		if (timing_value_types[i] == VALUE ||
Signature · 1 line
1.9.1
#4 lore raw
In reply to a message not in the archive
Quoted 14 lines · Christian Costa

The entry offset was use instead of the data it points to. Probably a regression.
The files showing script parsing errors has been reduced from 410 to 6 with the database of 505 vbios.

---
  nvbios/mem.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
nvbios/mem.c +0 -0
index 81f2d1b..e4797e3 100644
@@ -232,11 +232,11 @@ envy_bios_parse_bit_M (struct envy_bios *bios, struct envy_bios_bit_entry *bit)
 
  	if (bit->version == 1) {
  		if (bit->t_len >= 5) {

nvbios/mem.c envy_bios_parse_bit_M (struct envy_bios *bios, struct envy_bios_bit_entry *bit) · line 242

Quoted 10 lines
nvbios/mem.c +2 -2
-			bios_u8(bios, bit->offset+2, &ram_restrict_group_count);
+			bios_u8(bios, bit->t_offset+2, &ram_restrict_group_count);
  		}
  	} else if (bit->version == 2) {
  		if (bit->t_len >= 3) {
-			bios_u8(bios, bit->offset, &ram_restrict_group_count);
+			bios_u8(bios, bit->t_offset, &ram_restrict_group_count);
  		}
  	}
 

A very big thank you Christian for this fix! It had been bothering a few of us but we never really looked into it because we always was reminded of this bug while doing something else.

I pushed all three patches! Looking forward to seeing what's next ;)