Fix AES-NI CTR optimization compiling failure with gas 2.16.1
Subsystems (2)
Andrew Morton reported that AES-NI CTR optimization failed to compile with gas 2.16.1, the error message is as follow:
arch/x86/crypto/aesni-intel_asm.S: Assembler messages:arch/x86/crypto/aesni-intel_asm.S:752: Error: suffix or operands invalid for movq' arch/x86/crypto/aesni-intel_asm.S:753: Error: suffix or operands invalid for movq'
To fix this, a gas macro is defined to assemble movq with 64bit general purpose registers and XMM registers. The macro will generate the raw .byte sequence for needed instructions.
--- arch/x86/crypto/aesni-intel_asm.S | 4 - arch/x86/include/asm/inst.h | 96 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 95 insertions(+), 5 deletions(-)
arch/x86/crypto/aesni-intel_asm.S +2 -2
@@ -749,8 +749,8 @@ _aesni_inc_init: movaps IV, CTR PSHUFB_XMM BSWAP_MASK CTR mov $1, TCTR_LOW - movq TCTR_LOW, INC - movq CTR, TCTR_LOW + MOVQ_R64_XMM TCTR_LOW INC + MOVQ_R64_XMM CTR TCTR_LOW ret /*
arch/x86/include/asm/inst.h +93 -3
119 lines not on this page · raw message
Quoted 12 lines · Huang Ying
Andrew Morton reported that AES-NI CTR optimization failed to compile with gas 2.16.1, the error message is as follow:
arch/x86/crypto/aesni-intel_asm.S: Assembler messages:arch/x86/crypto/aesni-intel_asm.S:752: Error: suffix or operands invalid formovq' arch/x86/crypto/aesni-intel_asm.S:753: Error: suffix or operands invalid formovq'To fix this, a gas macro is defined to assemble movq with 64bit general purpose registers and XMM registers. The macro will generate the raw .byte sequence for needed instructions.
Eventually you'll port the entire assembler into macros, as instructions are introduced more frequently that people upgrade their assemblers. Maybe we should disable the new features and warn people (and distros) to upgrade their tools instead.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
David Miller
maintainerFrom: Avi Kivity <[email protected]>
Date: Fri, 12 Mar 2010 10:37:33 +0200
Quoted 4 lines
Eventually you'll port the entire assembler into macros, as instructions are introduced more frequently that people upgrade their assemblers. Maybe we should disable the new features and warn people (and distros) to upgrade their tools instead.
I totally and completely disagree.
It would have taken more than a year to get Niagara cpu support out to people if I had done what you are suggesting.
And here we're talking about one instruction in one specialized case in a very piece of crypto module assembler.
Quoted 9 lines · David Miller
From: Avi Kivity<[email protected]>
Date: Fri, 12 Mar 2010 10:37:33 +0200Quoted 5 lines
Eventually you'll port the entire assembler into macros, as instructions are introduced more frequently that people upgrade their assemblers. Maybe we should disable the new features and warn people (and distros) to upgrade their tools instead.
Quoted 5 lines
I totally and completely disagree.
It would have taken more than a year to get Niagara cpu support out to people if I had done what you are suggesting.
Strange, that people can install a new kernel, but not a new assembler.
Quoted 3 lines
And here we're talking about one instruction in one specialized case in a very piece of crypto module assembler.
If it were one place, I'd agree, but there are more. kvm for example also uses .byte instead of the actual instructions.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
David Miller
maintainerFrom: Avi Kivity <[email protected]>
Date: Fri, 12 Mar 2010 10:44:58 +0200
Quoted 2 lines
Strange, that people can install a new kernel, but not a new assembler.
Someone shouldn't have to upgrade their tools to build the kernel.
And we work very hard to make sure this is the case except in the most unavoidable situations.
Quoted 10 lines · David Miller
From: Avi Kivity<[email protected]>
Date: Fri, 12 Mar 2010 10:44:58 +0200Quoted 3 lines
Strange, that people can install a new kernel, but not a new assembler.
Someone shouldn't have to upgrade their tools to build the kernel.
The kernel would still build, just without the AES-NI CTR optimization (or kvm).
Quoted 3 lines
And we work very hard to make sure this is the case except in the most unavoidable situations.
Why so hard? It has a cost. The user can certainly 'make AS=~/new-binutils/bin/gas' and it wouldn't even affect the rest of their system.
tools/as/ anyone?
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Herbert Xu
maintainerQuoted 7 lines · Huang Ying
Andrew Morton reported that AES-NI CTR optimization failed to compile with gas 2.16.1, the error message is as follow:
arch/x86/crypto/aesni-intel_asm.S: Assembler messages:arch/x86/crypto/aesni-intel_asm.S:752: Error: suffix or operands invalid formovq' arch/x86/crypto/aesni-intel_asm.S:753: Error: suffix or operands invalid formovq'
Quoted 6 lines
To fix this, a gas macro is defined to assemble movq with 64bit general purpose registers and XMM registers. The macro will generate the raw .byte sequence for needed instructions.
Reported-by Andrew Morton <[email protected]>Signed-off-by Huang Ying <[email protected]>
Patch applied. Thanks a lot!
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 11 lines · On Fri, 12 Mar 2010 15:01:47 +0800 Huang Ying <[email protected]> wrote:
Andrew Morton reported that AES-NI CTR optimization failed to compile with gas 2.16.1, the error message is as follow:
arch/x86/crypto/aesni-intel_asm.S: Assembler messages:arch/x86/crypto/aesni-intel_asm.S:752: Error: suffix or operands invalid formovq' arch/x86/crypto/aesni-intel_asm.S:753: Error: suffix or operands invalid formovq'To fix this, a gas macro is defined to assemble movq with 64bit general purpose registers and XMM registers. The macro will generate the raw .byte sequence for needed instructions.
Still no go.
arch/x86/crypto/aesni-intel_asm.S: Assembler messages:arch/x86/crypto/aesni-intel_asm.S:752: Error: bad expression arch/x86/crypto/aesni-intel_asm.S:752: Error: junk at end of line, first unrecognized character is 1' arch/x86/crypto/aesni-intel_asm.S:753: Error: bad expression arch/x86/crypto/aesni-intel_asm.S:753: Error: junk at end of line, first unrecognized character is 1'
it doesn't like this:
REG_TYPE movq_r64_xmm_opd1_type \opd1
Hi, Andrew,
Quoted 23 lines · Andrew Morton
Quoted 11 lines · On Fri, 12 Mar 2010 15:01:47 +0800 Huang Ying <[email protected]> wrote:
Andrew Morton reported that AES-NI CTR optimization failed to compile with gas 2.16.1, the error message is as follow:
arch/x86/crypto/aesni-intel_asm.S: Assembler messages:arch/x86/crypto/aesni-intel_asm.S:752: Error: suffix or operands invalid formovq' arch/x86/crypto/aesni-intel_asm.S:753: Error: suffix or operands invalid formovq'To fix this, a gas macro is defined to assemble movq with 64bit general purpose registers and XMM registers. The macro will generate the raw .byte sequence for needed instructions.
Still no go.
arch/x86/crypto/aesni-intel_asm.S: Assembler messages:arch/x86/crypto/aesni-intel_asm.S:752: Error: bad expressionarch/x86/crypto/aesni-intel_asm.S:752: Error: junk at end of line, first unrecognized character is1' arch/x86/crypto/aesni-intel_asm.S:753: Error: bad expression arch/x86/crypto/aesni-intel_asm.S:753: Error: junk at end of line, first unrecognized character is1'
Quoted 3 lines
it doesn't like this:
REG_TYPE movq_r64_xmm_opd1_type \opd1
Try to compile the latest kernel with binutils 2.16.1 this time to debug and verify my fix. Now, with patch followed, aesni-intel_asm.S can be compiled. But I failed to compile whole kernel with binutils 2.16.1. First ld report unknown options, after use latest ld instead of that of 2.16.1, "as" reports errors as follow:
AS arch/x86/kernel/acpi/realmode/wakeup.o
cc1: error: CPU you selected does not support x86-64 instruction set
cc1: error: CPU you selected does not support x86-64 instruction set
cc1: warning: -mregparm is ignored in 64-bit mode
Can you tell me how to setup the building environment with binutils 2.16.1? I just build it by hand and make the installed bin directory the first one in $PATH.
Best Regards,
Huang Ying ------------------------------------------------------------------------>
Subject: [BUGFIX] Fix another AES-NI CTR optimization compiling failure with gas 2.16.1
The previous AES-NI CTR optimization compiling failure gas 2.16.1 fix introduces another compiling failure by itself. This patch fixes that.
--- arch/x86/include/asm/inst.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/inst.h +2 -2
@@ -120,9 +120,9 @@ .macro REG_TYPE type reg R64_NUM reg_type_r64 \reg XMM_NUM reg_type_xmm \reg - .if reg_type_r64 != REG_NUM_INVALID + .if reg_type_r64 <> REG_NUM_INVALID \type = REG_TYPE_R64 - .elseif reg_type_xmm != REG_NUM_INVALID + .elseif reg_type_xmm <> REG_NUM_INVALID \type = REG_TYPE_XMM .else \type = REG_TYPE_INVALID
Quoted 3 lines · On Wed, 24 Mar 2010 14:24:18 +0800 Huang Ying <[email protected]> wrote:
Can you tell me how to setup the building environment with binutils 2.16.1? I just build it by hand and make the installed bin directory the first one in $PATH.
gcc searches an internal search patch before $PATH. They say this can be overridden with the -B option or the GCC_EXEC_PREFIX environment var.
For once-off stuff I just get dirty and do make V=1'. Then copy and paste the gcc command line and add -v'. Then copy, paste and edit the various gcc subcommands.
Herbert Xu
maintainerQuoted 8 lines · Huang Ying
Subject: [BUGFIX] Fix another AES-NI CTR optimization compiling failure with gas 2.16.1
The previous AES-NI CTR optimization compiling failure gas 2.16.1 fix introduces another compiling failure by itself. This patch fixes that.
Reported-by Andrew Morton <[email protected]>Signed-off-by Huang Ying <[email protected]>
Patch applied. Thank you.
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt