Project

General

Profile

Actions

Bug #13715

closed

pcieadm save-cfgspace doesn't work with b/d/f

Added by Robert Mustacchi 25 days ago. Updated 22 days ago.

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

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

If you try to use a pcieadm save-cfgspace -d b/d/f that fails when you use the form that comes out of pcieadm show-devs. The reason for this is because we're trying to catch two bdf forms, one is %x/%x/%x and the other is %02x/%02x/%02x, but we overwrite the buffer rather than using the alternate buffer we meant to use. To catch this I added regression tests to make sure we can easily round trip this.

Actions #1

Updated by Electric Monk 25 days ago

  • Gerrit CR set to 1413
Actions #2

Updated by Stephan Althaus 24 days ago

The same issue with show-cfgspace

  1. ./pcieadm.1 show-cfgspace -d 1/0/0
    pcieadm.1: failed to find device node 1/0/0
  2. ./pcieadm.1 show-cfgspace -d 0/0/0
    pcieadm.1: failed to find device node 0/0/0
  3. ./pcieadm.1 show-cfgspace d 01/00/00
    Device 01/00/00 -
    Type 0 Header
    Vendor ID: 0x10de -- NVIDIA Corporation
    Device ID: 0x13b6 -- GM107GLM [Quadro M1200 Mobile]
    Command: 0x47 |--> I/O Space: enabled (0x1) |--> Memory Space: enabled (0x2)
    ...
Actions #3

Updated by Robert Mustacchi 24 days ago

Yes, that's the symptom of this bug. It was the case that only the version with leading zeros was working when there was logic in here that was meant to work with both.

Actions #4

Updated by Robert Mustacchi 22 days ago

This was tested with the pcieadm test suites and new tests designed to catch this case explicitly:

rm@beowulf:~$ /opt/util-tests/tests/pcieadmtest ; pfexec /opt/util-tests/tests/pcieadm-priv ; pfexec /opt/util-tests/bin/utiltest 
TEST PASSED: invalid arguments 
TEST PASSED: invalid arguments -d
TEST PASSED: invalid arguments foobar
TEST PASSED: invalid arguments save-cfgspace
TEST PASSED: invalid arguments save-cfgspace -a
TEST PASSED: invalid arguments save-cfgspace -d
TEST PASSED: invalid arguments save-cfgspace -d final
TEST PASSED: invalid arguments save-cfgspace -a -d fantasy
TEST PASSED: invalid arguments show-devs -h
TEST PASSED: invalid arguments show-devs -p
TEST PASSED: invalid arguments show-devs -s -o
TEST PASSED: invalid arguments show-cfgspace
TEST PASSED: invalid arguments show-cfgspace -d -H
TEST PASSED: invalid arguments show-cfgspace -d
TEST PASSED: invalid arguments show-cfgspace -f
TEST PASSED: invalid arguments show-cfgspace -h
TEST PASSED: invalid arguments show-cfgspace -L
TEST PASSED: invalid arguments show-cfgspace -L -n -f /opt/util-tests/tests/pci/igb.pci
TEST PASSED: invalid arguments show-cfgspace -L -p -f /opt/util-tests/tests/pci/igb.pci
TEST PASSED: invalid arguments show-cfgspace -p -f /opt/util-tests/tests/pci/igb.pci
TEST PASSED: invalid arguments show-cfgspace -o foo -f /opt/util-tests/tests/pci/igb.pci
TEST PASSED: invalid arguments show-cfgspace -L -o foo -f /opt/util-tests/tests/pci/igb.pci
TEST PASSED: show-cfgspace -f /dev/stdin header0.vendor header0.device
TEST PASSED: show-cfgspace -L -f /dev/stdin header0.vendor header0.device
TEST PASSED: show-cfgspace -n -f /dev/stdin header0.vendor header0.device
TEST PASSED: show-cfgspace -L -H -f /dev/stdin header0.vendor header0.device
TEST PASSED: show-cfgspace -f /dev/stdin ltr
TEST PASSED: show-cfgspace -p -o short,value -f /dev/stdin ltr
TEST PASSED: show-cfgspace -p -o short,value -f /dev/stdin header0.vendor header0.device
TEST PASSED: show-cfgspace -f /dev/stdin ht
TEST PASSED: show-cfgspace -f /dev/stdin ht.msi
TEST PASSED: show-cfgspace -f /dev/stdin ht.msi.command
TEST PASSED: show-cfgspace -p -o value,short -f /dev/stdin ht
TEST PASSED: show-cfgspace -p -o value,short -f /dev/stdin ht.msi
TEST PASSED: show-cfgspace -p -o value,short -f /dev/stdin ht.msi.command
TEST PASSED: show-cfgspace -f /dev/stdin pcie.linksts atelier
TEST PASSED: show-cfgspace -p -o short,value -f /dev/stdin pcie.linksts atelier
All tests passed successfully!
successfully listed devices
TEST PASSED: show-devs 0/0/0
TEST PASSED: show-cfgspace -d 0/0/0
TEST PASSED: save-cfgspace -d 0/0/0
TEST PASSED: show-devs /pci@0,0/pci1849,1480@0
TEST PASSED: show-cfgspace -d /pci@0,0/pci1849,1480@0
TEST PASSED: save-cfgspace -d /pci@0,0/pci1849,1480@0
TEST PASSED: show-devs amdzen_stub0
TEST PASSED: show-cfgspace -d amdzen_stub0
TEST PASSED: save-cfgspace -d amdzen_stub0
TEST PASSED: save-cfgspace -a
All tests passed successfully!
Test: /opt/util-tests/tests/allowed-ips (run as root)             [00:00] [PASS]
Test: /opt/util-tests/tests/chown_test (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/date_test (run as root)               [00:00] [PASS]
Test: /opt/util-tests/tests/find/findtest (run as root)           [00:00] [PASS]
Test: /opt/util-tests/tests/grep_test (run as root)               [00:03] [PASS]
Test: /opt/util-tests/tests/head/head_test (run as root)          [00:00] [PASS]
Test: /opt/util-tests/tests/libjedec_test (run as root)           [00:00] [PASS]
Test: /opt/util-tests/tests/libsff/libsff (run as root)           [00:00] [PASS]
Test: /opt/util-tests/tests/make_test (run as root)               [00:00] [PASS]
Test: /opt/util-tests/tests/mdb/mdbtest (run as root)             [00:00] [PASS]
Test: /opt/util-tests/tests/mergeq/mqt (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/mergeq/wqt (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/pcidbtest (run as root)               [00:01] [PASS]
Test: /opt/util-tests/tests/pcieadm-priv (run as root)            [00:03] [PASS]
Test: /opt/util-tests/tests/pcieadmtest (run as root)             [00:03] [PASS]
Test: /opt/util-tests/tests/printf_test (run as root)             [00:00] [PASS]
Test: /opt/util-tests/tests/set-linkprop (run as root)            [00:00] [PASS]
Test: /opt/util-tests/tests/sleep/sleeptest (run as root)         [00:23] [PASS]
Test: /opt/util-tests/tests/smbios (run as root)                  [00:00] [PASS]
Test: /opt/util-tests/tests/xargs_test (run as root)              [00:00] [PASS]
Test: /opt/util-tests/tests/awk/runtests.sh (run as nobody)       [02:57] [PASS]
Test: /opt/util-tests/tests/ctf/precheck (run as root)            [00:00] [PASS]
Test: /opt/util-tests/tests/ctf/ctftest (run as root)             [00:06] [PASS]
Test: /opt/util-tests/tests/demangle/afl-fast (run as root)       [00:01] [PASS]
Test: /opt/util-tests/tests/demangle/gcc-libstdc++ (run as root)  [00:00] [PASS]
Test: /opt/util-tests/tests/demangle/llvm-stdcxxabi (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libcustr/custr_remove (run as root)   [00:00] [PASS]
Test: /opt/util-tests/tests/libcustr/custr_trunc (run as root)    [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_00_blank (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_01_boolean (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_02_numbers (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_03_empty_arrays (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_04_number_arrays (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_05_strings (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_06_nested (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/libnvpair_json/json_07_nested_arrays (run as root) [00:00] [PASS]
Test: /opt/util-tests/tests/sed/sed_addr (run as root)            [00:00] [PASS]
Test: /opt/util-tests/tests/sed/multi_test (run as root)          [00:00] [PASS]

Results Summary
PASS      38

Running Time:   00:03:47
Percent passed: 100.0%
Log directory:  /var/tmp/test_results/20210415T090220
Actions #5

Updated by Electric Monk 22 days ago

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

git commit 414dafc0a71bccb9c69d6801ed11ba1016a8082b

commit  414dafc0a71bccb9c69d6801ed11ba1016a8082b
Author: Robert Mustacchi <rm@fingolfin.org>
Date:   2021-04-15T20:44:29.000Z

    13714 pcieadm pci check misses renamed nodes
    13715 pcieadm save-cfgspace doesn't work with b/d/f
    13716 pcieadm save-cfgspace -a can't open files
    Reviewed by: C Fraire <cfraire@me.com>
    Reviewed by: Andy Fiddaman <andy@omnios.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF