Project

General

Profile

Actions

Feature #14822

closed

Need new word of hardware capabilities

Added by Robert Mustacchi 2 months ago. Updated 20 days ago.

Status:
Closed
Priority:
Normal
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Hard
Tags:
Gerrit CR:
External Bug:

Description

Today, hardware capabilities are spread across two different aux vector entries: AT_HWCAP and AT_HWCAP2. The work going on in #14821 has pushed us beyond the capacity of AT_HWCAP2. This means that we need to add a new aux vector entry and add a new ld symbol capability that corresponds to this. The latter is somewhat more involved and requires an additional ELF symbol capability tag, mapfile support, elfedit support, and logic placed throughout rtld and ld.so.1.


Related issues

Related to illumos gate - Bug #14823: aux vector feature mapping should use x86_featuresetClosedRobert Mustacchi

Actions
Related to illumos gate - Feature #14821: Add additional AVX512 capabilitiesClosedRobert Mustacchi

Actions
Related to illumos gate - Bug #14969: Improve elfcap.chk CPPFLAGSClosedRobert Mustacchi

Actions
Actions #1

Updated by Robert Mustacchi 2 months ago

  • Related to Bug #14823: aux vector feature mapping should use x86_featureset added
Actions #2

Updated by Robert Mustacchi 2 months ago

Actions #3

Updated by Robert Mustacchi about 2 months ago

As the first part of testing this, in addition to the fact that the tools ld uses this and built everything, I wrote two new tests to exercise the features of symbol and object capabilities. Those ran successfully:

