[systemd-devel] rdrand generated with march=winchip-c6 in systemd-241

tedheadster tedheadster at gmail.com
Tue May 7 12:50:07 UTC 2019


GCC and systemd teams:
  I compiled systemd-241 and expressly set march=winchip-c6 (an i486
class cpu). It generated illegal instructions (rdrand) in the code.
Oddly, it does NOT do this when I set march=i486:

Dump of assembler code for function rdrand:
   0xb7e21440 <+0>:     push   %esi
   0xb7e21441 <+1>:     push   %ebx
   0xb7e21442 <+2>:     call   0xb7e0af5d <__x86.get_pc_thunk.si>
   0xb7e21447 <+7>:     add    $0x1acb39,%esi
   0xb7e2144d <+13>:    mov    0x2870(%esi),%ecx
   0xb7e21453 <+19>:    test   %ecx,%ecx
   0xb7e21455 <+21>:    js     0xb7e21480 <rdrand+64>
   0xb7e21457 <+23>:    test   %ecx,%ecx
   0xb7e21459 <+25>:    je     0xb7e214e0 <rdrand+160>
   0xb7e2145f <+31>:    rdrand %ecx <------ bad opcode
   0xb7e21462 <+34>:    setb   %al
   0xb7e21465 <+37>:    mov    0xc(%esp),%edx
   0xb7e21469 <+41>:    mov    %ecx,(%edx)
   0xb7e2146b <+43>:    cmp    $0x1,%al
   0xb7e2146d <+45>:    sbb    %eax,%eax
   0xb7e2146f <+47>:    and    $0xfffffff5,%eax
   0xb7e21472 <+50>:    pop    %ebx
   0xb7e21473 <+51>:    pop    %esi
   0xb7e21474 <+52>:    ret
...

It sure looks like systemd-v241 is trying to detect support for this
instruction before using it:

https://github.com/systemd/systemd/blob/v241/src/basic/random-util.c#L36

I confirmed that the processor does NOT report support for the rdrand
instruction :

# cpuid
CPU 0:
   vendor_id = "CentaurHauls"
   version information (1/eax):
      processor type  = primary processor (0)
      family          = Intel Pentium, AMD K5/K6, Cyrix M1, NexGen
