10 Aug 2011 21:50
binutil hacks for loongson2
Manuel Bouyer <bouyer <at> antioche.eu.org>
2011-08-10 19:50:54 GMT
2011-08-10 19:50:54 GMT
Hello, the loongson2f CPU has hardware bugs that must be worked around in software. Fortunably the workaround is only required for kernel mode, to userland can be shared with other MIPS platforms. binutils have 2 options for this: -fix-loongson2f-nop and -mfix-loongson2f-jump. The first one cause nop instructions to be replaced with a 'or at,at,zero'. No problem with this (although my CPU doens't seem to need it). But from what I've read, this could be required for both kernel and userland :( The second one is to work around an issue in kernel mode with jump register instructions and branch prediction logic, as explained here: https://groups.google.com/group/loongson-dev/msg/e0d2e220958f10a6?dmode=source&hl=zh Basically, if the branch prediction logic got the wrong choise, the CPU would end up fetching an instruction with a wrong register value and this can hang the system if the wrong value happens to be in I/O space. What -fix-loongson2f-jump does it to insert instructions before the j reg or jr reg: lui at, 0xcfff0000; ori at, at, 0xffff and reg, reg, at j(r) reg (instead of jump reg we do jump (reg & 0xcfffffff)). I've issues with this approach. For example, you can't do a jump 0xbfc00000 anymore without special care. Basically, this assumes that all kernel code is within the low part of kseg0, but with a 64bit kernel and/or modules we may want to calls outside of this region (for example, calls to(Continue reading)
RSS Feed