Hi Dmity,

On Mon, Feb 24, 2020 at 08:58:44PM +0300, Dmitry Baryshkov wrote:

> > > I will check with fresh Yocto build later or tomorrow.
> > Thanks!
> I have checked both armv7vet2b and armv5eb targets with qemu. Your
> patch fixes the issue for me.

Perfect!

@Niels: What do you think of these changes?

These comment changes are bugging me:

diff --git a/arm/memxor.asm b/arm/memxor.asm
index 239a4034..b802e95c 100644
--- a/arm/memxor.asm
+++ b/arm/memxor.asm
@@ -138,24 +138,24 @@ PROLOGUE(nettle_memxor)
        adds    N, #8
        beq     .Lmemxor_odd_done
 
-       C We have TNC/8 left-over bytes in r4, high end
+       C We have TNC/8 left-over bytes in r4, (since working upwards) low
+       C end on LE and high end on BE
        S0ADJ   r4, CNT
        ldr     r3, [DST]
        eor     r3, r4
 
diff --git a/arm/memxor3.asm b/arm/memxor3.asm
index 69598e1c..76b8aae6 100644
--- a/arm/memxor3.asm
+++ b/arm/memxor3.asm
@@ -159,21 +159,21 @@ PROLOGUE(nettle_memxor3)
        adds    N, #8
        beq     .Lmemxor3_done
 
