{
#if defined(ASM_X86_32) || defined(ASM_X86_64)
- if (have_cpuid() != 0)
+ if (_gnutls_have_cpuid() != 0)
{
register_x86_crypto ();
register_padlock_crypto ();
if ASM_X86_64
AM_CPPFLAGS += -DASM_X86_64
-libintel_la_SOURCES += asm/appro-aes-x86-64.s asm/appro-aes-gcm-x86-64.s aes-gcm-x86.c asm/padlock-x86-64.s
+libintel_la_SOURCES += asm/appro-aes-x86-64.s asm/appro-aes-gcm-x86-64.s aes-gcm-x86.c asm/padlock-x86-64.s asm/cpuid-x86-64.s
else
-libintel_la_SOURCES += asm/appro-aes-x86.s asm/padlock-x86.s
+libintel_la_SOURCES += asm/appro-aes-x86.s asm/padlock-x86.s asm/cpuid-x86.s
endif
static unsigned check_via(void)
{
unsigned int a, b, c, d;
- cpuid(0, a, b, c, d);
+ _gnutls_cpuid(0, &a, &b, &c, &d);
if ((memcmp(&b, "VIA ", 4) == 0 &&
memcmp(&d, "VIA ", 4) == 0 && memcmp(&c, "VIA ", 4) == 0)) {
check_optimized_aes (void)
{
unsigned int a, b, c, d;
- cpuid (1, a, b, c, d);
+ _gnutls_cpuid (1, &a, &b, &c, &d);
return (c & 0x2000000);
}
check_pclmul (void)
{
unsigned int a, b, c, d;
- cpuid (1, a, b, c, d);
+ _gnutls_cpuid (1, &a, &b, &c, &d);
return (c & 0x2);
}
check_intel_or_amd (void)
{
unsigned int a, b, c, d;
- cpuid (0, a, b, c, d);
+ _gnutls_cpuid (0, &a, &b, &c, &d);
if ((memcmp (&b, "Genu", 4) == 0 &&
memcmp (&d, "ineI", 4) == 0 &&
--- /dev/null
+ .file "cpuid.asm"
+
+ .text
+ .align 16
+.globl _gnutls_cpuid
+.type _gnutls_cpuid,%function
+_gnutls_cpuid:
+ pushq %rbp
+ movq %rsp, %rbp
+ pushq %rbx
+ movl %edi, -12(%rbp)
+ movq %rsi, -24(%rbp)
+ movq %rdx, -32(%rbp)
+ movq %rcx, -40(%rbp)
+ movq %r8, -48(%rbp)
+ movl -12(%rbp), %eax
+ movl %eax, -60(%rbp)
+ movl -60(%rbp), %eax
+ cpuid
+ movl %edx, -56(%rbp)
+ movl %ecx, %esi
+ movl %eax, -52(%rbp)
+ movq -24(%rbp), %rax
+ movl -52(%rbp), %edx
+ movl %edx, (%rax)
+ movq -32(%rbp), %rax
+ movl %ebx, (%rax)
+ movq -40(%rbp), %rax
+ movl %esi, (%rax)
+ movq -48(%rbp), %rax
+ movl -56(%rbp), %ecx
+ movl %ecx, (%rax)
+ popq %rbx
+ leave
+ ret
+.size _gnutls_cpuid, . - _gnutls_cpuid
+
+
+.section .note.GNU-stack,"",@progbits
--- /dev/null
+ .file "cpuid.asm"
+
+ .text
+ .align 16
+.globl _gnutls_cpuid
+.type _gnutls_cpuid,%function
+_gnutls_cpuid:
+ pushl %ebp
+ movl %esp, %ebp
+ subl $12, %esp
+ movl %ebx, (%esp)
+ movl 8(%ebp), %eax
+ movl %esi, 4(%esp)
+ movl %edi, 8(%esp)
+ pushl %ebx
+ cpuid
+ movl %ebx, %edi
+ popl %ebx
+ movl %edx, %esi
+ movl 12(%ebp), %edx
+ movl %eax, (%edx)
+ movl 16(%ebp), %eax
+ movl %edi, (%eax)
+ movl 20(%ebp), %eax
+ movl %ecx, (%eax)
+ movl 24(%ebp), %eax
+ movl %esi, (%eax)
+ movl (%esp), %ebx
+ movl 4(%esp), %esi
+ movl 8(%esp), %edi
+ movl %ebp, %esp
+ popl %ebp
+ ret
+.size _gnutls_cpuid, . - _gnutls_cpuid
+
+ .globl _gnutls_have_cpuid
+ .type _gnutls_have_cpuid, @function
+_gnutls_have_cpuid:
+.LFB0:
+ .cfi_startproc
+ pushfl
+ pop %eax
+ orl $0x200000, %eax
+ push %eax
+ popfl
+ pushfl
+ pop %eax
+ andl $0x200000, %eax
+ ret
+ .cfi_endproc
+.LFE0:
+ .size _gnutls_have_cpuid, .-_gnutls_have_cpuid
+
+.section .note.GNU-stack,"",@progbits
#include <config.h>
-#ifdef ASM_X86_64
+#if defined(ASM_X86_32) || defined(ASM_X86_64)
-# ifdef HAVE_CPUID_H
-# include <cpuid.h>
-# define cpuid __cpuid
-# else
-
-#define cpuid(func,ax,bx,cx,dx)\
- __asm__ __volatile__ ("cpuid":\
- "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (func));
-
-# endif
-
-# define have_cpuid() 1
+void _gnutls_cpuid(unsigned int func, unsigned int *ax, unsigned int *bx, unsigned int *cx, unsigned int* dx);
-#endif /* ASM_X86_64 */
-
-
-#ifdef ASM_X86_32
-/* some GCC versions complain on the version above */
-# define cpuid(func, a, b, c, d) g_cpuid(func, &a, &b, &c, &d)
+# ifdef ASM_X86_32
+unsigned int _gnutls_have_cpuid(void);
+# else
+# define _gnutls_have_cpuid() 1
+# endif /* ASM_X86_32 */
-inline static void g_cpuid(uint32_t func, unsigned int *ax, unsigned int *bx, unsigned int *cx, unsigned int* dx)
-{
- asm volatile ("pushl %%ebx\n"
- "cpuid\n"
- "movl %%ebx, %1\n"
- "popl %%ebx\n"
- :"=a" (*ax), "=r"(*bx), "=c"(*cx), "=d"(*dx)
- :"a"(func)
- :"cc");
-}
+#endif
-inline static unsigned int have_cpuid(void)
-{
- unsigned int have_id;
- asm volatile(
- "pushfl\t\n"
- "pop %0\t\n"
- "orl $0x200000, %0\t\n"
- "push %0\t\n"
- "popfl\t\n"
- "pushfl\t\n"
- "pop %0\t\n"
- "andl $0x200000, %0\t\n"
- :"=r" (have_id)
- ::
- );
-
- return have_id;
-}
-#endif /* ASM_X86_32 */