rm@gilgamesh /opt $ ./elf-tests/bin/elftest 
Test: /opt/elf-tests/tests/assert-deflib/test-deflib (run as rm)  [00:00] [PASS]
Test: /opt/elf-tests/tests/capabilities/objcap (run as rm)        [00:00] [PASS]
Test: /opt/elf-tests/tests/capabilities/symcap (run as rm)        [00:00] [PASS]
Test: /opt/elf-tests/tests/groups/no-relobj-group-merge/no-relobj-group-merge (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/linker-sets/simple (run as rm)         [00:00] [PASS]
Test: /opt/elf-tests/tests/linker-sets/in-use-check (run as rm)   [00:00] [PASS]
Test: /opt/elf-tests/tests/mapfiles/assert/test-assert (run as rm) [00:01] [PASS]
Test: /opt/elf-tests/tests/mapfiles/parser/test-parser (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/relocs/amd64/gotpcrelx/gotpcrelx (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/relocs/amd64/gotpcrelx/rex_gotpcrelx (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/relocs/i386/got32x/got32x (run as rm)  [00:00] [PASS]
Test: /opt/elf-tests/tests/resolution/mixed-hidden-comdat/mixed-hidden-comdat (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/sections/shf-exclude/exclude-kmod (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/sections/shf-exclude/exclude-exec (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/sections/shf-exclude/exclude-so (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/sections/shf-exclude/include-reloc (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/sections/shf-exclude/unknown-os (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/string-merge/simple (run as rm)        [00:00] [PASS]
Test: /opt/elf-tests/tests/tls/amd64/ie/amd64-ie-test (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/tls/amd64/ld/amd64-ld-test (run as rm) [00:00] [PASS]
Test: /opt/elf-tests/tests/tls/i386/ld/i386-ld-test (run as rm)   [00:00] [PASS]

Results Summary
PASS      21

Running Time:   00:00:05
Percent passed: 100.0%

If you look at the tests manually you'll see:

rm@gilgamesh /opt $ /opt/elf-tests/tests/capabilities/objcap
TEST PASSED: elfdump -H /tmp/objcap.101602/prog.nocap contained no output
TEST PASSED: elfdump -H /tmp/objcap.101602/prog.hw1 has CA_SUNW_HW_1
TEST PASSED: elfedit has correct value for cap:hw1 in /tmp/objcap.101602/prog.hw1
TEST PASSED: elfdump -H /tmp/objcap.101602/prog.hw3 has CA_SUNW_HW_3
TEST PASSED: elfedit has correct value for cap:hw3 in /tmp/objcap.101602/prog.hw3
TEST PASSED: elfdump -H /tmp/objcap.101602/prog.hw123 has CA_SUNW_HW_1
TEST PASSED: elfedit has correct value for cap:hw1 in /tmp/objcap.101602/prog.hw123
TEST PASSED: elfdump -H /tmp/objcap.101602/prog.hw123 has CA_SUNW_HW_2
TEST PASSED: elfedit has correct value for cap:hw2 in /tmp/objcap.101602/prog.hw123
TEST PASSED: elfdump -H /tmp/objcap.101602/prog.hw123 has CA_SUNW_HW_3
TEST PASSED: elfedit has correct value for cap:hw3 in /tmp/objcap.101602/prog.hw123
TEST PASSED: exec prog no need, no caps
TEST PASSED: exec prog need hw1, no caps
TEST PASSED: exec prog need hw3, no caps
TEST PASSED: exec prog need hw{123}, no caps
TEST PASSED: exec prog no need, hw1=0x42
TEST PASSED: exec prog need hw1, hw1=0x42
TEST PASSED: exec prog need hw3, hw1=0x42
TEST PASSED: exec prog need hw{123}, hw1=0x42
TEST PASSED: exec prog no need, hw3=0x7777
TEST PASSED: exec prog need hw1, hw3=0x7777
TEST PASSED: exec prog need hw3, hw3=0x7777
TEST PASSED: exec prog need hw{123}, hw3=0x7777
TEST PASSED: exec prog no need, hw2=0x1369
TEST PASSED: exec prog need hw1, hw2=0x1369
TEST PASSED: exec prog need hw3, hw2=0x1369
TEST PASSED: exec prog need hw{123}, hw2=0x1369
TEST PASSED: exec prog no need, hw1=0x42,hw3=0x7777
TEST PASSED: exec prog need hw1, hw1=0x42,hw3=0x7777
TEST PASSED: exec prog need hw3, hw1=0x42,hw3=0x7777
TEST PASSED: exec prog need hw{123}, hw1=0x42,hw3=0x7777
TEST PASSED: exec prog no need, hw1=0x42,hw2=0x1369,hw3=0x7777
TEST PASSED: exec prog need hw1, hw1=0x42,hw2=0x1369,hw3=0x7777
TEST PASSED: exec prog need hw3, hw1=0x42,hw2=0x1369,hw3=0x7777
TEST PASSED: exec prog need hw{123}, hw1=0x42,hw2=0x1369,hw3=0x7777
TEST PASSED: elfedit -e cap:hw1 -or 0x1000 /tmp/objcap.101602/prog.hw1
TEST PASSED: elfedit -e cap:hw1 -and 0x1000 /tmp/objcap.101602/prog.hw1
TEST PASSED: elfedit -e cap:hw1 -cmp 0x42 /tmp/objcap.101602/prog.hw1
TEST PASSED: elfedit -e cap:hw3 -and 0x643f /tmp/objcap.101602/prog.hw3
TEST PASSED: elfedit -e cap:hw2 0x12345 /tmp/objcap.101602/prog.hw123
TEST PASSED: elfedit -e cap:hw1 -or zelda /tmp/objcap.101602/prog.hw1 failed correctly
TEST PASSED: elfedit -e cap:hw2 -or 0x100 /tmp/objcap.101602/prog.hw1 failed correctly
TEST PASSED: elfedit -e cap:hw1 -or 0x1 /tmp/objcap.101602/prog.nocap failed correctly
TEST PASSED: elfedit -e cap:hw1 -and 0xff /tmp/objcap.101602/prog.hw3 failed correctly
TEST PASSED: elfedit -e cap:hw2 -and 0xff /tmp/objcap.101602/prog.hw3 failed correctly
TEST PASSED: elfedit -e cap:hw3 -and link /tmp/objcap.101602/prog.hw3 failed correctly
TEST PASSED: elfedit -e cap:hw2 ganondorf /tmp/objcap.101602/prog.hw123 failed correctly
All tests passed successfully
rm@gilgamesh /opt $ /opt/elf-tests/tests/capabilities/symcap
TEST PASSED: LD_HWCAP=[1]0x0,[2]0x0,[3]0x0
TEST PASSED: LD_HWCAP=[1]0x5,[2]0x0,[3]0x0
TEST PASSED: LD_HWCAP=[1]0x42,[2]0x0,[3]0x0
TEST PASSED: LD_HWCAP=[1]0x0,[2]0x23,[3]0x0
TEST PASSED: LD_HWCAP=[1]0x0,[2]0xff00,[3]0x0
TEST PASSED: LD_HWCAP=[1]0x0,[2]0x0,[3]0x12345
TEST PASSED: LD_HWCAP=[1]0x0,[2]0x0,[3]0x7000000
TEST PASSED: LD_HWCAP=[1]0x3,[2]0xff7ff6,[3]0x87654321
TEST PASSED: LD_HWCAP=[1]0x8,[2]0xff7ff6,[3]0x87654321
TEST PASSED: LD_HWCAP=[1]0x40,[2]0x0,[3]0x0
TEST PASSED: LD_HWCAP=[1]0x45,[2]0x0,[3]0x0
TEST PASSED: LD_HWCAP=[1]0x45,[2]0x10,[3]0x0
TEST PASSED: LD_HWCAP=[1]0x142,[2]0x10,[3]0x0
TEST PASSED: LD_HWCAP=[1]0x1,[2]0x137,[3]0x0
TEST PASSED: LD_HWCAP=[1]0x47,[2]0xff23,[3]0x7012345
TEST PASSED: LD_HWCAP=[1]0x47,[2]0xff23,[3]0x6012345
TEST PASSED: LD_HWCAP=[1]0x47,[2]0xff23,[3]0x1012345
TEST PASSED: LD_HWCAP=[1]0x47,[2]0xff23,[3]0x1002345
TEST PASSED: LD_HWCAP=[1]0x47,[2]0x7723,[3]0x1002345
TEST PASSED: LD_HWCAP=[1]0x47,[2]0x0f23,[3]0x1002345
TEST PASSED: LD_HWCAP=[1]0x47,[2]0x0023,[3]0x1002345
TEST PASSED: LD_HWCAP=[1]0x47,[2]0x0003,[3]0x1002345
TEST PASSED: LD_HWCAP=[1]0x46,[2]0x0003,[3]0x1002345
TEST PASSED: LD_HWCAP=[1]0x35,[2]0x0003,[3]0x1002345
TEST PASSED: LD_HWCAP=[1]0x15,[2]0x0003,[3]0x1002345
TEST PASSED: LD_HWCAP=[1]0x10,[2]0x0003,[3]0x1002345
TEST PASSED: LD_HWCAP=[1]0xb,[2]0xff7ff6,[3]0x87654321
TEST PASSED: LD_HWCAP=[1]0x3b,[2]0xff7ff6,[3]0x87654321
TEST PASSED: LD_HWCAP=[1]0xffffffff,[2]0xffffffff,[3]0xffffffff
TEST PASSED: LD_HWCAP=[1]0xfffffff7,[2]0xffffffff,[3]0xffffffff

Actions #4

Updated by Robert Mustacchi about 2 months ago

The above tests cover the symbol cap and object cap parts of this. The other pieces here are showing that we have the aux vector entries, the printing of these via elfcap, and related. In particular here's what we I've verified. Note, the following is a summary with additional data and details where appropriate following:

  • pauxv on core files and live processes shows AT_SUN_HWCAP3 and the elfcap logic
  • elfdump -n on the core file showed the note processing part of this for SUN_HWCAP3
  • LD_DEBUG=cap also exercises the elfcap logic
  • The test suites above leverage elfedit changes and verify the general ld features for identifying and selecting capabilities are correct as well as rejecting programs with unusable object capabilities. This also exercised the mapfile, alternate hardware cap settings, and related features.
  • isainfo queries the cpuid_drv ioctl which proves we're now showing hwcap3 features
  • I wrote a small program to exercise getisax(2)

The aux vector contents make sense both from pauxv on a live process and matches what we see from its corresponding core file taken via gcore:

rm@gilgamesh ~ $ pauxv ./core.100517 
core './core.100517' of 100517: -bash
AT_SUN_PLATFORM 0xfffffc7fffdff8e2 i86pc
AT_SUN_EXECNAME 0xfffffc7fffdff8e8 /usr/bin/bash
AT_PHDR         0x0000000000400040 
AT_PHENT        0x0000000000000038 
AT_PHNUM        0x0000000000000006 
AT_ENTRY        0x0000000000430630 
AT_SUN_LDDATA   0xfffffc7fe5739000 
AT_BASE         0xfffffc7fe56d3000 
AT_FLAGS        0x0000000000000000 
AT_PAGESZ       0x0000000000001000 
AT_SUN_AUXFLAGS 0x0000000000000002 
AT_SUN_HWCAP    0x00000000bfff5cf7 AMD_SVM | AVX | XSAVE | PCLMULQDQ | AES | MOVBE | SSE4.2 | SSE4.1 | SSSE3 | AMD_LZCNT | POPCNT | AMD_SSE4A | TSCP | AHF | CX16 | SSE3 | SSE2 | SSE | FXSR | AMD_MMX | MMX | CMOV | AMD_SYSC | CX8 | TSC | FPU
AT_SUN_HWCAP2   0x00000000bff3e7ff AVX512_BITALG | GFNI | VAES | VPCLMULQDQ | AVX512_VNNI | CLZERO | MONITORX | CLWB | CLFLUSHOPT | FSGSBASE | SHA | AVX512_VPOPCDQ | AVX512VBMI | AVX512VL | AVX512BW | AVX512CD | AVX512IFMA | AVX512DQ | AVX512F | RDSEED | ADX | AVX2 | FMA | BMI2 | BMI1 | RDRAND | F16C
AT_SUN_HWCAP3   0x0000000000000003 AVX512_BF16 | AVX512_VBMI2
AT_SUN_COMMPAGE 0xfffffc7fef3f0000 
AT_SUN_FPTYPE   0x0000000000000002 
AT_SUN_FPSIZE   0x0000000000000988 
rm@gilgamesh ~ $ pauxv $$
100517: -bash
AT_SUN_PLATFORM 0xfffffc7fffdff8e2 i86pc
AT_SUN_EXECNAME 0xfffffc7fffdff8e8 /usr/bin/bash
AT_PHDR         0x0000000000400040 
AT_PHENT        0x0000000000000038 
AT_PHNUM        0x0000000000000006 
AT_ENTRY        0x0000000000430630 
AT_SUN_LDDATA   0xfffffc7fe5739000 
AT_BASE         0xfffffc7fe56d3000 
AT_FLAGS        0x0000000000000000 
AT_PAGESZ       0x0000000000001000 
AT_SUN_AUXFLAGS 0x0000000000000002 
AT_SUN_HWCAP    0x00000000bfff5cf7 AMD_SVM | AVX | XSAVE | PCLMULQDQ | AES | MOVBE | SSE4.2 | SSE4.1 | SSSE3 | AMD_LZCNT | POPCNT | AMD_SSE4A | TSCP | AHF | CX16 | SSE3 | SSE2 | SSE | FXSR | AMD_MMX | MMX | CMOV | AMD_SYSC | CX8 | TSC | FPU
AT_SUN_HWCAP2   0x00000000bff3e7ff AVX512_BITALG | GFNI | VAES | VPCLMULQDQ | AVX512_VNNI | CLZERO | MONITORX | CLWB | CLFLUSHOPT | FSGSBASE | SHA | AVX512_VPOPCDQ | AVX512VBMI | AVX512VL | AVX512BW | AVX512CD | AVX512IFMA | AVX512DQ | AVX512F | RDSEED | ADX | AVX2 | FMA | BMI2 | BMI1 | RDRAND | F16C
AT_SUN_HWCAP3   0x0000000000000003 AVX512_BF16 | AVX512_VBMI2
AT_SUN_COMMPAGE 0xfffffc7fef3f0000 
AT_SUN_FPTYPE   0x0000000000000002 
AT_SUN_FPSIZE   0x0000000000000988 

We have also used LD_DEBUG=cap to additionally verify the elfcap printing logic:

rm@gilgamesh ~ $ LD_DEBUG=cap ls /tmp
debug: 
debug: Solaris Linkers: 5.11-1.1784 (illumos)
debug: 
101801: 
101801: platform capability (CA_SUNW_PLAT) - i86pc
101801: machine capability (CA_SUNW_MACH) - i86pc
101801: hardware capabilities (CA_SUNW_HW_3) - 0x3  [ AVX512_BF16 AVX512_VBMI2 ]
101801: hardware capabilities (CA_SUNW_HW_2) - 0xbfd3e7ff  [ AVX512_BITALG GFNI VAES VPCLMULQDQ AVX512_VNNI CLZERO MONITORX CLWB CLFLUSHOPT SHA AVX512_VPOPCDQ AVX512VBMI AVX512VL AVX512BW AVX512CD AVX512IFMA AVX512DQ AVX512F RDSEED ADX AVX2 FMA BMI2 BMI1 RDRAND F16C ]
101801: hardware capabilities (CA_SUNW_HW_1) - 0xbfff5cf7  [ AMD_SVM AVX XSAVE PCLMULQDQ AES MOVBE SSE4.2 SSE4.1 SSSE3 AMD_LZCNT POPCNT AMD_SSE4A TSCP AHF CX16 SSE3 SSE2 SSE FXSR AMD_MMX MMX CMOV AMD_SYSC CX8 TSC FPU ]
101801: 
101801: 
101801: configuration file=/var/ld/ld.config: unable to process file
101801: 
101801: 
101801: 1: 
101801: 1: transferring control: /usr/bin/ls
101801: 1: 
tmpdsdlmvqx  tmpnx2mr6uj
101801: 1: 

The following is a program to exercise some basic features of getisax() and the corresponding output:

rm@gilgamesh ~ $ cat isa.c 
#include <sys/auxv.h>
#include <stdio.h>

int
main(void)
{
        uint32_t data[8];
        uint_t ret;

        ret = getisax(data, 3); 
        printf("%x %x %x: %u\n", data[0], data[1], data[2], ret);

        data[0] = data[1] = 0;
        data[2] = 0x12345678;
        ret = getisax(data, 2); 
        printf("%x %x %x: %u\n", data[0], data[1], data[2], ret);

        ret = getisax(data, 8); 
        printf("%x %x %x: %u\n", data[0], data[1], data[2], ret);
        return (0);
}
rm@gilgamesh ~ $ ./a.out 
bfff5cf7 bff3e7ff 3: 3
bfff5cf7 bff3e7ff 12345678: 2
bfff5cf7 bff3e7ff 3: 3

Here is the relevant aux vector snippet from elfdump -n on a core file:

  entry [1]
    namesz: 0x5
    descsz: 0x1a0
    type:   [ NT_AUXV ]
    name:
        CORE\0
    desc: (auxv_t)
           [0]  SUN_PLATFORM    0xfffffc7fffdff8e2
           [1]  SUN_EXECNAME    0xfffffc7fffdff8e8
           [2]  PHDR            0x0000000000400040
           [3]  PHENT           56
           [4]  PHNUM           6
           [5]  ENTRY           0x0000000000430630
           [6]  SUN_LDDATA      0xfffffc7fe5739000
           [7]  BASE            0xfffffc7fe56d3000
           [8]  FLAGS           0
           [9]  PAGESZ          4096
          [10]  SUN_AUXFLAGS    [ AF_SUN_HWCAPVERIFY ]
          [11]  SUN_HWCAP       [ AMD_SVM AVX XSAVE PCLMULQDQ AES MOVBE SSE4.2 SSE4.1 SSSE3 AMD_LZCNT POPCNT AMD_SSE4A TSCP AHF CX16 SSE3 SSE2 SSE FXSR AMD_MMX MMX CMOV AMD_SYSC CX8 TSC FPU ]
          [12]  SUN_HWCAP2      [ AVX512_BITALG GFNI VAES VPCLMULQDQ AVX512_VNNI CLZERO MONITORX CLWB CLFLUSHOPT FSGSBASE SHA AVX512_VPOPCDQ AVX512VBMI AVX512VL AVX512BW AVX512CD AVX512IFMA AVX512DQ AVX512F RDSEED ADX AVX2 FMA BMI2 BMI1 RDRAND F16C ]
          [13]  SUN_HWCAP3      [ AVX512_BF16 AVX512_VBMI2 ]
          [14]  SUN_COMMPAGE    0xfffffc7fef3f0000
          [15]  SUN_FPTYPE      2
          [16]  SUN_FPSIZE      2440
       [17-25]  NULL            0
Actions #5

Updated by Electric Monk about 2 months ago

  • Gerrit CR set to 2300
Actions #6

Updated by Electric Monk 20 days ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit 56726c7e321b6e5ecb2f10215f5386016547e68c

commit  56726c7e321b6e5ecb2f10215f5386016547e68c
Author: Robert Mustacchi <rm@fingolfin.org>
Date:   2022-09-11T04:06:00.000Z

    14821 Add additional AVX512 capabilities
    14822 Need new word of hardware capabilities
    14823 aux vector feature mapping should use x86_featureset
    Reviewed by: Richard Lowe <richlowe@richlowe.net>
    Reviewed by: Patrick Mooney <pmooney@pfmooney.com>
    Approved by: Dan McDonald <danmcd@mnx.io>

Actions #7

Updated by Robert Mustacchi 18 days ago

  • Related to Bug #14969: Improve elfcap.chk CPPFLAGS added
Actions

Also available in: Atom PDF