Skip to contentSkip to conversation

nvbios: Add missing null byte to string read from file.

PATCH In review Christian Costa 2 participants 14 messages Aug 31, 2014 10 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvbios: Add missing null byte to string read from file.

---
 nvbios/nvbios.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
nvbios/nvbios.c +3 -2
index f7aafe3..28e62ad 100644
@@ -774,11 +774,12 @@ int set_strap_from_string(const char* strap_s)
 int set_strap_from_file(const char *path)
 {
 	FILE *strapfile = NULL;
-	char tmp[21];
+	char tmp[22];
 
 	strapfile = fopen(path, "r");
 	if (strapfile) {
-		fread(tmp, 1, 21, strapfile);
+		size_t size = fread(tmp, 1, 21, strapfile);
+		tmp[size] = 0;
 		return set_strap_from_string(tmp);
 	}
 
Signature · 1 line
1.9.1

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

#2 lore raw

PATCH 1/1 nva: Add nvaforcetemp to git ignore and sort it for better update

---
 nva/.gitignore | 53 +++++++++++++++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 26 deletions(-)
nva/.gitignore +27 -26
index 5c9184b..72de056 100644
@@ -1,39 +1,40 @@
+evotiming
+libnva.a
+libnva.so
+nv01dump
+nv01post
+nvacounter
+nvadownload
+nvaevo
+nvafakebios
 nvafill
+nvaforcetemp
+nvafucstart
+nvafuzz
+nvagetbios
+nvagetpmu
 nvahammer
 nvalist
+nvamemtiming
+nvammiotracereplay
 nvapeek
+nvapeeki
 nvapeekstat
+nvapms
 nvapoke
-nvapeeki
-nvagetbios
-nvafakebios
+nvapy.c
+nvapy.so
 nvascan
+nvaspyi2c
+nvastrscan
 nvatiming
-nvapms
-nvafuzz
+nvaupload
+nvavucstart
 nvawatch
-nvacounter
-nvastrscan
-nvaevo
-nvaxttime
-nvaxtstart
+nvaxtinsn
 nvaxtpeek
 nvaxtpoke
 nvaxtrsr
 nvaxtssr
-nvaxtinsn
-nvaupload
-nvadownload
-evotiming
-nvavucstart
-nvafucstart
-nvamemtiming
-nv01post
-nv01dump
-nvammiotracereplay
-nvaspyi2c
-libnva.a
-libnva.so
-nvapy.c
-nvapy.so
-nvagetpmu
+nvaxtstart
+nvaxttime
Signature · 1 line
1.9.1

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

#4 lore raw

Re: [PATCH envytools] nva: Add nvaforcetemp to git ignore and sort it for better update

Woops, my bad... Sorry!

#5 lore raw

PATCH 1/1 nvamemtiming: Update usage.

In reply to a message not in the archive
---
 nva/nvamemtiming.c | 2 ++
 1 file changed, 2 insertions(+)
nva/nvamemtiming.c +2 -0
index 4468f81..75c6e49 100644
@@ -51,6 +51,8 @@ void usage(int argc, char **argv)
 	fprintf(stderr, "\t-e: Only modify the specified index (to be used with -v)\n");
 	fprintf(stderr, "\t-v: Set the specified value to the specified entry\n");
 	fprintf(stderr, "\t-b index: Consider the specified index as a bitfield and RE it\n");
+	fprintf(stderr, "\t-s index: Specify range start in timing entry (Deep & Shallow modes)\n");
+	fprintf(stderr, "\t-f index: Specify range end in timing entry (Deep & Shallow modes)\n");
 	fprintf(stderr, "\t-d timing_entry_high: For each indexes, iterate between the timing_entry and the timing_entry_high value (Deep mode)\n");
 	exit(-1);
 }
Signature · 1 line
1.9.1
#6 lore raw

PATCH 1/1 nvamemtiming: Handle target < initial case when iterating values

In reply to a message not in the archive

Otherwise some values are not tested at all.

