[loongson-dev] [PATCH] Support Loongson FPU instructions to math-emu (was Illegal instruction with guile)
Hello all, Apologies if this has already been addressed, as I am new to this mailing list and have not had time to search the archives carefully. I have found and fixed the underlying cause of the illegal instruction (SIGILL) signals sent to processes that execute some Loongson-specific floating-point operations (e.g. an madd/msub/nmadd/nmsub instruction with a quiet NaN or denormalized floating-point input value). MIPS and Loongson processors only implement the common cases of floating-point arithmetic operations in hardware. In unusual cases, the FPU signals an "Unimplemented instruction exception" and relies upon the OS kernel to emulate the instruction in software. Linux includes a MIPS floating-point emulator to handle these cases, but its emulator does not include support for the Loongson variants of madd/msub/nmadd/nmsub. It also does not include support for the Loongson operations on "paired-single" floating-point format (vectors of two single-precision values). The following patches add support for these instructions to arch/mips/math-emu. I fixed some other deficiencies in that code as well, and those fixes are included in separate patches before the Loongson2f patch. Note that during testing, I found a mistake in the documentation for the Loongson 2F. Page 95 of Loongson2FUserGuide.pdf claims that the paired-single floating-point instructions should use a format (fmt) field of 11. However, the processor itself does not seem to recognize instructions with (fmt=11). It seems to be looking for (fmt=22). That's the case for the Loongson2F in my Yeeloong anyway (which /proc/cpuinfo identifies as "ICT Loongson-2 V0.3 FPU V0.1"). I also found that the GNU assembler generates instructions with (fmt=22) for most (but not all) of the paired-single floating-point instructions. The only exceptions I've found are the Loongson-specific madd.ps, msub.ps, nmadd.ps, and nmsub.ps instructions, for which GNU as generates (fmt=11), although that does not work on my Loongson2F. Therefore, I have also included a patch to GNU binutils (which will also apply to GDB) to use fmt=22 for those instructions on Loongson2F. I should note that the documentation for Loongson 2E (not 2F) also claims that the format field for paired-single instructions should use fmt=11. I don't know whether this is a mistake or not, since I do not have access to a Loongson 2E processor with which to test. Finally, two apologies are in order: * Ideally I should have added support for the entire set of MIPS 5 floating-point operations, but I did not have time to do that job, nor do I have a MIPS 5 processor with which to test. Therefore, these patches address only the Loongson 2F. * I must admit that I have not tested these patches against the linux-loongson-community kernel. However, I have tested them against the linux--2.6.39.1-libre-lemote kernel maintained by Alexandre Oliva, and there is no significant difference in arch/mips/math-emu between those two trees. Comments and suggestions solicited. Mark -- You received this message because you are subscribed to the Google Groups "loongson-dev" group. To post to this group, send email to loongson-dev@googlegroups.com. To unsubscribe from this group, send email to loongson-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/loongson-dev?hl=en. >From c0b01f6877177b8bb9859aaed2f9588600b48b3f Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Fri, 28 Oct 2011 13:18:43 -0400 Subject: [PATCH 1/4] Fix typos in comments of arch/mips/include/asm/inst.h --- arch/mips/include/asm/inst.h |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/asm/inst.h b/arch/mips/include/asm/inst.h index 7ebfc39..ab84064 100644 --- a/arch/mips/include/asm/inst.h +++ b/arch/mips/include/asm/inst.h @@ -251,7 +251,7 @@ struct f_format { /* FPU register format */ unsigned int func : 6; }; -struct ma_format { /* FPU multipy and add format (MIPS IV) */ +struct ma_format { /* FPU multiply and add format (MIPS IV) */ unsigned int opcode : 6; unsigned int fr : 5; unsigned int ft : 5; @@ -324,7 +324,7 @@ struct f_format { /* FPU register format */ unsigned int opcode : 6; }; -struct ma_format { /* FPU multipy and add format (MIPS IV) */ +struct ma_format { /* FPU multiply and add format (MIPS IV) */ unsigned int fmt : 2; unsigned int func : 4; unsigned int fd : 5; -- 1.7.5.4 >From bf55ef4e3c2f622ac013f196affbd11b67b59223 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Fri, 28 Oct 2011 13:24:37 -0400 Subject: [PATCH 2/4] Fix handling of prefx instruction in mips/math-emu * The instruction is named prefx, not pfetch, and its function field is 0x17, not 0x07. * Recognize the prefx instruction regardless of what bits happen to be in bits 21-25, which is the format field of the floating-point ops, bu
Re: [loongson-dev] [PATCH] Support Loongson FPU instructions to math-emu (was Illegal instruction with guile)
Wu Zhangjin writes: > Thanks very much for your work, will apply your patches. > > BTW, is there an easy way to test your patches? do you have such a > test program? I have attached a partial test program. It could easily be made more comprehensive. You'll need to install a fixed GNU assembler (using my patch) to compile this properly. Best, Mark -- You received this message because you are subscribed to the Google Groups "loongson-dev" group. To post to this group, send email to loongson-dev@googlegroups.com. To unsubscribe from this group, send email to loongson-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/loongson-dev?hl=en. loongson-fp-test.tar.gz Description: Partial test program for Loongson2F FPU instructions
Re: [loongson-dev] [PATCH] Support Loongson FPU instructions to math-emu (was Illegal instruction with guile)
Wu Zhangjin writes: > Thanks very much for your work, will apply your patches. > > BTW, is there an easy way to test your patches? do you have such a > test program? I have attached here a significantly improved version of the test program. Please disregard the earlier version. Best, Mark -- You received this message because you are subscribed to the Google Groups "loongson-dev" group. To post to this group, send email to loongson-dev@googlegroups.com. To unsubscribe from this group, send email to loongson-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/loongson-dev?hl=en. loongson-fp-test-v2.tar.gz Description: Loongson FPU test program v2
Re: [loongson-dev] [PATCH] Support Loongson FPU instructions to math-emu (was Illegal instruction with guile)
Wu Zhangjin writes: > Seems some of your patches are common to MIPS, could you please send > them to linux-mips mailing list[1] and CC to its maintainer: Ralf[2], > the MIPS experts may give you more professional feedbacks. Yes, I hope to submit it to linux-mips in the next couple of weeks. First I'd like to try to make the patch less Loongson2F-specific. I may even try to add more of the MIPS 5/3D/64 instructions. > Since Ralf maintains the patches through patchwork which requires the > patches as mail body, please don't send him as attachment, git > send-email may help. > > And could you please add a Signed-off-by line in the patches: > > Signed-off-by: Mark H Weaver > > And for the last binutils patch, you may need to send it to Nick > Clifton , Richard Sandiford > and the mailing list: > binut...@sourceware.org Will do. Thanks for the feedback! Best, Mark -- You received this message because you are subscribed to the Google Groups "loongson-dev" group. To post to this group, send email to loongson-dev@googlegroups.com. To unsubscribe from this group, send email to loongson-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/loongson-dev?hl=en.
Re: [loongson-dev] [PATCH] Support Loongson FPU instructions to math-emu (was Illegal instruction with guile)
Hi Matt, Matt Turner writes: > Are you going to attempt to get these patches upstream any time soon? > > If not, I'll do it. Sounds great, thanks! If you don't mind, please copy me on correspondence regarding these patches. A few notes regarding the Linux patches: * In several places I wrote "Loongson paired-single format", but I've since learned that the format is not Loongson-specific. Therefore the name "Loongson" should probably be removed from those places. * In the preliminary patches to GCC to add support for the Loongson-specific madd/msub/nmadd/nmsub opcodes, these instructions are referred to without the Loongson name, but rather by appending "3" to their names, referring to the fact that they take 3 operands as opposed to the usual 4 operands supported by the standard MIPS madd/msub/nmadd/nmsub opcodes. The same patches rename the GCC identifiers that refer to the standards 4-operand opcodes by appending "4" to their names. Therefore, whereas I named these opcodes 'loongson_madd_op' et al, it's probably better to follow the naming convention of the preliminary GCC patches. After all, it's quite possible that other MIPS processors will adopt these Loongson opcodes. Note that the reason they reduced the number of operands was to make space for the 'fmt' field, which allows these instructions to work on paired-singles and maybe some other formats too (I have forgotten those details). * In the current patches, the new code is within "#ifdef __loongson_fp", but that will no longer be appropriate after making the changes recommended above. * Feel free to remove the copyright notice that I added near the top of cp1emu.c. > Assuming you don't have copyright assignment for binutils and gdb, can > you please declare the final patch to be public domain? I suspect the final patch is small enough that copyright assignment will not be needed, but if the maintainers complain, I can file the paperwork easily enough. I live very close to the main FSF offices. Thanks, Mark -- You received this message because you are subscribed to the Google Groups "loongson-dev" group. To post to this group, send email to loongson-dev@googlegroups.com. To unsubscribe from this group, send email to loongson-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/loongson-dev?hl=en.
Re: [loongson-dev] [PATCH] Support Loongson FPU instructions to math-emu (was Illegal instruction with guile)
I wrote: > * In the preliminary patches to GCC to add support for the > Loongson-specific madd/msub/nmadd/nmsub opcodes, [...] I forgot to post a link to the GCC patches, which were first submitted around four years ago, although the work was never finished. The relevant threads start here: http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01389.html Mark -- You received this message because you are subscribed to the Google Groups "loongson-dev" group. To post to this group, send email to loongson-dev@googlegroups.com. To unsubscribe from this group, send email to loongson-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/loongson-dev?hl=en.
Re: [loongson-dev] [Kernel BUG] After Connect to Any WiFi - Kernel Panic - not syncing: Fatal exception in interrupt.
Tom Li writes: > According to a few users' report, since Linux 3.11, there is a major > bug in the rtl8187 kernel driver. After connect to any wireless access > point, we will got a kernel panic message. I see the exact same problem with linux-libre 3.10.15. Mark -- You received this message because you are subscribed to the Google Groups "loongson-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to loongson-dev+unsubscr...@googlegroups.com. To post to this group, send email to loongson-dev@googlegroups.com. Visit this group at http://groups.google.com/group/loongson-dev. For more options, visit https://groups.google.com/groups/opt_out.
Re: [loongson-dev] [Kernel BUG] After Connect to Any WiFi - Kernel Panic - not syncing: Fatal exception in interrupt.
Tom Li writes: > According to a few users' report, since Linux 3.11, there is a major > bug in the rtl8187 kernel driver. After connect to any wireless access > point, we will got a kernel panic message. FYI, for those who haven't been following the bug tracker, we now have a patch to fix this problem. Hopefully it will be upstream soon. Thanks to Tom Li for doing the git bisect and making this happen! :) http://www.linux-mips.org/archives/linux-mips/2014-02/msg00071.html Mark -- You received this message because you are subscribed to the Google Groups "loongson-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to loongson-dev+unsubscr...@googlegroups.com. To post to this group, send email to loongson-dev@googlegroups.com. Visit this group at http://groups.google.com/group/loongson-dev. For more options, visit https://groups.google.com/groups/opt_out.