-       C Leftover bytes in r4, low end
+       C Leftover bytes in r4, (since working downwards) in high end on LE and
+       C low end on BE
        ldr     r5, [AP, #-4]
        eor     r4, r5, r4, S1ADJ ATNC
 
Have I totally misunderstood how strb works or how the comment is meant
if to my thinking the bytes are sitting in the low or high end bits of
the register and ror #24 and lsr #8 bring the next byte down into the
lowermost 8 bits for saving by strb?

Full patch for reference again below and at
https://git.lysator.liu.se/michaelweiser/nettle/-/tree/arm-memxor-generic.

If it's acceptable shall I rather git send-email it or do a MR on
gitlab?

> > Could Yocto be used for CI then? Do they do any kind of binary releases
> > for armeb? How long and voluminous is a build of an armeb system with
> > and without a native toolchain?
> No, I found no package feeds/binary releases for armeb. So to use
> Yocto for CI, we'd have to build an image with Yocto SDK inside. I can
> try implementing it.

I'm currently doing the same with buildroot. The advantage there is that
it builds relatively quickly (around an hour on my quad-core
workstation) and with minimal configuration:

FROM debian:buster AS build

MAINTAINER Nikos Mavrogiannopoulos <[email protected]>

RUN apt-get update -qq -y
RUN apt-get install -y dash [...] g++ cpio unzip bc
# tlsfuzzer deps
RUN apt-get install -y python-six

RUN useradd -m buildroot
USER buildroot

WORKDIR /home/buildroot
RUN git clone https://github.com/buildroot/buildroot
WORKDIR /home/buildroot/buildroot
RUN ( \
        echo 'BR2_armeb=y' ; \
        echo 'BR2_TOOLCHAIN_BUILDROOT_GLIBC=y' ; \
        echo 'BR2_TOOLCHAIN_BUILDROOT_CXX=y' ; \
        echo 'BR2_PACKAGE_GMP=y' ; \
        ) > .config
RUN make olddefconfig
RUN make -j16

The downside is that it will not output a native toolchain for armeb. So
nettle needs to be cross-compiled using the buildroot toolchain and then
run either using the EMULATOR mechanism of the testsuite or by chrooting
into the buildroot rootfs.

So if Yocto can be made to build a native toolchain that would certainly
simplify things (at the cost of image build time).

Do you know Nikos' build-images project for gnutls/nettle
(https://gitlab.com/gnutls/build-images)? There's some qemu bits
(specific to Debian's multiarch though) in docker-debian-cross that
might be helpful.
-- 
Thanks,
Michael

From 3e2118d41472842c368bb5bb56d71023b861b59d Mon Sep 17 00:00:00 2001
From: Michael Weiser <[email protected]>
Date: Sun, 23 Feb 2020 15:22:51 +0100
Subject: [PATCH] arm: Fix memxor for non-armv6+ big-endian systems

ARM assembly adjustments for big-endian systems contained armv6+-only
instructions (rev) in generic arm memxor code. Replace those with an
actual conversion of the leftover byte store routines for big-endian
systems. This also provides a slight optimisation by removing the
additional instruction as well as increased symmetry between little- and
big-endian implementations.

Signed-off-by: Michael Weiser <[email protected]>
---
 arm/memxor.asm  | 12 ++++++------
 arm/memxor3.asm | 27 ++++++++++++++-------------
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/arm/memxor.asm b/arm/memxor.asm
index 239a4034..b802e95c 100644
--- a/arm/memxor.asm
+++ b/arm/memxor.asm
@@ -138,24 +138,24 @@ PROLOGUE(nettle_memxor)
        adds    N, #8
        beq     .Lmemxor_odd_done
 
-       C We have TNC/8 left-over bytes in r4, high end
+       C We have TNC/8 left-over bytes in r4, (since working upwards) low
+       C end on LE and high end on BE
        S0ADJ   r4, CNT
        ldr     r3, [DST]
        eor     r3, r4
 
-       C memxor_leftover does an LSB store
-       C so we need to reverse if actually BE
-IF_BE(<        rev     r3, r3>)
-
        pop     {r4,r5,r6}
 
        C Store bytes, one by one.
 .Lmemxor_leftover:
+       C bring uppermost byte down for saving while preserving lower ones
+IF_BE(<        ror     r3, #24>)
        strb    r3, [DST], #+1
        subs    N, #1
        beq     .Lmemxor_done
        subs    TNC, #8
-       lsr     r3, #8
+       C bring down next byte, no need to preserve
+IF_LE(<        lsr     r3, #8>)
        bne     .Lmemxor_leftover
        b       .Lmemxor_bytes
 .Lmemxor_odd_done:
diff --git a/arm/memxor3.asm b/arm/memxor3.asm
index 69598e1c..76b8aae6 100644
--- a/arm/memxor3.asm
+++ b/arm/memxor3.asm
@@ -159,21 +159,21 @@ PROLOGUE(nettle_memxor3)
        adds    N, #8
        beq     .Lmemxor3_done
 
-       C Leftover bytes in r4, low end
+       C Leftover bytes in r4, (since working downwards) in high end on LE and
+       C low end on BE
        ldr     r5, [AP, #-4]
        eor     r4, r5, r4, S1ADJ ATNC
 
-       C leftover does an LSB store
-       C so we need to reverse if actually BE
-IF_BE(<        rev     r4, r4>)
-
 .Lmemxor3_au_leftover:
        C Store a byte at a time
-       ror     r4, #24
+       C bring uppermost byte down for saving while preserving lower ones
+IF_LE(<        ror     r4, #24>)
        strb    r4, [DST, #-1]!
        subs    N, #1
        beq     .Lmemxor3_done
        subs    ACNT, #8
+       C bring down next byte, no need to preserve
+IF_BE(<        lsr     r4, #8>)
        sub     AP, #1
        bne     .Lmemxor3_au_leftover
        b       .Lmemxor3_bytes
@@ -273,18 +273,19 @@ IF_BE(<   rev     r4, r4>)
        adds    N, #8
        beq     .Lmemxor3_done
 
-       C leftover does an LSB store
-       C so we need to reverse if actually BE
-IF_BE(<        rev     r4, r4>)
-
-       C Leftover bytes in a4, low end
-       ror     r4, ACNT
+       C Leftover bytes in r4, (since working downwards) in high end on LE and
+       C low end on BE after preparatory alignment correction
+IF_LE(<        ror     r4, ACNT>)
+IF_BE(<        ror     r4, ATNC>)
 .Lmemxor3_uu_leftover:
-       ror     r4, #24
+       C bring uppermost byte down for saving while preserving lower ones
+IF_LE(<        ror     r4, #24>)
        strb    r4, [DST, #-1]!
        subs    N, #1
        beq     .Lmemxor3_done
        subs    ACNT, #8
+       C bring down next byte, no need to preserve
+IF_BE(<        lsr     r4, #8>)
        bne     .Lmemxor3_uu_leftover
        b       .Lmemxor3_bytes
 
-- 
2.25.0

_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to