---
 nva/set_timings.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
nva/set_timings.c +3 -2
index 6cd831c..7a8f845 100644
@@ -408,7 +408,7 @@ static void
 iterate_values(struct nvamemtiming_conf *conf, FILE *outf, uint8_t index, enum color color)
 {
 	uint8_t initial, target;
-	int v;
+	int v, incr;
 
 	if (conf->mode != MODE_DEEP)
 		return;
@@ -416,7 +416,8 @@ iterate_values(struct nvamemtiming_conf *conf, FILE *outf, uint8_t index, enum c
 	initial = conf->vbios.data[conf->vbios.timing_entry_offset + index];
 	target = conf->vbios.data[conf->deep.timing_entry_offset + index];
 
-	for (v = initial+1; v <= target; v++) {
+	incr = target > initial ? 1 : -1;
+	for (v = initial+incr; v != target+incr; v+=incr) {
 		conf->vbios.data[conf->vbios.timing_entry_offset + index] = v;
 		launch(conf, outf, index + 1 , COLOR);
 	}
Signature · 1 line
1.9.1

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

#8 lore raw

Re: [PATCH envytools] nvamemtiming: Handle target < initial case when iterating values

Quoted 1 line · Christian Costa

Otherwise some values are not tested at all.

I would rather have a warning than the program doing stuff behind my back. This is a dev tool, dumb == good ;)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

Re: [PATCH envytools] nvamemtiming: Handle target < initial case when iterating values

Quoted 4 lines · Martin Peres
Quoted 1 line · Christian Costa

Otherwise some values are not tested at all.

I would rather have a warning than the program doing stuff behind my back. This is a dev tool, dumb == good ;)

But why didn't you call it Dumb mode rather that Deep mode. That way, I wouldn't have tried to use it and figure out what it does. ;p

So about my problem,

Command:
sudo nvamemtiming pramin 0x6a22 3 0 -d 5

Vbios info:
Table offset at 0x6a22
Entry 3 => 0x6a73: 0d 06 0f 26 00 45 00 1b 00 0b 0d 08 04 0c 01 00 00 00 03 03 10 0a 09 00 03 Entry 5 => 0x6aa5: 05 04 08 05 00 09 00 03 00 02 02 02 02 0c 02 00 00 00 03 03 08 0a 0f 00 02

With the current code, I get these iterations:
timing table at: 6a22
Deep mode: Will iterate between 5 and 24
idx 5, initial 45, target 9
idx 7, initial 1b, target 3
idx 9, initial b, target 2
idx 10, initial d, target 2
idx 11, initial 8, target 2
idx 12, initial 4, target 2
idx 13, initial c, target c
idx 18, initial 3, target 3
idx 19, initial 3, target 3
idx 20, initial 10, target 8
idx 21, initial a, target a
idx 22, initial 9, target f => a b c d e f
idx 24, initial 3, target 2

It does not test much for the reason most of the time the target value is lower than the initial one.

With my patch:
timing table at: 6a22
Deep mode: Will iterate between 5 and 24
idx 5, initial 45, target 9 => 44 43 42 41 40 3f 3e 3d 3c 3b 3a 39 38 37 36 35 34 33 32 31 30 2f 2e 2d 2c 2b 2a 29 28 27 26 25 24 23 22 21 20 1f 1e 1d 1c 1b 1a 19 18 17 16 15 14 13 12 11 10 f e d c b a 9 idx 7, initial 1b, target 3 => 1a 19 18 17 16 15 14 13 12 11 10 f e d c b a 9 8 7 6 5 4 3
idx 9, initial b, target 2 => a 9 8 7 6 5 4 3 2
idx 10, initial d, target 2 => c b a 9 8 7 6 5 4 3 2
idx 11, initial 8, target 2 => 7 6 5 4 3 2
idx 12, initial 4, target 2 => 3 2
idx 13, initial c, target c
idx 18, initial 3, target 3
idx 19, initial 3, target 3
idx 20, initial 10, target 8 => f e d c b a 9 8
idx 21, initial a, target a
idx 22, initial 9, target f => a b c d e f
idx 24, initial 3, target 2 =>2

Maybe shallow mode would be enough to test timing but what the purpose of deep mode in that case ?

Christian

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw

Re: [PATCH envytools] nvamemtiming: Handle target < initial case when iterating values

Quoted 6 lines · Christian Costa
Quoted 4 lines · Martin Peres
Quoted 1 line · Christian Costa

Otherwise some values are not tested at all.

I would rather have a warning than the program doing stuff behind my back. This is a dev tool, dumb == good ;)

