* [Qemu-devel] mipsIV support for mips-linux-user
@ 2009-03-29 20:56 Vince Weaver
2009-03-30 1:05 ` Aurelien Jarno
0 siblings, 1 reply; 7+ messages in thread
From: Vince Weaver @ 2009-03-29 20:56 UTC (permalink / raw)
To: qemu-devel
Hello
I have some 32-bit mips binaries compiled with -mips4 -O3.
These run fine on an actual mips r12k system I have, but
fail with default mips-linux-user (0.10.1).
This is because by default mips-linux-user does not have support enabled
for mipsIV instructions. This is because MIPS_HFLAG_COP1X
is not enabled on any of the cpus supported by mips-linux-user.
So my question, what is the correct way to fix this? Add a R4000 class
CPU that can be seen with mips-linux-user? Or should the default for
user operation just enable this because it supports more binaries?
Vince
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] mipsIV support for mips-linux-user
2009-03-29 20:56 [Qemu-devel] mipsIV support for mips-linux-user Vince Weaver
@ 2009-03-30 1:05 ` Aurelien Jarno
2009-03-30 2:14 ` Vince Weaver
0 siblings, 1 reply; 7+ messages in thread
From: Aurelien Jarno @ 2009-03-30 1:05 UTC (permalink / raw)
To: qemu-devel
On Sun, Mar 29, 2009 at 04:56:35PM -0400, Vince Weaver wrote:
> Hello
>
> I have some 32-bit mips binaries compiled with -mips4 -O3.
>
> These run fine on an actual mips r12k system I have, but fail with
> default mips-linux-user (0.10.1).
>
> This is because by default mips-linux-user does not have support enabled
> for mipsIV instructions. This is because MIPS_HFLAG_COP1X
> is not enabled on any of the cpus supported by mips-linux-user.
>
> So my question, what is the correct way to fix this? Add a R4000 class
> CPU that can be seen with mips-linux-user? Or should the default for
> user operation just enable this because it supports more binaries?
Did you try with a MIPS32R2 CPU? It should have COP1X instructions.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] mipsIV support for mips-linux-user
2009-03-30 1:05 ` Aurelien Jarno
@ 2009-03-30 2:14 ` Vince Weaver
2009-03-30 4:35 ` Aurelien Jarno
0 siblings, 1 reply; 7+ messages in thread
From: Vince Weaver @ 2009-03-30 2:14 UTC (permalink / raw)
To: qemu-devel
On Mon, 30 Mar 2009, Aurelien Jarno wrote:
> On Sun, Mar 29, 2009 at 04:56:35PM -0400, Vince Weaver wrote:
>> Hello
>>
>> I have some 32-bit mips binaries compiled with -mips4 -O3.
>>
>> These run fine on an actual mips r12k system I have, but fail with
>> default mips-linux-user (0.10.1).
>>
>> This is because by default mips-linux-user does not have support enabled
>> for mipsIV instructions. This is because MIPS_HFLAG_COP1X
>> is not enabled on any of the cpus supported by mips-linux-user.
>>
>> So my question, what is the correct way to fix this? Add a R4000 class
>> CPU that can be seen with mips-linux-user? Or should the default for
>> user operation just enable this because it supports more binaries?
>
> Did you try with a MIPS32R2 CPU? It should have COP1X instructions.
I tried all of the variants listed with -cpu ?
no -cpu specified = fails at first cop1x insn
MIPS '4Kc' = segfaults invalid "cfc1 v1,$31" instruction
MIPS '4Km' = segfaults invalid "cfc1 v1,$31" instruction
MIPS '4KEcR1' = segfaults invalid "cfc1 v1,$31" instruction
MIPS '4KEmR1' = segfaults invalid "cfc1 v1,$31" instruction
MIPS '4KEc' = segfaults invalid "cfc1 v1,$31" instruction
MIPS '4KEm' = segfaults invalid "cfc1 v1,$31" instruction
MIPS '24Kc' = segfaults invalid "cfc1 v1,$31" instruction
MIPS '24Kf' = fails at first cop1x insn
MIPS '34Kf' = fails at first cop1x insn
If I modify the check for cop1x to always return valid, running with no
-cpu runs the program successfully to completion.
This might be some mistake in the cpu feature selection logic. The code
is a bit hard to follow, especially as I don't have a good document
specifying which CPUs have which features, especially since the real
machines I have access to for comparison are SGI R4600, R5000 and R12000
machines.
Vince
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] mipsIV support for mips-linux-user
2009-03-30 2:14 ` Vince Weaver
@ 2009-03-30 4:35 ` Aurelien Jarno
2009-03-30 17:29 ` Vince Weaver
0 siblings, 1 reply; 7+ messages in thread
From: Aurelien Jarno @ 2009-03-30 4:35 UTC (permalink / raw)
To: qemu-devel
On Sun, Mar 29, 2009 at 10:14:23PM -0400, Vince Weaver wrote:
> On Mon, 30 Mar 2009, Aurelien Jarno wrote:
>
>> On Sun, Mar 29, 2009 at 04:56:35PM -0400, Vince Weaver wrote:
>>> Hello
>>>
>>> I have some 32-bit mips binaries compiled with -mips4 -O3.
>>>
>>> These run fine on an actual mips r12k system I have, but fail with
>>> default mips-linux-user (0.10.1).
>>>
>>> This is because by default mips-linux-user does not have support enabled
>>> for mipsIV instructions. This is because MIPS_HFLAG_COP1X
>>> is not enabled on any of the cpus supported by mips-linux-user.
>>>
>>> So my question, what is the correct way to fix this? Add a R4000 class
>>> CPU that can be seen with mips-linux-user? Or should the default for
>>> user operation just enable this because it supports more binaries?
>>
>> Did you try with a MIPS32R2 CPU? It should have COP1X instructions.
>
> I tried all of the variants listed with -cpu ?
>
> no -cpu specified = fails at first cop1x insn
>
> MIPS '4Kc' = segfaults invalid "cfc1 v1,$31" instruction
> MIPS '4Km' = segfaults invalid "cfc1 v1,$31" instruction
> MIPS '4KEcR1' = segfaults invalid "cfc1 v1,$31" instruction
> MIPS '4KEmR1' = segfaults invalid "cfc1 v1,$31" instruction
> MIPS '4KEc' = segfaults invalid "cfc1 v1,$31" instruction
> MIPS '4KEm' = segfaults invalid "cfc1 v1,$31" instruction
> MIPS '24Kc' = segfaults invalid "cfc1 v1,$31" instruction
> MIPS '24Kf' = fails at first cop1x insn
> MIPS '34Kf' = fails at first cop1x insn
>
> If I modify the check for cop1x to always return valid, running with no
> -cpu runs the program successfully to completion.
>
> This might be some mistake in the cpu feature selection logic. The code
> is a bit hard to follow, especially as I don't have a good document
> specifying which CPUs have which features, especially since the real
> machines I have access to for comparison are SGI R4600, R5000 and R12000
> machines.
>
Do you have the end of qemu.log when running your code with -d in_asm,op?
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] mipsIV support for mips-linux-user
2009-03-30 4:35 ` Aurelien Jarno
@ 2009-03-30 17:29 ` Vince Weaver
2009-04-08 22:17 ` Aurelien Jarno
0 siblings, 1 reply; 7+ messages in thread
From: Vince Weaver @ 2009-03-30 17:29 UTC (permalink / raw)
To: qemu-devel
On Mon, 30 Mar 2009, Aurelien Jarno wrote:
> Do you have the end of qemu.log when running your code with -d in_asm,op?
The first cop1x instruction happens relatively deep into the program, so
the debugging dump is pretty larege. How far back do you want?
It looks like no matter what cpu option I pick, the HFLAGS is set to
0x0022 (which is only the usermode and FPU flags).
Because of this the generated assembly in the debug output unconditionally
generates an illegal instruction exception the first time a cop1x
instruction is executed (in my case, "msub.d")
I've been digging through the qemu mips code, and I can't seem to find
where the hflags are set in the usermode case.
The only place that sets the MIPS_HFLAG_COP1X is in exec.h,
"compute_hflags()" but that doesn't ever seem to be called if
CONFIG_USER_ONLY
Vince
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] mipsIV support for mips-linux-user
2009-03-30 17:29 ` Vince Weaver
@ 2009-04-08 22:17 ` Aurelien Jarno
2009-04-09 1:00 ` Vince Weaver
0 siblings, 1 reply; 7+ messages in thread
From: Aurelien Jarno @ 2009-04-08 22:17 UTC (permalink / raw)
To: qemu-devel
On Mon, Mar 30, 2009 at 01:29:29PM -0400, Vince Weaver wrote:
> On Mon, 30 Mar 2009, Aurelien Jarno wrote:
>
>> Do you have the end of qemu.log when running your code with -d in_asm,op?
>
> The first cop1x instruction happens relatively deep into the program, so
> the debugging dump is pretty larege. How far back do you want?
>
> It looks like no matter what cpu option I pick, the HFLAGS is set to
> 0x0022 (which is only the usermode and FPU flags).
>
> Because of this the generated assembly in the debug output
> unconditionally generates an illegal instruction exception the first time
> a cop1x instruction is executed (in my case, "msub.d")
This instruction is clearly marked as MIPS64 only in the manual.
> I've been digging through the qemu mips code, and I can't seem to find
> where the hflags are set in the usermode case.
>
> The only place that sets the MIPS_HFLAG_COP1X is in exec.h,
> "compute_hflags()" but that doesn't ever seem to be called if
> CONFIG_USER_ONLY
I think this should be enabled in cpu_reset(), where env->hflags is
setup for user mode.
But I am actually concern about the results you get when enabling
MIPS_HFLAG_COP1X. If your program is expecting to have the FPU in 64-bit
mode you may have really strange results. Did you check them?
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] mipsIV support for mips-linux-user
2009-04-08 22:17 ` Aurelien Jarno
@ 2009-04-09 1:00 ` Vince Weaver
0 siblings, 0 replies; 7+ messages in thread
From: Vince Weaver @ 2009-04-09 1:00 UTC (permalink / raw)
To: qemu-devel
>> Because of this the generated assembly in the debug output
>> unconditionally generates an illegal instruction exception the first time
>> a cop1x instruction is executed (in my case, "msub.d")
>
> This instruction is clearly marked as MIPS64 only in the manual.
I'm running MIPSIV compiled o32 binaries. Even though the binaries
are 32-bits, they are running on a 64-bit enabled OS. (I have actual r12k
and r5k machines running Debian Linux. They have 64-bit kernels but
32-bit userspace).
mips-linux-user can run these executables fine if you hack it so that
cop1x instructions are enabled.
Perhaps the proper solution is to run the binaries under
mips64-linux-user, but there you run into the 64-bit qemu-linux-user
can't load 32-bit ELF files problem. I'm also not sure if
mips64-linux-user implements the o32 syscalls.
> I think this should be enabled in cpu_reset(), where env->hflags is
> setup for user mode.
That's currently what I am doing to enable these binaries to run.
> But I am actually concern about the results you get when enabling
> MIPS_HFLAG_COP1X. If your program is expecting to have the FPU in 64-bit
> mode you may have really strange results. Did you check them?
I'm running the Spec2k benchmarks and the results are as close as can be
expected to the actual hardware.
Vince
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-04-09 1:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-29 20:56 [Qemu-devel] mipsIV support for mips-linux-user Vince Weaver
2009-03-30 1:05 ` Aurelien Jarno
2009-03-30 2:14 ` Vince Weaver
2009-03-30 4:35 ` Aurelien Jarno
2009-03-30 17:29 ` Vince Weaver
2009-04-08 22:17 ` Aurelien Jarno
2009-04-09 1:00 ` Vince Weaver
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).