SH4: Fixed last UTLB unused
PATCH 1/1 SH4: Fixed last UTLB unused
With my previous patch (the one monitoring tlb), I found that the last TLB entry was never use. Here a little fix.
--- target-sh4/helper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-sh4/helper.c +1 -1
@@ -305,7 +305,7 @@ static void increment_urc(CPUState * env) urb = ((env->mmucr) >>18 ) &0x3f ; urc = ((env->mmucr) >>10 ) &0x3f ; urc++; -if (urc == urb || urc ==UTLB_SIZE -1 ) +if (urc == urb || urc ==UTLB_SIZE ) urc =0 ; env->mmucr = (env->mmucr &0xffff03ff ) | (urc <<10 ); }
Signature · 7 lines
1.5.6.5 -- Lione Landwerlin O p e n W i d e 14, rue Gaillon 75002 Paris
A more exact patch (according to datasheet) would be :
--- target-sh4/helper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-sh4/helper.c +1 -1
@@ -305,7 +305,7 @@ static void increment_urc(CPUState * env) urb = ((env->mmucr) >>18 ) &0x3f ; urc = ((env->mmucr) >>10 ) &0x3f ; urc++; -if (urc == urb || urc ==UTLB_SIZE -1 ) +if (urc == urb || urc > (UTLB_SIZE -1 )) urc =0 ; env->mmucr = (env->mmucr &0xffff03ff ) | (urc <<10 ); }
Signature · 7 lines
1.5.6.5 -- Lione Landwerlin O p e n W i d e 14, rue Gaillon 75002 Paris
Still not happy with the fix ...
--- target-sh4/helper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-sh4/helper.c +1 -1
@@ -305,7 +305,7 @@ static void increment_urc(CPUState * env) urb = ((env->mmucr) >>18 ) &0x3f ; urc = ((env->mmucr) >>10 ) &0x3f ; urc++; -if (urc == urb || urc ==UTLB_SIZE -1 ) +if (urc > urb || urc > (UTLB_SIZE -1 )) urc =0 ; env->mmucr = (env->mmucr &0xffff03ff ) | (urc <<10 ); }
Signature · 7 lines
1.5.6.5 -- Lione Landwerlin O p e n W i d e 14, rue Gaillon 75002 Paris
Quoted 6 lines · Lionel Landwerlin
Still not happy with the fix ...
Signed-off-by Lionel Landwerlin <[email protected]>--- target-sh4/helper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Sorry I missed this one when committing the first patch. I have applied it on top of it.
Quoted 25 lines
target-sh4/helper.c +1
-1@@ -305,7 +305,7 @@ static void increment_urc(CPUState * env) urb = ((env->mmucr) >>18 ) &0x3f ; urc = ((env->mmucr) >>10 ) &0x3f ; urc++; -if (urc == urb || urc ==UTLB_SIZE -1 ) +if (urc > urb || urc > (UTLB_SIZE -1 )) urc =0 ; env->mmucr = (env->mmucr &0xffff03ff ) | (urc <<10 ); }Signature · 7 lines
1.5.6.5 -- Lione Landwerlin O p e n W i d e 14, rue Gaillon 75002 Paris
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 11 lines · Aurelien Jarno
Quoted 6 lines · Lionel Landwerlin
Still not happy with the fix ...
Signed-off-by Lionel Landwerlin <[email protected]>--- target-sh4/helper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)Sorry I missed this one when committing the first patch. I have applied it on top of it.
Quoted 15 lines
Quoted 15 lines
target-sh4/helper.c +1
-1@@ -305,7 +305,7 @@ static void increment_urc(CPUState * env) urb = ((env->mmucr) >>18 ) &0x3f ; urc = ((env->mmucr) >>10 ) &0x3f ; urc++; -if (urc == urb || urc ==UTLB_SIZE -1 ) +if (urc > urb || urc > (UTLB_SIZE -1 )) urc =0 ; env->mmucr = (env->mmucr &0xffff03ff ) | (urc <<10 ); }Signature · 1 line
1.5.6.5
Hi Aurelien,
Thanks for applying my patches, but even with this version, I was still missing the real condition (according to SH4 datasheet) :
Random counter for indicating the UTLB entry for which replacement is to be performed with an LDTLB instruction. URC is incremented each time the UTLB is accessed. When URB > 0, URC is reset to 0 when the condition URC = URB occurs. Also note that, if a value is written to URC by software which results in
the condition URC > URB, incrementing is first performed in excess of URB until URC = 0x3F. URC is not incremented by an LDTLB instruction.
So the final version is :
[PATCH] SH4: Fixed last UTLB unused and URB/URC management
--- target-sh4/helper.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
target-sh4/helper.c +0 -0
@@ -297,7 +297,7 @@ static int same_tlb_entry_exists(const tlb_t *
haystack, uint8_t nbtlb,
return 0;
}
static void increment_urc(CPUState * env)
{
uint8_t urb, urc;@@ -305,7 +305,7 @@ static void increment_urc(CPUState * env)
urb = ((env->mmucr) >> 18) & 0x3f;
urc = ((env->mmucr) >> 10) & 0x3f;
urc++;
- if (urc == urb || urc == UTLB_SIZE - 1)
+ if ((urb > 0 && urc > urb) || urc > (UTLB_SIZE - 1))
urc = 0;
env->mmucr = (env->mmucr & 0xffff03ff) | (urc << 10);}
Signature · 9 lines
1.5.6.5 Sorry for that mistake. -- Lionel Landwerlin <[email protected]>
Aurelien Jarno
AppliedQuoted 5 lines · Lionel Landwerlin
With my previous patch (the one monitoring tlb), I found that the last TLB entry was never use. Here a little fix.
Signed-off-by Lionel Landwerlin <[email protected]>
Thanks, applied.
Quoted 29 lines
--- target-sh4/helper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)target-sh4/helper.c +1
-1@@ -305,7 +305,7 @@ static void increment_urc(CPUState * env) urb = ((env->mmucr) >>18 ) &0x3f ; urc = ((env->mmucr) >>10 ) &0x3f ; urc++; -if (urc == urb || urc ==UTLB_SIZE -1 ) +if (urc == urb || urc ==UTLB_SIZE ) urc =0 ; env->mmucr = (env->mmucr &0xffff03ff ) | (urc <<10 ); }Signature · 7 lines
1.5.6.5 -- Lione Landwerlin O p e n W i d e 14, rue Gaillon 75002 Paris
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net