Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 30 Oct 2013 17:56:03 +0100
From: magnum <john.magnum@...hmail.com>
To: john-dev@...ts.openwall.com
Subject: Re: Linux-X32 support for DES_BS_ASM

On 2013-10-30 09:24, Solar Designer wrote:
> On Tue, Oct 29, 2013 at 11:39:13PM +0100, magnum wrote:
>> After warming up with Win64 I thought I'd have another go at enabling
>> DES_BS_ASM for Linux-X32. Contrary to Win64, X32 is exactly like AMD64
>> except pointers and longs are 32-bit. The NT assembler works fine as-is,
>> my problem is DES.
>
> Great.
>
>> I was hoping to get away with concentrating on these:
>>
>> /* Sun's assembler can't multiply, but at least it can add... */
>> #define nptr(n)				n+n+n+n+n+n+n+n
>> #define nvec(n)			 n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n
>>
>> I'm thinking if these are solely used for pointers and vectors
>> respectively, only the first should be changed and this could work:
>>
>> #ifdef __ILP32__
>> #define nptr(n)				n+n+n+n
>> #else
>> #define nptr(n)				n+n+n+n+n+n+n+n
>> #endif
>> #define nvec(n)			 n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n
>
> This looks right to me.
>
>> ...but I have tried that before (and other variants) to no avail. Are
>> you able to give a quick hint?
>
> Unfortunately, no.

The debugger could. Only one detail was missing - all instances of movq 
involving tmp1 or tmp2 needed a change. Example:

	movq k(0),tmp1
	...
	movdqa (tmp1),%xmm0

Under X32, tmp1 would get 8 bytes of which 4 was correct and when 
dereferenced, it ended up totally wrong (wrong half used, or whatever).

Solution was change all "movq" to "mov" and define two new macros tmp1p 
and tmp2p, which are used for these movs.

   #define tmp1            %r9
+#ifdef __ILP32__
+#define tmp1p           %r9d
+#else
+#define tmp1p           tmp1
+#endif

-	movq k(0),tmp1
+	mov k(0),tmp1p

About 20 such changes. Full version is in efb18645. All DES formats pass 
self-tests and Test Suite (tripcode is not in TS though). Speeds are on 
par with x86-64.

magnum

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.