Skip to contentSkip to conversation

qemu/target-ppc cpu.h exec.h helper.c op.c op_h...

Qemu-devel Jocelyn Mayer 2 participants 6 messages Mar 17, 2007 – Mar 22, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /sources/qemu
Module name: qemu
Changes by: Jocelyn Mayer <j_mayer> 07/03/17 14:02:15

Modified files:
target-ppc : cpu.h exec.h helper.c op.c op_helper.c
op_helper.h op_helper_mem.h op_mem.h translate.c

Log message:
Make it safe to use 64 bits GPR and/or 64 bits host registers. For "symetry", add 64 bits versions of all modified functions. As a side effect, add a lot of code provision for PowerPC 64 support. Move overflow and carry checks in common routines for simple cases. Add isel and popcntb instructions from PowerPC 2.03 specification. Remove remaining micro-operations helpers prototypes from op.c. Fix XER_BC field to be 7 bits long.
Add power management support for PowerPC 603 & 604.
Fix compilation warnings.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/cpu.h?cvsroot=qemu&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/exec.h?cvsroot=qemu&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/helper.c?cvsroot=qemu&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/op.c?cvsroot=qemu&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/op_helper.c?cvsroot=qemu&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/op_helper.h?cvsroot=qemu&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/op_helper_mem.h?cvsroot=qemu&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/op_mem.h?cvsroot=qemu&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/translate.c?cvsroot=qemu&r1=1.44&r2=1.45

#1 lore raw

Hi Jocelyn,

Previously it was mentioned that there is a regression that was introduced by your original merge on March 8, 2007. I tested this latest code and it is still there. The nature of the problem is that the networking does not work when booting QEMU and using the built in slirp networking. A dhcp packet will work but the udp and tcp packets do not appear to send.