Nx586, Centaur C6, Rise mP6, Transmeta Crusoe (5)
      model           = 0x8 (8)
      stepping id     = 0x5 (5)
      extended family = 0x0 (0)
      extended model  = 0x0 (0)
      (simple synth)  = VIA WinChip 2 (C6-2)
   miscellaneous (1/ebx):
      process local APIC physical ID = 0x0 (0)
      cpu count                      = 0x0 (0)
      CLFLUSH line size              = 0x0 (0)
      brand index                    = 0x0 (0)
   brand id = 0x00 (0): unknown
   feature information (1/edx):
      x87 FPU on chip                        = true
      virtual-8086 mode enhancement          = false
      debugging extensions                   = true
      page size extensions                   = false
      time stamp counter                     = true
      RDMSR and WRMSR support                = true
      physical address extensions            = false
      machine check exception                = true
      CMPXCHG8B inst.                        = true
      APIC on chip                           = false
      SYSENTER and SYSEXIT                   = false
      memory type range registers            = false
      PTE global bit                         = false
      machine check architecture             = false
      conditional move/compare instruction   = false
      page attribute table                   = false
      page size extension                    = false
      processor serial number                = false
      CLFLUSH instruction                    = false
      debug store                            = false
      thermal monitor and clock ctrl         = false
      MMX Technology                         = true
      FXSAVE/FXRSTOR                         = false
      SSE extensions                         = false
      SSE2 extensions                        = false
      self snoop                             = false
      hyper-threading / multi-core supported = false
      therm. monitor                         = false
      IA64                                   = false
      pending break event                    = false
   feature information (1/ecx):
      PNI/SSE3: Prescott New Instructions     = false
      PCLMULDQ instruction                    = false
      64-bit debug store                      = false
      MONITOR/MWAIT                           = false
      CPL-qualified debug store               = false
      VMX: virtual machine extensions         = false
      SMX: safer mode extensions              = false
      Enhanced Intel SpeedStep Technology     = false
      thermal monitor 2                       = false
      SSSE3 extensions                        = false
      context ID: adaptive or shared L1 data  = false
      FMA instruction                         = false
      CMPXCHG16B instruction                  = false
      xTPR disable                            = false
      perfmon and debug                       = false
      process context identifiers             = false
      direct cache access                     = false
      SSE4.1 extensions                       = false
      SSE4.2 extensions                       = false
      extended xAPIC support                  = false
      MOVBE instruction                       = false
      POPCNT instruction                      = false
      time stamp counter deadline             = false
      AES instruction                         = false
      XSAVE/XSTOR states                      = false
      OS-enabled XSAVE/XSTOR                  = false
      AVX: advanced vector extensions         = false
      F16C half-precision convert instruction = false
      RDRAND instruction                      = false  <------- NOT SUPPORTED
      hypervisor guest status                 = false
   extended processor signature (0x80000001/eax):
      generation = 0x5 (5)
      model      = 0x8 (8)
      stepping   = 0x5 (5)
      (simple synth) = unknown
   extended feature flags (0x80000001/edx):
      x87 FPU on chip                       = true
      virtual-8086 mode enhancement         = false
      debugging extensions                  = true
      page size extensions                  = false
      time stamp counter                    = true
      RDMSR and WRMSR support               = true
      physical address extensions           = false
      machine check exception               = true
      CMPXCHG8B inst.                       = true
      APIC on chip                          = false
      SYSCALL and SYSRET instructions       = false
      memory type range registers           = false
      global paging extension               = false
      machine check architecture            = false
      conditional move/compare instruction  = false
      page attribute table                  = false
      page size extension                   = false
      multiprocessing capable               = false
      AMD multimedia instruction extensions = false
      MMX Technology                        = true
      extended MMX                          = false
      SSE extensions                        = false
      AA-64                                 = false
      3DNow! instruction extensions         = false
      3DNow! instructions                   = true
   brand = "IDT WinChip 2-3D"
   L1 TLB/cache information: 2M/4M pages & L1 TLB (0x80000005/eax):
      instruction # entries     = 0x5 (5)
      instruction associativity = 0x0 (0)
      data # entries            = 0x0 (0)
      data associativity        = 0x80 (128)
   L1 TLB/cache information: 4K pages & L1 TLB (0x80000005/ebx):
      instruction # entries     = 0x80 (128)
      instruction associativity = 0x8 (8)
      data # entries            = 0x80 (128)
      data associativity        = 0x8 (8)
   L1 data cache information (0x80000005/ecx):
      line size (bytes) = 0x20 (32)
      lines per tag     = 0x1 (1)
      associativity     = 0x4 (4)
      size (KB)         = 0x20 (32)
   L1 instruction cache information (0x80000005/edx):
      line size (bytes) = 0x20 (32)
      lines per tag     = 0x1 (1)
      associativity     = 0x2 (2)
      size (KB)         = 0x20 (32)
   0xc0000001 0x00: eax=0x00000585
   extended feature flags (0xc0000001/edx):
      alternate instruction set                 = true
      alternate instruction set enabled         = false
      random number generator                   = true
      random number generator enabled           = false
      LongHaul MSR 0000_110Ah                   = true
      FEMMS                                     = true
      advanced cryptography engine (ACE)        = false
      advanced cryptography engine (ACE)enabled = true
      montgomery multiplier/hash (ACE2)         = true
      montgomery multiplier/hash (ACE2) enabled = false
      padlock hash engine (PHE)                 = false
      padlock hash engine (PHE) enabled         = false
      padlock montgomery mult. (PMM)            = false
      padlock montgomery mult. (PMM) enabled    = false
   VIA C7 Temperature/Voltage Sensors (0xc0000002):
      core temperature (degrees C) = 0x44 (68)
      input voltage (mV)           = 2092 (0x57)
   0xc0000002 0x00: ebx=0x436e6957 ecx=0x20706968 edx=0x44332d32
   0xc0000003 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000
   0xc0000004 0x00: eax=0x00000000 ebx=0x00000000 ecx=0x00000000 edx=0x00000000
   0xc0000005 0x00: eax=0xc0000005 ebx=0x08800880 ecx=0x20040120 edx=0x20020120
   (multi-processing synth): none
   (multi-processing method): Generic leaf 1 no multi-threading
   (synth) = VIA WinChip 2 (C6-2)

- Matthew


More information about the systemd-devel mailing list