But why didn't you call it Dumb mode rather that Deep mode. That way, I wouldn't have tried to use it and figure out what it does. ;p

Target is supposed to be higher than initial! Initial == minimum safe timing.

You just reversed the order, try:
sudo nvamemtiming pramin 0x6a22 5 0 -d 3

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw

Re: [PATCH envytools] nvamemtiming: Handle target < initial case when iterating values

Quoted 4 lines · Martin Peres
Quoted 3 lines · Christian Costa
Quoted 2 lines · Martin Peres
Quoted 1 line · Christian Costa

Otherwise some values are not tested at all.

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

I would rather have a warning than the program doing stuff behind my back. This is a dev tool, dumb == good ;)

But why didn't you call it Dumb mode rather that Deep mode. That way, I wouldn't have tried to use it and figure out what it does. ;p

Target is supposed to be higher than initial! Initial == minimum safe timing.

You just reversed the order, try:
sudo nvamemtiming pramin 0x6a22 5 0 -d 3

Ok. It's intended then. Thanks!

A message that is not in the archive (sent off-list or not yet received): [email protected]

#16 lore raw

Re: [PATCH envytools] nvamemtiming: Handle target < initial case when iterating values

Quoted 7 lines · Christian Costa
Quoted 6 lines · Martin Peres
Quoted 5 lines · Christian Costa
Quoted 4 lines · Martin Peres
Quoted 1 line · Christian Costa

Otherwise some values are not tested at all.

I would rather have a warning than the program doing stuff behind my back. This is a dev tool, dumb == good ;)

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

But why didn't you call it Dumb mode rather that Deep mode. That way, I wouldn't have tried to use it and figure out what it does. ;p

Target is supposed to be higher than initial! Initial == minimum safe timing.

You just reversed the order, try:
sudo nvamemtiming pramin 0x6a22 5 0 -d 3

Ok. It's intended then. Thanks!

I totally agree that this tool is a little confusing. If you have suggestions on how to improve the usage doc, feel free to propose me something better :)

fprintf(stderr, "\t-d timing_entry_high: For each indexes, iterate between the timing_entry and the timing_entry_high value (Deep mode)\n");

Speaking about this, this should be corrected to "For each index", no plural after each. I'll fix it right now.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#18 lore raw

Re: [PATCH envytools] nvamemtiming: Handle target < initial case when iterating values

Quoted 15 lines · Martin Peres
Quoted 14 lines · Christian Costa
Quoted 13 lines · Martin Peres
Quoted 6 lines · Christian Costa
Quoted 4 lines · Martin Peres
Quoted 1 line · Christian Costa

Otherwise some values are not tested at all.

I would rather have a warning than the program doing stuff behind my back. This is a dev tool, dumb == good ;)

But why didn't you call it Dumb mode rather that Deep mode. That way, I wouldn't have tried to use it and figure out what it does. ;p

Target is supposed to be higher than initial! Initial == minimum safe timing.

You just reversed the order, try:
sudo nvamemtiming pramin 0x6a22 5 0 -d 3

Quoted 8 lines
Quoted 1 line

Ok. It's intended then. Thanks!

I totally agree that this tool is a little confusing. If you have suggestions on how to improve the usage doc, feel free to propose me something better :)

fprintf(stderr, "\t-d timing_entry_high: For each indexes, iterate between the timing_entry and the timing_entry_high value (Deep mode)\n");

