From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7194 invoked by alias); 12 Aug 2014 13:29:43 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 7178 invoked by uid 89); 12 Aug 2014 13:29:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_PASS,URIBL_BLACK autolearn=no version=3.3.2 X-HELO: mail.lysator.liu.se Received: from mail.lysator.liu.se (HELO mail.lysator.liu.se) (130.236.254.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 12 Aug 2014 13:29:38 +0000 Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 1291E40021 for ; Tue, 12 Aug 2014 15:29:34 +0200 (CEST) Received: from [192.168.0.68] (217-210-101-82-no95.business.telia.com [217.210.101.82]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id CC5D14001F for ; Tue, 12 Aug 2014 15:29:33 +0200 (CEST) Message-ID: <53EA16B9.5020402@lysator.liu.se> Date: Tue, 12 Aug 2014 13:29:00 -0000 From: Peter Rosin User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: cygwin@cygwin.com Subject: Re: [ANNOUNCEMENT] New package: rng-tools-5-1 References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------090007000904030509090202" X-SW-Source: 2014-08/txt/msg00229.txt.bz2 --------------090007000904030509090202 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 1340 On 2014-08-09 16:37, Corinna Vinschen wrote: > I just uploaded rng-tools-5-1. > > The Cygwin release only comes with the rngtest tool for now. > > The rngd daemon requires porting assembler code to COFF and the > Microsoft calling convention. Any help porting this code would > be greatly appreciated. Ok, I took a stab at it. The problems I identified in the assembly are ELF debug info, different register use for the x86-64 calls and a missing underscore prefix for the i686 symbols. I'm unsure if used registers (and which) have to be saved in the MS x86-64 ABI, but that shouldn't be too hard to fix if that's the case. I also moved up the AC_SEARCH_LIBS hunk in configure.ac since the existing AC_CHECK_LIB is buried inside some other construct (AC_CHECK_HEADER is possibly the culprit) which causes this: checking for library containing argp_parse... /usr/src/rng-tools-5-1.src/rng-tools-5-1.i686/src/rng-tools-5/configure: line 4335: ac_fn_c_try_link: command not found /usr/src/rng-tools-5-1.src/rng-tools-5-1.i686/src/rng-tools-5/configure: line 4335: ac_fn_c_try_link: command not found no Anyway, with the attached patch instead of the one included in the src package, it builds for both arches, but my cpu appears to lack the rdrand instruction, so I have a hard time taking this any further. Bummer. Cheers, Peter --------------090007000904030509090202 Content-Type: text/x-patch; name="cygwin-rng-tools-5-peda.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cygwin-rng-tools-5-peda.patch" Content-length: 3464 diff -rup origsrc/rng-tools-5/configure.ac src/rng-tools-5/configure.ac --- origsrc/rng-tools-5/configure.ac 2014-08-12 10:33:32.064585400 +0200 +++ src/rng-tools-5/configure.ac 2014-08-12 11:18:44.431782000 +0200 @@ -56,6 +56,8 @@ dnl ------------------------------------ dnl Checks for optional library functions dnl ------------------------------------- +AC_SEARCH_LIBS([argp_parse],[argp]) + dnl ------------------------------------- dnl Check for libgcrypt support dnl ------------------------------------- diff -rup origsrc/rng-tools-5/rdrand_asm.S src/rng-tools-5/rdrand_asm.S --- origsrc/rng-tools-5/rdrand_asm.S 2014-08-12 10:33:32.066585400 +0200 +++ src/rng-tools-5/rdrand_asm.S 2014-08-12 11:26:27.429381800 +0200 @@ -20,20 +20,41 @@ #if defined(__i386__) || defined(__x86_64__) -#define ENTRY(x) \ - .balign 64 ; \ - .globl x ; \ -x: +#if defined __CYGWIN__ +# if defined __x86_64__ +# define MS_x86_64_ABI +# else +# define SYMBOL(name) _ ## name +# endif +#else +# define ELF_DEBUG_INFO +#endif +#if !defined SYMBOL +# define SYMBOL(name) name +#endif + +#define ENTRY(x) \ + .balign 64 ; \ + .globl SYMBOL(x) ; \ +SYMBOL(x): +#if defined ELF_DEBUG_INFO #define ENDPROC(x) \ .size x, .-x ; \ .type x, @function +#else +#define ENDPROC(x) +#endif #define RDRAND_RETRY_LIMIT 10 #ifdef __x86_64__ ENTRY(x86_rdrand_bytes) +#if defined MS_x86_64_ABI + mov %rcx, %rdi + mov %rdx, %rsi +#endif mov %esi, %eax 1: mov $RDRAND_RETRY_LIMIT, %ecx @@ -55,6 +76,12 @@ ENDPROC(x86_rdrand_bytes) ENTRY(x86_rdseed_or_rdrand_bytes) +#if defined MS_x86_64_ABI + mov %rcx, %rdi + mov %rdx, %rsi + mov %r8, %rdx + mov %r9, %rcx +#endif mov (%rsi), %r8d /* RDSEED count */ mov (%rcx), %r9d /* RDRAND count */ 1: @@ -191,6 +218,10 @@ movl 12(%ebp), %edx push %esi #endif +#if defined MS_x86_64_ABI + mov %rcx, %rdi + mov %rdx, %rsi +#endif movl $512, CTR3 /* Number of rounds */ movdqa (0*16)(PTR1), %xmm0 @@ -295,6 +326,9 @@ mov %esp, %ebp movl 8(%ebp), %eax #endif +#if defined MS_x86_64_ABI + mov %rcx, %rdi +#endif SETPTR(aes_round_keys, PTR1) movdqu (PTR0), %xmm0 @@ -347,12 +381,16 @@ .balign 64 aes_round_keys: .space 11*16 +#if defined ELF_DEBUG_INFO .size aes_round_keys, .-aes_round_keys +#endif /* ELF_DEBUG_INFO */ #endif /* i386 or x86_64 */ +#if defined ELF_DEBUG_INFO /* * This is necessary to keep the whole executable * from needing a writable stack. */ .section .note.GNU-stack,"",%progbits +#endif /* ELF_DEBUG_INFO */ diff -rup origsrc/rng-tools-5/rngd_linux.c src/rng-tools-5/rngd_linux.c --- origsrc/rng-tools-5/rngd_linux.c 2012-08-06 19:04:12.000000000 +0200 +++ src/rng-tools-5/rngd_linux.c 2014-08-09 15:09:21.081616358 +0200 @@ -39,8 +39,10 @@ #include #include #include +#ifndef __CYGWIN__ #include #include +#endif #include #include "rngd.h" @@ -130,11 +132,19 @@ void random_add_entropy(void *buf, size_ entropy.size = size; memcpy(entropy.data, buf, size); +#ifdef __CYGWIN__ + if (write(random_fd, entropy.data, size) != size) { + message(LOG_DAEMON|LOG_ERR, "Add Entropy failed: %s\n", + strerror(errno)); + exit(1); + } +#else if (ioctl(random_fd, RNDADDENTROPY, &entropy) != 0) { message(LOG_DAEMON|LOG_ERR, "RNDADDENTROPY failed: %s\n", strerror(errno)); exit(1); } +#endif } void random_sleep(void) --------------090007000904030509090202 Content-Type: text/plain; charset=us-ascii Content-length: 218 -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --------------090007000904030509090202--