NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-arm/55854: bogus thumb code in bswap32

>Number:         55854
>Category:       port-arm
>Synopsis:       bogus thumb code in bswap32
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    port-arm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 09 03:00:00 +0000 2020
>Originator:     David A. Holland
>Release:        NetBSD 9.99.75 (20201208)
System: n/a
Architecture: arm
Machine: arm

I found this in byte_swap_4.S:

#ifdef _ARM_ARCH_6
#elif !defined(__thumb__)
        movs    r3, #16
        lsls    r1, r0, #8              /* d.c.b.a -> c.b.a.0 /*
        lsrs    r0, r0, #8              /* d.c.b.a -> 0.d.c.b */
        rors    r1, r3                  /* c.b.a.0 -> a.0.c.b */
        rors    r0, r3                  /* 0.d.c.b -> c.b.0.d */
        lsrs    r1, r1, #8              /* a.0.c.b -> 0.a.0.c */
        lsls    r1, r1, #8              /* 0.a.0.c -> a.0.c.0 */
        lsls    r0, r0, #8              /* c.b.0.d -> b.0.d.0 */
        lsrs    r0, r0, #8              /* b.0.d.0 -> 0.b.0.d */
        orrs    r0, r0, r1              /* a.0.c.0 | 0.b.0.d -> a.b.c.d */

Note the comment delimiter at the end of the second line; that
silently comments out the third line, which according to the byte flow
comments (which I just went over to change [1-4] to [a-d], so I'm
pretty sure they're right) makes the code wrong.

It's been this way since the thumb version was first committed in
2013. Likely as not it's just a typo, but...

Is the thumb code actually used/tested at all? Enquiring minds would
like to know.


Code inspection.

apply bswap16 to the comment delimiter :-)

Home | Main Index | Thread Index | Old Index