2005-11-24 10:43:30

by Denis Vlasenko

[permalink] [raw]
Subject: [PATCH] tiny improvement to x86_64 asm aes encryption

Basically, when de do:

encrypt_round(aes_ft_tab,-96)
encrypt_round(aes_ft_tab,-80)

first encrypt_round produces results in R5,R6,R3,R4,
and then moves R5->R1, R6->R2 for use in second one:

#define encrypt_round(TAB,OFFSET) \
round(TAB,OFFSET,R1,R2,R3,R4,R5,R6,R7,R10,R5,R6,R3,R4) \
move_regs(R1,R2,R5,R6)


But since we _always_ call them in pairs, we can just
swap arguments in second one, eliminating move_regs!


#define encrypt_round1(TAB,OFFSET) \
round(TAB,OFFSET,R1,R2,R3,R4,R5,R6,R7,R10,R5,R6,R3,R4)
^^^^^ ^^^^^
#define encrypt_round2(TAB,OFFSET) \
round(TAB,OFFSET,R5,R6,R3,R4,R1,R2,R7,R10,R1,R2,R3,R4)
^^^^^ ^^^^^
...
encrypt_round1(aes_ft_tab,-96)
encrypt_round2(aes_ft_tab,-80)

"encrypt_final" and "return" macros are changed accordingly.

Of course same thing is done on decrypt path.

Patch is not tested.
--
vda


Attachments:
(No filename) (983.00 B)
z.diff (3.39 kB)
Download all attachments

2005-11-24 12:56:43

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] tiny improvement to x86_64 asm aes encryption

Denis Vlasenko <[email protected]> writes:
>
> Patch is not tested.

Which means it won't get applied.

-Andi

2005-11-24 13:34:28

by Denis Vlasenko

[permalink] [raw]
Subject: Re: [PATCH] tiny improvement to x86_64 asm aes encryption

On Thursday 24 November 2005 19:23, Andi Kleen wrote:
> Denis Vlasenko <[email protected]> writes:
> >
> > Patch is not tested.
>
> Which means it won't get applied.

I have no 64bit machine here, sorry.
--
vda

2005-11-24 18:06:16

by Andreas Steinmetz

[permalink] [raw]
Subject: Re: [PATCH] tiny improvement to x86_64 asm aes encryption

Denis Vlasenko wrote:
[snip]
> #define encrypt_round1(TAB,OFFSET) \
> round(TAB,OFFSET,R1,R2,R3,R4,R5,R6,R7,R10,R5,R6,R3,R4)
> ^^^^^ ^^^^^
> #define encrypt_round2(TAB,OFFSET) \
> round(TAB,OFFSET,R5,R6,R3,R4,R1,R2,R7,R10,R1,R2,R3,R4)
> ^^^^^ ^^^^^

Won't work. You don't have "%sh", "%sl", "dh" (*) and "%dl" (*) as
registers.
(*) from %edi
--
Andreas Steinmetz SPAMmers use [email protected]