Speaking about this, this should be corrected to "For each index", no plural after each. I'll fix it right now.

Ok. I will think about it.
Some comments in the source code can help also to know what it does and what it is used for. Same for README.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#20 lore raw

Re: [PATCH envytools] nvamemtiming: Handle target < initial case when iterating values

Quoted 18 lines · Christian Costa
Quoted 17 lines · Martin Peres
Quoted 15 lines · Christian Costa
Quoted 4 lines · Martin Peres
Quoted 3 lines · Christian Costa
Quoted 2 lines · Martin Peres
Quoted 1 line · Christian Costa

Otherwise some values are not tested at all.

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

I would rather have a warning than the program doing stuff behind my back. This is a dev tool, dumb == good ;)

But why didn't you call it Dumb mode rather that Deep mode. That way, I wouldn't have tried to use it and figure out what it does. ;p

Target is supposed to be higher than initial! Initial == minimum safe timing.

You just reversed the order, try:
sudo nvamemtiming pramin 0x6a22 5 0 -d 3

Ok. It's intended then. Thanks!

Quoted 8 lines
Quoted 6 lines

I totally agree that this tool is a little confusing. If you have suggestions on how to improve the usage doc, feel free to propose me something better :)

fprintf(stderr, "\t-d timing_entry_high: For each indexes, iterate between the timing_entry and the timing_entry_high value (Deep mode)\n");

Speaking about this, this should be corrected to "For each index", no plural after each. I'll fix it right now.

Ok. I will think about it.
Some comments in the source code can help also to know what it does and what it is used for. Same for README.

Btw, the plural of index is indices.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#22 lore raw

Re: [PATCH envytools] nvamemtiming: Handle target < initial case when iterating values

Quoted 21 lines · Christian Costa
Quoted 20 lines · Christian Costa
Quoted 19 lines · Martin Peres
Quoted 7 lines · Christian Costa
Quoted 6 lines · Martin Peres
Quoted 5 lines · Christian Costa
Quoted 4 lines · Martin Peres
Quoted 1 line · Christian Costa

Otherwise some values are not tested at all.

I would rather have a warning than the program doing stuff behind my back. This is a dev tool, dumb == good ;)

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

But why didn't you call it Dumb mode rather that Deep mode. That way, I wouldn't have tried to use it and figure out what it does. ;p

Target is supposed to be higher than initial! Initial == minimum safe timing.

You just reversed the order, try:
sudo nvamemtiming pramin 0x6a22 5 0 -d 3

Ok. It's intended then. Thanks!

I totally agree that this tool is a little confusing. If you have suggestions on how to improve the usage doc, feel free to propose me something better :)

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

fprintf(stderr, "\t-d timing_entry_high: For each indexes, iterate between the timing_entry and the timing_entry_high value (Deep mode)\n");

Speaking about this, this should be corrected to "For each index", no plural after each. I'll fix it right now.

Ok. I will think about it.
Some comments in the source code can help also to know what it does and what it is used for. Same for README.

Btw, the plural of index is indices.

Yeah, it was doubly wrong ;)

#23 lore raw
In reply to a message not in the archive
Quoted 13 lines · Christian Costa
---
  nvbios/nvbios.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
nvbios/nvbios.c +0 -1
index f7aafe3..28e62ad 100644
@@ -774,11 +774,12 @@ int set_strap_from_string(const char* strap_s)
  int set_strap_from_file(const char *path)
  {
  	FILE *strapfile = NULL;
-	char tmp[21];

nvbios/nvbios.c int set_strap_from_string(const char* strap_s) · line 785

Quoted 10 lines
nvbios/nvbios.c +3 -1
+	char tmp[22];
 
  	strapfile = fopen(path, "r");
  	if (strapfile) {
-		fread(tmp, 1, 21, strapfile);
+		size_t size = fread(tmp, 1, 21, strapfile);
+		tmp[size] = 0;
  		return set_strap_from_string(tmp);
  	}
 

Thanks, I pushed the first 3 patches!