It appears that the packet check sum computed by the Linux network stack is incorrect. When the code in slirp/ip_input.c checks the checksum of the udp or tcp packet it throws the packet away because the checksum was invalid. I took the code from March 7, 2007 in cvs for target-ppc/* and used it with the latest of everything else and the packet checksums are computed correct and the target boots with networking.

This points to the problem being what ever instructions the kernel is using to compute the checksum are not being translated correctly by your latest changes. The next step will be to take a closer look at which instructions are used to compute the checksum. I thought I might send out some further analysis of the original stated problem in case you had an idea of where to look to fix the problem off the top of your head. If you have any ideas, please drop me some e-mail.

Also with regard to the 2.6.21 kernel and the ppc-prep machine, I patched the kernel to make it send PCI interrupts the same way the prior kernels did. It seems there is a regression there inside the kernel in the way that the IRQ acknowledgements are handled. It could be that the emulation is not right in QEMU, but I figure that mystery is one for another day. If you need a kernel that boots on the ppc-prep please let me know. I also patched the prep loader in the linux kernel so I could boot an image that was larger than 4 megs.

Thanks,
Jason.

Quoted 59 lines

-----Original Message-----
From:
[email protected] [mailto:[email protected] rg] On Behalf Of Jocelyn Mayer
Sent: Saturday, March 17, 2007 9:02 AM
To: [email protected]
Subject: [Qemu-devel] qemu/target-ppc cpu.h exec.h helper.c op.c op_h...

CVSROOT: /sources/qemu
Module name: qemu
Changes by: Jocelyn Mayer <j_mayer> 07/03/17 14:02:15

Modified files:
target-ppc : cpu.h exec.h helper.c op.c op_helper.c
op_helper.h op_helper_mem.h op_mem.h translate.c

Log message:
Make it safe to use 64 bits GPR and/or 64 bits host registers. For "symetry", add 64 bits versions of all modified functions. As a side effect, add a lot of code provision for
PowerPC 64 support.
Move overflow and carry checks in common routines for
simple cases.
Add isel and popcntb instructions from PowerPC 2.03
specification.
Remove remaining micro-operations helpers prototypes from op.c. Fix XER_BC field to be 7 bits long.
Add power management support for PowerPC 603 & 604. Fix compilation warnings.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/cpu.h?cvsr
oot=qemu&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/exec.h?cvs
root=qemu&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/helper.c?c
vsroot=qemu&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/op.c?cvsro
ot=qemu&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/op_helper.
c?cvsroot=qemu&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/op_helper.
h?cvsroot=qemu&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/op_helper_
mem.h?cvsroot=qemu&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/op_mem.h?c
vsroot=qemu&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/qemu/target-ppc/translate.
c?cvsroot=qemu&r1=1.44&r2=1.45

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

author
#2 lore raw

[Qemu-devel] Re: Qemu PPC ethernet checksum bug

Quoted 24 lines · Jason

Hi Jocelyn,

Previously it was mentioned that there is a regression that was introduced by your original merge on March 8, 2007. I tested this latest code and it is still there. The nature of the problem is that the networking does not work when booting QEMU and using the built in slirp networking. A dhcp packet will work but the udp and tcp packets do not appear to send.

It appears that the packet check sum computed by the Linux network stack is incorrect. When the code in slirp/ip_input.c checks the checksum of the udp or tcp packet it throws the packet away because the checksum was invalid. I took the code from March 7, 2007 in cvs for target-ppc/* and used it with the latest of everything else and the packet checksums are computed correct and the target boots with networking.

This points to the problem being what ever instructions the kernel is using to compute the checksum are not being translated correctly by your latest changes. The next step will be to take a closer look at which instructions are used to compute the checksum. I thought I might send out some further analysis of the original stated problem in case you had an idea of where to look to fix the problem off the top of your head. If you have any ideas, please drop me some e-mail.

Quoted 8 lines

Also with regard to the 2.6.21 kernel and the ppc-prep machine, I patched the kernel to make it send PCI interrupts the same way the prior kernels did. It seems there is a regression there inside the kernel in the way that the IRQ acknowledgements are handled. It could be that the emulation is not right in QEMU, but I figure that mystery is one for another day. If you need a kernel that boots on the ppc-prep please let me know. I also patched the prep loader in the linux kernel so I could boot an image that was larger than 4 megs.

Hi,

My concern is I cannot reproduce your problem for the following reasons:
- the PREP machine (and the heathrow too...) is broken and cannot even boot. PCI and/or IRQ are broken, so the Linux kernel hangs.
- when using the "known to work" Linux distributions on the mac99 machine (please take a look at the STATUS file), I am able to download a kernel from www.kernel.org, which makes me think TCP packets are sent and received correctly, with valid checksums.

Then, it would be a great thing if you could isolate the failing routine and, for example, make a test case usable with linux-user emulation. This would be a great help to solve this issue.

Thanks by advance.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#3 lore raw

Re: [Qemu-devel] Re: Qemu PPC ethernet checksum bug

Quoted 10 lines · J. Mayer

Hi,

My concern is I cannot reproduce your problem for the following reasons:
- the PREP machine (and the heathrow too...) is broken and cannot even boot. PCI and/or IRQ are broken, so the Linux kernel hangs.
- when using the "known to work" Linux distributions on the mac99 machine (please take a look at the STATUS file), I am able to download a kernel from www.kernel.org, which makes me think TCP packets are sent and received correctly, with valid checksums.

Quoted 7 lines

Then, it would be a great thing if you could isolate the failing routine and, for example, make a test case usable with linux-user emulation. This would be a great help to solve this issue.

Thanks by advance.

Attached is a test program which demonstrates the issue. You can run % ./ppc-linux-user/qemu-ppc /tmp/csum_test/main
Testing
Result 0x956a3263

Above is the correct result prior to 3/8/2007. If you run from CVS today, you get % ./ppc-linux-user/qemu-ppc /tmp/csum_test/main
Testing
Result 0x956a3264

It appears to be a result of the corruption of the xer_ca by the time you do the first adde instruction.

Thanks,
Jason.

#4 lore raw

Re: [Qemu-devel] Re: Qemu PPC ethernet checksum bug [PATCH]

In reply to J. Mayer

Attached is a patch as well as an example program, where I took the code from the from the linux kernel and made a call in with a dummy packet.

It appears the problem is the addic translation does not correctly set/reset the carry bit, and this is a regression vs the source base on 3/7/2007. With the change here, I can boot the ppc-prep machine again and use ethernet.

If you would like a pre-compiled binary of the test case, let me know because it was too big to send to the list.

Signed-off-by [email protected]

Jason.

Quoted 10 lines · J. Mayer

Hi,

My concern is I cannot reproduce your problem for the following reasons:
- the PREP machine (and the heathrow too...) is broken and cannot even boot. PCI and/or IRQ are broken, so the Linux kernel hangs.
- when using the "known to work" Linux distributions on the mac99 machine (please take a look at the STATUS file), I am able to download a kernel from www.kernel.org, which makes me think TCP packets are sent and received correctly, with valid checksums.

Quoted 7 lines

Then, it would be a great thing if you could isolate the failing routine and, for example, make a test case usable with linux-user emulation. This would be a great help to solve this issue.

Thanks by advance.

target-ppc/translate.c +6 -8
Index: qemu/target-ppc/translate.c
===================================================================
@@ -772,16 +772,14 @@ GEN_HANDLER(addic, 0x0C, 0xFF, 0xFF, 0x0
     target_long simm = SIMM(ctx->opcode);
 
     gen_op_load_gpr_T0(rA(ctx->opcode));
-    if (likely(simm != 0)) {
-        gen_op_move_T2_T0();
-        gen_op_addi(simm);
+    gen_op_move_T2_T0();
+    gen_op_addi(simm);
 #if defined(TARGET_PPC64)
-        if (ctx->sf_mode)
-            gen_op_check_addc_64();
-        else
+    if (ctx->sf_mode)
+        gen_op_check_addc_64();
+    else
 #endif
-            gen_op_check_addc();
-    }
+        gen_op_check_addc();
     gen_op_store_T0_gpr(rD(ctx->opcode));
 }
 /* addic. */
author
#5 lore raw

Re: [Qemu-devel] Re: Qemu PPC ethernet checksum bug [PATCH]

Quoted 7 lines · Jason Wessel

Attached is a patch as well as an example program, where I took the code from the from the linux kernel and made a call in with a dummy packet.

It appears the problem is the addic translation does not correctly set/reset the carry bit, and this is a regression vs the source base on 3/7/2007. With the change here, I can boot the ppc-prep machine again and use ethernet.

OK, thanks for this detailed report, I can now see what the bug is: the carry should be reset when immediate value is zero.
Your patch is not great because it disables useful optimization, but I will test another one and commit it soon.

Quoted 17 lines
Quoted 16 lines · J. Mayer

Hi,

My concern is I cannot reproduce your problem for the following reasons:
- the PREP machine (and the heathrow too...) is broken and cannot even boot. PCI and/or IRQ are broken, so the Linux kernel hangs.
- when using the "known to work" Linux distributions on the mac99 machine (please take a look at the STATUS file), I am able to download a kernel from www.kernel.org, which makes me think TCP packets are sent and received correctly, with valid checksums.

Then, it would be a great thing if you could isolate the failing routine and, for example, make a test case usable with linux-user emulation. This would be a great help to solve this issue.

Thanks by advance.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized