Bug 159147 - Patch cmp to cmpq for security/libgcrypt 1.5.0 fails on earlier Pentium 4
Summary: Patch cmp to cmpq for security/libgcrypt 1.5.0 fails on earlier Pentium 4
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-23 21:50 UTC by David Shao
Modified: 2011-07-30 17:35 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Shao 2011-07-23 21:50:03 UTC
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.

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.
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'
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2011-07-23 21:50:10 UTC
Maintainer of security/libgcrypt,

Please note that PR ports/159147 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/159147

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2011-07-23 21:50:13 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 3 dfilter service freebsd_committer freebsd_triage 2011-07-26 07:54:59 UTC
dim         2011-07-26 06:54:46 UTC

  FreeBSD ports repository (src committer)

  Modified files:
    security/libgcrypt/files patch-cipher-rijndael.c 
  Log:
  In the AES-NI inline assembly, change instances of 'cmpq' to 'cmpl'.  I
  had erroneously assumed this would only be compiled on amd64, but even
  then a 64 bit compare is wrong.  The variables referenced in the inline
  assembly are all plain int, so 32 bit.
  
  PR:     ports/159147
  Pointy hat to:  dim
  Requested by:   Hirohisa Yamaguchi <umq@ueo.co.jp> (maintainer)
  
  Revision  Changes    Path
  1.2       +8 -8      ports/security/libgcrypt/files/patch-cipher-rijndael.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 4 Tilman Keskinoz freebsd_committer freebsd_triage 2011-07-30 15:52:30 UTC
State Changed
From-To: feedback->patched

I think this PR can be closed, over to committer for evaluation 


Comment 5 Tilman Keskinoz freebsd_committer freebsd_triage 2011-07-30 15:52:30 UTC
Responsible Changed
From-To: freebsd-ports-bugs->dim
Comment 6 Dimitry Andric freebsd_committer freebsd_triage 2011-07-30 17:34:54 UTC
State Changed
From-To: patched->closed

Patch has been fixed.