checking if linux-user address is mapped (sparc)
Hello
so now I'm trying to get the vpr spec2k benchmarks going under sparc32plus-linux-user
In an optimized memory scanning routine the code is doing:
ldxa [ %o0 ] #ASI_PNF, %o3
Which is a load from the "no fault" address space.
What this means is that even if you are loading from an invalid address, no fault should occur.
qemu of course segfaults when the address is invalid.
Is there some way to check in linux-user if a virtual memory address is mapped? That way it could be checked before the ldl_raw() is run?
hopefully I am not misunderstanding the bug here.
Vince
Quoted 13 lines · Vince Weaver
Hello
so now I'm trying to get the vpr spec2k benchmarks going under sparc32plus-linux-user
In an optimized memory scanning routine the code is doing:
ldxa [ %o0 ] #ASI_PNF, %o3Which is a load from the "no fault" address space.
What this means is that even if you are loading from an invalid address, no
fault should occur.
Quoted 6 lines
qemu of course segfaults when the address is invalid.
Is there some way to check in linux-user if a virtual memory address is
mapped? That way it could be checked before theldl_raw()is run?hopefully I am not misunderstanding the bug here.
Could you test this patch?
target-sparc/op_helper.c +36 -8
@@ -1402,10 +1402,17 @@address_mask (env, &addr);switch (asi) { -case 0x80 :// Primary case 0x82 :// Primary no-fault -case 0x88 :// Primary LE case 0x8a :// Primary no-fault LE +if (page_check_range (addr, size,PAGE_READ ) ==-1 ) { +#ifdef DEBUG_ASI +dump_asi ("read " , last_addr, asi, size, ret); +#endif +return 0 ; + } +// Fall through +case 0x80 :// Primary +case 0x88 :// Primary LE {switch (size) {case 1 :
@@ -1424,10 +1431,17 @@ } }break ; -case 0x81 :// Secondary case 0x83 :// Secondary no-fault -case 0x89 :// Secondary LE case 0x8b :// Secondary no-fault LE +if (page_check_range (addr, size,PAGE_READ ) ==-1 ) { +#ifdef DEBUG_ASI +dump_asi ("read " , last_addr, asi, size, ret); +#endif +return 0 ; + } +// Fall through +case 0x81 :// Secondary +case 0x89 :// Secondary LE // XXX break ;default :
@@ -1564,12 +1578,19 @@helper_check_align (addr, size -1 );switch (asi) { +case 0x82 :// Primary no-fault +case 0x8a :// Primary no-fault LE +if (cpu_get_phys_page_debug (env, addr) ==-1ULL ) { +#ifdef DEBUG_ASI +dump_asi ("read " , last_addr, asi, size, ret); +#endif +return 0 ; + } +// Fall through case 0x10 :// As if user primary case 0x18 :// As if user primary LE case 0x80 :// Primary -case 0x82 :// Primary no-fault case 0x88 :// Primary LE -case 0x8a :// Primary no-fault LE if ((asi &0x80 ) && (env->pstate &PS_PRIV )) {if ((env->def->features &CPU_FEATURE_HYPV ) && env->hpstate &HS_PRIV ) {
@@ -1650,15 +1671,22 @@// Only ldda allowed raise_exception (TT_ILL_INSN );return 0 ; +case 0x83 :// Secondary no-fault +case 0x8b :// Secondary no-fault LE +if (cpu_get_phys_page_debug (env, addr) ==-1ULL ) { +#ifdef DEBUG_ASI +dump_asi ("read " , last_addr, asi, size, ret); +#endif +return 0 ; + } +// Fall through case 0x04 :// Nucleus case 0x0c :// Nucleus Little Endian (LE) case 0x11 :// As if user secondary case 0x19 :// As if user secondary LE case 0x4a :// UPA config case 0x81 :// Secondary -case 0x83 :// Secondary no-fault case 0x89 :// Secondary LE -case 0x8b :// Secondary no-fault LE // XXX break ;case 0x45 :// LSU
Quoted 1 line · Blue Swirl
Could you test this patch?
The patch works great! vpr works now, and it also fixes the parser benchmark.
Thanks for fixing this, I always get completely mixed up when digging through the memory access code trying to figure which parts apply to linux-user and which parts don't.
Of the 48 Spec2000 benchmarks, we are down to only 2 that don't work (facerec and sixtrack). The remaining problem is floating point related, I'll see if I can track it down.
Thanks!
Vince