Re: libgcrypt clang asm configure issue.

2022-11-04 Thread Jussi Kivilinna

Hello,

On 28.10.2022 22.00, Dmytro Kovalov via Gnupg-users wrote:

Hello,

I found a strange libgcrypt behavior on ARM with clang built.

There is a big gap in performance of libgcrypt, built by clang, in comparison 
with gcc on my ARM target machine.
The simple profile test shows 100-500% advantage of gcc gcrypt.
I found an awkward workaround to beat this issue, but need your help to find 
the best way to fix it.

The root cause is next:
Due to clang strict assembler syntax rules the unified assembler ARM check 
doesn't pass.
Assembler check fails while ./configure for flags:
HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS
HAVE_GCC_INLINE_ASM_NEON

As a workaround I remove '%' from registers names in
configure.ac ,
arm mips lib *.S files,
cipher/*arm.S,*armv7-neon.S files.

Could you please help with a more correct - polite way to compile libgcrypt 
with assembler code?


This looks correct fix for improving compatibility with clang. It seems that 
GNU assembler works with those extra '%', but clang arm assembler does not. 
Only some of the arm assembly in libgcrypt have those extra '%' on register 
names but not all.

-Jussi



Tested on:
libgcrypt-1.8.6
libgcrypt-1.9.3

Equipment:

build machine:
intel based cpu x86_64
Ubnuntu-20.04

Software
compiler        : clang 11.1.0
linker lld      : lld 11.1.0
assembler       : llvm-as 11.1.0
cflags          : "-m32 -march=armv7-a -mthumb -mfpu=vfpv3-d16 
--target=arm-linux-gnueabihf"

arm-linux-gnueabihf sysroot based on glibc 2.31

libgcrypt configuring:
CC="arm-linux-gnueabihf-clang" \
./configure \
   --with-libgpg-error-prefix= \
   --prefix= \
   --host=arm-linux-gnueabihf \
   --enable-static \
   --disable-doc


target machine:
hardware:
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 2304.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 
lpae aes pmull sha1 sha2 crc32


Best Regards,
Dmytro Kovalov
dmytro.a.kova...@globallogic.com 

___
Gnupg-users mailing list
Gnupg-users@gnupg.org
https://lists.gnupg.org/mailman/listinfo/gnupg-users



___
Gnupg-users mailing list
Gnupg-users@gnupg.org
https://lists.gnupg.org/mailman/listinfo/gnupg-users


Re: Compilation of libgcrypt 1.7.5 on cygwin 64 bit fails

2017-05-13 Thread Jussi Kivilinna
Hello,

On 11.05.2017 12:26, Roger Qiu wrote:
> Hi Gcrypt devs,
> 
> I just tried compiling from source libgcrypt 1.7.5 (and I also tried earlier 
> versions).
> 
> It always comes to this:
> 
> ```
> 
> libtool: link: ranlib .libs/libgcrypt.alibtool: link: rm -fr 
> .libs/libgcrypt.laxlibtool: link: ( cd ".libs" && rm -f "libgcrypt.la" && ln 
> -s "../libgcrypt.la" "libgcrypt.la" )gcc -DHAVE_CONFIG_H -I. -I..
> -I/usr/local/include -g -O2 -Wall -MT mpicalc-mpicalc.o -MD -MP -MF 
> .deps/mpicalc-mpicalc.Tpo -c -o mpicalc-mpicalc.o `test -f 'mpicalc.c' || 
> echo './'`mpicalc.cmv -f .deps/mpicalc-mpicalc.Tpo 
> .deps/mpicalc-mpicalc.Po/bin/sh ../libtool  --tag=CC   --mode=link gcc 
> -I/usr/local/include -g -O2 -Wall   -o mpicalc.exe mpicalc-mpicalc.o 
> libgcrypt.la  -L/usr/local/lib -lgpg-errorlibtool: link: gcc 
> -I/usr/local/include -g -O2 -Wall -o .libs/mpicalc.exe mpicalc-mpicalc.o  
> ./.libs/libgcrypt.a -L/usr/local/lib /usr/local/lib/libgpg-error.a 
> -lintl./.libs/libgcrypt.a(rijndael.o): In function 
> `do_encrypt':/cygdrive/c/Users/CMCDragonkai/.src/libgcrypt-1.7.5/cipher/rijndael.c:747:(.text+0x9f):
>  relocation truncated to fit: R_X86_64_32S against 
> `.rdata'./.libs/libgcrypt.a(rijndael.o): In
> function 
> `do_decrypt':/cygdrive/c/Users/CMCDragonkai/.src/libgcrypt-1.7.5/cipher/rijndael.c:1130:(.text+0x110):
>  relocation truncated to fit: R_X86_64_32S against 
> `.rdata'./.libs/libgcrypt.a(cast5-amd64.o):/cygdrive/c/Users/CMCDragonkai/.src/libgcrypt-1.7.5/cipher/cast5-amd64.S:201:(.text+0x9):
>  relocation truncated to fit: R_X86_64_32S against symbol `_gcry_cast5_s1to4' 
> defined in .rdata section in 
> ./.libs/libgcrypt.a(cast5.o)./.libs/libgcrypt.a(cast5-amd64.o):/cygdrive/c/Users/CMCDragonkai/.src/libgcrypt-1.7.5/cipher/cast5-amd64.S:241:(.text+0x429):
>  relocation truncated to fit: R_X86_64_32S against symbol `_gcry_cast5_s1to4' 
> defined in .rdata section in 
> ./.libs/libgcrypt.a(cast5.o)./.libs/libgcrypt.a(cast5-amd64.o):/cygdrive/c/Users/CMCDragonkai/.src/libgcrypt-1.7.5/cipher/cast5-amd64.S:376:(.text+0x844):
>  relocation truncated to fit: R_X86_64_32S against symbol `_gcry_cast5_s1to4' 
> defined in .rdata section in
> ./.libs/libgcrypt.a(cast5.o)./.libs/libgcrypt.a(cast5-amd64.o):/cygdrive/c/Users/CMCDragonkai/.src/libgcrypt-1.7.5/cipher/cast5-amd64.S:404:(.text+0x177c):
>  relocation truncated to fit: R_X86_64_32S against symbol `_gcry_cast5_s1to4' 
> defined in .rdata section in ./.libs/libgcrypt.a(cast5.o)collect2: error: ld 
> returned 1 exit statusmake[2]: *** [Makefile:712: mpicalc.exe] Error 
> 1make[2]: Leaving directory 
> '/cygdrive/c/Users/CMCDragonkai/.src/libgcrypt-1.7.5/src'make[1]: *** 
> [Makefile:477: all-recursive] Error 1make[1]: Leaving directory 
> '/cygdrive/c/Users/CMCDragonkai/.src/libgcrypt-1.7.5'make: *** [Makefile:408: 
> all] Error 2
> 
> ```
> 
> Please cc me as I am not subscribed to the mailing list.
> 
> All other dependencies of gnupg works on cygwin 64 bit, this is the only one 
> that fails, and thus prevents building gpg2 on Cygwin 64 bit.

Does attached patch solve the problem? Patch is made on top of libgcrypt 
development branch, but I think it should apply to 1.7.5 too.

-Jussi

Fix building on 64-bit cygwin

From: Jussi Kivilinna <jussi.kivili...@iki.fi>

* cipher/cast5-amd64.S [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS]
(GET_EXTERN_POINTER): Load 64-bit address instead of 32-bit.
* cipher/rijndael.c (do_encrypt, do_decrypt)
[USE_AMD64_ASM && !HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS]: Load
table pointer through register instead of generic reference.
--

Signed-off-by: Jussi Kivilinna <jussi.kivili...@iki.fi>
---
 cipher/cast5-amd64.S |2 +-
 cipher/rijndael.c|4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cipher/cast5-amd64.S b/cipher/cast5-amd64.S
index a5f078e3..608fb64e 100644
--- a/cipher/cast5-amd64.S
+++ b/cipher/cast5-amd64.S
@@ -24,7 +24,7 @@
  defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS)) && defined(USE_CAST5)
 
 #if defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS) || !defined(__PIC__)
-#  define GET_EXTERN_POINTER(name, reg) leaq name, reg
+#  define GET_EXTERN_POINTER(name, reg) movabsq $name, reg
 #else
 #  define GET_EXTERN_POINTER(name, reg) movq name@GOTPCREL(%rip), reg
 #endif
diff --git a/cipher/rijndael.c b/cipher/rijndael.c
index 66ea0f3a..8637195a 100644
--- a/cipher/rijndael.c
+++ b/cipher/rijndael.c
@@ -752,7 +752,7 @@ do_encrypt (const RIJNDAEL_context *ctx,
   "+d" (ax),
   "+c" (rounds)
 : "0" (_gcry_aes_amd64_encrypt_block),
-  [encT] "g" (encT)
+  [encT] "r" (encT)
 : "cc", &qu

Re: Gpg Aes-ni

2013-01-14 Thread Jussi Kivilinna

Hello,

gpg 1.4.13 does not have AES-NI acceleration. You'd need to use gpg  
2.0.x with libgcrypt version that has AES-NI support (libgcrypt 1.5.0  
or newer).


If you have more questions with regards to GnuPG, please use GnuPG  
mailing list (gnupg-users@gnupg.org) instead.


-Jussi

Quoting Ertunga Arsal ertunga.ar...@esnc.de:


Hi Jussi,

Does the latest cli, gpg 1.4.13 support AES-NI?

Does a command like gpg -r a...@esnc.de  --cipher-algo AES256  
--compress-algo none  --encrypt xyz.bin use the accelerated routines?


I'm currently receiving 30MB throughput, it should be actually close  
to 500MB. Is there a way to make it work?


Kind regards,
Ertunga

___
Ertunga Arsal, CISSP, ISSAP
ESNC GmbH
Bliesstr. 16 66538 Neunkirchen
Tel :   +49-6821-920-6852
Fax :  +49-6821-912-7354
ertunga.ar...@esnc.de
http://www.esnc.de
HRB 18216 Saarbrücken






___
Gnupg-users mailing list
Gnupg-users@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-users