Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Jul 2011 20:40:25 GMT
From:      David Shao <davshao@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/159147: Patch cmp to cmpq for security/libgcrypt 1.5.0 fails on earlier Pentium 4
Message-ID:  <201107232040.p6NKePUm000736@red.freebsd.org>
Resent-Message-ID: <201107232050.p6NKo3Qa017062@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         159147
>Category:       ports
>Synopsis:       Patch cmp to cmpq for security/libgcrypt 1.5.0 fails on earlier Pentium 4
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 23 20:50:03 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     David Shao
>Release:        FreeBSD 9.0-CURRENT
>Organization:
>Environment:
FreeBSD  9.0-CURRENT FreeBSD 9.0-CURRENT #1: Thu Jul 21 14:13:09 PDT 2011     root@:/usr/obj/usr/src/sys/MYKERNEL  i386
>Description:
PR 158994 "Fix security/libgcrypt 1.5.0 build with clang" included a patch to change inline asm cmp to cmpq in rijndael.c of libgcrypt 1.5.0, patch file patch-cipher-rijndael.c.

The system with problems has for its compiler:

Target: i386-undermydesk-freebsd
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 4.2.2 20070831 prerelease [FreeBSD]

Unfortunately on an early Pentium 4 without EMT64 instructions, partial dmesg output of:

CPU: Intel(R) Pentium(R) 4 CPU 1.80GHz (1816.21-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0xf24  Family = f  Model = 2  Stepping = 4
  Features=0x3febfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM>

and partial kenv output of:
smbios.bios.reldate="08/06/2002"
smbios.bios.vendor="Award Software, Inc."
smbios.bios.version="ASUS P4B266 ACPI BIOS Revision 1010"

tests using the gcc compiler show that "cmpq" is not recognized in inline asm whereas "cmp" and "cmpl" are recognized.
>How-To-Repeat:
On an earlier Pentium 4 machine without emt64 instructions, update to latest ports and try to update libgcrypt to 1.5.0.  An error similar to the following will occur:

/bin/sh /usr/local/bin/libtool --tag=CC    --mode=compile cc -DHAVE_CONFIG_H -I. -I..   -I../src -I../src -I/usr/local/include -I/usr/local/include -O2 -pipe -fno-strict-aliasing -std=gnu89 -fvisibility=hidden -Wall -MT rijndael.lo -MD -MP -MF .deps/rijndael.Tpo -c -o rijndael.lo rijndael.c
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -I/usr/local/include -I/usr/local/include -O2 -pipe -fno-strict-aliasing -std=gnu89 -fvisibility=hidden -Wall -MT rijndael.lo -MD -MP -MF .deps/rijndael.Tpo -c rijndael.c  -fPIC -DPIC -o .libs/rijndael.o
{standard input}: Assembler messages:
{standard input}:423: Error: suffix or operands invalid for `cmp'
{standard input}:429: Error: suffix or operands invalid for `cmp'
{standard input}:439: Error: suffix or operands invalid for `cmp'
{standard input}:498: Error: suffix or operands invalid for `cmp'
{standard input}:504: Error: suffix or operands invalid for `cmp'
{standard input}:605: Error: suffix or operands invalid for `cmp'
{standard input}:617: Error: suffix or operands invalid for `cmp'

>Fix:
The gcc 4.2.2 compiler appears perfectly capable of deducing an acceptable suffix for cmp for inline asm, perhaps due to the compiler's ability to use type information of memory arguments of integer size "int".  The problem may be more with the present clang compiler than with the source code of libgcrypt 1.5.0.

If a suffix for cmp must be supplied, it seems a general policy of using "cmpl" would be preferable to maintain backwards compatibility with older hardware that does not support 64-bit extensions.

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107232040.p6NKePUm000736>