Compare commits

...

492 Commits

Author SHA1 Message Date
Steffen Eiden
03f7566436 New release s390-tools-2.44.0
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-31 15:51:50 +02:00
Marc Hartmayer
177d8ae0dd pvimg: Get rid of most 'ignore' doctest directives
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-31 09:51:14 +02:00
Marc Hartmayer
08d21b24b4 pvimg: Use indexed array for UV key hashes
Replace individual UV key hash fields with an indexed array and
introduce dedicated types for hash indices and key hash kinds. This
simplifies hash handling.

Co-developed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-31 09:51:14 +02:00
Marc Hartmayer
ed74e84862 pvimg: Report host-key document type mismatches
Report host-key document type mismatches before hash verification.

For example, when testing a v2 Secure Execution header with a classical
host-key document, report that a hybrid host-key document is required
instead of failing with a generic header validation error.

Before:

$ pvimg -- test --host-key-document v1.hkd se.v2.img
error: Invalid Secure Execution header

After:

$ pvimg -- test --host-key-document v1.hkd se.v2.img
Host-key document 'v1.hkd' is not a hybrid host-key document.
error: The provided host key document in v1.hkd contains the wrong number of keys!

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-31 09:51:14 +02:00
Marc Hartmayer
0263637d9f pv: Refactor 'get_verified_hkds'
Get rid of 'read_hkd' by refactoring the 'get_verified_hkds' function.
For this a new HkdLoader::load_and_verify is introduced that is a
reworked version of the original code.

In addition, add test cases for testing all the edge cases.

Assisted-by: IBM Bob:1.0.6
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-31 09:51:14 +02:00
Mete Durlu
1aa1558f91 zmemtopo: Add case-insensitive partition name filtering
Introduce the -p/--partition-filter option to display only partitions
whose names contain a specified substring. The filter performs
case-insensitive matching and applies consistently across all output
formats (table, tree, and reverse tree views).

Example:

$ zmemtopo -p "part74"
LPAR/LEVEL      SIZE
PARTITION74      12G
└LEVEL4_1        12G
  ├LEVEL3_0       3G
  ├LEVEL3_1       3G
  ├LEVEL3_2       3G
  └LEVEL3_3       3G

Suggested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-31 09:51:14 +02:00
Mete Durlu
29a1ef0023 zmemtopo: Fix table view spacing
Left justify partition number and partition name fields on table view
to better accommodate untrimmed and longer partition names.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-31 09:51:14 +02:00
Mete Durlu
39eb46763b zmemtopo: Remove false leading/trailing space trimming
Remove all util_strstrip() calls. The current users are command line
option stripping and partition name stripping.
Keep user passed arguments as is, typical shells already remove leading
and trailing whitespace unless explicitly quoted.
Spaces in partition names are valid. Keep the leading/trailing spaces
to preserve user given partition names.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-31 09:51:14 +02:00
Mete Durlu
ce1464ad5f zmemtopo: Clean up hardcoded value
Replace array length of lpar name with LPAR_NAME_LEN macro.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-31 09:51:14 +02:00
Steffen Eiden
c6d74eebfb pvimg: Fix hash comparison in SeHdrAadV2::contains_hash
Ensure both sides of the hash comparison use the same slice length
by explicitly slicing both the keyslot hash and the input hash to
UV_KEY_HASH_SIZE. Previously, only the keyslot hash was sliced while
comparing against the full input hash reference, which could lead to
incorrect comparisons if the input hash length differs.

This makes the comparison more explicit and ensures we're always
comparing equal-length hashes. This is useful if one hash is a subset of
another, e.g. a sha512 hash truncated to 32 bytes.

Fixes: 89577c2f8c ("pvimg: Use hybrid keys")
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-31 09:51:14 +02:00
Marc Hartmayer
ad129057b5 pvattest: tests: Implement TODO
Instead of blindly casting the values to u32 use try_into().unwrap().

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:01 +02:00
Marc Hartmayer
5b8fdc2bec pv: Improve API by marking some functions as must_use
Make the API less prone to error by specifying some of them as must_use.
This avoids issues that the result is not used.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:01 +02:00
Marc Hartmayer
784cff18c3 pv: Reuse RequestVersion and RequestMagic
Use the typedefs to make the intention and compatibility of the fields
more clear.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:01 +02:00
Timo Keller
fb33935c9b pvsecret: test using hybrid keys
Add unite tests and (binary) test asses for the hybrid key patch.

Co-developed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:01 +02:00
Marc Hartmayer
175b336d32 rust/utils: Replace get_verified_hkds with get_verified_hkds_new
Now as no users of get_verified_hkds exists, replace it with
get_verified_hkds_new.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:01 +02:00
Steffen Eiden
9a5c9cd7f9 pv: Require matching versions of request and HKD
Enforce that a v{1,2} request also has a v{1,2} hostkey.
This requires to change the signature of Request::add_hostkey to return
a Result.

Co-Developed-by: Timo Keller <tkeller@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:01 +02:00
Steffen Eiden
73c227fa9a pvattest: Verify hybrid keys
Allow pvattest verify to verify hybrid keys. The hybrid key is
represented by a sha512 hash truncated to 32 bytes.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:01 +02:00
Steffen Eiden
1078e6d45f pvverify: Use hybrid keys
Allow pvverify to also verify hybrid keys. By default the key format is
autodetected.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:01 +02:00
Timo Keller
50808edb7c pvsecret: Use hybrid keys
Allow the creation of Add-secret requests using hybrid (=quantum safe)
keys. This results in using the headers in version 2 (0x200).

Co-developed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:01 +02:00
Timo Keller
9dca2d3181 pvattest: Use hybrid keys
Allow the creation of Attestation requests using hybrid (=quantum safe)
keys. This results in using the headers in version 2 (0x200).

Co-developed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Timo Keller
fc853f3259 pvimg/create-sehdr: Use hybrid keys
Allow the creation of SE headers with hybrid (=quantum safe) keys. This
results in using the headers in version 2 (0x200).

Co-developed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Timo Keller
89577c2f8c pvimg: Use hybrid keys
Allow the creation of SE images using headers with hybrid (=quantum safe) keys.
This results in using the headers in version 2 (0x200).

Co-developed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Marc Hartmayer
d6fc4921fb utils: Read hybrid HKDs
* Add `HkdVersion` (classic or hybrid) and `HkdVersionSelection`.
* Add `get_verified_hkds_new` that returns a list of verified HKDs
  read according to the given `HkdVersionSelection`.

Co-Developed-by: Timo Keller <tkeller@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Marc Hartmayer
cb9c2f993c utils/cli: Introduce AutoOrExplicit
* Add `AutoOrExplicit` that dispatches between `Auto` and `Explicit`.
* Add `AutoOrExplicitParser` for it.

In a later commit, this will be used for auto detection of HKD version
or explicitly specifying the version.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Marc Hartmayer
637c8196a6 pvimg: tests: Refactor test code and increase coverage
Refactor test code and increase coverage. The new test code tests for
the correct error kind instead of simply for an error.

Assisted-by: IBM Bob:1.0.6
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Marc Hartmayer
c87d11abfe pvimg and create-sehdr: Refactor code to use generic flags
Replace version-specific flag enums (PcfV1, ScfV1) with a unified
SeHdrFlag enum and generic ControlFlagsModel. This refactoring provides:

 - Single SeHdrFlag enum for all control flags across SE header versions
 - Generic SeHdrControlFlagsModel with version-specific configurations
 - EffectiveControlFlags type replacing PlaintextControlFlagsV1/SecretControlFlagsV1
 - FlagsOverride mechanism for customizing flag configurations
 - Enhanced FromStr implementation for flag parsing
 - Comprehensive test coverage for flag operations and conversions

The new design improves maintainability by eliminating code duplication
and provides a more flexible API for working with SE header control
flags.

Assisted-by: IBM Bob:1.0.4
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Marc Hartmayer
20fffb31d7 pvimg: Introduce generic flags
Add a generic flags framework for managing (Secure Execution) header
control flags. This implementation provides:

  - Clap compatibility for auto-completion and proper help messages
  - ControlFlagTrait for defining flag types with bit positions and version support
  - ControlFlagsModel for managing default flags and validation rules
  - FlagsOverride for customizing individual flag states
  - EffectiveControlFlags representing the final flag configuration
  - UnknownFlags handling for forward compatibility
  - Comprehensive error handling via FlagValidationError
  - Display implementations for both human-readable and binary formats
  - Type-safe conversions between flag representations

The framework supports version-aware flag validation, allowing flags to
be marked as supported only in specific Secure Execution header
versions. It enables flexible flag configuration through overrides while
maintaining type safety and validation.

Assisted-by: IBM Bob:1.0.4
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Marc Hartmayer
2d330cd45f utils_macros: Implement derive_control_flag
Add a new derive macro 'derive_control_flag' that is used in the next
commit to reimplement how the code deals with Secure Execution control
flags.

It implements Display, IntoEnumIterator and the ControlFlagTrait for
enums using unit variants only.

  /// Trait for control flags that provide bit position information.
  pub trait ControlFlagTrait {
      /// Returns the bit position for this flag.
      fn bit_position(self) -> u8;
  }

Assisted-by: IBM Bob:1.0.4
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Marc Hartmayer
618e22e38b utils: Add utils_macros: Implement ValueEnumDisplay and ValueEnumFromStr macros
Add new derive macros ValueEnumDisplay and ValueEnumFromStr which can be
used to derive 'Display' and 'FromStr' for enums implementing
'clap::ValueEnum'. It helps in reducing boilerplate code and keep things
in sync.

Assisted-by: IBM Bob:1.0.4
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Marc Hartmayer
173a055372 pvimg: Use log level info for printing used flags
Use log level info for printed the used flags, instead of log level
debug.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Timo Keller
4670b108a6 pv: Implement HostKey::V2 and Keyslot::V2
Introduce HybridPublicKey combining ECDH and ML-KEM public keys. Use it
for HostKey::V2 and add Keyslot::V2 for hybrid keyslots.

Add tests for the new functionality.

Assisted-by: IBM Bob:1.0.5
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Timo Keller
ebe56592c8 pv: Add hybrid key derivation support
Add derive_aes256_gcm_key_hybrid() function that derives an Aes256GcmKey
and ML-KEM1024 ciphertext from a private ECDH customer key, a public
ECDH target key, and a public ML-KEM target key. This enables hybrid
post-quantum cryptography support.

Assisted-by: IBM Bob:1.0.5
Co-developed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Marc Hartmayer
1746d2bb6a pv: Change ec_key() to return Option<&PKeyRef<Public>>
Prepare the API for future host keys that might not have an EC key by
returning Option instead of a direct reference. Additionally, use
&PKeyRef<Public> as the borrowed view on PKey for better API
consistency.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Timo Keller <tkeller@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2026-07-28 11:00:00 +02:00
Niklas Schnelle
91123e5d45 lib/zt_common.h: zpcimon: Add __force and use it to annotate le32toh() conversions
When using sparse on zpcimon several warnings like the one below are
generated:

  warning: incorrect type in argument 1 (different base types)
     expected unsigned int [usertype] __bsx
     got restricted __le32 [usertype] warning_temp_time

This is because several members in struct nvme_smart_log are marked as
__le32. These members are correctly converted to host endianness before
use via le32toh() respectively le16toh(). Since these functions take
their parameters as plain uint32_t or uint16_t however the implicit
conversion triggers the above warning. Fix this by adding the __force
attribute and using it to mark type conversions in the leXXtoh() calls.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:51 +02:00
Niklas Schnelle
0f0e8cf33b zpcimon: Make optics_los_implemente() static
Sparse noted that optics_los_implemente() can be static. Make it so.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:51 +02:00
Niklas Schnelle
7586a1ad59 zpcimon: Add missing include for __packed attribute
The __packed attribute is used without including the necessary
zt_common.h header, add it. Note that luckily the struct as it currently
exists doesn't actually required __packed as the natural alignment
leaves no holes. Still if in the future the reserved field is split up
it would need it and this keeps it consistent with the kernel
declaration.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:51 +02:00
Niklas Schnelle
1da328921b dbginfo.sh: Let zpcimon log both optical module and SMART data
Add zpcimon data collection with both SMART log and optical module data.
Do so in the Z device subsystem commands section to account for the fact
that zpcimon is no longer network specific. At the same time keep the
existing opticsmon invocation for compatibility when executed on systems
without zpcimon.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Jörn Siglen <siglen@de.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:51 +02:00
Niklas Schnelle
f96f09a5c9 nvmemon: libzpci: Skip SCLP on NVMes with non-IBM subsystem vendor ID
The SCLP Write Event Data Action Qualifier 4 is only available for
NVMes with subsystem vendor ID matching IBM. Add both IDs to struct
zpci_dev in libzpci. Also add them to the libzpci_example output
and adjust its output to multiline to handle more data.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:51 +02:00
Niklas Schnelle
4fd607ae5c zpcimon: Monitor for hotplug of NVMes to trigger SMART collection
Use libudev to monitor for "change" events in the "nvme" subsystem that
use the "pcie" transport to trigger NVMe SMART data collection. Only
collect data from the NVMe referenced by the udev event.

Assisted-by: IBM Bob:1.0.1
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:51 +02:00
Niklas Schnelle
f1a11a01df zpcimon: Add JSON output for SMART data details
This uses the same format as:

   nvme smart-log --output-format=json /dev/nvmeX

One complication being that several values in the SMART data use
unsigned 128 bit integers. Both GCC and Clang support __uint128_t as
a C extension but don't offer printf() support for it. Just like
nvme-cli add a custom uint128_t to string function..

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
2eceedeb11 zpcimon: Add NVMe SMART data monitor
Add a new monitor which uses libnvme to collect SMART data from NVMes.
This monitor only implements the .collect_adapter_data operation since
it carries no state across data collections. Nevertheless for future
symmetry and possible future expansion also add an empty struct
nvmemon_ctx.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
a9dbb8a1a2 zpcimon: Factor out JSON printing of common PCI adapter attributes
Some of the attributes printed as JSON by opticsmon are common to all
PCI adapters factor these out into reusable helper functions
zpci_adapter_json_print_start() and zpci_adapter_json_print_end().

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
78dd82d129 libzpci: Extract get_device_node() from zpcictl to libzpci
The get_device_node() function for getting the name of an NVMe's
controller device e.g. "nvme0" as implemented in zpcictl is generally
useful and will be needed for NVMe SMART data collection in zpcimon as
well. Move it to libzpci and rename it to zpci_get_nvme_device_node() to
account for the change in namespace.

It would be tempting to pass a struct zpci_dev* instead of a const char*
but as zpcictl uses an incompatible struct zpci_device* this will
require a larger rework. Prioritize minimizing code duplication for now.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
113e9ebfef zpcimon: Split optics monitoring out into separate monitor
Introduce the concept of a generic zPCI device monitor by creating the
zpcimon_ops operations struct turning all optics specific calls into
abstract monitor calls. Handle monitors as a static array of zpcimon_ops
based monitors of which the now split out optics monitor is currently
the only one. All operations are in principle optional though a monitor
which provides an init operation must also provide the corresponding
destroy operation.

Keep the base64 based JSON pair as non optics specific for later re-use
and make it just skip the output in the very unlikely case that encoding
fails. In follow on commits a monitor for NVMe devices collecting SMART
data will be added.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
f9ef8a0106 util_time: zpcimon: Use a constant for seconds per day
Replace the magic value 86400 with a new util_time.h constant
SEC_PER_DAY.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
2c63c69af4 zpcimon: Allow setting output format and use JSON Lines in systemd unit
Introduce separate '--format' option to set output format. Use the new
JSON Lines format explicitly in the systemd unit. Since JSON Lines
format only uses printable characters this removes the need for passing
'-a' to systemctl status. At the same time JSON-SEQ is more easily
parsable using 'jq --seq' so keep it the default for easier scripting.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
8a4a4e0557 libutil/util_fmt: Add util_fmt_type_to_name()
Add a function to get the textual name of an enum util_fmt_t value. To
make this robust to changes in the order of elements in the format array
initialize this using named indices.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
e8550a4f8d opticsmon: zpcimon: Rename opticsmon to zpcimon
The opticsmon tool started out as a tool for monitoring the health of
optical modules in directly attached PCI NICs. In the future however it
will also monitor the health of other PCI devices. In particular in
a first step it will monitor the health of directly attached NVMe
devices.

To reflect this broadening of its scope rename opticsmon to zpcimon. Add
zpcimon.service and install it both under the new name and symlinked as
opticsmon.service for backwards compatibility. Since users are expected
to mostly just enable the service this keeps old instructions just
working.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
e7bc4a5d31 opticsmon: Enforce 1 second as minimal interval
So far it was possible for the user to specify an interval of 0 which
would result in not re-arming the timer at all thus disabling interval
based data collection. While this would still do optics data collection
on startup and link changes the intention is to collect data at least
every 24 hours. If interval is given as 0 treat this as minimum update
interval of 1 second.

Fixes: c34adb9cab ("opticsmon: Introduce opticsmon tool")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
8b38bf37b0 opticsmon: Fix wrong size check for OPTICS_QSFP28_LOS_IMPLEMENTED_OFFSET
The code accesses OPTICS_QSFP28_LOS_IMPLEMENTED_OFFSET so the size needs
to be one larger for the LOS to be accessible.

Fixes: c34adb9cab ("opticsmon: Introduce opticsmon tool")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
3696d6bd08 opticsmon: Handle error return of ethtool_nl_connect()
Don't just ignore the return of ethtool_nl_connect(). This would also
otherwise lead to invalid socket accesses later. Also make
ethtool_nl_connect() return negative error values instead of
EXIT_FAILURE.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
6847b6a8cf opticsmon: Fix error path free of struct optics in ethtool_nl_get_optics()
When ethtool_nl_get_optics() fails after ethtool_nl_cb() has allocated
oi->raw this memory would leak because only the struct optics* itself
was freed. Fix this by using optics_free() and relying on free(oi->raw)
being a no-op for NULL pointers in combination with using util_zalloc()
to handle errors both before and after oi->raw was allocated.

Fixes: c34adb9cab ("opticsmon: Introduce opticsmon tool")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
1f339a9e7e opticsmon: Return errors from monitor_wait_loop() in monitor_mode()
Don't ignore the return value of monitor_wait_loop() but instead forward
it to the caller.

Fixes: c34adb9cab ("opticsmon: Introduce opticsmon tool")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
905c3921af opticsmon: Close epoll fd in monitor_wait_loop()
The epoll fd (epfd) in monitor_wait_loop() is never closed. Close it in
all return paths. Also there is no explicit check for an error return of
epoll_create1() add that too.

Fixes: c34adb9cab ("opticsmon: Introduce opticsmon tool")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Niklas Schnelle
e55e0e470a opticsmon: Fix wrong JSON print for tx_fault
The "tx_fault" field in the JSON output accidentally contained the
rx_los value instead of the tx_fault one. Change it to the correct
value. Note that this does not impact the data relayed to firmware as
that uses the raw module data.

Fixes: c34adb9cab ("opticsmon: Introduce opticsmon tool")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00
Jan Höppner
9d9fca6e72 Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 18:49:20 +02:00
Jan Höppner
2a6657dfd1 New release s390-tools-2.43.1
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 18:46:13 +02:00
Hendrik Brueckner
b3dd05e16d iucvterm/ts-shell: Add Perl taint tests for auditdir and getpwuid()
The audit directory ts-shell configuration and also the output of
getpwuid() are considered tainted when running in Perl taint (-T) mode.

Provide untaint checks with validating the content.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
f216862052 iucvterm/ts-shell: Split reading and checking configuration
The updateConfiguration() function updates and checks the ts-shell
configuration for each line in the ts-shell configuration file.

Run the checks just once after the configuration is completely read.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
e4aeeef8eb iucvterm/ts-shell: Introduce config parameter to specify iucvconn binary
Introduce a configuration setting to allow administrators to specify
path to the iucvconn binary as part of the ts-shell configuration.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
c911419121 iucvterm/ts-shell: Validate guest name before constructing the audit file
The guest name is provided on the CLI and needs to be validated before
the file path to the session audit file is constructed.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
e6de495daa iucvterm/ts-shell: Improve regex for matching terminal identifier
Anchor the regex to no longer match a part within the terminal
identifier.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
419d93bef7 iucvterm/ts-shell: Corrections to run in Perl Taint (-T) mode
Perl provides a Taint (-T) mode which tracks data that is obtained
by external means (e.g. arguments, reading file contents, environment
variables, ...)

Introduce a first set of corrections to clear and validate data
obtained from external sources.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
2714f1d90e iucvterm/ts-shell: Introduce pager config to replace env variable
Do not obtain the pager program through the PAGER environment
variable.  Instead, introduce a configuration setting to specify
the pager program as part of the ts-shell configuration.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
10ec3f18fc iucvterm/ts-shell: Correct user/group names being interpreted as regex
When ts-shell creates the authorization for current user, the
user name and group names are interpreted as regex.  This might
create additional authorizations which are not permitted for
current user.

Correct this behavior by quoting the user name in the regex.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
0c771423b4 iucvterm/iucvtty: Ensure PTY and server fd's are closed at exec
Check the return code of fcntl() calls to ensure the close-on-exec
setting succeeded.  Otherwise, the PTY and server file descriptors
would become available to the forked client process.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
f67fa03581 iucvterm/iucvtty: Prevent connection stalls when receiving TERM env
iucvtty expects to receive the TERM environment information right
after a connection has been established. Reading this information
can lead to a connection stall (DoS).  Introduce a temporary timeout
and fall back to the default TERM environment.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
29db9032b3 iucvterm: Improve received message type and length checking
The iucvtty_read_msg() now receives the entire message header.
Perform message header checks for specific message types where the
payload length is clearly defined.  Also this needs to be done prior
starting the message chunk processing because the message datalen
field will be adjusted based on the read chunks.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:06 +02:00
Hendrik Brueckner
56a55901c1 iucvterm/tests: Update test cases to use iucvtty_skip_msg_chunk()
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:45:04 +02:00
Jan Höppner
43edafd088 iucvterm/tests: Remove unused termio.h
The inclusion of termio.h leads to the following compilation error:

  CC          iucvterm/tests/test_functions.o
test_functions.c:16:10: fatal error: termio.h: No such file or directory
   16 | #include <termio.h>
      |          ^~~~~~~~~~

The termio ioctl interface has been obsolete for a very long time and
was replaced by termios. termio.h was still present for compatibility
but was removed with glibc 2.42.
iucvterm uses termios.h correctly in the tool. The test however not only
includes termio.h erroneously, it doesn't even require it. Remove the
inclusion of termio.h.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Hendrik Brueckner
b1e3ee255f iucvterm: Improve receiving of IUCV terminal messages
If iucvtty_read_data() receives message data and reads less than
MSG_DATA_OFFSET, out-of-bound reads will happen.

Correct and improve the receiving path by always reading the entire
message header. Also improve the "residual" message data handling by
replacing and processing every message now as chunk.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Hendrik Brueckner
a69a46eafd iucvterm/iucvtty: Close PTY slave fd after fork
The PTY slave file descriptor is the controlling terminal
allocated for the child process.  When all file descriptors
are being closed, a SIGHUP is triggered for the child process.

Keeping the file descriptor in the parent open would prevent
the SIGHUP to be delivered to the child process.

For proper SIGHUP processing, close the file descriptor in
the parent process.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Hendrik Brueckner
c85b4e54dd iucvterm/iucvtty: Validate TERM environment name
Improve handling of TERM environment processing by validating
the received terminal name.  If the terminal name is not valid,
a message will be displayed and the default terminal will be used.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Finn Callies
da4b881eac 95sel-ebc: Add umount to boot service
Explicitly unmount the root partition on unit stopping to prevent still
mounted boot partition on switch root which results in boot being unable
to be mounted after switch root.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Finn Callies
9f03ddf519 95sel-ebc: Add udev-settle dependency
Since this unit cannot have a dependency on the actual needed
dev-disk-by2xdlabel-boot.device unit because it might not exist if the
label is never set but this unit has to run after it when it does exist
wait for udev-settle which creates the symlink if it does exist.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Aswin Karuvally
a05935cca9 osasnmpd: Fix SNMP non-compliance
Update osasnmpd to support Object ID Sub-IDs with length up-to and
including 10 digits, in line with SNMP specification. While at it, also
replace sprintf() calls with snprintf(). Together, these changes
contribute to better memory safety.

Suggested-by: Alexandra Winter <wintera@linux.ibm.com>
Reviewed-by: Hidayath Khan <hidayath@linux.ibm.com>
Signed-off-by: Aswin Karuvally <aswin@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Marc Hartmayer
6f9f846bc0 pv: verify_chain: Use error statements instead of debug
These messages indicate verification failures and are therefore reported
as errors rather than debug output. Unfortunately,
X509StoreContext::init(...) expects the callback to return an OpenSSL
ErrorStack, so it's not possible to propagate these failures through our
own error hierarchy.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Marc Hartmayer
603a2b1762 pv: Increase flexibility of verify_chain()
Increase the flexibility of verify_chain and reduce the need of using
clone.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Marc Hartmayer
dcece3f980 pv: Fix typo
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Marc Hartmayer
ff19180f03 pv: Add root CA organization pinning to certificate verification
Enforce root CA organization name requirements during certificate chain
validation to prevent accepting certificates from unexpected root CAs.

Add RootCaVerification enum with RootCaOrganizationPinning and
SkipPinning variants. Extend verify_chain() to validate root CA
organization. Default to pinning "DigiCert" for standard trust chains,
skip pinning when custom root CA is provided.

Assisted-by: IBM Bob:1.0.6
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-22 17:44:10 +02:00
Gerald Schaefer
42eba67268 mon_procd: Fix possible static buffer overflow
The command line length value is not properly checked and limited to the
documented 1024 bytes, even though a MAX_CMD_LEN is already defined but
not used.

With this, an overflow of the static char mon_record[] buffer is possible
in read_cmdline(), corrupting adjacent .bss data. The data is sanitized to
printable ASCII bytes, but in theory a crash of the mon_procd daemon could
be possible.

Fix it by adding a check and truncation similar to the other restricted
fields like e.g. ruser_len or cmd_len.

Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Peter Oberparleiter
3cf95a1d92 zdev: Harden against invalid udev data
Reduce chances of unintended side-effects when importing udev
data which might have been corrupted.

Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Peter Oberparleiter
5e93b53f78 zdev: Harden against invalid import data
Reduce chances of unintended side-effects when importing device
configuration data which might have been corrupted.

Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Peter Oberparleiter
360e8d4156 zdev: Harden against invalid firmware data
Reduce chances of unintended side-effects when evaluating firmware
data which might have been corrupted.

Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Peter Oberparleiter
a048670bec zdev: Harden against invalid hypervisor data
Reduce chances of unintended side-effects when evaluating hypervisor
data which might have been corrupted.

Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Volkan Unal
4ca93aa808 fdasd: Fix memory leak in yes_no() function
The yes_no() function was leaking memory when returning
early from the loop, as the 'answer' buffer allocated by
getline() was not freed before the return statements.

Restructure the function to use a single exit point, ensuring
free(answer) is always called before returning.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Volkan Unal <vunal@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Eduard Shishkin
9a5886c0b3 zipl/src: Check keyword duplications in BLS entries
sort_bls_entries() already checks for the keyword "title"
duplication. Add also checks for keywords "linux", "initrd", and
"options" duplication (Rule #5).

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Eduard Shishkin
78676df2f0 zipl-editenv: Check in-bootmap environment block validity
Check decimal prefixes, representing site values in on-disk
environment block. Reject any values different from {0, ..., 9}
as invalid ones.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Eduard Shishkin
224e35b600 zipl/src: Check file trailer
Before extracting a file trailer, check that the file is big enough;
Check that signature length stored in the extracted trailer doesn't
exceed the size of the file without the trailer. Treat the case of
the failed checks as unsigned file.

Without the checks, memcmp() may read the area before the allocated
@buffer, dumping heap into bootmap or crashing.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Eduard Shishkin
bd52e14740 zipl/boot: Check in-bootmap environment block syntax
When parsing environment block, check each its line for the
compliance with the 'foo=bar\n' pattern. In case of missing '=',
or '\n' abort the parsing procedure with a warning message.

Without this check, stage3 may write a zero byte to the absolute
address 0 (robustness defect)

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Eduard Shishkin
dd380942ed zipl/boot: Limit the hash table size when parsing environment block
When parsing environment block, limit the number of the hash table
entries, so that total size of all records doesn't exceed PAGE_SIZE
bytes allocated for that hash table.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Eduard Shishkin
9ce9ed72a9 zipl/boot: Fix the bounds check in the command line processing
By design, before replacement of '${FOO}' with its value, the
procedure checks that the resulted command line doesn't exceed the
maximum one.
The old check used the never updated length of the original command
line, which is incorrect. Instead, use its current length resulting
from the replacement happened at the previous iteration.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Mikhail Zaslonko
a8a87779c0 zdump/dfi_lkcd: Validate LKCD page address against mem_end
mem_init_flex() allocates the page header index array sized for
ADDR_TO_IDX(mem_end) + 1 entries, but never checked that each
page record's address falls within [0, mem_end).
A crafted LKCD page record with addr >= mem_end writes 8 bytes
beyond the allocation.

Fix by rejecting any page record whose address is > mem_end - PAGE_SIZE
with ERR_EXIT(), immediately after the end-of-dump marker check.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Mikhail Zaslonko
cdabf280ac zdump/dfi_lkcd: Validate LKCD page size before buffer read
read_page_buf() uses the file-controlled pg_hdr->size directly as the
byte count for zg_read() into fixed stack buffers of PAGE_SIZE.
A crafted LKCD dump with pg_hdr->size > PAGE_SIZE overflows the buffer
and smashes the stack frame. A size of 0 for a raw page silently
produces uninitialised data.

Enforce page header size constraints following crash-utility's logic:
- Compressed or Raw pages with size > PAGE_SIZE are invalid;
  exit with an error.
- Raw pages with size 0 contain no data in the file; fill the
  output buffer with zeros without reading.
- Compressed pages with size 0 are caught by the uncompress() return
  code check.
- Raw pages with size != PAGE_SIZE are invalid; exit with an error.

Check the return code of uncompress() and exit with an error if
decompression fails, rather than silently proceeding with an incomplete
output buffer.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Marc Hartmayer
33c75584cd zipl: Fix -Wstringop-overread warning in IMPORT_DATA macro
Declare binary data symbols as arrays to correctly represent
linker-provided symbols of unknown size. This resolves compiler warnings
about reading 22-24 bytes from a 1-byte region when including stage*
loaders.

DEBUG: In function ‘memcpy’,
DEBUG:     inlined from ‘boot_init_eckd_ldl_stage0’ at boot.c:181:2,
DEBUG:     inlined from ‘install_svdump_eckd_ldl’ at install.c:891:2,
DEBUG:     inlined from ‘install_dump’ at install.c:1221:9,
DEBUG:     inlined from ‘main’ at zipl.c:185:9:
DEBUG: /usr/include/bits/string_fortified.h:29:10: warning: ‘__builtin_memcpy’ reading 22 bytes from a region of size 1 [-Wstringop-overread]
DEBUG:    29 |   return __builtin___memcpy_chk (__dest, __src, __len,
DEBUG:       |          ^

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Alexander Egorenkov
1f68c1aaf3 zdump/ngdump: Perform sanity checks on path to dump image
Ensure that the path to a dump image specified in the NGDump meta file
of a dump device points to a valid location within the dump device.
Especially, disallow escaping from a dump device with a dump image path
using references to '..' or symbolic links pointing outside of the dump
device.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Alexander Egorenkov
6c6938d1e2 zdump/ngdump: Use OpenSSL's SHA256 to compute digest of dump image
Replace the popen() call to the external tool sha256sum with OpenSSL's
SHA256 digest algorithm to compute the checksum of a dump image
to improve security of NGDump.

The call to popen() is inherently insecure because a malicious user
controlling a dump device could manipulate the latter and let the user
applying zgetdump to the dump device execute arbitrary shell code.

Furthermore, getting rid of process and shell spawning performed by
popen() shall improve performance of calculation of dump image
checksums.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Alexander Egorenkov
90ad42d814 zdump/zg: Use fstat() to obtain file information in zg_open()
Use the file descriptor opened in zg_open() before to obtain information
about the file. Theoretically, there is a tiny window for a race
condition between opening a file and obtaining its information with
stat(). A malicious user could use it to entice incorrect behavior
from zgetdump. Using the same file descriptor for both operations
prevents such situations.

Suggested-by: Peter Jin <pjin@linux.ibm.com>
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Alexander Egorenkov
cf7c74b2dc zdump/ngdump: Include header zg.h in ngdump.h
Add the missing header include statement because some function
declarations use struct zg_fh from zg.h.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Alexander Egorenkov
4388a6d299 zdump/ngdump: Remove prefix 'ngdump_' from the name of private functions
The name of a private NGDump function does not require to have a unique
prefix to avoid naming conflicts with public functions of other C modules.
Furthermore, be consistent with private NGDump functions not having
the prefix 'ngdump_'.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Mikhail Zaslonko
44821d0586 zdump/dfo_elf: Include vmcoreinfo note size in ELF header allocation
dfo_elf_init() allocates the output ELF header buffer based on
HDR_BASE_SIZE, per-CPU note sizes, and per-memory-chunk overhead,
but does not account for the vmcoreinfo note. notes_init() then
writes the full vmcoreinfo string into the buffer via nt_vmcoreinfo(),
overflowing the heap allocation for any dump with a vmcoreinfo blob
larger than what fits in HDR_BASE_SIZE. The following ABORT check
fires after the heap was already corrupted.

Fix by extracting the allocation size calculation into a new
hdr_alloc_size() function that explicitly accounts for all items
written into the header buffer.
Remove the opaque HDR_BASE_SIZE and HDR_PER_MEMC_SIZE macros.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Mikhail Zaslonko
405b2da3f3 zdump/dfi_vmcoreinfo: Validate vmcoreinfo value length before memcpy
vmcoreinfo_item() copies a key's value string from the vmcoreinfo heap
blob into the caller's buffer using memcpy() without checking the source
length. The length is derived from the distance between the '=' separator
and the next '\n' (or '\0') in the blob, which is bounded only by the
total vmcoreinfo size. A crafted dump with a vmcoreinfo value >= 1024
bytes would overflow the buffer.
Additionally, the len parameter of vmcoreinfo_item() was declared UNUSED
and never checked.
Fix by computing val_len before the copy and returning -1 if val_len >= len.
Change len type from int to size_t, which is natural for a buffer size,
drops the need for a negativity guard, and makes the call site passing
sizeof(str) type-consistent.
Write directly into the caller's buf, instead of going through the
intermediate str[].
Replace two strchr() calls with a single strchrnul().

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Mikhail Zaslonko
d3ac9f3365 zdump/dfi_vmdump: Validate ADSR sec5_len before buffer read
The 16-bit sec5_len field from the ADSR record was used directly as
the byte count for zg_read() and ebc_2_asc() into a pair of 1024-byte
stack buffers.  A crafted VMDUMP file with sec5_len > 1024 would
overflow both buffers and write past the stack frame.

The overflow is only reachable when zgetdump is invoked with the -V
(verbose) flag, but that is a common diagnostic usage.

Section 5 contains a human-readable dump symptom string used only for
display purposes.  Truncate sec5_len to sizeof(buf) - 1 so that
oversized values are silently clamped rather than causing an abort,
and the symptom string is still printed up to the buffer limit.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Ingo Franzki
7535682b1b zkey: Silence false positive -Wstringop-overflow= warning
Building with ASAN=1 produces the following warning:

    utils.c: In function 'sysfs_get_mkvps':
    utils.c:416:9: warning: writing 8 bytes into a region of size 0
                                                [-Wstringop-overflow=]
      416 |         memcpy(mk_reg->mkvp, &mkvp, sizeof(mkvp));
          |         ^
    In file included from utils.c:32:
    utils.h:51:17: note: at offset 4 into destination object 'mk_state'
                                                 of size 4
       51 |         int     mk_state;

This is a false positive, field mk_reg->mkvp is defined as an array of
u8 with a length of 16 elements, thus it is 16 bytes in size, and thus
more than long enough to copy 8 bytes into it.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Ingo Franzki
72f1a2e0a9 zkey: Fix typo
The word 'device' is spelled wrongly at 2 places.

Reported-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Ingo Franzki
220f51fb98 libseckey: Fix integer underflow for malformed SPKIs
When the BER encoded BITRSTRING field has a zero length, then skipping
the unused-bits byte that a BITRSTING normally contains will cause a
underflow and thus may cause an out of bounds read by the caller of
sk_ep11_parse_spki().

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Ingo Franzki
5ab3473442 libseckey: Fix length check in sk_cca_get_public_from_rsa_key()
Check for the size of struct cca_rsa_pub_key_section, instead of
struct cca_ec_pub_key_section.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Ingo Franzki
cf51aa1421 libseckey: Fix incorrect flag checking related to RSA X9.31
Use a bit-wise AND, not a logical AND to mask the flag out of the flags
field.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Ingo Franzki
b1d44876bd libseckey: FIx memory leak in error path (OpenSSL 1.1.1 only)
When EVP_PKEY_get0_EC_KEY(), EC_KEY_set_ex_data(), EVP_PKEY_get0_RSA()
or RSA_set_ex_data() fails, the function returns -EIO without freeing
the data struct or the data->key_blob that were allocated before.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Ingo Franzki
c006800bd5 libseckey: Fix length check of SPKI
Field spki_size is defined as size_t, so it can never be negative.
Before the check, sk_ep11_valid_ep11_blob() ensures that hdr->len is
never greater than key_token_length, so the subtraction can never
overflow the result, but it still can be zero.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:59 +02:00
Ingo Franzki
634095aa24 libseckey: Fix possible out of bounds read in sk_ep11_parse_der_tag()
For long-length field encoding, check if the number of length bytes
exceed the data size.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
b4f575abc4 libseckey: Fix possible endless loop for malformed CCA key tokens
A malformed CCA key token with a zero size section can cause an endless
loop in sk_cca_get_pka_section().

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
6c729fba9e libseckey: Fix error checking in SK_OPENSSL_init() (OpenSSL 1.1.1 only)
Fix the NULL-checks to test the variable that was just assigned.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
71503c0e7d libseckey: Fix wrong RSA public exponent value 257 assignment
Array element key_value_structure.public_exponent[0] is written twice,
but key_value_structure.public_exponent[1] is not set, leading to a
wrong public exponent value (i.e. 0x01) in the key value structure.

CCA key generation will fail is this case.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
5c8bd68f6f libseckey: Fix and document size query call with NULL key_token
Functions SK_CCA_generate_ec_key_pair(), SK_CCA_generate_ec_key_pair(),
SK_EP11_generate_ec_key_pair() and SK_EP11_generate_rsa_key_pair() are
supposed to allow parameter key_token to be NULL. In this case the
required buffer size is returned in key_token_length only.

This size query does not work because the parameter checking rejects
the call with a NULL key_token returning -EINVAL.

Currently the size query is not used by any known caller, but lets
correct it anyway.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
927f901969 libekmfweb: Fix size check of the response party info
The party info contained in the response might be of an arbitrary size.
Check for an overflow before allocating the party info buffer for the
combined request and response party info data. With a very large
response party info size, the combined size might overflow (i.e. wrap
around), causing a too small buffer being allocated and the following
memcpy's would cause an out of bounds write.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
35cc35894b libekmfweb: Fix integer overflow errors in base64 encode/decode functions
On large data sizes the calculation may cause an overflow, if done with
int type. Do the calculation with size_t instead to avoid an overflow.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
dfaa1791b7 libekmfweb: Fix error checking typos
Fix the error checking to check the correct variables using the right
conditions.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
52158e73fa libekmfweb: Fix invalid free in error path of parse_json_web_token()
Don't attempt to free the local function parameter 'signature', but the
memory where *signature points to.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
cc6f1a6d7b libkmipclient: Fix kmip_parse_decimal_uint() to reject negative numbers
Function strtoull() silently accepts a leading '-' and returns a large
positive number (two's complement wrap). Reject this by checking for
the minus character.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
866324bcd2 libkmipclient: Fix possible NULL pointer dereference
Function gmtime() might return NULL which would then be passed to
strftime(). Return an error in case gmtime() return NULL.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
7fd2421a2c libkmipclient: Detect possible length overflow situations
A deeply nested or pathologically large KMIP node tree crafted by a
malicious server can wrap the length calculation around to a small
value. Detect this and return an error in this case.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
66581d57f3 libkmipclient: Fix error checking in kmip_node_clone()
Check the right pointer after strdup.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
de688f350f libkmipclient: Fix invalid return of -1 for an unsigned int
Functions kmip_node_get_structure_element_count() and
kmip_node_get_structure_element_by_tag_count() return an unsigned int,
but the error case returns -1. This leads to a wrap around actually
returning 0xffffffff which the caller might interpret as a very large
number of elements.

Return 0 in case of an error instead.

Also fix some callers to not unconditionally subtract -1 from the
returned value,  but return an error if the returned value is zero.
These callers check the preconditions upfront, so the error case
won't be hit anyway.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
958ccb46c5 libkmipclient: Fix parsing of optional 'name' element
Duplicate the 'name_obj' string, not the 'tag_obj' that was previously
used.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
3ea90a2258 libkmipclient: Fix integer overflow with large value length
Limit the value_len to not be larger than INT_MAX, because later on
BIO_read() is called with value_len and it uses the int type for
length parameter and return value.

This check also prevents the 'value_len + 1' from overflow, because
value_len is a size_t and this accepts larger values than int (even
on 32 bit architectures).

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
7d56dde24a libkmipclient: Fix size underflow when padding bytes exceed remaining size
When decoding a value that is exactly at the boundary of the available size
(i.e., *size == value_len), and the value length is not a multiple of the
TTLV block length, then *size wraps to a huge value when the pad_len is
subtracted.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
c7d0d3c1b9 libkmipclient: Fix integer overflow in kmip_format_hex()
If length is >= 0x80000000 (2 GB), length * 2 wraps around to a small
value, calloc allocates a too small buffer, then the loop writes
length * 2 bytes into it causing a heap buffer overflow.

Fix this by using a size_t for size calculation, and also checking
the length before multiplication (needed on 32 bit platforms).

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
d7648875cc libkmipclient: Fix signed-integer overflow in TTLV tag/length byte-shift
In C, operands of '<<' are subject to integer promotion. So the unsigned
char array elements are promoted to signed int and then shifted producing
signed overflow — undefined behaviour in C.

Fix this by first casting to uint32_t and then shift.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
5fdeaab3d0 libkmipclient: Limit the nesting level of KMIP STRUCTURE recursion
KMIP STRUCTURE elements can be nested, which causes a recursion of
functions kmip_decode_ttlv(), kmip_decode_xml(), and kmip_decode_json().
A malformed KMIP response may thus cause stack exhaustion.

Limit the KMIP STRUCTURE nesting level to 32 levels. This is more than
enough for currently defined KMIP responses. The practically used
nesting level is 8 or 9, dependent on the type of KMIP response.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
f0bf1985c3 libkmipclient: Protect from symlink-following attacks
When creating or writing files, make sure that the file is not a
sysmlink. Such files created by libkmipclient are typically stored inside
the zkey repository and the owner and mode of them are changed to.
allow read/write for the owner user and the 'zkeyadm' group. It
would allow a symlink-following attack if the file being created are
symlinks. Make sure to open such files with the 'O_NOFOLLOW' flag.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
a3a2d70603 libekmfweb: Protect from symlink-following attacks
When creating or writing files, make sure that the file is not a
sysmlink. Such files created by libekmfweb are typically stored inside
the zkey repository and the owner and mode of them are changed to.
allow read/write for the owner user and the 'zkeyadm' group. It
would allow a symlink-following attack if the file being created are
symlinks. Make sure to open such files with the 'O_NOFOLLOW' flag.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
226728731c libseckey: Protect from symlink-following attacks
When creating or writing files, make sure that the file is not a
sysmlink. Such files created by libseckey are typically stored inside
the zkey repository and the owner and mode of them are changed to.
allow read/write for the owner user and the 'zkeyadm' group. It
would allow a symlink-following attack if the file being created are
symlinks. Make sure to open such files with the 'O_NOFOLLOW' flag.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
94292dac54 zkey: Protect from symlink-following attacks
Files in the zkey repository can be created by any member of the
'zkeyadm' group as well as 'root'. Such files are owned by the creator
and the 'zkeyadm' group, and allow read and write for the owner user
and owner group.

When creating or writing files inside the zkey repository, make sure
that the file is not a sysmlink. That way, only files within the zkey
repository are set to be read/write for the owner user and members of
the 'zkeyadm' group. Make sure to open such files with the 'O_NOFOLLOW'
flag, and use 'lstat()' to check for files and directories.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Ingo Franzki
278f4f6fd5 zkey: Check values before constructing a command to execute
Check the values that are incorporated into commands that might get
executed to not contain any characters that could be used for
shell-injection attacks.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Finn Callies
17007ab121 95sel-ebc: Harden boot mount service
Pin the supported filesystem type to ext4 to prevent the risk of auto fs
parsing bugs. Additionally mount the boot partition with more
restrictive options.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Finn Callies
4f9e5d7842 95sel-ebc: Reorder PAES enforcement service
Fix the sel-ebc-paes-enforce.service to run AFTER the sysroot.mount
which prevents a TOCTOU situation.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Finn Callies
8a52693acc 95sel-ebc: Fix SICS existence check
Fix the sel-ebc-pvebc.service unit to execute the failure action when
the sics directory does not exist instead of getting skipped.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Marc Hartmayer
a93146d976 pv: BinReqValues: Fix length validation in get()
Return an error when the provided request data is smaller than the
expected request length. The previous condition used the wrong
comparison, which could lead to an out-of-bounds slice and panic.

Add a regression test.

Fixes: 34bef977e8 ("rust/pv: User-data signing and verifying")
Assisted-by: IBM Bob:1.0.5
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Marc Hartmayer
187437c6c8 pv: Defer CRL downloads until certificate validation succeeds
Perform certificate verification in two stages. First, verify the
certificate chain without CRL checks. Once the chain has been validated,
download the referenced CRLs and repeat the verification with CRL
checking enabled.

Fixes: c6f621d0dc ("rust: Add library for pv tools")
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Marc Hartmayer
cdc787d92d pv: download_first_crl_from_x509: Increase the timeout to 10s
3-second timeout might be too short for slow networks therefore increase
it to 10s. In addition move this constant to a more prominent position
and add documentation.

Assisted-by: IBM Bob:1.0.5
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Marc Hartmayer
5feee12827 pv: Limit CRL download size
Add a dedicated HKD verification error for CRL downloads that exceed the
maximum file size of 10 MiB and cover the max_filesize behavior in the
helper tests and add tests for it.

This commit adds a new development/test dependency as it verifies that
the correct messages are being logged.

Fixes: c6f621d0dc ("rust: Add library for pv tools")
Assisted-by: IBM Bob:1.0.5
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Marc Hartmayer
cf70a27d76 pv: Restrict CRL downloads to HTTP(S) and limit redirects
Only allow CRL downloads over HTTP and HTTPS to avoid accessing
unexpected protocol handlers.

The Rust curl bindings do not expose support for configuring allowed
protocols or the maximum number of redirects [1][2][3]. Therefore,
redirect handling is implemented manually, validating each redirect
target and enforcing a maximum of five redirects.

The redirect limit also prevents infinite redirect loops.

[1] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS_STR.html
[2] https://curl.se/libcurl/c/CURLOPT_REDIR_PROTOCOLS_STR.html
[3] https://curl.se/libcurl/c/CURLOPT_MAXREDIRS.html

Fixes: c6f621d0dc ("rust: Add library for pv tools")
Assisted-by: IBM Bob:1.0.5
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Marc Hartmayer
5552b476bd pv: tests: Regenerate the fake certificates using http:// URL
Adapt the script to generate the test certificates to use the prefix
'http://' for the CRL distribution points as otherwise the test would
fail with an upcoming change. Regenerate the certificates and adapt the
test case dist_points' accordingly as the distribution point has
changed.

Note: The files der.crt and der.crl are skipped as that would result in
      binary changes which caues trouble with quilt. They are only used
      by some basic tests read_crls and read_crts anyway

Assisted-by: IBM Bob:1.0.5
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Marc Hartmayer
7510b96238 pv: Fix script to generate the test certificates
Fix datetime.datetime.utcnow() deprecation and fix a TypeError.

  File "create_certs.py", line 16, in createEcKeyPair
    return ec.generate_private_key(curve=curve, backend=default_backend())
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  TypeError: curve must be an EllipticCurve instance

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:58 +02:00
Marc Hartmayer
778d9e436a pv: Add more tests for testing the CRL download functionality
Add more tests for testing the CRL download functionality.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:57 +02:00
Marc Hartmayer
692af4058c pv: Rewrite CRL download tests
Replace the existing mocks with a trait-based test infrastructure. This
allows testing download_first_crl_from_x509() functionally while
avoiding actual network access, resulting in more comprehensive and
realistic test coverage.

Assisted-by: IBM Bob:1.0.5
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:57 +02:00
Marc Hartmayer
2565a4ca99 pv: verify: helper: Rename module test into tests
Rename the module to the more common test module name tests and remove a
superfluous comment.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:57 +02:00
Marc Hartmayer
6d5f4a99de pv: Refactor CRL download code for easier testing
Use a trait-based abstraction for CRL downloads so the download
implementation can be replaced more easily, for example in tests that
should avoid real network calls.

Assisted-by: IBM Bob:1.0.5
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:57 +02:00
Marc Hartmayer
a9ed19285a pv: download_first_crl_from_x509: Fix comment
The comment mentions certificate but it's a certificate revocation
list (CRL). In addition, use 1200 bytes as vector capacity as the
comment says 1200.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:57 +02:00
Marc Hartmayer
4eb18bd6b7 pv: download_first_crl_from_x509: Log errors
Although most errors are ignored and the next CRL distribution point is
tried, log the errors as debug messages.

Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:57 +02:00
Finn Callies
cf45a6e108 pvics: Fail on non-existend BLE
Issue an error if the specified boot loader entry cannot be found.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-20 15:25:57 +02:00
Marc Hartmayer
a879036e3f pv/error: Fix typo in BinArcbSeaSmall error message
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:06 +02:00
Marc Hartmayer
5340d11165 pv: test_utils: Add TEST-RAND generator for testing
Implement a test random number generator (RNG) using the TEST-RAND [1]
generator provided by OpenSSL. This allows writing tests for OpenSSL
functionality where OpenSSL internally uses RNGs, e.g. used for ML-KEM.

The implementation uses RAND_set0_public [2] to set the
thread-local RNG, which requires OpenSSL >= 3.1.

[1] https://docs.openssl.org/3.0/man7/EVP_RAND-TEST-RAND/
[2] https://docs.openssl.org/3.1/man3/RAND_set0_public

Assisted-by: IBM Bob:1.0.5
Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Acked-by: Timo Keller <tkeller@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:06 +02:00
Sven Schnelle
162a041077 cmsfs-fuse: Fix strip_right() function
strip_right() strips spaces beginning at the end of the string moving
to the beginning. However, it doesn't check whether it's at beginning
of the array, and would continue reading if the string only contains
spaces.

Fix this by adding the necessary check.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:06 +02:00
Sven Schnelle
b38d5833fa hmcdrvfs: Fix hmcdrv_path_copy()
While iterating over the string, hmcdrv_path_copy() subtracts one byte
of the length to account for the NUL byte, but fails to account for
the '/' character it might add. Change the test to leave two bytes of
room.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:06 +02:00
Eduard Shishkin
ee8897f9db zipl/src: Add ->set_location() private method of program component
Add/use ->set_location() private method of struct component_footer
instead of checking component types every time when operating with
program components.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:06 +02:00
Eduard Shishkin
4f622325ef zipl/src: Fix add_component_file_range()
Fix add_component_file_range() to process components of all types
(not only of COMPONENT_TYPE_LOAD), similar to how it is going in
add_component_buffer().

Earlier components of COMPONENT_TYPE_SIGNATURE were processed only
by add_component_buffer(). Starting from 60bc1e3, signatures for
mirrors (i.e. base disks of #1 and larger ID) are processed also by
the function add_component_file_range(), which works incorrectly for
such type of components.

Fixes: 60bc1e38d0 ("zipl/src: Reuse data of buffer components in bootmap")
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:06 +02:00
Eduard Shishkin
f2902a1990 zipl/src: Fix alignment of componets location in bootmap file
Calculate the alignment value as maximum of physical block sizes of
disks participating in the mirrored setup. Earlier the alignment was
calculated as a physical block size of the first disk of a mirrored
setup.

Without this change, the assertion in disk_get_blocklist_from_file()
'assert(reg->offset % info->phy_block_size == 0)' is triggered in case
when blocksize of base disk #J > blocksize of base disk #I && (J>I).
To reproduce the problem, build a mixed mirrored setup with first SCSI
disk, second DASD disk and prepare it for IPL.

Fixes: 731f00202c ("zipl/src: Enable heterogeneous mirrors support")
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:06 +02:00
Eduard Shishkin
9882aabe44 zipl/src: Update format of zipl helpers output
Change the format of zipl helpers output to support hybrid mirrors
(i.e. composed of disks of different types and geometry).
The new format imposes an additional requirement that any key-value
pair "targetbase=X:Y" titles a new section with a set of target
parmeters for the base disk identified by that pair.

Without this change, zipl reports "Inconsistent script output".
To reproduce the problem, build a mixed mirrored setup with first
SCSI disk and second DASD disk, and prepare it for IPL.

Fixes: 731f00202c ("zipl/src: Enable heterogeneous mirrors support")
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:06 +02:00
Marc Hartmayer
d06d197522 pv: Fix unfulfilled_lint_expectations warning
The test cases uses the ml_kem functions, therefore disable the
directive for tests.

$ cargo test
...
 --> pv/src/openssl_extensions/ml_kem.rs:5:11
  |
5 | #![expect(unused)]
  |           ^^^^^^
  |
  = note: `#[warn(unfulfilled_lint_expectations)]` on by default

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:06 +02:00
Mikhail Zaslonko
3fd07bb7f2 zdump/df_vmdump: Add a documentation link to the header file
Add a link to 'CP Data Areas and Control Blocks' manual.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:06 +02:00
Ingo Franzki
58ede126cc zkey: Retry PKEY_KBLOB2PROTK3 ioctl in case of EBUSY
After a master key change, it can happen that the PKEY_KBLOB2PROTK3 ioctl
returns EBUSY. This is a temporary situation and the operation will
succeed, once the firmware has completed some internal processing related
with the master key change. Delay 1 second and retry up to 10 times.

A similar retry loop was previously used for the AF_ALG-based handling,
but the retry logic was not included for the new ioctl-based handling.

Fixes: 7fffdcfe8c ("zkey: Remove the use of AF_ALG for calculating key verification patterns")
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:05:03 +02:00
Volkan Unal
e4a03c6f71 dasdfmt: Check disk type before prompting for blocksize
Move check_disk() call before user input to fail fast
on unsupported or unavailable devices (FBA, read-only,
in-use, raw-track mode).

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Volkan Unal <vunal@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-03 12:01:58 +02:00
Jan Höppner
c66495888d Prepare for next release
Signed-off by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:49:06 +02:00
Jan Höppner
f85c8ebba0 New release s390-tools-2.43.0
Signed-off by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:49:06 +02:00
Marc Hartmayer
e4e455630b pv + tools: Introduce versioned HostKey and Keyslot enums
Add a HostKey enum (currently V1(PKey<Public>)) and introduce a
versioned Keyslot enum (V1(KeyslotV1)). Rename the existing Keyslot type
to KeyslotV1 to prepare for future format extensions.

Update pv, pvattest, pvimg, and pvsecret to use the new enums.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:45 +02:00
Timo Keller
d82beef937 pv: Implement Display for SymKey based on key_type()
Add a Display implementation for SymKey that formats values as
`SymKey(<type>)`, delegating to key_type(). This provides a clearer
and stable human-readable representation for logs and CLI output.

Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Marc Hartmayer
c3e61e5e0f pv: from_se_image: Return SE header version in addition to tags
Return the Secure Execution header version in addition to tags. This
comes handy as soon as multiple Secure Execution header versions are
supported.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Marc Hartmayer
f04e46baf0 pv: req: Improve documentation and fix typos
Improve documentation and fix typos.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Marc Hartmayer
e93bd7e61c pv: req: Split into multiple files
Split req.rs into multiple files so that additions can be done more
easily.

Assisted-by: IBM Bob:1.0.4
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Timo Keller
edf40976f0 pv: Add OpenSSL ML-KEM bindings
Add interfaces for creating an ML-KEM keypair and encapsulation and
decapsulation.

The public part of it can be used to encapsulate a shared secret in a
ciphertext. The latter can be decapsulated with the private part of the
keypair to recover the shared secret.

In terms of code, a keypair of type `PKey<Private>` can be generated
with `generate_ml_kem` specifying `KeyType::ML_KEM_512`,
`KeyType::ML_KEM_768`, or `KeyType::ML_KEM_1024`.

To encapsulate a shared secret, generate a `PkeyCtx<Public>` with
`PkeyCtx::new`, initialize it with `encapsulate_init`, and encapsulate
with `encapsulate_to_vec`.

To decapsulate the ciphertext to the shared secret, generate a
`PkeyCtx<Private>` with `PkeyCtx::new`, initialize it with
`decapsulate_init`, and decapsulate with `decapsulate_to_vec`.

Note that when https://github.com/rust-openssl/rust-openssl/pull/2532
is getting merged into `rust-openssl`, these changes will become
unnecessary.

Assisted-by: IBM Bob:1.0.4
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Timo Keller <tkeller@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Marc Hartmayer
e557f41c6e pvimg: Unignore a Rust doctest
While at it, improve it.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Marc Hartmayer
68fe816da9 pvimg: Add more CCK tests
Add more CCK tests to make sure that new changes do not introduce a
regression.

Assisted-by: IBM Bob:1.0.4
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Marc Hartmayer
367ca6e16b pvimg: Add comment why cck and not cck-available is required
Add a comment to the code to explain why cck and not cck-available is
required.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Volkan Unal
6c67f05ca7 dasdinfo: Fix memory leak in dinfo_get_uid_from_devnode()
The function dinfo_get_uid_from_devnode() allocates memory for
readbuf but fails to free it in two code paths:
1. When the device name is truncated (error path)
2. At the successful function exit

Add the missing free(readbuf) calls to prevent memory leaks in
both paths.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Volkan Unal <vunal@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Jörn Siglen
4887e80995 dbginfo.sh: Add IBM appliance specific files
Some IBM appliance has additional config data /etc/fpc files or directory

Reviewed-by: Mario Held <mario.held@de.ibm.com>
Signed-off-by: Jörn Siglen <siglen@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Steffen Eiden
74a338edfc pvattest: Expand HTTPS timeout to 2 min
Match the clients timeout to the servers timeout.

Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Steffen Eiden
8878ba4fd2 pvattest: Add firmware check version 2
Add Response version 2 which includes more details about the
verification process.

Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Steffen Eiden
e53f5ccfea pvattest: Refactor firmware checking
Refactor the firmware verification client such that adding a new
request/response versions is simpler.

Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Jan Polensky
6e7eb62ea1 cpumf/lshwc: Show explicitly selected unnamed counters with --hide
When an unnamed counter is explicitly selected by numeric ID via
--counters (for example, --counters=218), show it even when --hide is
enabled.

Keep --hide effective for unnamed counters that were not explicitly
selected. To do that, evaluate the counter filter once per counter and
reuse the result to distinguish between a generic match and an explicit
numeric-ID match.

Suggested-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:44 +02:00
Eduard Shishkin
2bb61f96c0 zipl/src: Make use of newly introduced verbosity classes/levels
Assign VERBOSITY_DEBUG class to the message printing information
about zipl helpers called by zipl tool.

Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:43 +02:00
Eduard Shishkin
a902fd9afe zipl/src: Introduce verbosity levels of zipl session
Introduce verbosity levels of zipl session and verbosity classes of
messages. This is used by the next patches in the series to suppress
information not corresponding the default output of zipl tool that
could be confusing for user.

Add a new option "--debug" of zipl tool to set up verbosity level 2
(and higher) of zipl session.

Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:43 +02:00
Finn Callies
dc42460d82 scripts/pvics: Fix virt-resize permission error
Although the script is to be run with root privileges virt-resize starts
as user qemu under the hood which depending on image location may cause
permission errors. To fix this use `LIBGUESTFS_BACKEND=direct`.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:43 +02:00
Marc Hartmayer
6689e25865 rust: Fix all cargo clippy findings
- Remove useless type conversion in uvdevice.rs
- Replace useless comparison in hostname.rs
- Replace unnecessary unwrap patterns in pvapconfig
- Use sort_by_key instead of sort_by in pvimg example

Command line used to get the findings:

  $ clippy --all-features -- --cap-lints=warn
  warning: useless conversion to the same type: `u64`
    --> pv_core/src/uvdevice.rs:56:28
     |
  56 |         rc = ioctl(raw_fd, cmd.try_into().unwrap(), cb.as_ptr_mut());
     |                            ^^^^^^^^^^^^^^
     |
     = help: consider removing `.try_into()`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
     = note: `#[warn(clippy::useless_conversion)]` on by default

  warning: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
    --> utils/src/hostname.rs:60:13
     |
  60 |     assert!(isize::try_from(buf_len).unwrap() <= isize::MAX);
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: because `isize::MAX` is the maximum value for this type, this comparison is always true
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
     = note: `#[warn(clippy::absurd_extreme_comparisons)]` on by default

  warning: `utils` (lib) generated 1 warning
      Checking pvebc v0.12.0 (/home/mhartmay/git/s390-tools/rust/pvebc)
  warning: consider using `sort_unstable_by_key`
     --> pvapconfig/src/ap.rs:177:9
      |
  177 |         self.0.sort_unstable_by(|a, b| b.gen.cmp(&a.gen));
      |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by
      = note: `#[warn(clippy::unnecessary_sort_by)]` on by default
  help: try
      |
  177 -         self.0.sort_unstable_by(|a, b| b.gen.cmp(&a.gen));
  177 +         self.0.sort_unstable_by_key(|b| std::cmp::Reverse(b.gen));

  warning: called `unwrap_err` on `r` after checking its variant with `is_err`
    --> pvapconfig/src/main.rs:55:29
     |
  54 |         if $r.is_err() {
     |         -------------- help: try: `if let Err(<item>) = r`
  55 |             eprintln!("{}", $r.unwrap_err());
     |                             ^^^^^^^^^^^^^^^
  ...
  87 |     on_error_print_and_exit!(r);
     |     --------------------------- in this macro invocation
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
     = note: this warning originates in the macro `on_error_print_and_exit` (in Nightly builds, run with -Z macro-backtrace for more info)

  warning: this `repeat().take()` can be written more concisely
    --> pvimg/src/se_img_comps/bootloader/ipl.rs:95:21
     |
  95 |           let comps = iter::repeat(ipl_pb0_pv_comp::default())
     |  _____________________^
  96 | |             .take(num_comp)
     | |___________________________^ help: consider using `repeat_n()` instead: `std::iter::repeat_n(ipl_pb0_pv_comp::default(), num_comp)`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_repeat_n
     = note: `#[warn(clippy::manual_repeat_n)]` on by default

  warning: this `repeat().take()` can be written more concisely
     --> pvimg/src/se_img_comps/bootloader/ipl.rs:113:21
      |
  113 |         let comps = iter::repeat(comp).take(num_comp).collect();
      |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `repeat_n()` instead: `std::iter::repeat_n(comp, num_comp)`
      |
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_repeat_n

Reviewed-by: Timo Keller <tkeller@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:43 +02:00
Marc Hartmayer
20f6791fb4 pvapconfig: Suppress unnecessary unwrap warning
The current code is easier to read as the suggested fix by Clippy.
Therefore adding directives to allow the unwrap.

  warning: called `unwrap` on `a1.info` after checking its variant with `is_some`
     --> pvapconfig/src/ap.rs:195:36
      |
  192 |                     && a1.info.is_some()
      |                        ----------------- the check is happening here
  ...
  195 |                     let i1 = match a1.info.as_ref().unwrap() {
      |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = help: try using `match`
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
      = note: `#[warn(clippy::unnecessary_unwrap)]` on by default

  warning: called `unwrap` on `a2.info` after checking its variant with `is_some`
     --> pvapconfig/src/ap.rs:199:36
      |
  193 |                     && a2.info.is_some()
      |                        ----------------- the check is happening here
  ...
  199 |                     let i2 = match a2.info.as_ref().unwrap() {
      |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^
      |
      = help: try using `match`
      = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap

Suggested-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:43 +02:00
Marc Hartmayer
f0a148fd0b rust: Fix cargo clippy false positives
Add allow attributes for intentional patterns in pvverify and pvsecret.

Command line used to get the findings:

  $ clippy --all-features -- --cap-lints=warn
  ...
  help: remove this field
    --> pvverify/src/cli.rs:22:5
     |
  22 |     version: (),
     |     ^^^^^^^^^^^
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive
     = note: `#[warn(clippy::manual_non_exhaustive)]` on by default
  help: use the `#[non_exhaustive]` attribute instead
     |
  16 + #[non_exhaustive]
  17 | pub struct CliOptions {
     |

  warning: struct `AddSecretOptComb` is never constructed
     --> pvsecret/src/cli.rs:313:12
      |
  313 | pub struct AddSecretOptComb<'a> {
      |            ^^^^^^^^^^^^^^^^
      |
      = note: `-W dead-code` implied by `-W unused`
      = help: to override `-W unused` add `#[expect(dead_code)]` or `#[allow(dead_code)]`

  warning: struct `ListSecretOptComb` is never constructed
     --> pvsecret/src/cli.rs:355:12
      |
  355 | pub struct ListSecretOptComb<'a> {
      |            ^^^^^^^^^^^^^^^^^

  warning: struct `RetrSecretOptionsComb` is never constructed
     --> pvsecret/src/cli.rs:490:12
      |
  490 | pub struct RetrSecretOptionsComb<'a> {
      |            ^^^^^^^^^^^^^^^^^^^^^

Assisted-by: IBM Bob:1.0.4
Reviewed-by: Timo Keller <tkeller@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:43 +02:00
Marc Hartmayer
390e48869e pvebc: Fix cargo doc warning
$ cargo doc
...
warning: unclosed HTML tag `u8`
  --> pvebc/src/ebc_utils.rs:25:43
   |
25 | /// Read all data from a reader into a Vec<u8>
   |                                           ^^^^
   |
   = note: `#[warn(rustdoc::invalid_html_tags)]` on by default
help: try marking as source code
   |
25 | /// Read all data from a reader into a `Vec<u8>`
   |                                        +       +

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-25 14:14:43 +02:00
Finn Callies
3635a19462 pvebc: Log services to journal+console
Change StandardOutput=console to StandardOutput=journal+console and
StandardError=console to StandardError=journal+console respectively for
the pvebc dracut module systemd services.

Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/205
Fixes: 3d679f61f ("pvebc: Disable unit logging to /boot")
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:03 +02:00
Ingo Franzki
584e785f5c zkey: Adjust the error message when calculating the KVP fails
The 'paes' and 'phmac' kernel ciphers and the respective kernel modules
are no longer used for calculating the key verification pattern. Instead,
the 'pkey' kernel module and its sub modules is used now.

In case the 'pkey' kernel module is not available, an appropriate error
message is already printed by open_pkey_device() when opening the device.

Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:03 +02:00
Ingo Franzki
7fffdcfe8c zkey: Remove the use of AF_ALG for calculating key verification patterns
Instead of using AF_ALG to calculate key verification patterns, transform
the key blob into a protected key and calculate the key verification
patterns with CAPCF calls.

The 'zkey-cryptsetup convert' command also calculates key verification
patterns from clear keys. Support this, too.

Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:03 +02:00
Ingo Franzki
44d6020774 zkey: Pass /dev/pkey file descriptor through to all functions
To be able to calculate the key verification pattern of a key blob without
the use of AF_ALG, the file descriptor of the /dev/pkey device needs to
be passed through to all functions that might need to calculate the key
verification pattern.

Also make sure that all commands that might need to calculate the key
verification pattern have 'need_pkey_device = 1' so that the device is
opened.

Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:03 +02:00
Ingo Franzki
30ce11b8da zkey: Add helper function to transform a key blob into a protected key
To be able to calculate the key verification pattern of a key blob without
the use of AF_ALG, the key blob needs to be transformed into a protected
key via the PKEY_KBLOB2PROTK3 ioctl.

Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:03 +02:00
Ingo Franzki
c7ab70df2c zkey: Fix possible out of bounds access with malformed property files
When reading a properties file with a line containing a binary zero as first
character, an array access at index -1 is attempted, because strlen considers
this as an empty string (len = 0). The following array access 'line[len - 1]'
accesses the array at index -1.

Fix this by checking the line length and skip empty lines.

Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:03 +02:00
Ingo Franzki
c953486dec zkey-cryptsetup: Fix handling of 'hmac(sha512)' integrity algorithm
Fix a copy & paste error on handling the 'hmac(sha512)' integrity algorithm
with the 'convert' command.

Fixes: 97136585da ("zkey-cryptsetup: Support PHMAC integrity with convert command")
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:03 +02:00
Ingo Franzki
610cc581da zkey: Fix file size checking in read_secure_key()
Key files read by read_secure_key() may not be just a key blob, but it
might also contain an additional integrity key blob.

Correct the upper bounds checking and allow up to 3 key blobs to be read.
This allows for an AES-XTS key blob consisting of 2 key blobs plus an
integrity key blob concatenated to the encryption key blob.

Fixes: 771c794580 ("zkey-cryptsetup: Support PHMAC integrity with setkey command")
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Ingo Franzki
604c34e66b libkmipclient: Fix 'assignment discards 'const' qualifier' warnings
Fix compile warnings like

   warning: assignment discards 'const' qualifier from pointer target type
                                                   [-Wdiscarded-qualifiers]

by declaring the variables as const.

Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Ingo Franzki
e2cd2e78c5 libekmfweb: Fix 'assignment discards 'const' qualifier' warnings
Fix compile warnings like

   warning: assignment discards 'const' qualifier from pointer target type
                                                   [-Wdiscarded-qualifiers]

by declaring the variables as const.

Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Ingo Franzki
d04d331673 zkey/kmip: Fix 'assignment discards 'const' qualifier' warnings
Fix compile warnings like

   warning: assignment discards 'const' qualifier from pointer target type
                                                   [-Wdiscarded-qualifiers]

by declaring the variables as const or cast appropriately.

Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Ingo Franzki
27f20495a7 zkey: Fix 'assignment discards 'const' qualifier' warnings
Fix compile warnings like

   warning: assignment discards 'const' qualifier from pointer target type
                                                   [-Wdiscarded-qualifiers]

by declaring the variables as const or cast appropriately.

Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Stephen Gallagher
679ab77b96 Use EVP_PKEY_id() for OpenSSL 1.1 detection
The previous function, EVP_PKEY_meth_remove(), was deprecated in OpenSSL
3.0 and fully removed in OpenSSL 4.0. As a result, it fails detection of
OpenSSL 1.1+ if OpenSSL 4 is present.

Closes: https://github.com/ibm-s390-linux/s390-tools/pull/204
[seiden@linux.ibm.com: Add link to GH PR]
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Dan Horák
8bb20be528 ebc: implement --version option for pvics
For consistency reasons implement the --version option handling for the new
pvics tool.

Closes: https://github.com/ibm-s390-linux/s390-tools/pull/203
[seiden@linux.ibm.com: Add link to GH PR]
Signed-off-by: Dan Horák <dan@danny.cz>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Jan Höppner
d04ea8603d rust: Upgrade MSRV and dependencies
Bump MSRV to 1.85.0 and upgrade all dependencies using 'cargo upgrade'
from cargo-edit. The bump to 1.85.0 is requiered to get at least openssl
version 0.10.79 including fixes for a couple security issues.

Link: https://crates.io/crates/cargo-edit
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Steffen Eiden
51d2c92067 rust: Remove non_ascii_idents lint
This lint also covers dependencies that generate code i.e. derives.
Those dependencies might introduce non-ascii chars deliberately as e.g.
zerocopy 0.8.32+ does.

Remove it to avoid any confusing warnings regarding non-ascii chars.

Link: https://github.com/rust-lang/rust/issues/151025
[hoeppner@linux.ibm.com: Add link to reported issue]
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Marc Hartmayer
7e3b8b8c16 pvinfo: Remove comments after formatting the code
Remove them as they are pointless.

Suggested-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Marc Hartmayer
f8fb9ce32a rust: Run rustfmt with some experimental options
+ Sort and group the imports
+ Normalize and format comments (100 characters width)

Command used:

$ cargo +nightly fmt --

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Marc Hartmayer
3d5f75d6c3 rustfmt.toml: Enable additional formatting options
Enable more settings, including some that are currently unstable. Prefer
options that are also used by the Rust project itself [1].

[1] 64a965e901/rustfmt.toml (L5-L6)

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-06-22 16:43:02 +02:00
Jan Höppner
ddc8248b21 Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-22 16:34:46 +02:00
Jan Höppner
77083b1cbb New release s390-tools-2.42.1
Signed-off by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-22 16:34:32 +02:00
Thomas Richter
21c2a04347 cpumf/pai: Remove unnecessary const parameter definition
With glibc 2.43 const-ness is preserved for standard library functions
and a compiler warning will be issued if this is violated.

pai parse_cpulist() receives user input via the parm function
parameter. The parameter is defined as 'const char *' and used as input
value for strchr(). The target pointer (cp) is defined as mutable
'char *' leading to violation of const correctness and this compiler
warning:

pai.c: In function ‘parse_cpulist’:
pai.c:907:20: warning: assignment discards ‘const’ qualifier from
			pointer target type [-Wdiscarded-qualifiers]
  907 |                 cp = strchr(parm, ':');

Since the user input is coming from optarg 'non-const char *', it is
unnecessary to have the function parameters carrying this data defined
as const.

Remove the unnecessary const definition in the function call chain to
fix the described issue.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Suggested-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Suggested-by: Juergen Christ <jchrist@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-22 15:59:36 +02:00
Thomas Richter
8f2d77c9d3 cpumf/pai: Improve -m XXX argument verification
Speed up the check of the option -m argument and improve
the error message. The argument number must be a power of 2 number
and this check is improved.
Furthermore split the error message and provide one message for
invalid characters and one error message for the argument
not being a power of 2 number.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Suggested-by: Eduard Stefes <eddy@linux.ibm.com>
Suggested-by: Juergen Christ <jchrist@linux.ibm.com>
Tested-by: Jan Polensky <japo@linux.ibm.com>
Reviewed-by: Jan Polensky <japo@linux.ibm.com>
Reviewed-by: Juergen Christ <jchrist@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-22 15:59:36 +02:00
Steffen Eiden
b6a4d7a6c1 pvsecret: Update man files
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-22 15:50:15 +02:00
Steffen Eiden
f223069f0b pvsecret: Fix argument parsing
The latest commit 'promote' a few optional arguments to required.
Fix this breaking behaviour by making them optional again.

Fixes: 080a6678fb ("pvsecret: Add -i -o option variants")
Reported-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Tested-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-22 15:50:15 +02:00
Steffen Eiden
19a5af8da9 rust/utils: Add functions to combine I/O arguments
Add functions to properly parse required and optional input/output
parameters that have to be combined into one.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-22 15:49:45 +02:00
Steffen Eiden
03b73ab3f9 pvsecret: Update man and Readme
man and README got out of sync with --help over time.
Resync them.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Steffen Eiden
080a6678fb pvsecret: Add -i -o option variants
All pvattest subcommands use the command line option -i <input> and -o
<output> to specify file input and output respectively. pvsecret however
uses mostly positional arguments for <input> and <output> exclusively,
e.g. pvattest check input.bin output.yaml

$ pvsecret add secret.bin

This provides an inconsistent user interface within the Secure
Execution tools and may confuse users.

Add the -i and -o option to the subcommands if applicable.
Input/output can then be specified like so:

$ pvsecret add -i secret.bin
$ pvsecret list -o list.yaml
$ pvsecret verify -i FILE -o out.yaml
$ pvsecret retrieve -i ID -o id.yaml

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Steffen Eiden
1d6f7d0bec pvattest: Update man and Readme
man and README got out of sync with --help over time.
Resync them.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Steffen Eiden
a50d0485c9 pvattest: Add -i -o option variant for check
Most pvattest subcommands use the command line option -i <input> and -o
<output> to specify file input and output respectively. pvattest check
however only uses positional arguments for <input> and <output>, e.g.

$ pvattest check input.bin output.yaml

This provides an inconsistent user interface within the tool and may
confuse users.

Add the command -i and -o option to the check subcommand to bring it in
line with the rest of the tool.

$ pvattest check -i input.bin -o output.yaml

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Steffen Eiden
d2a6a771a5 pvattest: Show perform -i & -o option in help
Show -i & -o option and display them in the help output. Showing the
additional options to the user may provide a better experience. Users
may expect -i /-o options as other subcommands have them as well.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Steffen Eiden
7568a0790f pv: Fix error description
The error texts printed a hardcoded .0 instead of the actual value.
Fix this by using the proper string format arguments.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Fixes: 61c5d7d431 ("rust/pv: Attestation generation and verification support")
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Finn Callies
ca0ee966b8 pvics: Add image prereqs in manpage
Specify the requirements for the base image in the pvics manpage.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Finn Callies
36a7b2e6eb pvebc: Minor bash improvements
Add minor improvements to the scripts the dracut module calls.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Finn Callies
851f63eb03 pvebc: Fix dependency for non EBC guests
For guests that do not make use of the EBC feature the boot should not
be impacted by this module. This requires removing the boot.mount unit
because it will unconditionally create a dependency on a unit that
conflicts with that idea. The downside is that mounting of the boot
partition has to be done manually.

Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/202
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Finn Callies
3d679f61fc pvebc: Disable unit logging to /boot
The boot partition is not designed for log files. Disable logging of the
EBC units to /boot/sics/log.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Finn Callies
9237c5b675 pvebc: Fix kernel module dependencies
Include the required kernel modules unconditionally when this module is
installed into an initramfs.
The new .conf file contains a list of kernel modules that are loaded by
the systemd-modules-load.service systemd unit.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Eduard Shishkin
d1ab6be082 zipl/src: Don't modify job->data.dump and job->data.mvdump sequentially
Set job->data.dump.no_compress (job->data.mvdump.force) only after
making sure that the job is 'dump' ('mvdump') respectively. Othrewise,
the second assignment can potentially corrupt the value that was set by
the first assignment.

Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-05-21 13:20:06 +02:00
Jan Höppner
d6c2bac99f Prepare for next release
Signed-off by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 17:07:01 +02:00
Jan Höppner
997343f841 New release s390-tools-2.42.0
Signed-off by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 17:06:55 +02:00
Finn Callies
6a767408b3 ebc: Add new tool pvics
pvics (PV Image Customization Support) is a comprehensive tool for
converting existing qcow2 KVM guest images to IBM Secure Execution for
Linux (SEL) images with Early Boot Customization (EBC) support and
encrypted root filesystems.

The tool provides four main actions:
- list: Retrieve information about boot loader entries in a base image
- convert: Convert a base image to an EBC-ready SEL image
- encrypt: Encrypt the root filesystem and prepare EBC resources
- full: Perform both conversion and encryption in one operation

Assisted-by: IBM Bob:1.0.1
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 13:47:26 +02:00
Finn Callies
3aa5c38714 ebc: Add ibm-sel-ebc dracut module
Add 95ibm-sel-ebc dracut module for secure boot-time customization of
SEL guests.

Introduce the IBM SEL EBC dracut module (95ibm-sel-ebc) that enables
Early Boot Customization for SEL guests during the initramfs phase.

The module implements a critical security architecture to prevent
injection attacks: all EBC resources (.asr and .pol files) are copied from
/boot/sics (which resides in the qcow2 image on the host filesystem) to
/run/ibm-sel-ebc (a tmpfs/RAM-backed directory). Since guest RAM is
protected by the Ultravisor, this prevents malicious hosts from modifying
EBC resources during boot.

Systemd units and their purposes:
 - ibm-sel-ebc.target: Groups all EBC-related units
 - boot.mount: Mounts /dev/disk/by-label/boot to /boot
 - ibm-sel-ebc-ensure-sics.service: Fallback to create /boot/sics/ if boot
   partition mount fails (supports Kata VM scenarios)
 - ibm-sel-ebc-pvebc.service: Main unit that copies EBC resources to RAM,
   invokes pvebc tool to verify integrity and add ASRs to UV, retrieves
   LUKS passphrase from UV secret store
 - ibm-sel-ebc-override-crypttab.service: Replaces /etc/crypttab with
   prepared IBM SEL EBC crypttab, reloads systemd daemon, starts cryptsetup
   service
 - ibm-sel-ebc-paes-enforce.service: Verifies root filesystem uses PAES
   encryption to prevent root filesystem substitution attacks

All units write logs to /boot/sics/log for debugging, accessible even if
root filesystem fails to mount. Units are triggered by rd.ibm-sel-ebc
kernel parameter and only execute in initramfs
(ConditionPathExists=/etc/initrd-release).

Assisted-by: IBM Bob:1.0.1
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 13:46:31 +02:00
Finn Callies
c04a0919f6 rust: Add new tool pvebc
Add pvebc tool for parsing and verifying EBC Add-Secret-Request structures

Introduce pvebc, a CLI tool that parses and verifies the integrity of
Add-Secret-Request (ASR) structures used in Early Boot Customization for
SEL guests.

The tool processes an integrity-protected ASR structure consisting of:
 - toc.asr: Meta secret that links to toc.pol via relative filepath and
   SHA512 hash, integrity-protected by its AES GCM authentication tag
 - toc.pol: Policy file containing AES GCM authentication tags (last 16
   bytes) of all user-provided ASRs
 - User ASRs: Individual Add-Secret-Requests containing encrypted secrets

This structure guarantees:
 - Prevents ASR removal: toc.pol lists all expected ASR authentication tags
 - Prevents ASR insertion: Unlisted ASRs are rejected
 - Prevents ASR modification: AES GCM authentication tags provide
   cryptographic integrity
 - Prevents toc.pol tampering: toc.asr's integrity protection secures the
   link

The tool verifies completeness by checking that all ASRs listed in toc.pol
are present and their AES GCM authentication tags match. This prevents
attackers from removing, inserting, or modifying ASRs during transport over
unsecured channels.

After verification, pvebc adds all ASRs to the Ultravisor (UV), which
decrypts them using the guest's secret key and makes them available to
the guest during early boot.

Assisted-by: IBM Bob:1.0.1
Acked-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 13:46:31 +02:00
Finn Callies
c803cb925e rust: Add toc support for ebc to pvsecret
Add two new command-line options to pvsecret create for Early Boot
Customization (EBC) Table of Contents (TOC) support:

 1. --policy FILE
    Links an Add-Secret-Request (ASR) to a policy file by embedding a
    PolicyReference in the ASR's user data field. The PolicyReference
    contains the relative file path and SHA512 hash of the policy file,
    enabling integrity verification of the policy. This option conflicts
    with --user-data as both use the same user data field in the ASR
    structure.

 2. --toc-policy FILE
    Appends the AES-GCM authentication tag (MAC tag - last 16 bytes of
    the encrypted ASR) to the specified TOC policy file. This enables
    the TOC policy to maintain a list of all ASR MAC tags for
    completeness verification during boot. The TOC can verify that all
    expected ASRs are present and unmodified by checking their MAC tags
    against this list. This option also conflicts with --user-data.

Both options support the EBC multi-party workflow where an ISV/CSP builds
a generic SEL image and customers customize it with their own secrets. The
TOC mechanism ensures the integrity and completeness of all EBC resources
during the boot process.

Assisted-by: IBM Bob:1.0.1
Acked-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 13:46:31 +02:00
Finn Callies
1741ecff96 rust: Add EBC support to pv_core library
Add EBC (Early Boot Customization) utility functions to pv_core library
for parsing and verifying Add-Secret-Request structures.

Introduce the core library functionality needed for EBC:
- Add ebc_utils module to pv_core with ASR parsing and verification
- Export ebc_utils in pv_core lib.rs
- Re-export ebc_utils in pv lib.rs for downstream consumers
- Update pvsecret Cargo.toml dependencies

The library provides the foundation for tools that work with
integrity-protected ASR structures used in SEL guest customization.

Assisted-by: IBM Bob:1.0.1
Acked-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 13:46:31 +02:00
Finn Callies
20de1fce2a rust: Fix typo in pv
Change "Extracrted" to "Extracted".

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 13:46:31 +02:00
Szabina Korbai
a5af5bcf70 zcrypt: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts
to chzcrypt, lszcrypt and zcryptstats.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:51:04 +02:00
Szabina Korbai
7730f2489f zipl-editenv: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:51:04 +02:00
Szabina Korbai
6dbc5646f9 lsscm: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:51:04 +02:00
Szabina Korbai
f70991ab1e lsqeth: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:51:04 +02:00
Szabina Korbai
e9ee658492 lscss: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.
Modify --devtype flag description to make it
compatible with zsh autocompletion.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:51:04 +02:00
Szabina Korbai
35d5f41232 chpstat: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:51:03 +02:00
Szabina Korbai
260a0a2428 chp: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts
to chchp and lschp.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:50:38 +02:00
Szabina Korbai
b444e71ee3 zmemtopo: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Tested-by: Mete Durlu <meted@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:50:10 +02:00
Szabina Korbai
31d576a595 zpwr: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:49:28 +02:00
Szabina Korbai
68309ccb7f zpcictl: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:49:26 +02:00
Szabina Korbai
755ea88d5d vmcp: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:49:03 +02:00
Szabina Korbai
af99efaab2 tunedasd: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:48:33 +02:00
Szabina Korbai
3b55ca085e opticsmon: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.
Modify --module-info flag description to make it
compatible with zsh autocompletion.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:48:33 +02:00
Szabina Korbai
9fdfd1a6dc lsstp: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:48:33 +02:00
Szabina Korbai
c459ec08c6 hsavmcore: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:48:33 +02:00
Szabina Korbai
eb63434f44 fdasd: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:48:30 +02:00
Szabina Korbai
0eae712cc2 dump2tar: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:47:35 +02:00
Szabina Korbai
e7e9f137c1 dasdview: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:47:33 +02:00
Szabina Korbai
364cb9d869 dasdinfo: Implement zsh and bash autocompletion
Add generation of shell	autocompletion scripts.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:47:05 +02:00
Szabina Korbai
a64e9cab67 dasdfmt: Remove license boilerplate
Remove outdated license boilerplate from autocompletion
generator and cli header file. Fix SPDX-tag style.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Szabina Korbai
74cb6ee40e cpumf: Remove license boilerplate
Remove outdated license boilerplate from autocompletion
generator and cli header files. Fix SPDX-tag style.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Szabina Korbai
8c99c3878e libutil/util_autocomp_host: Remove license boilerplate
Remove outdated license boilerplate and fix
SPDX-tag style.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Jan Höppner
f302f5734b zpwr: Adapt to new JSON Lines text format
util_fmt now provides support for JSON Lines text format. Adapt certain
checks in the code and document the newly supported format in the man
page accordingly.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Jan Höppner
3485192791 zmemtopo: Adapt to new JSON Lines text format
util_fmt now provides support for JSON Lines text format.
Document the newly supported format in the man page accordingly.

Reviewed-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Jan Höppner
715da84030 lschp: Adapt to new JSON Lines text format
util_fmt now provides support for JSON Lines text format.
Document the newly supported format in the man page accordingly.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Jan Höppner
6e53be736e chpstat: Adapt to new JSON Lines text format
util_fmt now provides support for JSON Lines text format. Adapt certain
checks in the code and document the newly supported format in the man
page accordingly.

Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Jan Höppner
88bf638487 cpumf: Adapt to new JSON Lines text format
util_fmt now provides support for JSON Lines text format. Adapt certain
checks in the code and document the newly supported format in the man
pages for lshwc and lspai accordingly.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Jan Höppner
182892da12 hyptop: Adapt to new JSON Lines text format
util_fmt now provides support for JSON Lines text format. Adapt certain
checks in the code and document the newly supported format in the man
page accordingly.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Jan Höppner
f9e07c3916 libutil/util_fmt: Introduce JSON Lines text format
JSON Lines text format (JSONL) [1] is a line-delimited JSON format where
objects are separated by the new line character (\n, LF) as opposed to
the JSON Sequence text format (json-seq) where JSON text is encapsulated
in an ASCII Record Separator (0x1E, RS) and ASCII Line Feed character
(0x0A, LF).

Whilst JSONL is also used for data streaming, this simpler format is
better suited for logging and works also well with traditional
line-oriented Unix tooling (e.g. grep or sed).

Add this format to util_fmt so that users have more choice and control
over formats that are required for their usecases.

Add helper functions that let the user determine whether a given format
type is JSON in general or a JSON streaming format (such as json-seq or
jsonl).

For better readability and more clarity use the helper function
util_fmt_is_json_stream() where the same decision is made for both
JSON streaming formats FMT_JSONSEQ and FMT_JSONL.

[1] https://jsonlines.org/

Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Thomas Richter
3aaf3c067e cpumf/pai.c: Install SIGINT/SIGTERM handler for graceful termination
Sending signal SIGINT/SIGTERM to a running pai process causes immediate
termination of that running process. This usually interrupts a
select() system call waiting for more input to read from the installed
events and its mapped memory buffers. As there is no signal handler
installed, a SIGINT or SIGTERM signal simply terminates the process,
sometimes leaving incomplete recorded output file paicryto.XXX
(where XXX is the CPU number).
Install a signal handler to intercept signal SIGINT or SIGTERM and run
one more data collection loop to read out pending data and close all
recording output files properly.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Steffen Eiden
801e404160 pvimg: Fix hidden inferred bound
The associated type bound  for Iterator::Item was unsatisfied for Self.
Fix this by requiring Sized for IntoEnumIterator.

Fixes: 1d2a89b387 ("pvimg: Improve the readability of Display output for control flags")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Steffen Eiden
280b8509d1 pvimg: Remove unnecessary references
Referencing here is superfluous and makes clippy sad.

Fixes: 87966251c4 ("pvimg: info: Improve JSON output")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Steffen Eiden
0f56416d82 pvsecret: Improve UX on non-s390 systems
If pvsecret {add, list, retrieve} is executed with options on a non-s390
system the user gets misleading error messages as the options are not
defined.

> pvsecret add -i secret.bin
error: unexpected argument '-i' found

This may lead the user to think wrong arguments where chosen, which is
not entirely true as they are valid on s390. The more helpful error
message would be
error: Command only available on s390x

Which is already the case if no arguments are given.
Solve this by allowing non-s390 systems to parse the options:

> pvsecret add -i secret.bin
  error: Command only available on s390x

Reported-by: Carlo Della Giusta <carlo.dellagiusta@suse.com>
Fixes: dd82c26f87 ("rust: Add tool to manage UV-secrets")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Steffen Eiden
c88e0276c1 pvattest: Improve UX on non-s390 systems
If pvattest perform is executed with options on a non-s390 system the
user gets misleading error messages as the options are not defined.

> pvattest perform -i attestation_request.bin  -o attresp.bin
  error: unexpected argument '-i' found

This may lead the user to think wrong arguments where chosen, which is
not entirely true as they are valid on s390. The more helpful error
message would be
error: Command only available on s390x

Which is already the case if no arguments are given.
Solve this by allowing non-s390 systems to parse the options:

> pvattest perform -i attestation_request.bin  -o attresp.bin
  error: Command only available on s390x

While at it ignore some unused code warnings in the exchange format code
that appear on non-s390 systems as not all code is used.

Reported-by: Carlo Della Giusta <carlo.dellagiusta@suse.com>
Fixes: 16610a211f ("rust: pvattest-Rust")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Szabina Korbai
5b7f08624b libutil/util_autocomp_host: Fix script updating
Force the autocompletion script generator to always write to a new
empty file, thus preventing the potential corruption of script contents.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>

Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Jörn Siglen
b94d5e8f87 dbginfo.sh: Add command zmemtopo
Display CEC memory topology of allocated memory increments

Suggested-by: Mario Held <mario.held@de.ibm.com>
Suggested-by: Eberhard Pasch <epasch@de.ibm.com>
Reviewed-by: Michael Storzer <MSTORZER@de.ibm.com>
Signed-off-by: Jörn Siglen <siglen@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Jörn Siglen
a4f171d4ba dbginfo.sh: Update comments and copyright year
first change for 2026 and some clarification in comments

Reviewed-by: Michael Storzer <MSTORZER@de.ibm.com>
Signed-off-by: Jörn Siglen <siglen@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Ingo Franzki
93f8d093ce libkmipclient: Adjustments for OpenSSL v4.0.0 API changes and deprecations
With OpenSSL 4.0.0 function SSL_set1_host() is deprecated and should be
replaced by SSL_set1_ipaddr() and SSL_set1_dnsname().

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Ingo Franzki
7e68d7f61a libseckey: Adjustments for OpenSSL v4.0.0 API changes and deprecations
With OpenSSL 4.0.0 function X509_NAME_get_entry() returns a const pointer.
Make the local variable also const to avoid compile warnings like:

  warning: assignment discards ‘const’ qualifier from pointer target type
  [-Wdiscarded-qualifiers]

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Ingo Franzki
7755d35995 libekmfweb: Adjustments for OpenSSL v4.0.0 API changes and deprecations
With OpenSSL 4.0.0 function X509_NAME_get_entry() returns a const pointer.
Make the local variable also const to avoid compile warnings like:

  warning: assignment discards ‘const’ qualifier from pointer target type
  [-Wdiscarded-qualifiers]

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Ingo Franzki
211431abc2 zkey: Adjustments for OpenSSL v4.0.0 API changes and deprecations
With OpenSSL 4.0.0 function X509_cmp_current_time() is deprecated and
should be replaced by X509_check_certificate_times().

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:02 +02:00
Jan Höppner
0ae29148f0 gitignore: Update gitignore
zdev usage files were converted from .c to .h files. Adapt the file
names in gitignore.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Jan Polensky
43cf7873be zdev: generate usage text headers instead of C files
Generating and then including C source files from another C file can
lead to unexpected compilation errors in certain environments.

Switch the usage text generation from %_usage.c to %_usage.h. The
generated header provides the usage_text definition directly, and
chzdev.c and lszdev.c include the corresponding *_usage.h instead.

Update depfile prerequisites and the clean target to match the new
generated artifacts.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Jan Polensky
d8cea21e1e zdev: Makefile: deduplicate *_usage.c generation
Consolidate the duplicated sed command sequences used to generate
*_usage.c files into a shared CSTR_SED definition and a single pattern
rule:

	%_usage.c: %_usage.txt

This removes the copy/pasted rules for chzdev_usage.c and lszdev_usage.c
and keeps the Makefile easier to maintain.

Also drop the explicit chzdev.o/lszdev.o prerequisites on the generated
sources as dependencies are already tracked via the .*.o.d depfiles.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Jan Polensky
7093a70b51 dasdinfo: Drop obsolete kernel check and use errx() for arg errors
Remove the uname()/sscanf()-based kernel version gate (Linux < 2.6),
which is long obsolete and does not belong in user-space argument
validation.

While touching the code, replace the repeated warnx() + exit(1) pattern
with errx(EXIT_FAILURE, ...) in the option sanity checks to reduce
boilerplate and keep error paths consistent.

Behaviour is unchanged for supported environments; the version gate is
dropped because it is obsolete.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Jan Polensky
06984cd9ee dasdinfo: Modernize NULL pointer checks
Replace explicit NULL comparisons with idiomatic C style:
- 'if (ptr == NULL)' -> 'if (!ptr)'
- 'if (ptr != NULL)' -> 'if (ptr)'

No functional changes.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Jan Polensky
3a05ab769d dasdinfo: Apply code style improvements
- Use __packed instead of __attribute__ ((packed))
- Rename EBCtoASC to ebc_to_asc following naming conventions
- Consolidate multi-line error message into single line

No functional changes.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Jan Polensky
bcbc69c77f zkey/kmip: Normalize encoding; remove non-UTF-8 artifact
Normalize the man page source to UTF-8/US-ASCII and remove a mojibake
artifact that could not be represented cleanly.

Documentation only, no functional changes.

Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Niklas Schnelle
b385b8cc38 opticsmon: Fix wrong reference to --daemon flag in man page
Even before release the flag was renamed to --monitor but the mention in
the man page was missed.

Reported-by: Halil Pasic <pasic@linux.ibm.com>
Fixes: c34adb9cab ("opticsmon: Introduce opticsmon tool")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Jan Höppner
2b282bdacd libutil/util_autocomp: Remove comments describing resulting scripts
Future updates might change the outcome of the resulting scripts and the
comments describing the script output would need to be updated every
time as well. It's not worth the effort.

Remove the comments that list script examples from the functions
generate_bash_autocomp() and generate_zsh_autocomp().

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Jan Höppner
bd2610d275 libutil/util_autocomp: Fix default file completion
For Bash, when compspecs are found the generated script is returned as
the full set of possible completions and default completions are
disabled [1]. This leads to the behaviour that command line arguments
are not completed, only options defined by the script.

Zsh has the same issue.

Fix the issue by always adding the bash defaults to the generated
script. For zsh the corresponding file completion is always added to the
end of the argument list and the -A "*" option is added to allow
completion after positional arguments.

[1] https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html#Programmable-Completion-1

Fixes: 638cbbe332 ("libutil: Implement zsh and bash autocompletion")
Reported-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Jan Höppner
5cf2cefa94 libutil/util_autocomp: Fix ShellCheck findings and apply coding style
Apply coding style changes by reducing line breaks for a more compactly
generated script and add double quotes to fix ShellCheck findings.
Furthermore, remove the unused variable previous_word and use mapfile to
read the output of compgen into the COMPREPLY array to avoid unwanted
splitting and glob expansion.

Reviewed-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:44:01 +02:00
Eduard Shishkin
984e008127 zipl/src: Indicate in a verbose output if a component is signed
Regardless of secure boot support, indicate in the verbose zipl(8)
output if a component is signed.

Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-10 11:22:10 +02:00
Eduard Shishkin
fcfee1aa84 zipl/src: Fix a bug in building replicated program tables
When installing IPL on mirrored targets, zipl builds multiple program
tables (one such table per each mirror). If the option "--add-files"
was specified, then zipl uses the in-bootmap files, that was written
at the prevoius iteration (for the mirror ID #0) to build program
tables for mirrors with ID #1 (and larger). The in-bootmap files
already don't contain trailers. Despite this, the building process
cuts off the tail of trailer size, which results in corrupted boot
data.

This bug may result in crashing the kernel when booting from mirrors
with ID #1 (and larger) and manifests only if the boot components are
signed and the option "--add-files" is specified for the installation
session.

Don't count the trailer, when building program tables using in-bootmap
files written at the previous iteration.

Fixes: 431e4542ca ("zipl/src: Reuse data of file components in bootmap")
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-10 11:22:10 +02:00
Chinmaya Kajagar
b401ad0da0 zfcpdbf: Print sysfs unit add store events
New trace tags "sysuas*" added in kernel to trace zfcp sysfs unit add
store events.

Print the trace events under HBA with new record ID 6. The fields under
this tag are WWPN, FCP LUN and return value of the device having issues.

Example zfcpdbf output for unit add store events:

Timestamp      : 2026-02-02-10:50:02:474983
Area           : HBA
Subarea        : 00
Level          : 4
Exception      : -
CPU ID         : 0003
Caller         : 0x000001d89a86bd0e
Record ID      : 6
Tag            : sysuas2
Description    : sysuas2 HBA, Sysfs unit add store failure, unit add failed
Request ID     : 0x00000000ffffffff
Request status : 0xffffffff
FSF cmnd       : 0xffffffff
FSF sequence no: 0xffffffff
WWPN           : 0x500507680b26c449
LUN            : 0x01d0000000000000
Return Value   : 0xfffffff4

Timestamp      : 2026-02-02-10:50:02:475037
Area           : HBA
Subarea        : 00
Level          : 4
Exception      : -
CPU ID         : 0003
Caller         : 0x000001d89a86bd0e
Record ID      : 6
Tag            : sysuas2
Description    : sysuas2 HBA, Sysfs unit add store failure, unit add failed
Request ID     : 0x00000000ffffffff
Request status : 0xffffffff
FSF cmnd       : 0xffffffff
FSF sequence no: 0xffffffff
WWPN           : 0x500507680b26c449
LUN            : 0x01d1000000000000
Return Value   : 0xfffffff4

Signed-off-by: Chinmaya Kajagar <chinmayk@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-10 11:21:23 +02:00
Vasily Gorbik
50f909db8f zipl/boot: Fix stage3 secure boot trailer placement
The stage3 linker script places .sb.trailer so that it must end at
COMMAND_LINE_EXTRA. The current script derives the start address from
SIZEOF(.sb.trailer) before the section is emitted:

  . = COMMAND_LINE_EXTRA - SIZEOF(.sb.trailer);

With binutils older than 2.39 before commit 648f6099d4dc ("-z relro
relaxation and ld script SIZEOF") this can result in .sb.trailer being
placed at COMMAND_LINE_EXTRA instead, moving the trailer into the
following area and breaking the expected layout.

The trailer has a fixed size, so use an explicit constant for the
placement calculation and keep the ASSERT to verify the final section
size. This makes the placement deterministic again.

Fixes: a1126352ec ("zipl/boot: Improve linker scripts")
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-10 11:21:23 +02:00
Harald Freudenberger
d0046257b6 lszcrypt/chzcrypt: Warn if default domain is unavailable
Improvements for lszcrypt and chzcrypt:
* lszcrypt -b and lszcrypt -d now check for default domain
  available and gives a warning if the current default domain
  is not in the usage_domain_mask of the AP bus.
* lszcrypt without any further device also checks for the
  default domain and emits a warning string if the default
  domain is not available.
* chzcrypt --default-domain emits a warning if the newly
  set default domain is not enabled in the usage_domain_mask
  of the AP bus.

Suggested-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:25:25 +01:00
Ajaykumar Rajappa
daad3bf0e7 ziomon: Send MQ poll status messages to stdout
Move MQ poll status messages from stderr to stdout since they are
normal progress indications rather than warnings/errors.

Signed-off-by: Ajaykumar Rajappa <ajaykr@linux.ibm.com>
Reviewed-by: M Nikhil <nikh1092@linux.ibm.com>
Reviewed-by: Nihar Panda <niharp@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:25:18 +01:00
Ajaykumar Rajappa
6537f711a6 ziomon: Ignore benign blkiomon early-read warnings
The blkiomon warnings "bad trace magic 0" and "blkiomon: bad trace" are
benign startup artifacts caused by early pipeline reads before blktrace
produces a complete record. These messages do not affect processing and
valid reports are still generated. Filter them out so only real errors
trigger failures.

Signed-off-by: Ajaykumar Rajappa <ajaykr@linux.ibm.com>
Reviewed-by: Nihar Panda <niharp@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:25:13 +01:00
Mete Durlu
7c75df9e96 hyptop/opts: Fix long command line option abbreviations
Hyptop should be able to accept abbreviations of the long command line
options as getopt() is able to match them. Ex;

$ hyptop --batch-mode

$ hyptop --batch

$ hyptop --bat

From getopt(3) man page:
"""
  Long option names may be abbreviated if the abbreviation is unique
  or is an exact match for some defined option.
"""

After the introduction of commit c5695e43c4 ("hyptop/opts: Replace long
option formats for consistency") long command line options for hyptop
received additional definitions to support dash separated option formats.
Unfortunately these definitions were defined as new and unique options
and caused an ambiguity for getopt() when abbreviations matched both
definitions. Ex;

$ hyptop --batch
hyptop: option '--batch' is ambiguous;
possibilities: '--batch-mode' '--batch_mode'

Map both long option formats to the same short option to fix the
issue and restore the functionality.

Fixes: c5695e43c4 ("hyptop/opts: Replace long option formats for consistency")
Reported-by: Gorkem Kilinc <kilinc@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:25:03 +01:00
Mete Durlu
376ddfbd22 hyptop/opts: Replace sort_field option with sort
Hyptop's "--sort_field" command line option has always been documented
as "--sort", while the code _only_ explicitly has "--sort_field".
Specifying the shorter "--sort" happened to work due to an unnoticed
getopt() behavior.

From getopt(3) man page:
"""
  Long option names may be abbreviated if the abbreviation is unique
  or is an exact match for some defined option.
"""

With the addition of "--sort-field" as another unique identifier via
commit c5695e43c4 ("hyptop/opts: Replace long option formats for
consistency") "--sort" is no longer unique. getopt() won't be able to
use that as an abbreviation, since there is ambiguity between
"--sort_field" and new "--sort-field" as they are defined as separate
options.

Replace "--sort-field" and "--sort_field" with plain "--sort" to adhere
to the documented hyptop command line argument specification and resolve
the broken behavior.

Fixes: c5695e43c4 ("hyptop/opts: Replace long option formats for consistency")
Reported-by: Gorkem Kilinc <kilinc@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:46 +01:00
Holger Dengler
1afa6efb26 lszcrypt: Change exit code to 0 for empty device list
An empty device list is not an error case, if `lszcrypt` is called
without a specific device list or device filter. Return with rc == 0 in
such cases.

Remove the message about the empty device list on stderr.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:42 +01:00
Jan Höppner
69c89416b0 lsznet: Remove support for lcs device type
Kernel support for LCS devices was removed with commit 6cccb3bb0561
("s390/net: Remove LCS driver") in kernel v6.15. Remove the associated
lsznet support for the lcs device type.

Reviewed-by: Aswin Karuvally <aswin@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:38 +01:00
Jan Höppner
81e0d02d90 znetcontrolunits: Remove znetcontrolunits library
znetcontrolunits provided two arrays and a search function that were
only used by lsznet. Since lsznet has it's own implementation of this
function now and the CU array was a duplicate of CU_TCPIP anyway, remove
znetcontrolunits as it serves no purpose.

Reviewed-by: Aswin Karuvally <aswin@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:36 +01:00
Jan Höppner
d41d968792 znet: Move functionality from znetcontrolunits to lsznet
lsznet sources znetcontrolunits to use search_cu() and set the variable
cu_idx. lsznet's own function search_cu_tcpip() is doing the same thing
as search_cu() without setting cu_idx.

Declare and move cu_idx to the global variable CU_IDX and consolidate
the functions by letting search_cu_tcpip() set CU_IDX. Call
search_cu_tcpip() instead of search_cu() and replace cu_idx with CU_IDX
accordingly. search_cu() is removed and the CU_DEVDRV array is moved to
lsznet.

Reviewed-by: Aswin Karuvally <aswin@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:35 +01:00
Jan Höppner
c81ca8f01b lsznet: Convert space indentation to tabs
Reviewed-by: Aswin Karuvally <aswin@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:33 +01:00
Mikhail Zaslonko
73ab25f419 zipl/boot: Add secure boot option to the dump programm
With SECURE_BOOT_DISABLED always set in add_dump_program() no signature
entries for a dump kernel are written. This might lead to security
violation error from the IPL Loader on the systems with secure boot support
on the attempt to boot the dump kernel:
  MLOLOA6269321F A security violation error was encountered when loading from device <device>
  MLOLOA62693212 Audit: No signed components found for program 0 loaded from device <device>

Propagate '--secure' zipl option to add_dump_program() in order to sign
relevant components upon dump program installation and thus support
secure boot execution for List-directed dump kernels.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Acked-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Tested-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:23 +01:00
Chinmaya Kajagar
6fc1ed1a67 zfcpdbf: Print plogi and prli within open port response as payload
Print plogi and prli of each incoming open port response. Additional
payload ‘fsf_els’ HBA area to trace and print the new open port response
details.

Relevant kernel dbf structure changes are done in a separate patch. New
fields plogi_len and prli_len (u32 i.e. 4 hex digits at new appended
offsets 112 and 120) and payload record(s) are available.
The kernel structure with added members,
struct zfcp_dbf_hba_res {
	u64                        req_issued;           /*     0     8 */
	u32                        prot_status;          /*     8     4 */
	u8                         prot_status_qual[16]; /*    12    16 */
	u32                        fsf_status;           /*    28     4 */
	u8                         fsf_status_qual[16];  /*    32    16 */
	u32                        port_handle;          /*    48     4 */
	u32                        lun_handle;           /*    52     4 */
	u32                        plogi_len;            /*    56     4 */
	u32                        prli_len;             /*    60     4 */
};

zfcpdbf partial output for HBA area with relevant kernel code changes
displaying PLOGI/ PRLI info log with length for each:

PLOGI length   : 116
PRLI length    : 20
Payload time   : 2026-01-29-06:19:15:626629
PLOGI/PRLIinfo : 02000000 00000000 80000800 000a0002
                 00000000 2002000e 1115c62f 2001000e
                 1115c62f 00000000 00000000 00000000
                 00000000 80000000 00000000 00000000
                 00000000 80000000 00000000 000a0000
                 00010000 00000000 00000000 00000000
                 00000000 00000000 00000000 00000000
                 00000000 02100014 08002100 00000000
                 00000000 00000112

Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Chinmaya Kajagar <chinmayk@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:16 +01:00
Chinmaya Kajagar
1c3547d205 zfcpdbf: Trace all fsf status read buffer fields under HBA
This patch is to enhance fsf status read buffer tracing. Add remaining
status read buffer (SRB) fields including S_ID and reserved fields under
HBA trace area.

Relevant kernel dbf structure changes are done in a seperate patch.

zfcpdbf output for HBA area with relevant kernel code changes:

Timestamp      : 2025-08-22-05:52:04:171750
Area           : HBA
Subarea        : 00
Level          : 2
Exception      : -
CPU ID         : 0003
Caller         : 0x0000021e278c07c8
Record ID      : 2
Tag            : fssrh_4
Description    : fssrh_4 HBA, FSF unsolicited status
Request ID     : 0x0000000000004bfc
Request status : 0x00000000
FSF cmnd       : 0x00006305
FSF sequence no: 0x00000000
SRB stat type  : 0x00000002
SRB stat sub   : 0x00000000
SRB D_ID       : 0x00fffffd
SRB LUN        : 0x0000000000000000
SRB q-design.  : 0x0000000000000000
SRB length     : 0x0000004c
SRB res1       : 0x00000000
SRB res2       : 0x00
SRB class      : 0x00000000
SRB res3       : 0x00
SRB S_ID       : 0x0033c048
SRB res4       : 00000000 00000000 00000000 00000000
                 00000000
SRB pay length : 12
Payload time   : 2025-08-22-05:52:04:171743
SRB info       : 6104000c 0033c024 0033c02e

Signed-off-by: Chinmaya Kajagar <chinmayk@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:11 +01:00
Vineeth Vijayan
b6bb87f377 zdev: Remove support for lcs device type
Kernel support for LCS devices was removed with commit 6cccb3bb0561
("s390/net: Remove LCS driver") in kernel v6.15. Remove the associated
zdev support for the lcs device type.

Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:07 +01:00
Jan Höppner
bd0bb9dd5c zipl/man: Remove trailing whitespace
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:05 +01:00
Jan Höppner
075f7f7186 zipl/man: Only mention 3490 tape devices
The Virtual Tape Server (VTS) only supports 3490 tape devices. Remove
all other older device types from the man pages.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:04 +01:00
Jan Höppner
5af1e8cc69 zipl/tape2dump: Remove check for data compaction support
Data compaction is only supported by 3490 tape devices. For Virtual Tape
Server (VTS) this is the only supported device. Reading device
characteristics and checking the type is unnecessary.

Remove the corresponding code and simply enable data compaction.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:02 +01:00
Jan Höppner
145c21a9ca zipl/tape2dump: Remove load display command
Load Display (LDD) X'9F' is still accepted by the Virtual Tape Server
(VTS) but does not perform any action. Remove code that still uses this
command in tape2dump.c.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:01 +01:00
Jan Höppner
1bd8ee4b79 lstape: Remove type filter support
There is only one supported tape device type left. A filter command line
option doesn't make any sense anymore.

Remove the functionality and documentation of the --type option.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:00 +01:00
Jan Höppner
4f0dfae97e lstape: Remove 3480 and 3590 tape support
The device models 3480 and 3590 are no longer supported by the tape
device driver. Remove them from the device list

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:23:58 +01:00
Jan Höppner
3d6bb988c2 lstape: Remove trailing whitespace
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:23:57 +01:00
Jan Höppner
8f83002e37 tape390: Remove tape390_display and tape390_crypt
The tape390_display tool was used to send text to the display of tape
storage server. The corresponding command is still accepted by the
Virtual Tape Server (VTS) but no action is performed. The tool is
useless, remove it.

The tape390_crypt tool was used to manage encryption for tape devices.
However, only 3590/3592 models did support encryption. Support for these
models is removed from the Kernel as there is no support for these tape
models in general anymore. The tool is not required anymore, remove it.

Note: VTS uses encryption transparantly for its virtualized 3490 models.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:23:55 +01:00
Mikhail Zaslonko
d92f419836 zdump/dfi: Fix dump header check for dfi_s390tape
The magic number used in the dump header for all stage2 dumps (including
tape dump) is DF_S390_MAGIC_EXT since commit ff475d9c7d0a ("zipl: Extend
DASD stand-alone dumpers to drop zero pages").
Adjust dfi_s390tape code accordingly.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:23:52 +01:00
Jan Höppner
8ff8b40182 Prepare for next release
Signed-off by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 15:34:05 +01:00
Ingo Franzki
5e07b30bdf New release s390-tools-2.41.0
Signed-off by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 15:33:48 +01:00
Jan Höppner
35596e1dd7 rust: Update Cargo.lock
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 12:04:50 +01:00
Marc Hartmayer
0311cf7c5e pvimg/man: Update 'pvimg info' manpage
Update the manpage of the 'pvimg info' command.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:49:00 +01:00
Marc Hartmayer
78fdf56d38 pvimg: Improve long help message of the info subcommand
Improve the long help message of the 'info' subcommand.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:49:00 +01:00
Marc Hartmayer
b5c4ff68d7 pvimg: Document the JSON output format of the info command
Add documentation for the JSON structure outputted by 'pvimg info
--format=json ...'.

Created with assistance from IBM Bob AI.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:49:00 +01:00
Marc Hartmayer
3b0fc8cfda pvimg: Add '--print-schema <FORMAT>' option to 'pvimg info'
Add a new '--print-schema <FORMAT>' option to the 'pvimg info' command
that prints the schema, if available, describing the given output
format. For example, 'pvimg info --print-schema json' prints the JSON
schema for the 'pvimg info' command output.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:49:00 +01:00
Marc Hartmayer
8d40b5c97a pvimg info: Add '--show-secrets' flag
Add '--show-secrets' flag to 'pvimg info' to make secret output explicit
and avoid accidental disclosure.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
ad4075804f pvimg: Auto-detect default format for info command
Auto-detect default format for 'pvimg info' command. If stdout is a
terminal, use 'text', otherwise 'json'.

Adapt the tests accordingly.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
126ba7e336 pvimg: info: Add '--format text' support
Add human-readable output format to 'pvimg info' command. The format
'text:normal' shows only basic information about the Secure Execution
header, but skips the keys and other binary data; the format 'text:full'
shows everything.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
1d2a89b387 pvimg: Improve the readability of Display output for control flags
The Display implementation should produce human-readable output. Convert
the flags into a descriptive flag list to improve readability.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
7c4b029020 pvimg: info: Use the s390-tools JSON meta data
Use the s390-tools JSON meta data for the JSON output of 'pvimg info' to
make the JSON output more stable and to provide an stable API.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
b5a750c2cc rust: utils: Introduce S390ToolsMetaData
Introduce S390ToolsMetaData struct, it can be used to generate the
s390-tools specific JSON metadata.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
893667e73e rust: utils: Add 'gethostname()' function
Add 'gethostname' function to retrieve the system hostname using libc
gethostname.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
95fb1e2b03 pvimg: Improve error messages
Improve error messages for errors when reading the SE header protection
key or when the decryption/verification of the SE header has failed.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
87966251c4 pvimg: info: Improve JSON output
Improve JSON output and implement deserialization.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
012025595f pvimg: info: Provide two JSON output variants: pretty and minify
Add two JSON output variants: pretty and minify. The desired variant can
be selected via '--format json:pretty' and '--format json:minify'. Using
'--format json' without a variant defaults to pretty.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
48c8fc8321 pvimg: info: Warn when the SE header has not been verified
Add a warning to notify the user when the Secure Execution (SE) header
is present but its integrity and authenticity has not been verified.
This makes the lack of validation explicit and helps avoid unintended
use of untrusted data.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
19995638e9 pvimg: Remove redundant check
Remove redundant check.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
91ee8e0593 pvimg: Improve code documentation
Improve the documentation of flags and secured components.

Created with assistance from IBM Bob AI.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Marc Hartmayer
238ca83b99 Update pvattest and pvsecret mapnages and README.md
Update pvattest and pvsecret mapnages and README.md, as for example the
'pvsecret create update-cck' was not documented.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-16 11:48:59 +01:00
Jan Polensky
df8aac7084 zdev: Remove misc_readlink() helper function
zdev uses util_readlink() now and there are no users left
for misc_readlink() anymore. Remove it.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:54 +01:00
Jan Polensky
8ad28f7856 zdev: Use util_readlink() for consistent error handling
Avoid code duplication and inconsistent error handling by replacing
readlink() with util_readlink(), which is used project-wide to
standardize readlink() usage.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:54 +01:00
Jan Polensky
dd818ccc15 lsqeth: Use util_readlink() for consistent error handling
Avoid code duplication and inconsistent error handling by replacing
readlink() with util_readlink(), which is used project-wide to
standardize readlink() usage.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:54 +01:00
Jan Polensky
e7203069cc libutil/util_sys: Use util_readlink() for consistent error handling
Avoid code duplication and inconsistent error handling by replacing
readlink() with util_readlink(), which is used project-wide to
standardize readlink() usage.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:54 +01:00
Jan Polensky
d4ee1ff01f zconf/lscss: Use util_readlink() for consistent error handling
Avoid code duplication and inconsistent error handling by replacing
readlink() with util_readlink(), which is used project-wide to
standardize readlink() usage.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:54 +01:00
Jan Polensky
9c60ceccd4 dasdinfo: Use util_readlink() for consistent error handling
Avoid code duplication and inconsistent error handling by replacing
readlink() with util_readlink(), which is used project-wide to
standardize readlink() usage.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:54 +01:00
Jan Polensky
6da56acf4b dump2tar: Use readlinkat() unconditionally in read_symlink()
Replace the readlink() branch with readlinkat() and normalize
parameters: use AT_FDCWD with filename when relname is NULL. This
removes duplicate code paths while preserving behavior, including the
growth loop and size limits. readlinkat() is a superset of readlink().

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:54 +01:00
Jan Polensky
365be71dfc util_libc: Add util_readlink() and util_readlinkat() helpers
Introduce util_readlinkat() to read symbolic links relative to a
directory file descriptor, and util_readlink() as a convenience wrapper
using AT_FDCWD.

util_readlink() delegates to util_readlinkat() instead of duplicating
logic, ensuring a single implementation for both interfaces.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:54 +01:00
Jan Polensky
789b097d3a libvtoc: Cleanup trailing whitespaces
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:54 +01:00
Jan Polensky
06df08ae49 libvtoc: Convert comments from ISO-8859-1 to UTF-8
Convert comment encoding from ISO-8859-1 to UTF-8 to avoid encoding
mismatches and simplify future maintenance.

Align the libvtoc comments with the change introduced in the kernel
by commit 8f2bc80c6ef8 ("s390: ebcdic: convert comments to UTF-8").

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:44 +01:00
Jan Polensky
56a656f1c9 lsqeth: Fix typos
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:44 +01:00
Jan Polensky
8efd4da53b cpumf/pai: Fix sparse warning for NULL pointer usage
Fix sparse warning by using NULL instead of integer literal for pointer.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:44 +01:00
Wisdom
d2efda1ac2 libutil: Add utility parsing functions
Add functions to parse boolean values, sizes, ranges, and numbers.
Declarations are in util_parse.h for use across all s390-tools.

Signed-off-by: Wisdom Erhimwionsobo <werh29@linux.ibm.com>
Co-developed-by: Dean Doyle <ddoyle@linux.ibm.com>
Signed-off-by: Dean Doyle <ddoyle@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:44 +01:00
Wisdom Erhimwionsobo
aa29a5f1f9 libutil: Add util_startswith() to util_str
Add util_startswith to util_str to check if a string starts with the
given prefix and returns a pointer to the rest of the string,
or NULL if it does not.

Signed-off-by: Wisdom Erhimwionsobo <werh29@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:44 +01:00
Vasily Gorbik
28815d3928 ipl_tools/chreipl: Rename BOOTPARMS_FCP_MAX to BOOTPARMS_SCPDATA_MAX
chreipl passes additional boot parameters via the firmware scp_data
sysfs attribute. This mechanism is shared by multiple re-IPL types (FCP,
NVMe, and ECKD) and they all have the same scp_data size limit. The
BOOTPARMS_FCP_MAX name is therefore misleading.

Rename BOOTPARMS_FCP_MAX to BOOTPARMS_SCPDATA_MAX and update all callers
to make the intent clear and avoid implying this limit is FCP-only.

Reviewed-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:44 +01:00
Vasily Gorbik
65a891fa35 ipl_tools/chreipl: Make --bootparms work for ECKD re-IPL
chreipl accepts --bootparms for list-directed IPL, but for ECKD re-IPL the
value was never committed to sysfs, so the requested boot parameters did
not take effect.

Write the boot parameters to the firmware scp_data attribute when
configuring an ECKD re-IPL target. Also validate that the ECKD re-IPL
sysfs interface exists and enforce the maximum supported boot parameter
length up front.

Fixes: 7c24855ba1 ("ipl_tools: add support for list-directed IPL from ECKD DASD")
Reviewed-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:44 +01:00
Vasily Gorbik
5dc39e87e7 ipl_tools/lsreipl: Suppress 'clear' output if not supported
Some environments do not expose the /sys/firmware/reipl/*/clear attribute
(e.g. z/VM guests without "Load Normal" support). lsreipl currently tries to
read the attribute unconditionally for ECKD re-IPL and emits a confusing
"Could not read file .../clear" error when it is missing.

Re-IPL type: eckd
Device:      0.0.6d74
bootprog:    0
br_chr:      auto
Bootparm:    ""
Loadparm:    ""
Could not read file /sys/firmware/reipl/eckd/clear: No such file or directory
clear:       (null)
Secure boot: 0

Only print the "clear" field when the corresponding sysfs attribute is
present, avoiding the spurious error output.

Fixes: 7c24855ba1 ("ipl_tools: add support for list-directed IPL from ECKD DASD")
Reviewed-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:44 +01:00
Vasily Gorbik
3358a30dae zipl/stage3: Always use diag308 LOAD_NORMAL_RESET
stage3 still contains a legacy fallback path that transfers control to
the new kernel via LPSW 0 when diag 0x308 is not available.

The current start_kernel() inline asm issues "diag %[code],%[code],0x308"
without enforcing the required even/odd register pairing for the first
operand. With recent distro toolchains (e.g. GCC 15.x as shipped by Fedora
43 and Ubuntu 25.10), register allocation picks an odd register for the
first diag operand in start_kernel(), which triggers a specification
exception. That exception is then caught by the program-check handler
and stage3 silently takes the fallback, booting the kernel via LPSW 0
instead of performing diag308 LOAD_NORMAL_RESET.

All supported environments are expected to provide diag308, and the rest
of the code already relies on it. Drop start_kernel() and the obsolete
LPSW fallback and always reset into the new kernel via the properly
coded diag308() helper. Mark start() as __noreturn.

Reviewed-by: Eduard Shishkin <edward6@linux.ibm.com>
Tested-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:44 +01:00
Marc Hartmayer
d7ba322d69 uvsecret: Fix unresolved links in the documentation
warning: unresolved link to `GuestSecret::retrievable`
  --> pv/src/uvsecret/guest_secret.rs:56:37
   |
56 |     /// Create Retrievables using [`GuestSecret::retrievable`]
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^ the enum `GuestSecret` has no variant or associated item named `retrievable`
   |
   = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

warning: unresolved link to `GuestSecret::RetrievableKey::name`
  --> pv/src/uvsecret/guest_secret.rs:63:30
   |
63 |         /// SHA256 hash of [`GuestSecret::RetrievableKey::name`]
   |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the enum `GuestSecret` has no variant or associated item named `RetrievableKey`

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:11:44 +01:00
Nikita Dubrovskii
3123f56765 scripts/cpictl: Detect RHCOS using VARIANT_ID
CoreOS uses VARIANT_ID instead of a unique ID in /etc/os-release.
Extend distro detection to identify RHCOS, other CoreOS variants
may be added later if needed.

RHCOS is showing in HMC as RHEL, because `system_level' is:
```
[core@cosa-devsh ~]$ cat /sys/firmware/cpi/system_level
0x010906023a050e00
```
But should be:
```
[core@cosa-devsh ~]$ cat /sys/firmware/cpi/system_level
0x070906023a050e00
```

Issue: https://jsw.ibm.com/browse/OCPVIP-1471

Closes: https://github.com/ibm-s390-linux/s390-tools/pull/199
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:09:34 +01:00
Nikita Dubrovskii
eb881c2a39 scripts/cpictl: Fix ShellCheck warnings
Fix SC2162, SC2166 and SC2181 reported by ShellCheck without changing
script behavior.

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/199
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:08:47 +01:00
Eduard Shishkin
5c2e6fd730 zipl/src: Fix dump job on tape devices
Fix incorrect handling of tape devices leading to inability of
creating dumps on them.
Make the check for tape device go first, to not miss it on irrelevant
errors

Reported-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:08:47 +01:00
Volkan Unal
47cac92ca2 lscss: Fix memory leak
When the subchannel type read from sysfs does not match the requested
type, the allocated path is not freed before continuing to the next
loop iteration. This causes a memory leak as reported by valgrind.

Free the path before continuing.

Signed-off-by: Volkan Unal <vunal@linux.ibm.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-12 13:08:47 +01:00
Aswin Karuvally
11f2ccb957 hsci: Automatically set appropriate MTU for HSCI
At present, the hsci tool creates HiperSockets Converged Interface
(HSCI) with MTU of 1500 bytes regardless of the values of MTU for the
external and HiperSockets interface from which it is formed. This can
degrade performance or worse, affect network connectivity through the
converged interface.

Update the tool to automatically set MTU of HSCI as the lower of the
MTU values of external and HiperSockets interface.

Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
Signed-off-by: Aswin Karuvally <aswin@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-06 18:10:34 +01:00
Finn Callies
5b909a40cb cpacfstats: Add unauthorized state to CPU-MF counters
Introduce the new state 'unauthorized' to the three already existing
states disabled, enabled, and unsupported to CPU-MF counters.
CPU-MF counters are only available on LPARs.
The intent is to differentiate whether a system simply does not support
the CPU-MF counters like a z/VM guest or if they are supported like on
LPAR but have to be authorized via HMC/SE.

Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
[hoeppner@linux.ibm.com: Adapt commit message]
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-06 18:10:34 +01:00
Volkan Unal
591eb30854 lschp: Support for structured output
Introduce a new command line flag ("--format") to specify the output
format. Valid options are "pairs" for shell-compatible key
value pairs, "csv" for CSV, "json" for a formatted JSON document, and
"json-seq" for a stream of JSON text sequences as per RFC7464[1].

[1]: https://datatracker.ietf.org/doc/html/rfc7464

Signed-off-by: Volkan Unal <vunal@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-06 18:10:34 +01:00
Volkan Unal
3083f5dc85 lschp: Clean up unnecessary padding
Alignment in tabular output is already guaranteed via the
UTIL_REC_ALIGN_LEFT setting.

Signed-off-by: Volkan Unal <vunal@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-06 18:10:34 +01:00
Volkan Unal
2325d94453 lschp: Refactor channel path strings into macros
Replace repeated channel path strings with macros in preparation
for a follow-up patch.

Signed-off-by: Volkan Unal <vunal@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-06 18:10:34 +01:00
Steffen Eiden
fef70e3e95 pvinfo: Improve User experience on non-SE enabled systems
For systems without SE:
	- Do not exit with an error if `--version` is specified but
	  print the version
	- Do not exit with an error if `--se-status` is specified but
	  print `Secure Execution is not enabled`

Closes: https://github.com/ibm-s390-linux/s390-tools/issues/197
Closes: https://github.com/ibm-s390-linux/s390-tools/issues/198
Reported-by: Dan Horák <dan@danny.cz>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-06 18:08:58 +01:00
Steffen Eiden
808b766407 pvattest: Change default firmware hash verification endpoint
Change the default firmware hash verification to its final location.
For the old one, there is a redirection in place for the foreseeable
future.

Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Acked-by: Brendon Drew <bdrew@us.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-06 18:08:53 +01:00
Harald Freudenberger
346a69e5a9 lszcrypt: Update depth field calculation based on kernel change
The sysfs field 'depth' for AP queues now shows the real depth
and not the depth -1 as it is reported by the TAPQ instruction.
lszcrypt did under the hood already this +1 but now this increment
is done by the kernel and thus not needed in lszcrypt any more.

Suggested-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-02-06 17:58:54 +01:00
Thomas Richter
52ddd291d4 cpumf/pai: Handle different size of perf_event_attr
The structure perf_event_attr sometimes gets new members appended
at the end of the structure. Then the size of the structure increases.
This may lead to the situation where sizeof(struct perf_event_attr)
calculated at the pai program compile time during s390-tools build
differs from the one used to build application programs on the target
system.

The report files written by various tools write the contents of the
perf_event_attr structure followed by indivual samples to a binary file.
The second member perf_event_attr::size contains the size of that
structure in bytes.

Use that perf_event_attr::size from the target system to scan the
report files given as command line argument. This ensure the correct
size of structure perf_event_attr is used.

Output before:
Current situation: The pai program uses a perf_event_attr structure
which contains 8 bytes less than the one used on the target system.
The first sample header (8 bytes) then actually refers to the last
eight bytes of structure perf_event_attr, which are all zeroes. This
is an invalid sample entry and the program terminates with error.

 # pai -r -V painnpa.0004043; echo $?
 painnpa.0004043 size:1344
 [0x000088] type 0 misc 0 size 0
 1

Output after:
Use the correct size of structure perf_event_attr, which was read
from be binary file, written by the tools compiled on the target system:
 # pai -r -V painnpa.0004043; echo $?
 painnpa.0004043 size:1344
 size perf_event_attr mismatch 136/144
 [0x000090] type 9 misc 1 size 58 0x13537f71715 18 event 6144 \
	 sample pid 4043/4043 15:0x8a,16:0x88,22:0x112,25:0xc0
 ...
 0

Also show an debug message when verbose mode is turned on.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
André Wild
4cf239b8b6 scripts/cpictl: Fix typo --permit_cpi to --permit-cpi in help output
Signed-off-by: André Wild <awild@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
André Wild
b292ce565f ap_tools/ap-check: Fix typo AQPN -> APQN
Signed-off-by: André Wild <awild@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Peter Oberparleiter
75ab455cf6 libutil: Avoid realloc() with zero size
According to the valgrind man-page, "the behaviour of realloc() with a
size of zero is implementation defined in C17 and undefined in C23."

The current glibc implementation frees the specified buffer, returns
NULL and doesn't set errno. While this behavior is unlikely to change
in the near future, code relying on it may not be compatible with other
libc implementations. Also this realloc() use is flagged as an error in
valgrind runs, making valgrind output less usable.

Fix this by explicitly adding code to cover the realloc(buffer, 0) case
in util_realloc(). Also change libutil users of realloc() to use
util_realloc() instead.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Alexander Egorenkov
25088b340b README.md: zipl depends on mkfs.ext4
Add mkfs.ext4 to zipl dependency list. It is required to prepare
a NGDump dump partition.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Alexander Egorenkov
8edc5558b5 zipl/ngdump: Ensure ext4 file system is used on dump partition
If not specified, mkfs' default file system type is ext2 but
a NGDump dump partition must be formatted with ext4 file system.

Fixes: 41108c98aa ("zipl: move mkfs to ngdump prepare script")
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Tested-by:   Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
cd93949d17 zkey: Add phmac_s390 to initramfs and load it via modules-load.d
Add kernel module phmac_s390 to the initramfs hook and dracut config file
to ensure that the PHMAC cipher is available during early boot, in case
the root disk is integrity protected via PHMAC.

Also load phmac_s390 via modules-load.d to ensure that the PHMAC ciphers
are available.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
97136585da zkey-cryptsetup: Support PHMAC integrity with convert command
In case the volume is integrity protected, and the integrity algorithm is
PHMAC, then the convert command also checks the integrity key part of the
volume key, and then uses the secure integrity key, and sets the
verification pattern to the verification-pattern token.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
96d5b0bb02 zkey-cryptsetup: Support PHMAC integrity with reencipher command
In case the volume is integrity protected, and the integrity algorithm is
PHMAC, then the reencipher command also reenciphers the integrity key part
of the volume key.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
771c794580 zkey-cryptsetup: Support PHMAC integrity with setkey command
In case the volume is integrity protected, and the integrity algorithm is
PHMAC, then the setkey command also checks the integrity key part of the
volume key, and then sets the key into a new key slot, and sets the
verification pattern to the verification-pattern token.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
f11c71237e zkey-cryptsetup: Support PHMAC integrity with setvp command
In case the volume is integrity protected, and the integrity algorithm is
PHMAC, then the setvp command also adds the verification pattern of the
integrity key into the token.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
8dd5758341 zkey-cryptsetup: Support PHMAC integrity with validate command
In case the volume is integrity protected, and the integrity algorithm is
PHMAC, then also validate the integrity key and print its validation
status.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
20cc99feb7 zkey-cryptsetup: Add support for integrity verification pattern in token
In case the volume is integrity protected, and the integrity algorithm is
PHMAC, then the verification-pattern token as well as the reencipher-token
contain the verification pattern of the integrity key as well.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
9fa165de7a zkey-cryptsetup: Unify type of pointer to key blob
Use 'u8 *' instead of 'char *' for pointers to key blobs everywhere.
This saves a lot of casts.

The libcryptsetup API still uses 'char *' as pointer type for volume keys,
so a few casts are required when passing those pointers to libcryptsetup
API functions.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
103a99fa34 zkey: Support LUKS2 with combined encryption and integrity
The commands 'zkey cryptsetup' generates commands for formatting and
opening volumes of type PLAIN and LUKS2.

For LUKS2, if there exists an HMAC key that is associated to the same
volume as the AES key, generate a 'cryptsetup luksFormat' command for
combined encryption and integrity protection. This uses the '--integrity'
and '--integrity-key-size' options of the 'cryptsetup luksFormat'
command to specify the integrity settings.

The volume key specified with '--master-key-file' must contain the
encryption key and the integrity key concatenated to each other. The
size of the volume key specified with '--key-size' however must be the
size of the encryption key only, in bits. The 'cryptsetup luksFormat'
command will internally read the whole file, use the first part as
encryption key, and the second part as integrity key. The size of the
second part must be specified with the '--integrity-key-size'.

Note: This requires 'wrapped integrity key' support in the cryptsetup
package, as well as in the dm-crypt kernel module.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
c161c04392 zkey: Add integritytab and integritysetup commands for integrity volumes
The commands 'zkey integritytab' generates /etc/integritytab entries for
volumes of type INTEGRITY.

The 'zkey integritysetup' generates integritysetup commands for formatting
and opening volumes of type INTEGRITY.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
8e74293c2d zkey: Generate crypttab and cryptsetup commands for AES type keys only
The commands 'zkey crypttab' and 'zkey cryptsetup' should only operate on
AES-type keys, but not on HMAC keys.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
e14e0aa858 zkey: Can't set a sector size for HMAC keys on LUKS2 volumes
You can only set a sector size for an HMAC key of a volume of type
INTEGTRITY. For combined integrity protection with encryption, the
sector size of a LUKS2 volume must be set on the AES key, but can
not be set on the HMAC key.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
355700d606 zkey: Allow to associate a LUKS volume to an AES key and a HMAC key
For combined integrity protected with encryption, a LUKS2 volume can be
associated to exactly one AES type key and also to exactly one HMAC type
key.

For other volume types, a volume can only be associated to exactly one
key, either an AES type key, or an HMAC type key.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
ddf30feb89 zkey: Only allow to set a dummy passphrase for AES-type keys
Although HMAC keys can be associated to volumes of type 'LUKS2', the dummy
passphrase can only be set to AES-type keys, i.e. to keys that encrypt the
volume.

Reject trying to set a dummy passphrase for an HMAC key with a volume type
of 'LUKS2'.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
0047fc162e zkey: Add INTEGRITY volume type
Keys of type PVSECRET-HMAC can be associated to volumes of volume type
'INTEGTRITY' or 'LUKS2'.

Volumes of type 'INTEGTRITY' are set up for standalone dm-integrity via
the 'integritysetup' tool. Volumes of type 'LUKS2' are setup for combined
encryption and integrity using the 'cryptsetup' tool using the integrity
option.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
d9eee82ab0 zkey: Support generating verification patterns for HMAC keys
Similar as for AES keys, a verification pattern is calculated from an HMAC
key by MACing an all zero message of 64 bytes. The first 32 bytes of the
result is the verification pattern.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
a9059449b9 zkey: Add PVSECRET-HMAC key type and general HMAC support
Add the definitions and utility functions for the PVSECRET-HMAC key type.
A PVSECRET-HMAC key token contains the secret id of a protected
virtualization secret. It does not contain the key material, just a
reference to the key in the ultravisor.

When such a key token is used to perform HMAC operations later on, the
PHMAC kernel cipher will obtain the protected key belonging to this secret
id with the help of the pkey kernel module.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Ingo Franzki
c3d8208a57 zkey: Require cryptsetup v2.8.2 or later
For supporting integrity protected volumes with dm-integrity,
cryptsetup of version 2.8.2 or later is required.

Make cryptsetup of version 2.8.2 a build requirement for zkey, not
only for zkey-cryptsetup. Although zkey could be built with an older
cryptsetup version, the commands that it generates might not work
with older cryptsetup versions.

This makes the compile switch HAVE_LUKS2_SUPPORT superfluous, since
cryptsetup v2.8.2 always includes LUKS2 support. Remove the ifdefs
from the code and update the man pages to not mention LUKS2 support.

Also, starting with cryptsetup version 2.5.0 the luksFormat command
accepts option '--volume-key-file' to specify the volume key file
instead of --master-key-file'. Thus, use '--volume-key-file' in
cryptsetup commands generated by zkey.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:03:19 +01:00
Marc Hartmayer
a2663ec8d3 zipl/boot: Fix unsigned long overflow
Fix two issues in boot menu input parsing:

1. ebcdic_strtoul returns unsigned long but the value was stored in an int.
2. ebcdic_strtoul could overflow if @value exceeds ULONG_MAX.

Both problems are easy to trigger by entering an excessively large value
in the boot menu, which can lead to unsigned long overflow and memory
corruption.

Use a checked addition to prevent overflow and change menu_read() return
type to unsigned long.

Suggested-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-01-19 13:01:01 +01:00
Jan Höppner
12d9d24437 Prepare for next release
Signed-off by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 17:03:36 +01:00
Jan Höppner
aca6704cfa New release s390-tools-2.40.0
Signed-off by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 17:03:28 +01:00
Sertonix
3a85d1ebe6 opticsmon: Remove unused execinfo.h include
Avoids the need to guard the include for only glibc

Closes: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:59 +01:00
Sertonix
e8f9244224 opticsmon: Use $(PKG_CONFIG) instead of calling pkg-config directly
Is more consistent with other Makefiles and fixes cross compilation
if it relies on a modified $(PKG_CONFIG).

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:59 +01:00
Sertonix
a49887de1f include/boot/s390.h: Always use __vector128 from asm/types.h
asm/types.h may be included after the guard. This happens eg. when
compiling with musl libc. When including the header directly the
include is always there and the fallback __vector128 is not needed
anymore.

The guard was introduced by commit 11bdab2629 ("include/boot/s390.h:
add guard for `struct __vector128`")

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
[hoeppner@linux.ibm.com: Adapt commit message]
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:59 +01:00
Sertonix
4e61b4c9f4 hyptop/helper: Define _PATH_MOUNTED fallback
_PATH_MOUNTED is not defined in musl libc

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:59 +01:00
Sertonix
d884cc27c1 hyptop/helper: Remove duplicate include
Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:59 +01:00
Sertonix
bf3810ea6a libutil/util_opt: Remove unused argz.h include
Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:59 +01:00
Sertonix
99d7ec51a7 Use execinfo.h only on glibc
libunwind could also work on musl but that would require more drastic
code changes

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:59 +01:00
Sertonix
327d132aac rust/pvcore/uvdevice: Fix compilation on musl libc
musl libc ioctl uses int instead of unsigned long.

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:59 +01:00
Sertonix
fcb89662e0 chreipl-fcp-mpath: Use sha256sum -c instead of --check
The --check long option is not available in some sha256sum
implementations like busybox.

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:59 +01:00
Sertonix
a52243ea04 Makefile: Install netboot on non-s390 architectures
mk-s390image can be used on all arches. mk-pxelinux-ramfs probably only
works on a s390 system but it should also not hurt to install since it's
just an example.

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:57 +01:00
Sertonix
805a4d4408 Use _FILE_OFFSET_BITS=64 instead of _LARGEFILE64_SOURCE everywhere
Allows using more portable function/type names while still using 64-bit
values on 32-bit glibc systems.

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:05 +01:00
Sertonix
b1e4f6f331 dasdinfo: Define FTW_{CONTINUE,STOP} when not available
These are not available in musl libc and not mentioned in the POSIX spec

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:05 +01:00
Sertonix
10d72caac0 Add missing includes
include/lib/util_sys.h: missing dev_t
ziomon/ziomon_msg_tools.h: missing time_t
zkey/keystore.c: missing open
mon_tools/mon_procd.c: missing gettimeofday

Fixes some build failures on musl libc

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:05 +01:00
Sertonix
0ea693d95c Use standard uint*_t instead of u_int*_t
Fixes some compilation issues on musl libc. uint*_t is already used so
this should not introduce any new issues.

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/193
Signed-off-by: Sertonix <sertonix@posteo.net>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-11 15:46:05 +01:00
Steffen Eiden
0ff130ed84 Add tool to verify host-key documents
Add a tool that can be used to verify if a given IBM host-key document is
valid. This uses the same logic (and code) as the image/request tools
for IBM Secure Execution, pvimg, pvattest, and pvsecret.

This tool basically just does the first step of the above tools; but without
creating any request or image.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:43:15 +01:00
Steffen Eiden
8a57017af3 rust/utils: Add s390-tools version macro
This new macro allows (rust) tools reporting the s390-tools version
string via clap functionalities, instead of implementing that on their
own. That clap interface requires a string and not a void function that
prints the version string. Define a macro that provides this string.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:41:43 +01:00
Ajaykumar Rajappa
41ec030db1 ziomon: Update man page to document device symlink support
Enhance the ziomon man page to document support for persistent SCSI device
symlinks under /dev/disk/ subdirectories (by-id, by-path, by-uuid, etc.).

The DESCRIPTION section now clarifies that multipath devices and/or device
symlinks resolve to their underlying regular block devices for monitoring.
Updated EXAMPLES to include a scenario demonstrating usage with a device
symlink alongside regular and multipath devices.

Signed-off-by: Ajaykumar Rajappa <ajaykr@linux.ibm.com>
Reviewed-by: M Nikhil <nikh1092@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:41:43 +01:00
Steffen Eiden
34aff761d0 rust: Do not fail install if no man page is available
Some (rust) tools may not provide man pages. In absence of a man file
the install process currently fails. Solve this by expanding the glob
using Make logic instead of sh logic.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:41:43 +01:00
Jan Höppner
01cb8c4085 clang-tidy: Do not warn about multiple declarations
Omit the readability-isolate-declaration [1] check that warns about
multiple declarations in one line as the s390-tools coding style prefers
this approach.

[1] https://clang.llvm.org/extra/clang-tidy/checks/readability/isolate-declaration.html

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:41:43 +01:00
Marc Hartmayer
8d58a9abb0 zipl/boot: Fix two off-by-one bugs
Fix two off-by-one errors:

+ One caused an out-of-bounds read when the loadparm value was 63
+ The other made a boot entry unselectable.

Currently, these bugs have no practical impact because:

1. The memory area beyond __stage2_params.config[63] is empty.
2. BOOT_MENU_ENTRIES is set to 63, which exceeds the number of boot menu
   entries that can be written to disk.

Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:41:43 +01:00
Annu Sharma
ce82010827 Add tool to display Secure Execution system information
Add 'pvinfo' a tool to display the information of enabled flags, and
print the debug information in Yaml and Human format.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Serena Santosh <serena@linux.ibm.com>
Signed-off-by: Ann Mariya Jojo <annjojo@linux.ibm.com>
Signed-off-by: Annu Sharma <annu09@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:41:43 +01:00
Ellen McIntyre
c0d8034962 dasdfmt: Implement zsh and bash autocompletion
Add autocomplete script generation for dasdfmt tool.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Ellen McIntyre <ellen@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:41:41 +01:00
Szabina Korbai
95290562e0 cpumf: Implement zsh and bash autocompletion
Add autocompletion script generation for the cpumf
family of tools (chcpumf, lscpumf, lshwc, lspai, pai)

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:52 +01:00
Szabina Korbai
638cbbe332 libutil: Implement zsh and bash autocompletion
Add functionality for generating autocompletion scripts,
allowing for tab completion of tool options for bash and zsh.

This functionality relies on reading the available options
from the util_opt struct at runtime.

The script generation happens on the build system.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:52 +01:00
Szabina Korbai
70157462d8 common.mak: Add explanation to *_FOR_BUILD variables
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:52 +01:00
Marc Hartmayer
40bc181f31 zipl/boot: Fix out-of-bounds read if loadparm value is too large
When a loadparm is presented by the user it's not checked whether it's
too large. Add this missing check to fix an out-of-bounds read.

The problem did not show up because the area behind the buffer is empty.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:52 +01:00
Marc Hartmayer
a2eb03660d zipl/boot: Fix unused loadparm when SCLP line-mode console is absent
Currently, 'sclp_setup(SCLP_INIT)' fails if no SCLP line-mode console is
available. As a result 'menu_param()' is never called, even though it is
required to retrieve the 'loadparm' value.

However, reading the loadparm via SCLP remains useful even when a SCLP
line-mode console is absent, because this value determines which boot
entry should be selected. Therefore, the boot process should continue by
retrieving the loadparm without requiring an SCLP line-mode console.

It's safe to continue without a SCLP console as 'printf' and
'menu_param' tolerates the absence of a SCLP line-mode console.

Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/196
Reported-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:52 +01:00
Mete Durlu
f4c4c40b78 hyptop: Remove unnecessary extern keywords in headers
Remove extern keyword from function signatures in header files.
Function signatures in headers are already extern implicitly.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:51 +01:00
Mete Durlu
fe78faa8ae hyptop/table: Fill system name column for CSV output
When machine parseable format is specified via hyptop --format csv
the summary row for csv does not have any indicator or and a blank
system name. Avoid this confusion by adding "SUM" as system name.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:51 +01:00
Mete Durlu
617a8248e8 hyptop: Add option to show omitted fields on formatted output
Fields without a valid value are normally excluded from formatted output
of hyptop. Add "--all" option to force hyptop to display those fields
with null values.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:51 +01:00
Mete Durlu
c5695e43c4 hyptop/opts: Replace long option formats for consistency
Hyptop uses underscore("_") in between words for options, this breaks
consistency. Use hyphens ("-") in between words in options moving
forward. Underscore formats are still supported for compatibility.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:51 +01:00
Mete Durlu
7b3add9389 hyptop: Use util_time helpers for time calculations
Use the common helpers in lib/util_time instead of using hardcoded
values for time calculations.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:51 +01:00
Mete Durlu
44fdf586e1 libutil: Introduce util_time
Introduce util_time as a place for time related macros, definitions,
and functions that are commonly used. Add NSEC_PER_USEC, NSEC_PER_MSEC,
USEC_PER_SEC and NSEC_PER_SEC definitions that are used for time
conversion calculations as a start. Add time conversion helper functions.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:51 +01:00
Mete Durlu
0d6e63abdc hyptop: Calculate sample time delta for physical partition
Physical machine information does not include any monotonically
increasing time field like other per CPU information blocks. This
Prevents the percentage calculation for the physical information fields
as the divisor(time_delta) is missing;

field% = (value_current - value_previous) / time_delta

To circumvent that, use the current partition's per CPU online time
values to calculate the time_delta. Integrate time_delta as a new
field(phys_delta_us) specific to the physical systems.

Explicitly CPU0 online time is used, since CPU0 is always online
and cannot be deconfigured on s390x. Its online-time deltas would
match those of the physical CPUs.

Since a new field has to be used for physical systems a new
column in the table also has to be created but instead map the
physical system field to the corresponding regular system fields
for a nicer table view.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:51 +01:00
Mete Durlu
1771e7f2f3 hyptop: Add physical information row
Introduce a new row to represent the underlying physical machine
and the physical information hyptop gathers from diag.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:51 +01:00
Steffen Eiden
c403208332 rust: Apply suggested fixes from clippy
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-12-10 14:40:51 +01:00
Steffen Eiden
2a99007a6e zkey: Fix spelling issues
Some codespell findings.

`codespell zkey/keystore.c`

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Steffen Eiden
994269c278 rust: Fix formatting issues
Some `rustfmt` findings.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
ae5687f1d1 libvtoc: Replace bzero with memset
Replace deprecated bzero() with memset() to maintain portability and
comply with the C standard.

No functional change.

Link: https://www.man7.org/linux/man-pages/man3/bzero.3.html
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
b856ae62a7 dasdview: Replace bzero with memset
Replace deprecated bzero() with memset() to maintain portability and
comply with the C standard.

Correct typo causing double zero on s4 instead of s4 and t4.

Link: https://www.man7.org/linux/man-pages/man3/bzero.3.html
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
7b4be02441 dasdview: Fix typo
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
2403d1e166 zdsfs: Replace bzero with memset
Replace deprecated bzero() with memset() to maintain portability and
comply with the C standard.

No functional change.

Link: https://www.man7.org/linux/man-pages/man3/bzero.3.html
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
3f03ceb007 fdasd: Replace bzero with memset
Replace deprecated bzero() with memset() to maintain portability and
comply with the C standard.

No functional change.

Link: https://www.man7.org/linux/man-pages/man3/bzero.3.html
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
150ae08678 dasdinfo: Replace bzero with memset
Replace deprecated bzero() with memset() to maintain portability and
comply with the C standard.

No functional change.

Link: https://www.man7.org/linux/man-pages/man3/bzero.3.html
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Ingo Franzki
43a10f4806 common.mak: Add '-Wl,--as-needed' to DEFAULT_LDFLAGS
Many distros and buildsystems use '-Wl,--as-needed' default-wise anyway.
For example, Ubuntu, Fedora, and Meson default to '-Wl,--as-needed'.
Considering some of the projects that use/support Meson, e.g. util-linux,
systemd, libvirt, or git, are all built with '-Wl,--as-needed' as well.

So add '-Wl,--as-needed' to DEFAULT_LDFLAGS to also default to that.

Note that with '-Wl,--as-needed' the order of flags, objects, and libraries
matters for the link step. The link rule in common.mak already has the
correct order, so using '-Wl,--as-needed' will not hurt.

    %: %.o
	    $(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Ingo Franzki
4e08c5fcd8 common.mak: Fix the check for shared libraries with check_dep
The check_dep macro allows to pass additional compiler & linker
options as 5th argument. This argument might contain shared
libraries to link against (i.e. -lsomething). To ensure that
the check_dep macro always attempts to link to these libraries
'-Wl,--no-as-needed' is needed.

At least on Ubuntu '-Wl,--as-needed' is the default, and with
that, the library might get skipped if it is not really needed
by the program built by the check_dep macro. Furthermore, with
'-Wl,--as-needed' the order of the arguments matters, and thus
a library specified in the 5th argument is at the wrong position,
which leads to link errors and thus the check_dep macro will
report that the dependency is not fulfilled, although it might
be fulfilled.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Matthew Rosato
6532bf02c2 zdev: Add ap bus coldplug replay trigger for ap.rules
Add an additional trigger to the zdev-generated 41-ap.rules file.  This
trigger will check the bindings_complete_count value during coldplug
replay of the ap bus, which allows the udev rule to handle the case
where zcrypt has already fired the BINDINGS==complete with
COMPLETECOUNT==1 before the udev rule was accessible (example: before
rootfs has been mounted).  Without this, it's possible for the rule to
never fire despite the initial bindings having completed.
While it was always possible for zcrypt to be forced onto initrd, it
becomes far more likely with changes like 14c977768 ("zkey/dracut: Add
a dracut config file for zkey").

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Acked-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
3f7b459606 dump2tar: Remove unused header file
Drop idcache.h as it is not used in this file.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
14830b1ead zdev: Remove unused header files
Remove unused header files from these sources.
This simplifies maintenance and slightly reduces compile time.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
1dae9b4f49 zconf/lsqeth: Remove unused internal headers
Drop unused headers from the internal s390-tools library. These headers
were only indirectly pulling in stdlib.h, which is now included
explicitly to support memory deallocation via free().

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
b58414d7dc zconf/lscss: Remove unused header
Drop lib/util_base.h and lib/zt_common.h as they are not used in this
file.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
64524f17fa libutil/util_path: Remove unused headers
Drop lib/util_base.h and lib/util_prg.h as they are not used in this
file.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
1b87b016d4 libutil/util_list: Remove unused header stdio.h
Drop stdio.h as it is not used in this file.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
94bdb17d01 cpumf/lscpumf: Remove unused header
Remove ctype.h and errno.h since they are not referenced in this
file.
Add err.h to explicitly declare the dependency on warnx().

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
2625cd704f cpumf/chcpumf: Remove unused header
Remove lib/util_base.h and errno.h since they are not referenced in this
file.
Add err.h to explicitly declare the dependency on err() and warn().

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:37 +01:00
Jan Polensky
59df2c6d02 util_libc: Fix typo
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Jan Polensky
8ba03642b7 libvtoc: Fix typos
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Jan Polensky
1956e7abc5 zdsfs: Fix typos
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Jan Polensky
d76cb1d53a fdasd: Fix typos
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Jan Polensky
7d5f2ba038 zconf/lscss: Fix typos
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Jan Polensky
8bbf1d5bea checkpatch: Ignore STRNCPY warning for userspace code
For s390-tools util_strlcpy() would be a safer replacement. However,
no code is changed, only .checkpatch.conf is updated to avoid false
positives in userspace.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Jan Polensky
b2fcb608d5 Add project-wide .clang-tidy configuration
Introduce a .clang-tidy file to provide consistent code quality checks
across the project.

The configuration is not integrated into .pre-commit-config.yaml because
it depends on a recently generated compile_commands.json file.

Example usage:

	clang-tidy --fix-errors **/*.[ch]

Note: Running clang-tidy should be considered optional, not enforced.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Marc Hartmayer
76b7928592 netboot: Format mk-s390image
Command line used:

  $ shfmt --space-redirects --case-indent --simplify --func-next-line --write mk-s390image

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Marc Hartmayer
339b69cf3b netboot: Ignore the removal of nonexistent file in mk-s390image
Ignore the removal of nonexistent $image file. This removes the
following error message:

$ mk-s390image /var/lib/libvirt/images/hades/vmlinux-s390x out.img
...
rm: cannot remove 'out.img': No such file or directory

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Marc Hartmayer
419f042f55 netboot: Improve error reporting in mk-s390image
If an input file is not readable return a proper error message indicating
this.

Before:

$ mk-s390image /var/lib/libvirt/images/hades/vmlinux-s390x out.img
mk-s390image: Unrecognized file format for /var/lib/libvirt/images/hades/vmlinux-s390x

After:

$ mk-s390image /var/lib/libvirt/images/hades/vmlinux-s390x out.img
mk-s390image: File /var/lib/libvirt/images/hades/vmlinux-s390x cannot be read, no read permission

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Marc Hartmayer
128e5f86fe netboot: Add longer kernel command lines support
Since Linux commit 5ecb2da660ab ("s390: support command lines longer
than 896 bytes") the s390x kernel supports longer command lines than 896
bytes. The indication of the maximum size is stored in a new field at
address 0x10430, older kernels without the support store a value of 0
there so in that case fallback to the old maximum length of 896.

In addition, use the checked size as limit to copy in the 'dd' call.
This prevents Linux kernel corruption in case the parmline has changed
in between.

Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/194
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Marc Hartmayer
b29e824923 netboot: Fix shellcheck findings in mk-s390image and make the script more robust
Most of the fixes were auto-generated using the following command:

     $ shellcheck --format=diff mk-s390image | git apply -

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:36 +01:00
Ajaykumar Rajappa
3175d52ce7 ziomon: Add support to sample device symlinks
Enhance 'ziomon' utility to support persistent SCSI device symlinks,
including regular, multipath and partitioned devices. Supports /dev/disk/
subdirectories (by-id, by-path, by-uuid, by-label, etc.), resolving the
symlinks to their SCSI block devices.

Signed-off-by: Ajaykumar Rajappa <ajaykr@linux.ibm.com>
Reviewed-by: Chinmaya Kajagar <chinmayk@linux.ibm.com>
Tested-by: Chinmaya Kajagar <chinmayk@linux.ibm.com>
Reviewed-by: Nihar Panda <niharp@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:33 +01:00
Jörn Siglen
17024c02af dbginfo.sh: Adding stp time information
Calling lsstp to get the status on STP time sync.

Suggested-by: Michael Storzer <MSTORZER@de.ibm.com>
Reviewed-by: Michael Storzer <MSTORZER@de.ibm.com>
Signed-off-by: Jörn Siglen <siglen@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:32 +01:00
Jörn Siglen
5cd680c0be dbginfo.sh: Simplify procfs collection
Using the base dir only, will ensure to get all needed info independent of
configuration and future changes.

├── dasd
│   ├── devices
│   └── statistics

├── net
│   ├── anycast6
│   ├── arp

│   ├── bonding

│   ├── dev
│   ├── dev_mcast
│   ├── dev_snmp6
│   │   ├── encbdf0
│   │   └── lo

│   ├── sockstat
│   ├── sockstat6
│   ├── softnet_stat
│   ├── stat
│   │   ├── arp_cache
│   │   ├── ndisc_cache
│   │   ├── nf_conntrack
│   │   └── rt_cache

│   ├── vlan

The change in size and collection speed can be ignored.

Reviewed-by: Michael Storzer <MSTORZER@de.ibm.com>
Signed-off-by: Jörn Siglen <siglen@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-12-01 13:45:32 +01:00
Ajaykumar Rajappa
c333f91d4c ziomon/ziorep_config: Add fcp-lun to -M option output
Update the ‘ziorep_config’ utility to print FCP-LUN details
when the ‘-M’ option is used.

Now, ‘ziorep_config -M' option prints FCP LUN(fcp-lun) ID along with the
existing FCP device bus-id and WWPN. This addition helps correlate the
output with command 'multipathd -k', subcommand 'show topo' output,
aiding in better visibility and mapping of FCP devices to their respective
LUNs in multipath environments.

$ ziorep_config -t -M
adapter  remote_port        LUN                scsi_dev multipath_device
========================================================================
0.0.1967 0x500507630704572c 0x405240f500000000 /dev/sda /dev/mapper/mpatha
0.0.1967 0x500507630704572c 0x405340f500000000 /dev/sdb /dev/mapper/mpathb
0.0.1927 0x500507630700572c 0x405240f500000000 /dev/sdc /dev/mapper/mpatha
0.0.1967 0x500507630704572c 0x405440f500000000 /dev/sdd /dev/mapper/mpathc
0.0.1927 0x500507630700572c 0x405340f500000000 /dev/sde /dev/mapper/mpathb
0.0.1927 0x500507630700572c 0x405440f500000000 /dev/sdf /dev/mapper/mpathc
0.0.1967 0x500507630704572c 0x405540f500000000 /dev/sdg /dev/mapper/mpathd
0.0.1927 0x500507630700572c 0x405540f500000000 /dev/sdh /dev/mapper/mpathd

The LUN IDs from the above output can be correlated with multipath's
H-C-T-L(LUN ID in decimal) of each FCP devices as shown below,
$ multipathd -k
multipathd > show topo
create: mpatha (36005076307ffd72c00000000000052f5) dm-0 IBM,2107900
size=40G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  |- 0:0:0:1089814610 sdc 8:32  active ready running
  `- 1:0:0:1089814610 sda 8:0   active ready running
create: mpathb (36005076307ffd72c00000000000053f5) dm-1 IBM,2107900
size=40G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  |- 0:0:0:1089814611 sde 8:64  active ready running
  `- 1:0:0:1089814611 sdb 8:16  active ready running
create: mpathc (36005076307ffd72c00000000000054f5) dm-4 IBM,2107900
size=20G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  |- 0:0:0:1089814612 sdf 8:80  active ready running
  `- 1:0:0:1089814612 sdd 8:48  active ready running
create: mpathd (36005076307ffd72c00000000000055f5) dm-5 IBM,2107900
size=20G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  |- 0:0:0:1089814613 sdh 8:112 active ready running
  `- 1:0:0:1089814613 sdg 8:96  active ready running

Signed-off-by: Ajaykumar Rajappa <ajaykr@linux.ibm.com>
Reviewed-by: Chinmaya Kajagar <chinmayk@linux.ibm.com>
Reviewed-by: Nihar Panda <niharp@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-10 10:30:08 +01:00
Ajaykumar Rajappa
095e5ee226 ziomon/ziorep_config: Add port_id and failed attributes to -A option output
Update ziorep_config utility to extract and display the local fc_host
port_id and failed /sysfs attributes when -A(adapter) option is used.

$ ziorep_config -A
Host:    host0
PCHID:   0308
CHPID:   60
Adapter: 0.0.1927
Sub-Ch.: 0.0.0004
Name:    0xc05076fff38075d4
Port-Id: 0x33c016
P-Name:  0xc05076fff3803081
Version: 0x000b
LIC:     0x24500103
Type:    NPIV VPORT
Speed:   32 Gbit
State:   Online
Failed:  No

Signed-off-by: Ajaykumar Rajappa <ajaykr@linux.ibm.com>
Reviewed-by: Chinmaya Kajagar <chinmayk@linux.ibm.com>
Reviewed-by: Nihar Panda <niharp@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-10 10:29:57 +01:00
Peter Jin
6ee5ffef91 udev/rules.d: Set default io scheduler to 'none' for virtio-blk
Use 'none' as default io scheduler for virtio-blk devices. Performance
improvements for multi-queue setups and to reduce CPU consumption.

Signed-off-by: Peter Jin <pjin@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-10 10:29:52 +01:00
Peter Jin
82f8c137e1 udev/rules.d: make virtio-blk devices non-rotational
Performance measurements turned out that in certain situations the
paging/swap logic turns on the rotational feature for block devices. In the
past, this feature has been disabled for DASD devices. FCP and NVMe devices
are considered non-rotational by default (or exposed by the storage server).
Because those are the backing devices on Linux on Z/LinuxONE instances,
ensure that virtio-blk devices are always non-rotational.

Signed-off-by: Peter Jin <pjin@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-10 10:29:46 +01:00
Marc Hartmayer
b21a824fda cpacfinfo and pv: Fix comment style
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:34:48 +01:00
Marc Hartmayer
f74b8d7d6f cpacfinfo: Remove commented-out code
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:34:48 +01:00
Marc Hartmayer
b766d4a53c rust: Apply clippy fixes to format strings
Makes the code easier to read.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:34:48 +01:00
Marc Hartmayer
a1126352ec zipl/boot: Improve linker scripts
Output all text input sections into one text section and map all input
sections .bss.* .text.*, .rodata.*, and .data.* as it's done by the
default linker script [1]. In addition, make the linker script easier to
read by replacing the magic value of 32 with 'SIZEOF(.sb.trailer)'.

[1] Check the output of 'ld --verbose'.

Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:34:48 +01:00
Marc Hartmayer
35e539a428 zipl/boot: Declare 'magic' variable as static
Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:34:48 +01:00
Marc Hartmayer
99100b3f99 zipl/boot: Explicitly declare stage2.head as used
Although stage2.head is not directly used in stage2, it is required by
other stages. To ensure it is retained during link-time
optimization (LTO), explicitly mark it as used. This improves code
readability and prevents LTO from mistakenly removing it.

Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:34:48 +01:00
Marc Hartmayer
49faa1d7fd lib/zt_common.h: Add '__used' macro
The macro will be used in the next patch and makes checkpatch happy.

Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:34:48 +01:00
Marc Hartmayer
86ce85b3a6 zipl/boot: Fix typos
Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:34:48 +01:00
Marc Hartmayer
b1c1bea4e2 zipl/boot: Rename *.exec into *.elf
Rename .exec into .elf because they are ELF files, no reason to use a
different file extension.

This change improves the shell's autocompletion of tools such as
'readelf'.

Acked-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:34:48 +01:00
Ingo Franzki
e68547f06f libkmipclient: Fix return code passing
Function kmip_connection_tls_verify_server() erroneously always returns
zero, even if an error is detected inside the function. Fix this by
returning the return code value at the end of the function.

Found by clang static code analyzer.

Fixes: 56fecf1832 ("libkmipclient: Add KMIP client shared library")
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:34:48 +01:00
Ajaykumar Rajappa
95d784d866 ziomon/ziomon_fcpconf: Set mode to 755 to match install
No functional changes to the file content.

Signed-off-by: Ajaykumar Rajappa <ajaykr@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
[hoeppner@linux.ibm.com: Adapt commit message]
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:26 +01:00
Shalini Chellathurai Saroja
783ae9735e dbginfo: Collect CPI data of the KVM guests
Collect Control-Program Identification (CPI) data of the KVM
guests. The CPI data contains system name, system type,
system level and sysplex name of the guests. It also provides
the timestamp in which these data were colleceted from the
guests.

Note:
CPI information for SEL guests require explicit enablement.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Suggested-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Jörn Siglen <siglen@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:26 +01:00
Ingo Franzki
5a78c7f45d zkey: Report the KCV as part of the KMS label for KMS keys
The key check value (KCV) is the first 3 bytes of the ENC-ZERO key
verification pattern of a key. ENC-ZERO encrypts an all zero block with
the key using AES-ECB and returns the result truncated to 3 bytes as
key check value.

Report the KCV of a KMS generated key as part of its label. This is
especially useful for AES-XTS keys, where the KCV is reported on each
of the 2 individual AES keys that an AES-XTS key is built of. It allows
users to compare the KCV displayed by zkey with the KCV displayed by
the key management system where the key was generated on. If the KCV
value is the same, then the key values are the same, too.

The key verification pattern reported by zkey is also an ENC-ZERO
key check value, but for AES-XTS keys it is built by encrypting
the all zero block with AES-XTS, which produces a KCV for the complete
AES-XTS key, but does not allow to check the individual key parts.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:26 +01:00
Ingo Franzki
586040a0ad zkey/ekmfweb: Validate the certificate during client registration
When registering a zkey client at the EKMFWeb server, validate the
certificate if it's public key matches with the identity key of
the zkey client.

Only allow registration when the certificate matches. This helps to
prevent users from erroneously registering a wrong or outdated
certificate for a zkey client.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:26 +01:00
Ingo Franzki
deb61b5cd9 libekmfweb: Add function to validate a certificate against the identity key
Function ekmf_validate_cert() checks if the public key contained in a x509
certificate matches the public key of the identity key.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:26 +01:00
Ingo Franzki
8be51ad454 zkey: Perform KMS login before making any permanent changes to a key
A KMS login may prompt the user for its credentials. Users may abort that
prompt by Cntl-C. Do not make any permanent changes to a key before the
KMS login, because those changes can not be undone when the user has
aborted during KMS login, leaving the key in a potentially inconsistent
state.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:26 +01:00
Finn Callies
cef50c2140 cpacfstats: Recommend systemctl to manage daemon
Update manpage to recommend using systemctl to manage the cpacfstatsd.

Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:17 +01:00
L. E. Segovia
33bd112e2f s390-tools: Fix compilation with musl and gcc 14
lscss.c: In function 'is_sch_vfio':
lscss.c:392:20: error: implicit declaration of function 'basename' [-Wimplicit-function-declaration]
  392 |         if (strcmp(basename(driver_path), "vfio_ccw") == 0)

device.c: In function 'device_read_active_attrib':
device.c:426:45: error: implicit declaration of function 'basename'; did you mean 'rename'? [-Wimplicit-function-declaration]
  426 |                         value = misc_strdup(basename(link));
      |                                             ^~~~~~~~
      |                                             rename

Closes: https://github.com/ibm-s390-linux/s390-tools/pull/192
[hoeppner@linux.ibm.com: Sort includes]
Signed-off-by: L. E. Segovia <amy@amyspark.me>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:17 +01:00
Sertonix
2c31ed6f14 lib(ekmfweb|kmipclient): Use ln without -r
The option isn't portable (not in POSIX or busybox) and it easily works
without.

Closes: https://github.com/ibm-s390-linux/s390-tools/pull/191
Signed-off-by: Sertonix <sertonix@posteo.net>
Acked-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:16 +01:00
Jörn Siglen
771623832b dbginfo.sh: Add NetworkManager and netplan
NetworkManager stores new network profiles in keyfile format in the
/etc/NetworkManager/system-connections/ directory.

/etc/network/interfaces might be replaced by /etc/netplan on some systems

Reviewed-by: Mario Held <mario.held@de.ibm.com>
Reviewed-by: Michael Storzer <MSTORZER@de.ibm.com>
Signed-off-by: Jörn Siglen <siglen@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:16 +01:00
Jörn Siglen
b8060baf44 dbginfo.sh: Add kvm_stat
Add collecting of KVM kernel module event counters for one second.

Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Mario Held <mario.held@de.ibm.com>
Reviewed-by: Michael Storzer <MSTORZER@de.ibm.com>
Signed-off-by: Jörn Siglen <siglen@de.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:33:16 +01:00
Jan Höppner
76a0401deb common.mak: Remove NO_PIE_CFLAGS
The definition NO_PIE_CFLAGS has only two users and specifies only a
single compiler flag. There is no point having this definition anymore.

Remove the definition and specify -fno-pie directly for the two users.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:31:47 +01:00
Jan Höppner
e6ac87d7a2 common.mak: Remove NO_PIE_LDFLAGS
Commit c5a91199e3 ("zipl: Always build and link without PIE.")
introduced -fno-pie (for compilation) and -no-pie (for linking) for
zipl. At the time the linker was still used directly before commit
5e46632767 ("zipl: Use the compiler for linking instead of ld")
eventually switched to calling the compiler for the linking step.

During that adaption -static was introduced to the linker flags. -no-pie
was carried over as well. However -static implies -no-pie and it is
therefore not required. For GCC see also man 1 gcc (-static) [1]. Whilst
not explicitly documented, Clang shows the same behaviour. Clang also
complains when -static and -no-pie are specified in the linker step at
the same time with the following warning:

clang: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]

Since -no-pie is not required, remove it and get rid of the warning.

[1] https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-static
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:31:47 +01:00
Jan Höppner
0a711d4934 common.mak: Remove no-pie support check
The command line options -fno-pie/-no-pie are required by boot loaders
as they have strict layout requirements. A check was implemented using
-dumpspecs to evaluate the compiler support as older compilers didn't
support the no-pie command line options.
However, -dumpspecs is a GCC specific option and the check will
therefore always fail for Clang. The objective is to enable Clang
compilation support for s390-tools in the long-run.

Since support for -fno-pie/-no-pie in GCC was introduced 2015 with
version 6.1.0 and in Clang 2010 with version 3.0.0, general support can
be assumed.

Simply remove the support check and get rid of another obstacle that's
in the way for full Clang support.

Suggested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:31:47 +01:00
Marc Hartmayer
f90e913806 pvimg/boot: Remove double quotes in section keyword
The 'clang' compiler generates a section with the name '".loader_parms"'
and gcc '.loader_parms' if the double quotes are used. Fix this by
removing the superfluous double quotes, this results in a section with
the name '.loader_parms' for both clang and gcc.

Reported-by: Richie Buturla <richie@linux.ibm.com>
Reviewed-by: Euan Bourke <euan@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-11-07 14:31:47 +01:00
Jan Höppner
94a7ec22f2 Prepare for next release
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 10:38:51 +02:00
664 changed files with 35407 additions and 11402 deletions

View File

@@ -10,3 +10,4 @@
--ignore FILE_PATH_CHANGES
--ignore NEW_TYPEDEFS
--ignore SPDX_LICENSE_TAG
--ignore STRNCPY

37
.clang-tidy Normal file
View File

@@ -0,0 +1,37 @@
Checks: >
bugprone-*,
clang-analyzer-*,
misc-*,
performance-*,
portability-*,
readability-*,
-bugprone-easily-swappable-parameters,
-misc-include-cleaner,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-isolate-declaration,
-modernize-*,
-performance-*,
-portability-*,
-readability-implicit-bool-conversion
CheckOptions:
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.StructCase
value: lower_case
- key: readability-identifier-naming.EnumCase
value: lower_case
- key: readability-identifier-naming.EnumConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.MacroDefinitionCase
value: UPPER_CASE
- key: bugprone-sizeof-expression.WarnOnSizeOfPointer
value: true
- key: misc-unused-parameters.StrictMode
value: true
FormatStyle: file
UseColor: true

71
.gitignore vendored
View File

@@ -25,6 +25,7 @@ compile_commands.json
#
**/.detect-openssl.dep.c
*.debug
**/autocompletion_generator_host
ap_tools/ap-check
cmsfs-fuse/cmsfs-fuse
cpacfstats/cpacfstats
@@ -34,15 +35,37 @@ cpumf/lscpumf
cpumf/lshwc
cpumf/lspai
cpumf/pai
cpumf/_chcpumf
cpumf/_lscpumf
cpumf/_lshwc
cpumf/_lspai
cpumf/_pai
cpumf/chcpumf.bash
cpumf/lscpumf.bash
cpumf/lshwc.bash
cpumf/lspai.bash
cpumf/pai.bash
cpuplugd/cpuplugd
dasdfmt/dasdfmt
dasdfmt/_dasdfmt
dasdfmt/dasdfmt.bash
dasdinfo/dasdinfo
dasdinfo/_dasdinfo
dasdinfo/dasdinfo.bash
dasdview/dasdview
dasdview/_dasdview
dasdview/dasdview.bash
dump2tar/src/dump2tar
dump2tar/src/_dump2tar
dump2tar/src/dump2tar.bash
fdasd/fdasd
fdasd/_fdasd
fdasd/fdasd.bash
hmcdrvfs/hmcdrvfs
hsavmcore/check-dep-fuse
hsavmcore/hsavmcore
hsavmcore/_hsavmcore
hsavmcore/hsavmcore.bash
hyptop/hyptop
ip_watcher/xcec-bridge
ipl_tools/chreipl
@@ -63,7 +86,7 @@ libekmfweb/check-dep-libekmfweb
libekmfweb/detect-openssl-version.dep
libekmfweb/libekmfweb.so
libekmfweb/libekmfweb.so.1
libekmfweb/libekmfweb.so.1.0
libekmfweb/libekmfweb.so.1.1
libkmipclient/check-dep-libkmipclient
libkmipclient/detect-openssl-version.dep
libkmipclient/libkmipclient.so
@@ -75,34 +98,60 @@ libutil/*_example
libvmcp/vmcp_example
libzds/libzds.a
lsstp/lsstp
lsstp/_lsstp
lsstp/lsstp.bash
mon_tools/mon_fsstatd
mon_tools/mon_procd
opticsmon/opticsmon
zpcimon/zpcimon
zpcimon/zpcimon.bash
zpcimon/_zpcimon
zpcimon/opticsmon.bash
zpcimon/_opticsmon
osasnmpd/osasnmpd
qetharp/qetharp
qethqoat/qethqoat
systemd/cpacfstatsd.service
systemd/iucvtty-login@.service
systemd/ttyrun-getty@.service
tape390/tape390_crypt
tape390/tape390_display
tunedasd/src/tunedasd
tunedasd/src/_tunedasd
tunedasd/src/tunedasd.bash
vmcp/vmcp
vmcp/_vmcp
vmcp/vmcp.bash
vmur/vmur
zconf/chp/chchp
zconf/chp/_chchp
zconf/chp/chchp.bash
zconf/chp/lschp
zconf/chp/_lschp
zconf/chp/lschp.bash
zconf/chp/chpstat/chpstat
zconf/chp/chpstat/_chpstat
zconf/chp/chpstat/chpstat.bash
zconf/css/lscss
zconf/css/_lscss
zconf/css/lscss.bash
zconf/qeth/lsqeth
zconf/qeth/_lsqeth
zconf/qeth/lsqeth.bash
zconf/scm/lsscm
zconf/scm/_lsscm
zconf/scm/lsscm.bash
zconf/zcrypt/chzcrypt
zconf/zcrypt/_chzcrypt
zconf/zcrypt/chzcrypt.bash
zconf/zcrypt/lszcrypt
zconf/zcrypt/_lszcrypt
zconf/zcrypt/lszcrypt.bash
zconf/zcrypt/zcryptctl
zconf/zcrypt/zcryptstats
zconf/zcrypt/_zcryptstats
zconf/zcrypt/zcryptstats.bash
zdev/src/chzdev
zdev/src/chzdev_usage.c
zdev/src/chzdev_usage.h
zdev/src/lszdev
zdev/src/lszdev_usage.c
zdev/src/lszdev_usage.h
zdev/src/zdev_id
zdsfs/zdsfs
zdump/.check_dep_fuse
@@ -119,13 +168,15 @@ ziomon/ziomon_zfcpdd
ziomon/ziorep_traffic
ziomon/ziorep_utilization
zipl/boot/*.bin
zipl/boot/*.exec
zipl/boot/*.elf
zipl/boot/.loaders
zipl/boot/data.h
zipl/src/chreipl_helper.device-mapper
zipl/src/chreipl_helper.md
zipl/src/zipl
zipl/src/zipl-editenv
zipl/src/_zipl-editenv
zipl/src/zipl-editenv.bash
zipl/src/zipl_helper.device-mapper
zipl/src/zipl_helper.md
zkey/check-dep-zkey
@@ -138,5 +189,11 @@ zkey/kmip/zkey-kmip.so
zkey/zkey
zkey/zkey-cryptsetup
zmemtopo/zmemtopo
zmemtopo/_zmemtopo
zmemtopo/zmemtopo.bash
zpcictl/zpcictl
zpcictl/_zpcictl
zpcictl/zpcictl.bash
zpwr/zpwr
zpwr/_zpwr
zpwr/zpwr.bash

View File

@@ -1,13 +1,12 @@
edition = "2021"
newline_style = "Unix"
# Unstable options that help catching some mistakes in formatting and that we may want to enable
# when they become stable.
#
# They are kept here since they are useful to run from time to time.
#comment_width = 100
#format_code_in_doc_comments = true
#group_imports = "StdExternalCrate"
#normalize_comments = true
# Unstable options that help catching some mistakes in formatting
group_imports = "StdExternalCrate"
imports_granularity = "Module"
use_field_init_shorthand = true
comment_width = 100
format_code_in_doc_comments = true
normalize_comments = true
wrap_comments = true
#reorder_impl_items = true
#wrap_comments = true

View File

@@ -1,19 +1,23 @@
List of all individuals having contributed content to s390-tools
----------------------------------------------------------------
- Ajaykumar Rajappa
- Alexander Egorenkov
- Alexandra Winter
- Alexey Ishchuk
- Andreas Herrmann
- André Wild
- Annu Sharma
- Antoinette Kaschner
- Arnd Bergmann
- Aswin Karuvally
- Axel Wirbser
- Balint Reczey
- Benjamin Block
- Bjoern Walk
- Brian C. Lane
- Carsten Otte
- Chinmaya Kajagar
- Christian Borntraeger
- Christian Ehrhardt
- Christof Schmitt
@@ -23,11 +27,13 @@ List of all individuals having contributed content to s390-tools
- Dan Horak
- Dan Horák
- Daniel S. Haischt
- Dean Doyle
- Despina Papadopoulou
- Dimitri John Ledkov
- Eberhard Pasch
- Eduard Shishkin
- Einar Lueck
- Ellen McIntyre
- Eric Farman
- Eric Sandeen
- Erwin Vicari
@@ -49,8 +55,8 @@ List of all individuals having contributed content to s390-tools
- Graham Inggs
- Guevenc Guelce
- Hannes Reinecke
- Hans-Joachim Picht
- Hans Wippel
- Hans-Joachim Picht
- Harald Freudenberger
- Heiko Carstens
- Hendrik Brueckner
@@ -71,13 +77,13 @@ List of all individuals having contributed content to s390-tools
- Jean-Baptiste Joret
- Jens Remus
- Jochen Roehrig
- Joern Siglen
- Jörn Siglen
- Juergen Christ
- Julian Wiedmann
- Jörn Siglen
- Karsten Graul
- Kittipon Meesompop
- Klaus-Dieter Wacker
- L. E. Segovia
- Lakhvich Dmitriy
- Marc Hartmayer
- Mario Held
@@ -128,11 +134,13 @@ List of all individuals having contributed content to s390-tools
- Steffen Eiden
- Steffen Maier
- Steffen Thoss
- Stephen Gallagher
- Sumanth Korikkar
- Susanne Wintenberger
- Sven Schnelle
- Sven Schuetz
- Swen Schillig
- Szabina Korbai
- Taraka R. Bodireddy
- Thomas Heidrich
- Thomas Huth
@@ -140,6 +148,7 @@ List of all individuals having contributed content to s390-tools
- Thomas Spatzier
- Thomas Weber
- Thorsten Winkler
- Timo Keller
- Tobias Huschle
- Tuan Hoang
- Ursula Braun
@@ -149,7 +158,9 @@ List of all individuals having contributed content to s390-tools
- Vasily Gorbik
- Viktor Mihajlovski
- Vineeth Vijayan
- Volkan Unal
- Volker Sameske
- Wenjia Zhang
- Wisdom Erhimwionsobo
- Wolfgang Taphorn
- Yaakov Selkowitz

View File

@@ -1,6 +1,195 @@
Release history for s390-tools (MIT version)
--------------------------------------------
* __v2.44.0 (2026-07-31)__
For Linux kernel version: 7.2
Changes of existing tools / libraries:
- create-sehdr: Enable quantum safe keys usage
- dbginfo.sh: Let zpcimon log both optical module and SMART data
- libutil/util_fmt: Add util_fmt_type_to_name()
- nvmemon: Skip SCLP on NVMes with non-IBM subsystem vendor ID
- opticsmon: zpcimon: Rename opticsmon to zpcimon
- pvattest: Enable quantum safe keys usage
- pvimg: Add '--flags <...>' and '--disable-flags <...>' option
- pvimg: Enable quantum safe keys usage
- pvsecret: Enable quantum safe keys usage
- pvverify: Enable quantum safe keys usage
- zmemtopo: Add CLI option to filter partitions by name
- zpcimon: Allow setting output format using --format CLI option
- zpcimon: Monitor for hotplug of NVMes to trigger SMART collection
Bug Fixes:
- opticsmon: Fix wrong size check for OPTICS_QSFP28_LOS_IMPLEMENTED_OFFSET
- opticsmon: Handle error return of ethtool_nl_connect()
- opticsmon: Fix error path free of struct optics in ethtool_nl_get_optics()
- opticsmon: Close epoll fd in monitor_wait_loop()
- opticsmon: Fix wrong JSON print for tx_fault
* __v2.43.1 (2026-07-22)__
For Linux kernel version: 7.1
Changes of existing tools:
- dasdfmt: Check disk type before prompting for blocksize
- iucvterm/ts-shell: Introduce config parameter to specify iucvconn binary
- iucvterm/ts-shell: Introduce pager config to replace env variable
- pv: Add root CA organization pinning to certificate verification
- zdump/ngdump: Use OpenSSL's SHA256 to compute digest of dump image
Bug Fixes:
- 95sel-ebc: Add udev-settle dependency
- 95sel-ebc: Add umount to boot service
- 95sel-ebc: Harden boot mount service
- fdasd: Fix memory leak in yes_no() function
- iucvterm/iucvtty: Ensure PTY and server fd's are closed at exec
- iucvterm/iucvtty: Prevent connection stalls when receiving TERM env
- iucvterm/iucvtty: Validate TERM environment name
- libkmipclient: Protect from symlink-following attacks
- libkmipclient: Various bugfixes
- libseckey: Protect from symlink-following attacks
- libseckey: Various bugfixes
- mon_procd: Fix possible static buffer overflow
- osasnmpd: Fix SNMP non-compliance
- zdev: Harden against invalid udev, import, firmware, or hypervisor data
- zipl-editenv: Check in-bootmap environment block validity
- zipl/boot: Check in-bootmap environment block syntax
- zipl: Check keyword duplications in BLS entries
- zipl: Fix bugs in mirror support
- zkey: Protect from symlink-following attacks
* __v2.43.0 (2026-06-25)__
For Linux kernel version: 7.1
s390-tools: Set Rust MSRV to 1.85.0
Changes of existing tools:
- dbginfo.sh: Add IBM appliance specific files
- lshwc: Show explicitly selected unnamed counters with --hide
- pvattest: Add firmware check version 2
- zipl: Introduce verbosity levels of zipl session (--debug)
- zkey: Remove the use of AF_ALG for calculating key verification patterns
Bug Fixes:
- ebc: implement --version option for pvics
- pvebc: Log services to journal+console
- pvics: Fix virt-resize permission error
* __v2.42.1 (2026-05-22)__
For Linux kernel version: 7.0
Changes of existing tools:
- cpumf/pai: Improve -m XXX argument verification
- pvattest: Add -i -o option variant for check
- pvattest: Show perform -i & -o option in help
- pvebc: Disable unit logging to /boot
- pvsecret: Add -i -o option variants
Bug Fixes:
- cpumf/pai: Remove unnecessary const parameter definition
- pv: Fix error description
- pvebc: Fix dependency for non EBC guests
- pvebc: Fix kernel module dependencies
- zipl: Don't modify job->data.dump and job->data.mvdump sequentially
* __v2.42.0 (2026-04-30)__
For Linux kernel version: 7.0
Add new tools / libraries:
- Enable zsh and bash autocompletion for various tools
- pvebc: Resolve ASR integrity structure for EBC
- pvics: Generate SEL guests from base images
Remove:
- tape390_display and tape390_crypt removed due to long gone hardware support
- znetcontrolunits: Remove znetcontrolunits library
Changes of existing tools:
- cpumf/pai: Install SIGINT/SIGTERM handler for graceful termination
- dbginfo.sh: Add command zmemtopo
- libutil/util_fmt: Add support for JSON Lines text format
- lstape: Remove 3480 and 3590 tape support
- lsznet: Remove support for lcs device type
- pvsecret: Add support for ASR integrity structure for EBC
- zfcpdbf: Print plogi and prli within open port response as payload
- zfcpdbf: Trace all fsf status read buffer fields under HBA
- zipl/boot: Add secure boot option to the dump programm
- zkey, libekmfweb, libseckey, libkmipclient: Adjust for OpenSSL v4.0.0 API
changes and deprecations
Bug Fixes:
- hyptop/opts: Fix long command line option abbreviations
- libutil/util_autocomp: Fix default file completion
- zipl/boot: Fix stage3 secure boot trailer placement
* __v2.41.0 (2026-02-16)__
For Linux kernel version: 6.19
Changes of existing tools:
- chreipl: Make --bootparms work for ECKD re-IPL
- cpacfstats: Add 'unauthorized' state to CPU-MF counters
- cpictl: Detect RHCOS using VARIANT_ID
- hsci: Automatically set appropriate MTU for HSCI
- libutil: Add util_readlink() and util_readlinkat() helpers
- libutil: Add util_startswith() to util_str
- libutil: Add utility parsing functions
- lschp: Add support for structured output (--format)
- lsreipl: Suppress 'clear' output if not supported
- pvimg: Add '--format text' support to 'pvimg info'
- pvimg: Add '--print-schema <FORMAT>' option to 'pvimg info'
- pvimg: Add '--show-secrets' flag to 'pvimg info'
- pvimg: Provide improved JSON output to 'pvimg info --format json'
- pvinfo: Improve User experience on non-SE enabled systems
- zipl/ngdump: Ensure ext4 file system is used on dump partition
- zkey: Add support for integrity protected disks using HMAC keys
Bug Fixes:
- cpumf/pai: Handle different size of perf_event_attr
- lscss: Fix memory leak
- zipl: Fix dump job on tape devices
* __v2.40.0 (2025-12-11)__
For Linux kernel version: 6.18
Add new tools / libraries:
- Add project-wide .clang-tidy configuration
- libutil: Introduce util_time for time related functionality
- libutil: Introduce zsh/bash autocompletion tooling based on util_opt
- pvinfo: Tool to display Secure Execution system information
- pvverify: Tool to verify host-key documents
Changes of existing tools:
- cpumf: Implement zsh and bash autocompletion
- dasdfmt: Implement zsh and bash autocompletion
- dbginfo.sh: Add NetworkManager and netplan
- dbginfo.sh: Add kvm_stat
- dbginfo.sh: Adding stp time information
- dbginfo.sh: Simplify procfs collection
- hyptop: Add physical information row
- hyptop: Calculate sample time delta for physical partition
- hyptop: Replace long option names using _ with - for consistency
For example: --cpu_types -> --cpu-types
(Options with _ are still supported for backward compatibility)
- libekmfweb: Add function to validate a certificate against the identity key
- netboot: Add longer kernel command lines support
- udev/rules.d: Make virtio-blk devices non-rotational
- udev/rules.d: Set default io scheduler to 'none' for virtio-blk
- ziomon: Add support to sample device symlinks (/dev/disk/...)
- ziorep_config: Add fcp-lun details to -M option output
- ziorep_config: Add port_id and failed attributes to -A option output
- netboot: Install on non-s390 architectures
Bug Fixes:
- lib(ekmfweb|kmipclient): Use ln without -r
- s390-tools: Fix various compilation issues with musl libc
- zipl/boot: Fix unused loadparm when SCLP line-mode console is absent
* __v2.39.0 (2025-10-14)__
For Linux kernel version: 6.16 / 6.17

View File

@@ -11,17 +11,17 @@ BASELIB_DIRS = libutil libseckey
LIB_DIRS = libvtoc libzds libdasd libccw libvmcp libekmfweb \
libkmipclient libcpumf libap libpv libzpci
TOOL_DIRS = zipl zdump fdasd dasdfmt dasdview tunedasd \
tape390 osasnmpd qetharp ip_watcher qethconf scripts zconf \
osasnmpd qetharp ip_watcher qethconf scripts zconf \
vmcp man mon_tools dasdinfo vmur cpuplugd ipl_tools \
ziomon iucvterm hyptop cmsfs-fuse qethqoat zfcpdump zdsfs cpumf \
systemd hmcdrvfs cpacfstats zdev dump2tar zkey netboot etc zpcictl \
lsstp hsci hsavmcore chreipl-fcp-mpath ap_tools rust opticsmon \
lsstp hsci hsavmcore chreipl-fcp-mpath ap_tools rust zpcimon \
zpwr zmemtopo
else
BASELIB_DIRS =
LIB_DIRS = libpv
TOOL_DIRS = rust
TOOL_DIRS = netboot rust
endif
SUB_DIRS = $(BASELIB_DIRS) $(LIB_DIRS) $(TOOL_DIRS)

View File

@@ -30,6 +30,8 @@ Package contents
Manage secrets for IBM Secure Execution guests
- pvimg:
Create and inspect IBM Secure Execution images
- pvebc:
Verify a secret structure for IBM Secure Execution for Linux.
* dasdfmt:
Low-level format ECKD DASDs with the classical Linux disk layout or the new
@@ -50,6 +52,10 @@ Package contents
Create an IBM Secure Execution (protected virtualization) image. The
genprotimg command is a symbolic link to the `pvimg create` command.
* pvics:
Convert a qcow2 image to a qcow2 image ready to boot as IBM Secure Execution
for Linux guest.
* udev rules:
- 59-dasd.rules: rules for unique DASD device nodes created in /dev/disk/.
- 57-osasnmpd.rules: udev rules for osasnmpd.
@@ -79,13 +85,6 @@ Package contents
* qetharp:
Read and flush the ARP cache on OSA Express network cards.
* tape390_display:
Display information on the message display facility of a s390 tape
device.
* tape390_crypt:
Control and query crypto settings for 3592 tape devices.
* osasnmpd:
NET-SNMP subagent implementing MIBs provided by OSA-Express
features Fast Ethernet, Gigabit Ethernet, 10 Gigabit Ethernet.
@@ -317,7 +316,7 @@ build options:
| glibc-static | `HAVE_LIBC_STATIC` | zfcpdump |
| openssl | `HAVE_OPENSSL` | zkey, libekmfweb, libkmipclient, |
| | | zgetdump, rust/pvattest, rust/pvimg, |
| | | zgetdump/pvsecret, opticsmon |
| | | zgetdump/pvsecret, zpcimon |
| cryptsetup | `HAVE_CRYPTSETUP2` | zkey-cryptsetup |
| json-c | `HAVE_JSONC` | zkey-cryptsetup, libekmfweb, |
| | | libkmipclient |
@@ -326,8 +325,9 @@ build options:
| | | rust/pvattest, rust/pvsecret, |
| libxml2 | `HAVE_LIBXML2` | libkmipclient |
| systemd | `HAVE_SYSTEMD` | hsavmcore |
| libudev | `HAVE_LIBUDEV` | cpacfstatsd |
| libnl3 | `HAVE_LIBNL3` | opticsmon |
| libudev | `HAVE_LIBUDEV` | cpacfstatsd, zpcimon |
| libnl3 | `HAVE_LIBNL3` | zpcimon |
| libnvme | `HAVE_LIBNVME` | zpcimon |
This table lists additional build or install options:
@@ -375,11 +375,11 @@ the different tools are provided:
The runtime requirements are: openssl-libs (>= 1.1.1) and libcurl.
* opticsmon:
For building opticsmon OpenSSL and the Netlink Library Suite (libnl3) are
required.
Tip: you may skip the opticsmon build by adding
`HAVE_OPENSSL=0` or `HAVE_LIBNL3=0`
* zpcimon:
For building zpcimon OpenSSL, the Netlink Library Suite (libnl3),
and libnvme are required.
Tip: you may skip the zpcimon build by adding
`HAVE_OPENSSL=0` or `HAVE_LIBNL3=0` or `HAVE_LIBNVME=0`.
* osasnmpd:
You need at least the NET-SNMP 5.1.x package (net-snmp-devel.rpm)
@@ -415,7 +415,7 @@ the different tools are provided:
Removing the inflate modules and function prototypes are the only major
modifications made to the kernel version of zlib.
For stand-alone NVMe and list-directed DASD dump, the following tools/packages
are required to populate dumper's initramfs:
are required to populate dumper's initramfs and prepare a dump partition:
- cat
- cut
- findmnt
@@ -426,6 +426,7 @@ the different tools are provided:
- sha256sum
- sync
- umount
- mkfs.ext4
* zgetdump
For building zgetdump you need OpenSSL version 1.1.0 or newer
@@ -517,11 +518,11 @@ the different tools are provided:
* zkey:
For building the zkey tools you need openssl version 0.9.7 or newer installed
(openssl-devel.rpm). Also required are cryptsetup version 2.0.3 or newer
(openssl-devel.rpm). Also required are cryptsetup version 2.8.2 or newer
(cryptsetup-devel.rpm), and json-c version 0.12 or newer (json-c-devel.rpm).
Tip: you may skip the zkey build by adding `HAVE_OPENSSL=0`, and you may
may skip the zkey-cryptsetup build by adding `HAVE_CRYPTSETUP2=0`, or
`HAVE_JSONC=0` to the make invocation.
Tip: you may skip the zkey build by adding `HAVE_OPENSSL=0` or
`HAVE_CRYPTSETUP2=0`, and you may skip the zkey-cryptsetup build
by adding `HAVE_JSONC=0` to the make invocation.
A new group 'zkeyadm' needs to be created and all users intending to use the
tool must be added to this group. The owner of the default key repository
'/etc/zkey/repository' must be set to group 'zkeyadm' with write permission

View File

@@ -303,11 +303,11 @@ static void conflict_error(const char *uuid, unsigned int a, unsigned int d,
}
} else {
if (persistent) {
fprintf(stderr, "AQPN %u.%u is not defined for "
fprintf(stderr, "APQN %u.%u is not defined for "
"vfio_ap-passthrough use by the persistent "
"ap bus mask settings\n", a, d);
} else {
fprintf(stderr, "AQPN %u.%u is not allowed for "
fprintf(stderr, "APQN %u.%u is not allowed for "
"vfio_ap-passthrough use by the active ap "
"bus mask settings\n", a, d);
}
@@ -531,7 +531,7 @@ out:
* Determine if there are any conflicts between the specified device and
* the apmask/aqmask settings stored in udev. This is done by treating
* the masks as a temporary vfio_ap_device with all of the associated
* AQPNs owned by the system.
* APQNs owned by the system.
*/
static int check_cfg_mask_conflicts(struct ap_check_anchor *anc)
{

View File

@@ -129,7 +129,7 @@ else # $(ENABLE_DOC) != 1
# freshness of the man page can be checked, even if `pandoc` is not available,
# or ENABLE_DOC disabled.
MANPAGE_FRESH := $(shell sha256sum --check .chreipl-fcp-mpath.7.cksum >/dev/null && echo 1 || echo 0)
MANPAGE_FRESH := $(shell sha256sum -c .chreipl-fcp-mpath.7.cksum >/dev/null && echo 1 || echo 0)
ifeq ($(MANPAGE_FRESH),0)
$(warning chreipl-fcp-mpath.7 is outdated, please regenerate it by calling `make ENABLE_DOC=1`)
endif

View File

@@ -713,7 +713,7 @@ static int readdir_entry(struct fst_entry *fst, off_t addr)
*/
static inline int strip_right(const char *str, int size)
{
while (str[size - 1] == 0x20)
while (size > 0 && str[size - 1] == 0x20)
size--;
return size;
}

View File

@@ -32,7 +32,7 @@ endif
# The variable "DISTRELEASE" should be overwritten in rpm spec files with:
# "make DISTRELEASE=%{release}" and "make install DISTRELEASE=%{release}"
VERSION := 2
RELEASE := 39
RELEASE := 44
PATCHLEVEL := 0
DISTRELEASE := build-$(shell date +%Y%m%d)
S390_TOOLS_RELEASE := $(VERSION).$(RELEASE).$(PATCHLEVEL)-$(DISTRELEASE)
@@ -119,6 +119,10 @@ ifneq ($(HOST_ARCH),$(BUILD_ARCH))
endif
endif
# *_FOR_BUILD variables define compilation configurations for binaries used
# during the build process (e.g. autocompleteion script generators). This
# is especially important for cross-compilation where these binaries need to
# be executed on the build system.
$(eval $(call define_toolchain_variables,_FOR_BUILD,))
$(eval $(call define_toolchain_variables,,$(CROSS_COMPILE)))
@@ -165,7 +169,7 @@ ifeq ("${ENABLE_WERROR}", "1")
endif
DEFAULT_CPPFLAGS = -D_GNU_SOURCE
DEFAULT_LDFLAGS = -rdynamic
DEFAULT_LDFLAGS = -rdynamic -Wl,--as-needed
ifeq ("${ASAN}","1")
DEFAULT_CFLAGS += -fsanitize=address -fno-omit-frame-pointer
@@ -201,7 +205,7 @@ endef
# $5: Additional compiler & linker options (optional)
#
check_dep=\
printf "\#include <%s>\n int main(void) {return 0;}\n" $2 | ( $(CC) $(filter-out --coverage, $(ALL_CFLAGS)) $(ALL_CPPFLAGS) $5 -o /dev/null -x c - ) > /dev/null 2>&1; \
printf "\#include <%s>\n int main(void) {return 0;}\n" $2 | ( $(CC) $(filter-out --coverage, $(ALL_CFLAGS)) $(ALL_CPPFLAGS) -Wl,--no-as-needed $5 -o /dev/null -x c - ) > /dev/null 2>&1; \
if [ $$? != 0 ]; \
then \
printf " REQCHK %s (%s)\n" $1 $2; \
@@ -340,14 +344,6 @@ endif
export INSTALL CFLAGS CXXFLAGS \
LDFLAGS CPPFLAGS ALL_CFLAGS ALL_CXXFLAGS ALL_LDFLAGS ALL_CPPFLAGS
ifneq ($(shell $(CC_SILENT) -dumpspecs 2>/dev/null | grep -e '[^f]no-pie'),)
NO_PIE_CFLAGS := -fno-pie
NO_PIE_LDFLAGS := -no-pie
else
NO_PIE_CFLAGS :=
NO_PIE_LDFLAGS :=
endif
# Overwrite implicit makefile rules for having nice compile output
%.o: %.c
ifeq ("${C}","1")

81
common_autocomp.mak Normal file
View File

@@ -0,0 +1,81 @@
# SPDX-License-Identifier: MIT
# Copyright IBM Corp. 2025
# This file defines the build process for shell autocompletion binaries
#
# How to incorporate it into tool Makefiles:
#
# 0. The file with the autocompletion script generation code should be named
# 'autocompletion_generator_host.c'
#
# 1. Define the 'bash-completions' and 'zsh-completions' variables: both must be a list
# of the names of all the shell completion scripts that belong to the tools the Makefile
# is responsible for building.
#
# (The name of a zsh completion script is the same as the name of the tool,
# prefixed by an underscore)
#
# (The name of a bash completion script is the same as the name of the tool,
# suffixed by '.bash')
#
# 2. include this file
#
# +1: Add the autocompletion scripts to the .gitignore file
#
# (See cpumf or dasdfmt as example)
autocomplete-bin := autocompletion_generator_host
autocomp-object := $(rootdir)/libutil/util_autocomp_host.o
$(autocomp-object): $(rootdir)/libutil
$(MAKE) -C $(rootdir)/libutil/ $(notdir $@)
$(autocomplete-bin).o: $(autocomplete-bin).c
$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) -I $(rootdir)/include -c $< -o $@
$(autocomplete-bin): $(autocomplete-bin).o $(autocomp-object)
$(LINK_FOR_BUILD) $^ -o $@
$(bash-completions) $(zsh-completions) &: $(autocomplete-bin)
./$(autocomplete-bin)
install-shell-completions: $(bash-completions) $(zsh-completions)
$(INSTALL) -d -m 755 $(DESTDIR)$(ZSHCOMPLETIONDIR)
$(INSTALL) -d -m 755 $(DESTDIR)$(BASHCOMPLETIONDIR)
for completion in $(bash-completions); do \
$(INSTALL) -m 644 $$completion $(DESTDIR)$(BASHCOMPLETIONDIR); \
done
for completion in $(zsh-completions); do \
$(INSTALL) -m 644 $$completion $(DESTDIR)$(ZSHCOMPLETIONDIR); \
done
all: $(zsh-completions) $(bash-completions)
install: install-shell-completions
.PHONY: install-shell-completions $(rootdir)/libutil
clean-autocomplete-bin:
$(RM) -- $(autocomplete-bin)
clean: clean-autocomplete-bin
ifdef bash-completions
clean-bash-completions:
$(RM) -- $(bash-completions)
clean: clean-bash-completions
endif
ifdef zsh-completions
clean-zsh-completions:
$(RM) -- $(zsh-completions)
clean: clean-zsh-completions
endif
.PHONY: clean-autocomplete-bin clean-bash-completions clean-zsh-completions

View File

@@ -79,9 +79,11 @@ the cpacfstats client application.
Example usage scenario:
.P
1. Start the cpacfstatsd daemon with root privileges.
1. Start the cpacfstatsd daemon with root privileges using 'systemctl start
cpacfstatsd'.
.P
2. Check for successful startup by using the ps and syslog commands.
2. Check for successful startup by using the 'systemctl status cpacfstatsd'
command.
.P
3. Enable the CPACF counters of interest. For example, enable all counters
by issuing cpacfstats -e.
@@ -95,7 +97,7 @@ cryptographic counters as required. To reset, use, for example, cpacfstats
6. Disable all the CPACF measurements, for example, by using cpacfstats
-d.
.P
7. Shutdown the cpacfstatsd daemon by using killall cpacfstatsd.
7. Shutdown the cpacfstatsd daemon by using 'systemctl stop cpacfstatsd'.
.SH OPTIONS
.TP
@@ -177,6 +179,12 @@ the errno value.
ECC counters are only available since z15. cpacfstats will show the
counters as \fIunsupported\fR if the hardware does not support ECC
counters.
CPU-MF counters have to be authorized on HMC or SE to be available and are
otherwise shown as \fIunauthorized\fR. On the HMC or SE, authorize the LPAR
for each counter set you want to use. Customize the LPAR activation profile
and modify the Counter Facility Security Options. You need to activate the
\fICrypto activity counter set authorization control\fR checkbox.
.
.SH APPENDIX
The detailed pai counter names are:

View File

@@ -175,9 +175,10 @@ static void print_virtual_counter_answer(int s,
int ctr, int state, uint64_t value)
{
static const char *const states[] = {
[DISABLED] = "disabled",
[ENABLED] = "enabled",
[UNSUPPORTED] = "unsupported"
[DISABLED] = "disabled",
[ENABLED] = "enabled",
[UNSUPPORTED] = "unsupported",
[UNAUTHORIZED] = "unauthorized"
};
int paictr = 0, paistate = 0, ec;
uint64_t i, paivalue = 0;
@@ -242,6 +243,8 @@ static void print_answer(int s, int ctr, int state, uint64_t value)
printf(" %s counter: disabled\n", counter_str[ctr]);
else if (state == UNSUPPORTED)
printf(" %s counter: unsupported\n", counter_str[ctr]);
else if (state == UNAUTHORIZED)
printf(" %s counter: unauthorized\n", counter_str[ctr]);
else
printf(" %s counter: %lu\n", counter_str[ctr], value);
}

View File

@@ -74,7 +74,8 @@ enum cmd_e {
enum state_e {
DISABLED = 0,
ENABLED,
UNSUPPORTED
UNSUPPORTED,
UNAUTHORIZED
};
enum counter_type {

View File

@@ -179,7 +179,7 @@ static int do_enable(int s, enum ctr_e ctr, unsigned int *supported_counters)
}
state = ENABLED;
}
if (state != UNSUPPORTED) {
if (state != UNSUPPORTED && state != UNAUTHORIZED) {
rc = perf_read_ctr(i, &value, supported_counters);
if (rc != 0) {
send_answer(s, i, rc, 0);

View File

@@ -141,6 +141,10 @@ static int perf_counter_supported(const char *pmu, const char *counter)
return !access(buf, R_OK);
}
/**
* Returns 1 if counters are authorized, -1 if counters are unauthorized,
* and 0 otherwise which indicates that the counters are unsupported
*/
static int cpumf_authorized(void)
{
unsigned vermin, vermax, auth;
@@ -159,10 +163,12 @@ static int cpumf_authorized(void)
if (sscanf(line,
"CPU-MF: Counter facility: version=%d.%d authorization=%x",
&vermin, &vermax, &auth) == 3) {
if (auth & 0x8)
if (auth & 0x8) {
res = 1;
else
} else {
eprint("CPU-MF counters not authorized.\n");
res = -1;
}
found = 1;
break;
}
@@ -233,7 +239,7 @@ static int activatecpu(unsigned int cpu, unsigned int *supported_counters)
}
/* activate CPU-MF */
for (i = 0; i < ALL_COUNTER; ++i) {
if (ctr_state[i] == UNSUPPORTED)
if (ctr_state[i] == UNSUPPORTED || ctr_state[i] == UNAUTHORIZED)
continue;
memset(&pfm_event, 0, sizeof(pfm_event));
pfm_event.size = sizeof(pfm_event);
@@ -398,7 +404,7 @@ static int perf_load_counter_data(void)
int i, res = 0;
for (i = 0; i < ALL_COUNTER; ++i) {
if (ctr_state[i] != UNSUPPORTED)
if (ctr_state[i] != UNSUPPORTED && ctr_state[i] != UNAUTHORIZED)
res |= perf_event_encode(&pmf_counter_data[i].pmutype,
&pmf_counter_data[i].eventid,
pmf_counter_name[i].pmu,
@@ -474,6 +480,7 @@ int perf_init(unsigned int *supported_counters)
};
unsigned long maxfd;
struct rlimit rlim;
int cpumf_state;
int i, num;
FILE *f;
@@ -487,10 +494,15 @@ int perf_init(unsigned int *supported_counters)
* counters for PAI. */
num = ALL_COUNTER + 2;
if (!cpumf_authorized()) {
cpumf_state = cpumf_authorized();
if (cpumf_state == 0) {
for (i = 0; i < ALL_COUNTER; ++i)
ctr_state[i] = UNSUPPORTED;
num -= ALL_COUNTER;
} else if (cpumf_state == -1) {
for (i = 0; i < ALL_COUNTER; ++i)
ctr_state[i] = UNAUTHORIZED;
num -= ALL_COUNTER;
} else {
for (i = 0; i < ALL_COUNTER; i++) {
if (!perf_counter_supported("cpum_cf", cpum_cf[i])) {

View File

@@ -16,6 +16,7 @@
#include <poll.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>

View File

@@ -3,6 +3,11 @@ include ../common.mak
BIN_FILES = lscpumf chcpumf lshwc pai lspai
MAN_FILES = lscpumf.8 chcpumf.8 lshwc.8 pai.8 lspai.8
zsh-completions := $(addprefix _,$(BIN_FILES))
bash-completions := $(addsuffix .bash,$(BIN_FILES))
include ../common_autocomp.mak
all: $(BIN_FILES)
libs = $(rootdir)/libcpumf/libcpumf.a $(rootdir)/libutil/libutil.a

View File

@@ -0,0 +1,24 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#include "lib/util_autocomp.h"
#include "chcpumf_cli.h"
#include "lscpumf_cli.h"
#include "lshwc_cli.h"
#include "lspai_cli.h"
#include "pai_cli.h"
int main(void)
{
generate_autocomp(chcpumf_opt_vec, "chcpumf");
generate_autocomp(lscpumf_opt_vec, "lscpumf");
generate_autocomp(lshwc_opt_vec, "lshwc");
generate_autocomp(lspai_opt_vec, "lspai");
generate_autocomp(pai_opt_vec, "pai");
return 0;
}

View File

@@ -7,7 +7,7 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <errno.h>
#include <err.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
@@ -17,37 +17,15 @@
#include <sys/stat.h>
#include "lib/libcpumf.h"
#include "lib/util_base.h"
#include "lib/util_opt.h"
#include "lib/util_path.h"
#include "lib/util_prg.h"
#include "chcpumf_cli.h"
static unsigned int verbose;
static unsigned long min_sdb, max_sdb;
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "min", required_argument, NULL, 'm' },
.argument = "num_sdb",
.desc = "Specifies the initial size of the sampling buffer.\n"
"A sample-data-block (SDB) consumes about 4 kilobytes.",
},
{
.option = { "max", required_argument, NULL, 'x' },
.argument = "num_sdb",
.desc = "Specifies the maximum size of the sampling buffer.\n"
"A sample-data-block (SDB) consumes about 4 kilobytes.",
},
{
.option = { "verbose", no_argument, NULL, 'V' },
.desc = "Verbose, display new sample-data-block values.",
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
static const struct util_prg prg = {
.desc = "Change CPU Measurement facility charactertics",
.copyright_vec = {
@@ -163,7 +141,7 @@ int main(int argc, char **argv)
unsigned long my_min, my_max;
util_prg_init(&prg);
util_opt_init(opt_vec, NULL);
util_opt_init(chcpumf_opt_vec, NULL);
parse_args(argc, argv);
if (geteuid())

36
cpumf/chcpumf_cli.h Normal file
View File

@@ -0,0 +1,36 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef CHCPUMF_CLI_H
#define CHCPUMF_CLI_H
#include "lib/util_fmt.h"
#include "lib/util_opt.h"
static struct util_opt chcpumf_opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "min", required_argument, NULL, 'm' },
.argument = "num_sdb",
.desc = "Specifies the initial size of the sampling buffer.\n"
"A sample-data-block (SDB) consumes about 4 kilobytes.",
},
{
.option = { "max", required_argument, NULL, 'x' },
.argument = "num_sdb",
.desc = "Specifies the maximum size of the sampling buffer.\n"
"A sample-data-block (SDB) consumes about 4 kilobytes.",
},
{
.option = { "verbose", no_argument, NULL, 'V' },
.desc = "Verbose, display new sample-data-block values.",
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
#endif

View File

@@ -7,8 +7,7 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <ctype.h>
#include <errno.h>
#include <err.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
@@ -31,6 +30,8 @@
#include "lib/libcpumf.h"
#include "lscpumf_cli.h"
#define ACTION_NONE 0
#define ACTION_INFO 1
#define ACTION_CNT 2
@@ -47,33 +48,6 @@ static bool actions[ACTION_SAMPLE + 1]; /* Specified command line options */
/* File names to read data from */
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "list-counters", no_argument, NULL, 'c' },
.desc = "Lists counters for which the LPAR is authorized.",
},
{
.option = { "list-all-counters", no_argument, NULL, 'C' },
.desc = "Lists counters regardless of LPAR authorization.",
},
{
.option = { "name", no_argument, NULL, 'n' },
.desc = "Displays counter names.",
},
{
.option = { "info", no_argument, NULL, 'i' },
.desc = "Displays detailed information.",
},
{
.option = { "list-sampling-events", no_argument, NULL, 's' },
.desc = "Lists sampling events for which the LPAR is authorized.",
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
static const struct util_prg prg = {
.desc = "List CPU Measurement facility charactertics",
.copyright_vec = {
@@ -4160,7 +4134,7 @@ int main(int argc, char **argv)
int ret;
util_prg_init(&prg);
util_opt_init(opt_vec, NULL);
util_opt_init(lscpumf_opt_vec, NULL);
ret = parse_args(argc, argv);
if (read_info() == EXIT_FAILURE)

40
cpumf/lscpumf_cli.h Normal file
View File

@@ -0,0 +1,40 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef LSCPUMF_CLI_H
#define LSCPUMF_CLI_H
#include "lib/util_fmt.h"
#include "lib/util_opt.h"
static struct util_opt lscpumf_opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "list-counters", no_argument, NULL, 'c' },
.desc = "Lists counters for which the LPAR is authorized.",
},
{
.option = { "list-all-counters", no_argument, NULL, 'C' },
.desc = "Lists counters regardless of LPAR authorization.",
},
{
.option = { "name", no_argument, NULL, 'n' },
.desc = "Displays counter names.",
},
{
.option = { "info", no_argument, NULL, 'i' },
.desc = "Displays detailed information.",
},
{
.option = { "list-sampling-events", no_argument, NULL, 's' },
.desc = "Lists sampling events for which the LPAR is authorized.",
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
#endif

View File

@@ -43,6 +43,7 @@
#include "lib/libcpumf.h"
#include "lshwc.h"
#include "lshwc_cli.h"
#define CPUS_ONLINE "/sys/devices/system/cpu/online"
#define CPUS_POSSIBLE "/sys/devices/system/cpu/possible"
@@ -405,6 +406,38 @@ static void output_times(struct time_formats date)
}
}
struct ctr_filter_match {
bool selected;
bool selected_by_id;
};
static struct ctr_filter_match ctr_match(const char *name, const char *list,
size_t id)
{
struct ctr_filter_match match = { .selected = !list };
char *copy, *token;
char id_str[32];
if (!list)
return match;
snprintf(id_str, sizeof(id_str), "%zu", id);
copy = util_strdup(list);
for (token = strtok(copy, ","); token; token = strtok(NULL, ",")) {
if (name && strcmp(token, name) == 0) {
match.selected = true;
break;
}
if (strcmp(token, id_str) == 0) {
match.selected = true;
match.selected_by_id = true;
break;
}
}
free(copy);
return match;
}
static void prepare_counter(size_t id, unsigned long value)
{
if (output_format == FMT_CSV) {
@@ -437,9 +470,14 @@ static void output_per_cpu(struct time_formats date)
util_fmt_obj_start(FMT_LIST, "counters");
}
for (size_t i = 0; i < ARRAY_SIZE(ctrname); ++i) {
struct ctr_filter_match match;
if (!ctrname[i].hitcnt)
continue;
if (hideundef && !ctrname[i].name)
match = ctr_match(ctrname[i].name, ctrlist, i);
if (!match.selected)
continue;
if (hideundef && !ctrname[i].name && !match.selected_by_id)
continue;
prepare_counter(i, ctrname[i].ccv[h]);
}
@@ -461,9 +499,14 @@ static void output_total(struct time_formats date)
util_fmt_obj_start(FMT_LIST, "counters");
}
for (size_t i = 0; i < ARRAY_SIZE(ctrname); ++i) {
struct ctr_filter_match match;
if (!ctrname[i].hitcnt)
continue;
if (hideundef && !ctrname[i].name)
match = ctr_match(ctrname[i].name, ctrlist, i);
if (!match.selected)
continue;
if (hideundef && !ctrname[i].name && !match.selected_by_id)
continue;
prepare_counter(i, ctrname[i].total);
ctrname[i].total = 0;
@@ -699,7 +742,7 @@ static int do_it(char *s)
if (output_format == FMT_CSV)
flags |= FMT_NOMETA;
if (output_format == FMT_JSON || output_format == FMT_JSONSEQ)
if (util_fmt_is_json(output_format))
flags |= FMT_HANDLEINT;
if (quote_all)
flags |= FMT_QUOTEALL;
@@ -707,7 +750,7 @@ static int do_it(char *s)
mk_labels();
util_fmt_init(stdout, output_format, flags, 1);
util_fmt_obj_start(FMT_DEFAULT, "lshwc");
if (output_format == FMT_JSON || output_format == FMT_JSONSEQ) {
if (util_fmt_is_json(output_format)) {
util_fmt_obj_start(FMT_ROW, "cpumcf info");
util_fmt_pair(FMT_PERSIST, "counter first", "%d", cfvn);
util_fmt_pair(FMT_PERSIST, "counter second", "%d", csvn);
@@ -732,67 +775,6 @@ static int do_it(char *s)
return rc ? EXIT_FAILURE : EXIT_SUCCESS;
}
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "all", no_argument, NULL, 'a' },
.desc = "Displays all CPUs in output"
},
{
.option = { "loop", required_argument, NULL, 'l' },
.argument = "NUMBER",
.desc = "Specifies loop count for next read"
},
{
.option = { "interval", required_argument, NULL, 'i' },
.argument = "NUMBER",
.desc = "Specifies interval between read operations (seconds)"
},
{
.option = { "short", no_argument, NULL, 's' },
.desc = "Abbreviate counter name with counter set letter and number"
},
{
.option = { "hex0x", no_argument, NULL, 'X' },
.desc = "Counter values in hexadecimal format with leading 0x"
},
{
.option = { "hex", no_argument, NULL, 'x' },
.desc = "Counter values in hexadecimal format"
},
{
.option = { "hide", no_argument, NULL, 'H' },
.desc = "Do not display undefined counters of a counter set"
},
{
.option = { "delta", no_argument, NULL, 'd' },
.desc = "Display delta counter values"
},
{
.option = { "timeout", required_argument, NULL, 't' },
.argument = "NUMBER",
.desc = "run time in s (seconds) m (minutes) h (hours) and d (days)"
},
{
.option = { "quote-all", no_argument, NULL, 'q' },
.desc = "Apply quoting to all output elements"
},
{
.option = { "format", required_argument, NULL, 'f' },
.argument = "FORMAT",
.desc = "List counters in specified FORMAT (" FMT_TYPE_NAMES ")"
},
{
.option = { "counters", required_argument, NULL, 'c' },
.argument = "LIST",
.flags = UTIL_OPT_FLAG_NOSHORT,
.desc = "Specify comma separated list of counters to display"
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
static const struct util_prg prg = {
.desc = "Read CPU Measurement facility counter sets",
.copyright_vec = {
@@ -823,7 +805,7 @@ int main(int argc, char **argv)
int ch;
util_prg_init(&prg);
util_opt_init(opt_vec, NULL);
util_opt_init(lshwc_opt_vec, NULL);
while ((ch = util_opt_getopt_long(argc, argv)) != -1) {
switch (ch) {

74
cpumf/lshwc_cli.h Normal file
View File

@@ -0,0 +1,74 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef LSHWC_CLI_H
#define LSHWC_CLI_H
#include "lib/util_fmt.h"
#include "lib/util_opt.h"
static struct util_opt lshwc_opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "all", no_argument, NULL, 'a' },
.desc = "Displays all CPUs in output"
},
{
.option = { "loop", required_argument, NULL, 'l' },
.argument = "NUMBER",
.desc = "Specifies loop count for next read"
},
{
.option = { "interval", required_argument, NULL, 'i' },
.argument = "NUMBER",
.desc = "Specifies interval between read operations (seconds)"
},
{
.option = { "short", no_argument, NULL, 's' },
.desc = "Abbreviate counter name with counter set letter and number"
},
{
.option = { "hex0x", no_argument, NULL, 'X' },
.desc = "Counter values in hexadecimal format with leading 0x"
},
{
.option = { "hex", no_argument, NULL, 'x' },
.desc = "Counter values in hexadecimal format"
},
{
.option = { "hide", no_argument, NULL, 'H' },
.desc = "Do not display undefined counters of a counter set"
},
{
.option = { "delta", no_argument, NULL, 'd' },
.desc = "Display delta counter values"
},
{
.option = { "timeout", required_argument, NULL, 't' },
.argument = "NUMBER",
.desc = "run time in s (seconds) m (minutes) h (hours) and d (days)"
},
{
.option = { "quote-all", no_argument, NULL, 'q' },
.desc = "Apply quoting to all output elements"
},
{
.option = { "format", required_argument, NULL, 'f' },
.argument = "FORMAT",
.desc = "List counters in specified FORMAT (" FMT_TYPE_NAMES ")"
},
{
.option = { "counters", required_argument, NULL, 'c' },
.argument = "LIST",
.flags = UTIL_OPT_FLAG_NOSHORT,
.desc = "Specify comma separated list of counters to display"
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
#endif

View File

@@ -35,69 +35,7 @@
#include "lib/util_str.h"
#include "lib/libcpumf.h"
#define STR_SUB(x) #x
#define STR(x) STR_SUB(x)
#define OPT_FORMAT 256 /* --format XXX option */
#define DEFAULT_LOOP_INTERVAL 60 /* loop interval in seconds */
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "all", no_argument, NULL, 'a' },
.desc = "Displays all CPUs in output"
},
{
.option = { "delta", no_argument, NULL, 'd' },
.desc = "Display delta counter values"
},
{
.option = { "counters", required_argument, NULL, 'c' },
.argument = "LIST",
.desc = "Specify comma separated list of counters to display"
},
{
.option = { "format", required_argument, NULL, OPT_FORMAT },
.argument = "FORMAT",
.flags = UTIL_OPT_FLAG_NOSHORT,
.desc = "List counters in specified FORMAT (" FMT_TYPE_NAMES ")"
},
{
.option = { "loops", required_argument, NULL, 'l' },
.argument = "COUNT",
.desc = "Number of read operations"
},
{
.option = { "interval", required_argument, NULL, 'i' },
.argument = "SECONDS",
.desc = "Time to wait between loop iterations (default "
STR(DEFAULT_LOOP_INTERVAL) "s)"
},
{
.option = { "numeric", no_argument, NULL, 'n' },
.desc = "Sort PAI counters by counter number"
},
{
.option = { "short", no_argument, NULL, 's' },
.desc = "Abbreviate counter name with counter set letter and number"
},
{
.option = { "type", required_argument, NULL, 't' },
.argument = "TYPE",
.desc = "Type of PAI counters to show: crypto, nnpa"
},
{
.option = { "hex0x", no_argument, NULL, 'X' },
.desc = "Counter values in hexadecimal format with leading 0x"
},
{
.option = { "hex", no_argument, NULL, 'x' },
.desc = "Counter values in hexadecimal format"
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
#include "lspai_cli.h"
static const struct util_prg prg = {
.desc = "List Processor Assist Information counter sets",
@@ -727,7 +665,7 @@ int main(int argc, char **argv)
util_list_init(&pai_list, struct pai_node, node);
util_prg_init(&prg);
util_opt_init(opt_vec, NULL);
util_opt_init(lspai_opt_vec, NULL);
while ((ch = util_opt_getopt_long(argc, argv)) != -1) {
switch (ch) {

77
cpumf/lspai_cli.h Normal file
View File

@@ -0,0 +1,77 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef LSPAI_CLI_H
#define LSPAI_CLI_H
#include "lib/util_fmt.h"
#include "lib/util_opt.h"
#define STR_SUB(x) #x
#define STR(x) STR_SUB(x)
#define OPT_FORMAT 256 /* --format XXX option */
#define DEFAULT_LOOP_INTERVAL 60 /* loop interval in seconds */
static struct util_opt lspai_opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "all", no_argument, NULL, 'a' },
.desc = "Displays all CPUs in output"
},
{
.option = { "delta", no_argument, NULL, 'd' },
.desc = "Display delta counter values"
},
{
.option = { "counters", required_argument, NULL, 'c' },
.argument = "LIST",
.desc = "Specify comma separated list of counters to display"
},
{
.option = { "format", required_argument, NULL, OPT_FORMAT },
.argument = "FORMAT",
.flags = UTIL_OPT_FLAG_NOSHORT,
.desc = "List counters in specified FORMAT (" FMT_TYPE_NAMES ")"
},
{
.option = { "loops", required_argument, NULL, 'l' },
.argument = "COUNT",
.desc = "Number of read operations"
},
{
.option = { "interval", required_argument, NULL, 'i' },
.argument = "SECONDS",
.desc = "Time to wait between loop iterations (default "
STR(DEFAULT_LOOP_INTERVAL) "s)"
},
{
.option = { "numeric", no_argument, NULL, 'n' },
.desc = "Sort PAI counters by counter number"
},
{
.option = { "short", no_argument, NULL, 's' },
.desc = "Abbreviate counter name with counter set letter and number"
},
{
.option = { "type", required_argument, NULL, 't' },
.argument = "TYPE",
.desc = "Type of PAI counters to show: crypto, nnpa"
},
{
.option = { "hex0x", no_argument, NULL, 'X' },
.desc = "Counter values in hexadecimal format with leading 0x"
},
{
.option = { "hex", no_argument, NULL, 'x' },
.desc = "Counter values in hexadecimal format"
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
#endif

View File

@@ -138,7 +138,7 @@ Apply quoting to every output element, regardless of content or format.
.TP
.BR \-f ", " \-\-format \fI\ FORMAT\fP
Retrieve output in one of the following formats:
JSON, CSV, JSON-SEQ or PAIRS.
JSON, CSV, JSON-SEQ, JSONL or PAIRS.
If no format is specified, the output defaults to CSV.
.
.SS JSON Output Structure

View File

@@ -136,7 +136,7 @@ Default sort order is PAI counter name.
.TP
.BI \-\-format "\ FORMAT"
Retrieve output in one of the following formats:
JSON, csv, json-seq or pairs.
JSON, csv, json-seq, jsonl or pairs.
If no format is specified,
the output defaults to a human-readable format.
.

View File

@@ -14,6 +14,7 @@
#include <fcntl.h>
#include <limits.h>
#include <sched.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
@@ -40,11 +41,15 @@
#include "lib/util_prg.h"
#include "lib/util_scandir.h"
#include "lib/libcpumf.h"
#include "pai.h"
#include "pai_cli.h"
#define S390_EVT_PAI_CRYPTO 0x1000
#define S390_EVT_PAI_NNPA 0x1800
/* SIGINT or SIGTERM signal received */
static volatile unsigned int sigterm;
/* Default values for select() timeout: 1 second */
static unsigned long read_interval = 1000;
/* Size of mapped perf event ring buffer in 4KB pages.
@@ -348,6 +353,10 @@ static int collect(unsigned long cnt)
if (FD_ISSET(i, &r_fds))
readmap(i);
}
} else if (errno == EINTR && sigterm) {
/* Interrupt by signal SIGINT/SIGTERM, one more iteration */
cnt = 2;
rc = 0;
}
} while (rc != -1 && --cnt > 0);
return rc;
@@ -501,7 +510,7 @@ static int evt_scan(char *fn, unsigned char *buf, size_t len,
__u64 sample_type = pa->sample_type;
int allcnt = 0, cnt = 0, rawok = 0;
struct perf_event_header *hdr;
size_t offset = sizeof(*pa);
size_t offset = pa->size;
__u64 evtnum = pa->config;
struct pai_event_out ev;
size_t limit;
@@ -512,6 +521,8 @@ static int evt_scan(char *fn, unsigned char *buf, size_t len,
unsigned char valid;
} last_csout = { 0, 0, 0 };
if (verbose && (sizeof(*pa) != pa->size))
printf("size perf_event_attr mismatch %zu/%zu\n", sizeof(*pa), offset);
while (offset < len) {
hdr = (struct perf_event_header *)(buf + offset);
memset(&ev, 0, sizeof(ev));
@@ -833,7 +844,7 @@ static int map_check(char *fn, int (*fct)(char *, unsigned char *, size_t,
return 0;
}
p = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
p = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (p == MAP_FAILED) {
warnx("%s cannot map file", fn);
close(fd);
@@ -883,7 +894,7 @@ static int parse_event_attr(char *cp)
}
/* Parse CPU list and event specifications */
static void parse_cpulist(int enr, const char *parm)
static void parse_cpulist(int enr, char *parm)
{
unsigned int evt_attr = 0;
cpu_set_t cmdlist, result;
@@ -925,54 +936,6 @@ static void parse_cpulist(int enr, const char *parm)
}
}
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "crypto", optional_argument, NULL, 'c' },
.argument = "CPULIST[:DATA]",
.desc = "Collect PAI crypto counters"
},
{
.option = { "nnpa", optional_argument, NULL, 'n' },
.argument = "CPULIST[:DATA]",
.desc = "Collect PAI nnpa counters"
},
{
.option = { "mapsize", required_argument, NULL, 'm' },
.argument = "SIZE",
.desc = "Specifies number of 4KB pages for event ring buffer"
},
{
.option = { "report", no_argument, NULL, 'r' },
.desc = "Report file contents"
},
{
.option = { "realtime", required_argument, NULL, 'R' },
.argument = "PRIO",
.desc = "Collect data with this RT SCHED_FIFO priority"
},
{
.option = { "interval", required_argument, NULL, 'i' },
.argument = "NUMBER",
.desc = "Specifies interval between read operations in milliseconds"
},
{
.option = { "verbose", no_argument, NULL, 'V' },
.desc = "Verbose output"
},
{
.option = { "humantime", no_argument, NULL, 'H' },
.desc = "Human readable timestamp in seconds.nanoseconds"
},
{
.option = { "summary", no_argument, NULL, 'S' },
.desc = "Print summary of all non-zero counter values"
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
static const struct util_prg prg = {
.desc = "Record and report Processor Activity Instrumentation Facility Counters.",
.copyright_vec = {
@@ -985,33 +948,27 @@ static const struct util_prg prg = {
}
};
static void record_cpus_crypto(const char *cp)
static void record_cpus_crypto(char *cp)
{
if (!libcpumf_have_pai_crypto())
errx(EXIT_FAILURE, "No support for PAI crypto counters");
parse_cpulist(S390_EVT_PAI_CRYPTO, cp);
}
static void record_cpus_nnpa(const char *cp)
static void record_cpus_nnpa(char *cp)
{
if (!libcpumf_have_pai_nnpa())
errx(EXIT_FAILURE, "No support for PAI nnpa counters");
parse_cpulist(S390_EVT_PAI_NNPA, cp);
}
/* Mapsize must be power of 2 and larger than 4. Count bits in n and
* return 0 if input is invalid and has a bit count larger than one.
/* Mapsize must be power of 2 and larger than 4. Return true in this case.
*/
static unsigned long check_mapsize(unsigned long n)
static bool check_mapsize(unsigned long n)
{
int bit, cnt = 0;
if (n < 4)
return 0;
for (bit = 0; bit < __BITS_PER_LONG; ++bit)
if (n & (1 << bit))
++cnt;
return cnt == 1 ? n : 0;
return (n & (n - 1)) == 0;
}
static void setprio(const char *prio)
@@ -1027,6 +984,12 @@ static void setprio(const char *prio)
err(EXIT_FAILURE, "Could not set realtime priority");
}
static void sig_handler(int no)
{
if (no == SIGINT || no == SIGTERM)
sigterm = 1;
}
int main(int argc, char **argv)
{
bool crypto_record = false, report = false;
@@ -1038,7 +1001,7 @@ int main(int argc, char **argv)
util_list_init(&list_pai_event, struct pai_event, node);
util_list_init(&list_pmu_event, struct pmu_events, node);
util_prg_init(&prg);
util_opt_init(opt_vec, NULL);
util_opt_init(pai_opt_vec, NULL);
/* Read currently online CPUs and create a bit mask.
* This bitmap of online CPUs is used to check command line parameter
@@ -1071,11 +1034,11 @@ int main(int argc, char **argv)
errx(EXIT_FAILURE, "Invalid argument for -%c", ch);
break;
case 'm':
errno = 0;
mapsize = strtoul(optarg, &slash, 0);
mapsize = check_mapsize(mapsize);
if (errno || !mapsize || *slash)
if (!mapsize || *slash)
errx(EXIT_FAILURE, "Invalid argument for -%c", ch);
if (!check_mapsize(mapsize))
errx(EXIT_FAILURE, "No power of 2 number for -%c", ch);
break;
case 'n':
record_cpus_nnpa(optarg);
@@ -1114,6 +1077,10 @@ int main(int argc, char **argv)
errx(EXIT_FAILURE, "Invalid argument for runtime");
}
if (signal(SIGTERM, sig_handler) == SIG_ERR ||
signal(SIGINT, sig_handler) == SIG_ERR)
errx(EXIT_FAILURE, "Failed to set signal handler");
ev_install(group);
ev_enable();

61
cpumf/pai_cli.h Normal file
View File

@@ -0,0 +1,61 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef PAI_CLI_H
#define PAI_CLI_H
#include "lib/util_fmt.h"
#include "lib/util_opt.h"
static struct util_opt pai_opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "crypto", optional_argument, NULL, 'c' },
.argument = "CPULIST[:DATA]",
.desc = "Collect PAI crypto counters"
},
{
.option = { "nnpa", optional_argument, NULL, 'n' },
.argument = "CPULIST[:DATA]",
.desc = "Collect PAI nnpa counters"
},
{
.option = { "mapsize", required_argument, NULL, 'm' },
.argument = "SIZE",
.desc = "Specifies number of 4KB pages for event ring buffer"
},
{
.option = { "report", no_argument, NULL, 'r' },
.desc = "Report file contents"
},
{
.option = { "realtime", required_argument, NULL, 'R' },
.argument = "PRIO",
.desc = "Collect data with this RT SCHED_FIFO priority"
},
{
.option = { "interval", required_argument, NULL, 'i' },
.argument = "NUMBER",
.desc = "Specifies interval between read operations in milliseconds"
},
{
.option = { "verbose", no_argument, NULL, 'V' },
.desc = "Verbose output"
},
{
.option = { "humantime", no_argument, NULL, 'H' },
.desc = "Human readable timestamp in seconds.nanoseconds"
},
{
.option = { "summary", no_argument, NULL, 'S' },
.desc = "Print summary of all non-zero counter values"
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
#endif

View File

@@ -1,5 +1,10 @@
include ../common.mak
zsh-completions = _dasdfmt
bash-completions = dasdfmt.bash
include ../common_autocomp.mak
all: dasdfmt
libs = $(rootdir)/libdasd/libdasd.a \

View File

@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#include "lib/util_autocomp.h"
#include "dasdfmt_cli.h"
int main(void)
{
generate_autocomp(opt_vec, "dasdfmt");
return 0;
}

View File

@@ -24,6 +24,7 @@
#include "lib/zt_common.h"
#include "dasdfmt.h"
#include "dasdfmt_cli.h"
#define BUSIDSIZE 8
#define SEC_PER_DAY (60 * 60 * 24)
@@ -81,112 +82,6 @@ static struct dasdfmt_globals {
.dasd_info = { 0 },
};
/* Defines for options with no short command */
#define OPT_CHECK 128
#define OPT_NOZERO 129
#define OPT_NODISCARD 130
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("FORMAT ACTIONS"),
{
.option = { "mode", required_argument, NULL, 'M' },
.argument = "MODE",
.desc = "Specify scope of operation using MODE:\n"
" full: Full device (default)\n"
" quick: Only the first two tracks\n"
" expand: Unformatted tracks at device end",
},
{
.option = { "check", no_argument, NULL, OPT_CHECK },
.desc = "Perform complete format check on device",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
UTIL_OPT_SECTION("FORMAT OPTIONS"),
{
.option = { "blocksize", required_argument, NULL, 'b' },
.argument = "SIZE",
.desc = "Format blocks to SIZE bytes (default 4096)",
},
{
.option = { "disk_layout", required_argument, NULL, 'd' },
.argument = "LAYOUT",
.desc = "Specify the disk layout:\n"
" cdl: Compatible Disk Layout (default)\n"
" ldl: Linux Disk Layout",
},
{
.option = { "keep_volser", no_argument, NULL, 'k' },
.desc = "Do not change the current volume serial",
},
{
.option = { "label", required_argument, NULL, 'l' },
.argument = "VOLSER",
.desc = "Specify volume serial number",
},
{
.option = { "no_label", no_argument, NULL, 'L' },
.desc = "Don't write a disk label",
},
{
.option = { "requestsize", required_argument, NULL, 'r' },
.argument = "NUM",
.desc = "Process NUM cylinders in one formatting step",
},
{
.option = { "norecordzero", no_argument, NULL, OPT_NOZERO },
.desc = "Prevent storage server from modifying record 0",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "no-discard", no_argument, NULL, OPT_NODISCARD },
.desc = "Do not discard space before formatting",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { NULL, no_argument, NULL, 'y' },
.desc = "Start formatting without further user-confirmation",
.flags = UTIL_OPT_FLAG_NOLONG,
},
UTIL_OPT_SECTION("DISPLAY PROGRESS"),
{
.option = { "hashmarks", required_argument, NULL, 'm' },
.argument = "NUM",
.desc = "Show a hashmark every NUM cylinders",
},
{
.option = { "progressbar", no_argument, NULL, 'p' },
.desc = "Show a progressbar",
},
{
.option = { "percentage", no_argument, NULL, 'P' },
.desc = "Show progress in percent",
},
UTIL_OPT_SECTION("MISC"),
{
.option = { "check_host_count", no_argument, NULL, 'C' },
.desc = "Check if device is in use by other hosts",
},
{
.option = { "force", no_argument, NULL, 'F' },
.desc = "Format without performing sanity checking",
},
{
.option = { "test", no_argument, NULL, 't' },
.desc = "Run in dry-run mode without modifying the DASD",
},
{
.option = { NULL, no_argument, NULL, 'v' },
.desc = "Print verbose messages when executing",
.flags = UTIL_OPT_FLAG_NOLONG,
},
UTIL_OPT_HELP,
{
.option = { "version", no_argument, NULL, 'V' },
.desc = "Print version information, then exit",
},
UTIL_OPT_END
};
/* Report error, free memory, and exit */
static void error(const char *format, ...)
{
@@ -1671,6 +1566,8 @@ int main(int argc, char *argv[])
g.ese = dasd_sys_ese(g.dev_node);
eval_format_mode();
check_disk();
/* Either let the user specify the blksize or get it from the kernel */
if (!g.blksize_specified) {
if (!(mode == FULL ||
@@ -1692,8 +1589,6 @@ int main(int argc, char *argv[])
error("VOLSER not found on device %s", g.dev_path);
}
check_disk();
if (check_param(str, ERR_LENGTH, &format_params) < 0)
error("%s", str);

View File

@@ -19,6 +19,7 @@
#include <limits.h>
#include <mntent.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -69,13 +70,13 @@ static void error(const char *format, ...)
"is in invalid format\n",prog_name);}
typedef struct bootstrap1 {
u_int32_t key;
u_int32_t data[6];
uint32_t key;
uint32_t data[6];
} __attribute__ ((packed)) bootstrap1_t;
typedef struct bootstrap2 {
u_int32_t key;
u_int32_t data[36];
uint32_t key;
uint32_t data[36];
} __attribute__ ((packed)) bootstrap2_t;

119
dasdfmt/dasdfmt_cli.h Normal file
View File

@@ -0,0 +1,119 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef DASDFMT_CLI_H
#define DASDFMT_CLI_H
#include "lib/util_fmt.h"
#include "lib/util_opt.h"
/* Defines for options with no short command */
#define OPT_CHECK 128
#define OPT_NOZERO 129
#define OPT_NODISCARD 130
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("FORMAT ACTIONS"),
{
.option = { "mode", required_argument, NULL, 'M' },
.argument = "MODE",
.desc = "Specify scope of operation using MODE:\n"
" full: Full device (default)\n"
" quick: Only the first two tracks\n"
" expand: Unformatted tracks at device end",
},
{
.option = { "check", no_argument, NULL, OPT_CHECK },
.desc = "Perform complete format check on device",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
UTIL_OPT_SECTION("FORMAT OPTIONS"),
{
.option = { "blocksize", required_argument, NULL, 'b' },
.argument = "SIZE",
.desc = "Format blocks to SIZE bytes (default 4096)",
},
{
.option = { "disk_layout", required_argument, NULL, 'd' },
.argument = "LAYOUT",
.desc = "Specify the disk layout:\n"
" cdl: Compatible Disk Layout (default)\n"
" ldl: Linux Disk Layout",
},
{
.option = { "keep_volser", no_argument, NULL, 'k' },
.desc = "Do not change the current volume serial",
},
{
.option = { "label", required_argument, NULL, 'l' },
.argument = "VOLSER",
.desc = "Specify volume serial number",
},
{
.option = { "no_label", no_argument, NULL, 'L' },
.desc = "Don't write a disk label",
},
{
.option = { "requestsize", required_argument, NULL, 'r' },
.argument = "NUM",
.desc = "Process NUM cylinders in one formatting step",
},
{
.option = { "norecordzero", no_argument, NULL, OPT_NOZERO },
.desc = "Prevent storage server from modifying record 0",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "no-discard", no_argument, NULL, OPT_NODISCARD },
.desc = "Do not discard space before formatting",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { NULL, no_argument, NULL, 'y' },
.desc = "Start formatting without further user-confirmation",
.flags = UTIL_OPT_FLAG_NOLONG,
},
UTIL_OPT_SECTION("DISPLAY PROGRESS"),
{
.option = { "hashmarks", required_argument, NULL, 'm' },
.argument = "NUM",
.desc = "Show a hashmark every NUM cylinders",
},
{
.option = { "progressbar", no_argument, NULL, 'p' },
.desc = "Show a progressbar",
},
{
.option = { "percentage", no_argument, NULL, 'P' },
.desc = "Show progress in percent",
},
UTIL_OPT_SECTION("MISC"),
{
.option = { "check_host_count", no_argument, NULL, 'C' },
.desc = "Check if device is in use by other hosts",
},
{
.option = { "force", no_argument, NULL, 'F' },
.desc = "Format without performing sanity checking",
},
{
.option = { "test", no_argument, NULL, 't' },
.desc = "Run in dry-run mode without modifying the DASD",
},
{
.option = { NULL, no_argument, NULL, 'v' },
.desc = "Print verbose messages when executing",
.flags = UTIL_OPT_FLAG_NOLONG,
},
UTIL_OPT_HELP,
{
.option = { "version", no_argument, NULL, 'V' },
.desc = "Print version information, then exit",
},
UTIL_OPT_END
};
#endif

View File

@@ -1,5 +1,10 @@
include ../common.mak
zsh-completions = _dasdinfo
bash-completions = dasdinfo.bash
include ../common_autocomp.mak
libs = $(rootdir)/libutil/libutil.a \
$(rootdir)/libdasd/libdasd.a

View File

@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#include "lib/util_autocomp.h"
#include "dasdinfo_cli.h"
int main(void)
{
generate_autocomp(opt_vec, "dasdinfo");
return 0;
}

View File

@@ -30,9 +30,16 @@
#include "lib/util_path.h"
#include "lib/zt_common.h"
#include "dasdinfo_cli.h"
#define RD_BUFFER_SIZE 80
#define TEMP_DEV_MAX_RETRIES 1000
#ifndef FTW_CONTINUE
#define FTW_CONTINUE 0
#define FTW_STOP 1
#endif
static const struct util_prg prg = {
.desc = "Display DASD volume serial number and ID information",
.args = "-i BUSID | -b BLOCKDEV | -d DEVNODE",
@@ -45,49 +52,6 @@ static const struct util_prg prg = {
}
};
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("DEVICE"),
{
.option = { "block", required_argument, NULL, 'b' },
.argument = "BLOCKDEV",
.desc = "Block device name, e.g. dasdb",
},
{
.option = { "devnode", required_argument, NULL, 'd' },
.argument = "DEVNODE",
.desc = "Device node, e.g. /dev/dasda",
},
{
.option = { "busid", required_argument, NULL, 'i' },
.argument = "BUSID",
.desc = "Bus ID, e.g. 0.0.e910",
},
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "label", no_argument, NULL, 'l' },
.desc = "Print DASD volume label (volser)",
},
{
.option = { "uid", no_argument, NULL, 'u' },
.desc = "Print DASD uid (without z/VM minidisk token)",
},
{
.option = { "extended-uid", no_argument, NULL, 'x' },
.desc = "Print DASD uid (including z/VM minidisk token)",
},
{
.option = { "all", no_argument, NULL, 'a' },
.desc = "Same as -u -x -l",
},
{
.option = { "export", no_argument, NULL, 'e' },
.desc = "Export ID_BUS, ID_TYPE, ID_SERIAL for use in udev",
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
/* needed because ftw can not pass arbitrary arguments */
static char *searchbusid;
static char *busiddir;
@@ -96,9 +60,9 @@ struct volume_label {
char volkey[4];
char vollbl[4];
char volid[6];
} __attribute__ ((packed));
} __packed;
static char EBCtoASC[256] = {
static char ebc_to_asc[256] = {
/* 0x00 NUL SOH STX ETX *SEL HT *RNL DEL */
0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F,
/* 0x08 -GE -SPS -RPT VT FF CR SO SI */
@@ -170,7 +134,7 @@ static char *dinfo_ebcdic_dec(char *source, char *target, int l)
int i;
for (i = 0; i < l; i++)
target[i] = EBCtoASC[(unsigned char)(source[i])];
target[i] = ebc_to_asc[(unsigned char)(source[i])];
return target;
}
@@ -212,7 +176,7 @@ static int dinfo_read_dasd_vlabel(char *device, struct volume_label *vlabel,
if (lseek(f, vlabel_start, SEEK_SET) < 0)
goto error_close;
bzero(vlabel, vlsize);
memset(vlabel, 0, vlsize);
if (read(f, vlabel, vlsize) != vlsize) {
warnx("Could not read volume label");
@@ -220,15 +184,15 @@ static int dinfo_read_dasd_vlabel(char *device, struct volume_label *vlabel,
}
if (dasd_info.FBA_layout) {
bzero(&tmp, vlsize);
memset(&tmp, 0, vlsize);
memcpy(&tmp, vlabel, vlsize);
memcpy(vlabel->vollbl, &tmp, vlsize - 4);
}
close(f);
bzero(readbuf, 7);
bzero(vollbl, 5);
memset(readbuf, 0, 7);
memset(vollbl, 0, 5);
strncpy(vollbl, vlabel->vollbl, 4);
dinfo_ebcdic_dec(vollbl, vollbl, 4);
@@ -256,7 +220,7 @@ static void *dinfo_malloc(size_t size)
void *result;
result = malloc(size);
if (result == NULL)
if (!result)
warnx("Could not allocate %lu bytes of memory", size);
return result;
@@ -269,7 +233,7 @@ static char *dinfo_make_path(char *dirname, char *filename)
len = strlen(dirname) + strlen(filename) + 2;
result = (char *)dinfo_malloc(len);
if (result == NULL)
if (!result)
return NULL;
sprintf(result, "%s/%s", dirname, filename);
return result;
@@ -291,12 +255,12 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
/* Try several locations for the temporary device node. */
for (path = 0; path < ARRAY_SIZE(pathname); path++) {
if (pathname[path] == NULL)
if (!pathname[path])
continue;
for (retry = 0; retry < TEMP_DEV_MAX_RETRIES; retry++) {
snprintf(filename, sizeof(filename), "dasdinfo%04d", retry);
result = dinfo_make_path(pathname[path], filename);
if (result == NULL)
if (!result)
return -1;
rc = mknod(result, mode, dev);
if (rc == 0) {
@@ -334,10 +298,10 @@ static int dinfo_extract_dev(dev_t *dev, char *str)
char *p = NULL;
int ma, mi;
bzero(tmp, RD_BUFFER_SIZE);
memset(tmp, 0, RD_BUFFER_SIZE);
util_strlcpy(tmp, str, RD_BUFFER_SIZE);
p = strchr(tmp, ':');
if (p == NULL) {
if (!p) {
warnx("Error: unable to extract major/minor");
return -1;
}
@@ -381,10 +345,8 @@ static int
dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
int tflag, struct FTW *ftwbuf)
{
enum { LINK_DIR_SIZE = 128 };
char linkdir[LINK_DIR_SIZE];
char *tempdir;
ssize_t i;
char *linkdir;
if (tflag != FTW_D || (strncmp((fpath + ftwbuf->base), searchbusid,
strlen(searchbusid)) != 0))
@@ -396,17 +358,16 @@ dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
*/
if (asprintf(&tempdir, "%s/driver", fpath) < 0)
return -1;
i = readlink(tempdir, linkdir, LINK_DIR_SIZE);
linkdir = util_readlink(tempdir);
free(tempdir);
if (i < 0 || i >= LINK_DIR_SIZE)
return -1;
/* append '\0' because readlink returns non zero terminated string */
linkdir[i] = '\0';
if (strstr(linkdir, "dasd") == NULL)
if (!strstr(linkdir, "dasd")) {
free(linkdir);
return FTW_CONTINUE;
}
free(linkdir);
free(busiddir);
busiddir = strdup(fpath);
if (busiddir == NULL)
if (!busiddir)
return -1;
return FTW_STOP;
}
@@ -419,7 +380,7 @@ dinfo_find_entry(const char *dir, const char *searchstring,
struct dirent *dir_entry = NULL;
directory = opendir(dir);
if (directory == NULL)
if (!directory)
return -1;
while ((dir_entry = readdir(directory)) != NULL) {
/* compare if the found entry has exactly the same name and type
@@ -429,7 +390,7 @@ dinfo_find_entry(const char *dir, const char *searchstring,
strlen(searchstring)) == 0) &&
(dir_entry->d_type & type)) {
*result = strdup(dir_entry->d_name);
if (*result == NULL)
if (!*result)
goto out;
closedir(directory);
return 0; /* found */
@@ -475,7 +436,7 @@ dinfo_get_blockdev_from_busid(char *busid, char **blkdev)
if (rc != 0)
goto out2;
*blkdev = strdup(strchr(result, ':') + 1);
if (*blkdev == NULL)
if (!*blkdev)
rc = -1;
}
@@ -508,7 +469,7 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
path = util_path_sysfs("block/");
directory = opendir(path);
if (directory == NULL) {
if (!directory) {
warnx("Error: could not open directory %s", path);
free(path);
return -1;
@@ -534,6 +495,7 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
fprintf(stderr,
"Error: Device name was truncated\n");
free(path);
free(readbuf);
return -1;
}
@@ -543,13 +505,12 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
closedir(directory);
free(path);
free(readbuf);
return 0;
}
int main(int argc, char *argv[])
{
struct utsname uname_buf;
int version, release;
char *uidfile = NULL;
char *device = NULL;
char *readbuf = NULL;
@@ -609,35 +570,19 @@ int main(int argc, char *argv[])
util_prg_print_version();
exit(EXIT_SUCCESS);
default:
fprintf(stderr, "Try 'dasdinfo --help' for more "
"information.\n");
fprintf(stderr, "Try 'dasdinfo --help' for more information.\n");
exit(1);
}
}
uname(&uname_buf);
sscanf(uname_buf.release, "%d.%d", &version, &release);
if (strcmp(uname_buf.sysname, "Linux") ||
version < 2 || (version == 2 && release < 6)) {
warnx("%s %d.%d is not supported", uname_buf.sysname,
version, release);
exit(1);
}
if (!busid && !blockdev && !devnode)
errx(EXIT_FAILURE, "Error: please specify a device using either -b, -i or -d");
if (!busid && !blockdev && !devnode) {
warnx("Error: please specify a device using either -b, -i or -d");
exit(1);
}
if ((busid && blockdev) || (busid && devnode) || (blockdev && devnode))
errx(EXIT_FAILURE, "Error: please specify device only once, either -b, -i or -d");
if ((busid && blockdev) || (busid && devnode) || (blockdev && devnode)) {
warnx("Error: please specify device only once, either -b, -i or -d");
exit(1);
}
if (!print_uid && !print_extended_uid && !print_vlabel) {
warnx("Error: no action specified (e.g. -u)");
exit(1);
}
if (!print_uid && !print_extended_uid && !print_vlabel)
errx(EXIT_FAILURE, "Error: no action specified (e.g. -u)");
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
if (!readbuf)

55
dasdinfo/dasdinfo_cli.h Normal file
View File

@@ -0,0 +1,55 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef DASDINFO_CLI_H
#define DASDINFO_CLI_H
#include "lib/util_opt.h"
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("DEVICE"),
{
.option = { "block", required_argument, NULL, 'b' },
.argument = "BLOCKDEV",
.desc = "Block device name, e.g. dasdb",
},
{
.option = { "devnode", required_argument, NULL, 'd' },
.argument = "DEVNODE",
.desc = "Device node, e.g. /dev/dasda",
},
{
.option = { "busid", required_argument, NULL, 'i' },
.argument = "BUSID",
.desc = "Bus ID, e.g. 0.0.e910",
},
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "label", no_argument, NULL, 'l' },
.desc = "Print DASD volume label (volser)",
},
{
.option = { "uid", no_argument, NULL, 'u' },
.desc = "Print DASD uid (without z/VM minidisk token)",
},
{
.option = { "extended-uid", no_argument, NULL, 'x' },
.desc = "Print DASD uid (including z/VM minidisk token)",
},
{
.option = { "all", no_argument, NULL, 'a' },
.desc = "Same as -u -x -l",
},
{
.option = { "export", no_argument, NULL, 'e' },
.desc = "Export ID_BUS, ID_TYPE, ID_SERIAL for use in udev",
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
#endif

View File

@@ -1,5 +1,10 @@
include ../common.mak
zsh-completions = _dasdview
bash-completions = dasdview.bash
include ../common_autocomp.mak
libs = $(rootdir)/libdasd/libdasd.a \
$(rootdir)/libzds/libzds.a \
$(rootdir)/libvtoc/libvtoc.a \

View File

@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#include "lib/util_autocomp.h"
#include "dasdview_cli.h"
int main(void)
{
generate_autocomp(opt_vec, "dasdview");
return 0;
}

View File

@@ -7,7 +7,6 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
#define _LARGEFILE64_SOURCE /* needed for unistd.h */
#define _FILE_OFFSET_BITS 64 /* needed for unistd.h */
#include <ctype.h>
@@ -17,6 +16,7 @@
#include <linux/version.h>
#include <malloc.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -37,6 +37,7 @@
#include "lib/zt_common.h"
#include "dasdview.h"
#include "dasdview_cli.h"
/* Characters per line */
#define DASDVIEW_CPL 16
@@ -56,61 +57,6 @@ static const struct util_prg prg = {
}
};
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("DUMP OPTIONS"),
{
.option = { NULL, no_argument, NULL, '1' },
.desc = "Show DASD content in short Hex/EBCDIC/ASCII format",
.flags = UTIL_OPT_FLAG_NOLONG,
},
{
.option = { NULL, no_argument, NULL, '2' },
.desc = "Show DASD content in detailed Hex/EBCDIC/ASCII format",
.flags = UTIL_OPT_FLAG_NOLONG,
},
{
.option = { "begin", required_argument, NULL, 'b' },
.argument = "BEGIN",
.desc = "Specify start of dump in kilobytes (suffix k), "
"megabytes (m), blocks (b), tracks (t), or cylinders (c)",
},
{
.option = { "size", required_argument, NULL, 's' },
.argument = "SIZE",
.desc = "Specify size of dump in kilobytes (suffix k), "
"megabytes (m), blocks (b), tracks (t), or cylinders (c)",
},
UTIL_OPT_SECTION("MISC"),
{
.option = { "characteristic", no_argument, NULL, 'c' },
.desc = "Print the characteristics of a device",
},
{
.option = { "info", no_argument, NULL, 'i' },
.desc = "Print general DASD information and geometry",
},
{
.option = { "volser", no_argument, NULL, 'j' },
.desc = "Print the volume serial number",
},
{
.option = { "label", no_argument, NULL, 'l' },
.desc = "Print information about the volume label",
},
{
.option = { "vtoc", required_argument, NULL, 't' },
.argument = "SPEC",
.desc = "Print the table of content (VTOC)",
},
{
.option = { "extended", no_argument, NULL, 'x' },
.desc = "Print extended DASD information",
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
/*
* Generate and print an error message based on the formatted
* text string FMT and a variable amount of extra arguments.
@@ -428,7 +374,7 @@ dasdview_read_vlabel(dasdview_info_t *info, volume_label_t *vlabel)
pos = info->dasd_info.label_block * info->blksize;
bzero(vlabel, sizeof(volume_label_t));
memset(vlabel, 0, sizeof(volume_label_t));
if ((strncmp(info->dasd_info.type, "ECKD", 4) == 0) &&
!info->dasd_info.FBA_layout) {
/* OS/390 and zOS compatible disk layout */
@@ -466,7 +412,9 @@ dasdview_print_vlabel(dasdview_info_t *info)
printf("\n--- volume label -----------------------------"
"---------------------------------\n");
bzero(s4, 5); bzero(t4, 5); strncpy((char *)s4, vlabel.volkey, 4);
memset(s4, 0, 5);
memset(t4, 0, 5);
strncpy((char *)s4, vlabel.volkey, 4);
printf("volume label key : ascii '%4s'\n", s4);
vtoc_ebcdic_dec((char *)s4, (char *)t4, 4);
printf(" : ebcdic '%4s'\n", t4);
@@ -474,7 +422,9 @@ dasdview_print_vlabel(dasdview_info_t *info)
for (i = 0; i < 4; i++)
printf("%02x", s4[i]);
bzero(s4, 5); bzero(s4, 5); strncpy((char *)s4, vlabel.vollbl, 4);
memset(s4, 0, 5);
memset(t4, 0, 5);
strncpy((char *)s4, vlabel.vollbl, 4);
printf("\n\nvolume label identifier : ascii '%4s'\n", s4);
vtoc_ebcdic_dec((char *)s4, (char *)t4, 4);
printf(" : ebcdic '%4s'\n", t4);
@@ -482,7 +432,9 @@ dasdview_print_vlabel(dasdview_info_t *info)
for (i = 0; i < 4; i++)
printf("%02x", s4[i]);
bzero(s6, 7); bzero(t6, 7); strncpy((char *)s6, vlabel.volid, 6);
memset(s6, 0, 7);
memset(t6, 0, 7);
strncpy((char *)s6, vlabel.volid, 6);
printf("\n\nvolume identifier : ascii '%6s'\n", s6);
vtoc_ebcdic_dec((char *)s6, (char *)t6, 6);
printf(" : ebcdic '%6s'\n", t6);
@@ -503,7 +455,9 @@ dasdview_print_vlabel(dasdview_info_t *info)
vtoc_get_cyl_from_cchhb(&vlabel.vtoc),
vtoc_get_head_from_cchhb(&vlabel.vtoc), vlabel.vtoc.b);
bzero(s5, 6); bzero(t5, 6); strncpy((char *)s5, vlabel.res1, 5);
memset(s5, 0, 6);
memset(t5, 0, 6);
strncpy((char *)s5, vlabel.res1, 5);
printf("reserved : ascii '%5s'\n", s5);
vtoc_ebcdic_dec((char *)s5, (char *)t5, 5);
printf(" : ebcdic '%5s'\n", t5);
@@ -511,7 +465,9 @@ dasdview_print_vlabel(dasdview_info_t *info)
for (i = 0; i < 5; i++)
printf("%02x", s5[i]);
bzero(s4, 5); bzero(t4, 5); strncpy((char *)s4, vlabel.cisize, 4);
memset(s4, 0, 5);
memset(t4, 0, 5);
strncpy((char *)s4, vlabel.cisize, 4);
printf("\n\nCI size for FBA : ascii '%4s'\n", s4);
vtoc_ebcdic_dec((char *)s4, (char *)t4, 4);
printf(" : ebcdic '%4s'\n", t4);
@@ -519,7 +475,9 @@ dasdview_print_vlabel(dasdview_info_t *info)
for (i = 0; i < 4; i++)
printf("%02x", s4[i]);
bzero(s4, 5); bzero(t4, 5); strncpy((char *)s4, vlabel.blkperci, 4);
memset(s4, 0, 5);
memset(t4, 0, 5);
strncpy((char *)s4, vlabel.blkperci, 4);
printf("\n\nblocks per CI (FBA) : ascii '%4s'\n", s4);
vtoc_ebcdic_dec((char *)s4, (char *)t4, 4);
printf(" : ebcdic '%4s'\n", t4);
@@ -527,7 +485,9 @@ dasdview_print_vlabel(dasdview_info_t *info)
for (i = 0; i < 4; i++)
printf("%02x", s4[i]);
bzero(s4, 5); bzero(t4, 5); strncpy((char *)s4, vlabel.labperci, 4);
memset(s4, 0, 5);
memset(t4, 0, 5);
strncpy((char *)s4, vlabel.labperci, 4);
printf("\n\nlabels per CI (FBA) : ascii '%4s'\n", s4);
vtoc_ebcdic_dec((char *)s4, (char *)t4, 4);
printf(" : ebcdic '%4s'\n", t4);
@@ -535,7 +495,9 @@ dasdview_print_vlabel(dasdview_info_t *info)
for (i = 0; i < 4; i++)
printf("%02x", s4[i]);
bzero(s4, 5); bzero(t4, 5); strncpy((char *)s4, vlabel.res2, 4);
memset(s4, 0, 5);
memset(t4, 0, 5);
strncpy((char *)s4, vlabel.res2, 4);
printf("\n\nreserved : ascii '%4s'\n", s4);
vtoc_ebcdic_dec((char *)s4, (char *)t4, 4);
printf(" : ebcdic '%4s'\n", t4);
@@ -543,7 +505,9 @@ dasdview_print_vlabel(dasdview_info_t *info)
for (i = 0; i < 4; i++)
printf("%02x", s4[i]);
bzero(s14, 15); bzero(t14, 15); strncpy(s14, vlabel.lvtoc, 14);
memset(s14, 0, 15);
memset(t14, 0, 15);
strncpy(s14, vlabel.lvtoc, 14);
printf("\n\nowner code for VTOC : ascii '%14s'\n", s14);
vtoc_ebcdic_dec(s14, t14, 14);
printf(" ebcdic '%14s'\n", t14);
@@ -556,9 +520,10 @@ dasdview_print_vlabel(dasdview_info_t *info)
printf(" ");
}
bzero(s29, 30); strncpy(s29, vlabel.res3, 28);
memset(s29, 0, 30);
strncpy(s29, vlabel.res3, 28);
printf("\n\nreserved : ascii '%28s'\n", s29);
bzero(t29, 30);
memset(t29, 0, 30);
vtoc_ebcdic_dec(s29, t29, 28);
printf(" ebcdic '%28s'\n", t29);
printf(" hex ");
@@ -573,7 +538,9 @@ dasdview_print_vlabel(dasdview_info_t *info)
" ");
}
bzero(s4, 5); bzero(t4, 5); s4[0] = vlabel.ldl_version;
memset(s4, 0, 5);
memset(t4, 0, 5);
s4[0] = vlabel.ldl_version;
printf("\n\nldl_version : ascii '%1s'\n", s4);
vtoc_ebcdic_dec((char *)s4, (char *)t4, 1);
printf(" : ebcdic '%1s'\n", t4);
@@ -609,8 +576,8 @@ dasdview_print_volser(dasdview_info_t *info)
dasdview_read_vlabel(info, &vlabel);
}
bzero(vollbl, 5);
bzero(volser, 7);
memset(vollbl, 0, 5);
memset(volser, 0, 7);
strncpy(vollbl, vlabel.vollbl, 4);
vtoc_ebcdic_dec(vollbl, vollbl, 4);
@@ -631,12 +598,12 @@ dasdview_read_vtoc(dasdview_info_t *info)
volume_label_t vlabel;
format1_label_t tmp;
unsigned long maxblk, pos;
u_int64_t vtocblk;
uint64_t vtocblk;
int i;
pos = info->dasd_info.label_block * info->blksize;
bzero(&vlabel, sizeof(vlabel));
memset(&vlabel, 0, sizeof(vlabel));
if ((strncmp(info->dasd_info.type, "ECKD", 4) == 0) &&
!info->dasd_info.FBA_layout) {
/* OS/390 and zOS compatible disk layout */
@@ -648,7 +615,7 @@ dasdview_read_vtoc(dasdview_info_t *info)
exit(EXIT_FAILURE);
}
vtocblk = (u_int64_t)vtoc_get_cyl_from_cchhb(&vlabel.vtoc) *
vtocblk = (uint64_t)vtoc_get_cyl_from_cchhb(&vlabel.vtoc) *
info->geo.heads * info->geo.sectors +
vtoc_get_head_from_cchhb(&vlabel.vtoc) * info->geo.sectors +
vlabel.vtoc.b;
@@ -747,13 +714,13 @@ static void dasdview_print_format1_8_short_info(format1_label_t *f1,
char s6[7], s13[14], s44[45];
unsigned long track_low, track_up;
bzero(s44, 45);
memset(s44, 0, 45);
strncpy(s44, f1->DS1DSNAM, 44);
vtoc_ebcdic_dec(s44, s44, 44);
bzero(s6, 7);
memset(s6, 0, 7);
strncpy(s6, (char *)f1->DS1DSSN, 6);
vtoc_ebcdic_dec(s6, s6, 6);
bzero(s13, 14);
memset(s13, 0, 14);
strncpy(s13, (char *)f1->DS1SYSCD, 13);
vtoc_ebcdic_dec(s13, s13, 13);
@@ -837,13 +804,13 @@ static void dasdview_print_format1_8_short_info_raw(format1_label_t *f1,
struct dscb *dscb;
int rc;
bzero(s44, 45);
memset(s44, 0, 45);
strncpy(s44, f1->DS1DSNAM, 44);
vtoc_ebcdic_dec(s44, s44, 44);
bzero(s6, 7);
memset(s6, 0, 7);
strncpy(s6, (char *)f1->DS1DSSN, 6);
vtoc_ebcdic_dec(s6, s6, 6);
bzero(s13, 14);
memset(s13, 0, 14);
strncpy(s13, (char *)f1->DS1SYSCD, 13);
vtoc_ebcdic_dec(s13, s13, 13);
@@ -1071,7 +1038,7 @@ static void dasdview_print_vtoc_info_raw(dasdview_info_t *info)
/*
* Note: the explicit cylinder/head conversion for large volume
* adresses should not be necessary for entries that point to
* addresses should not be necessary for entries that point to
* vtoc labels, as those must be located in the first 65K-1 tracks,
* but we do it anyway to be on the safe side.
*/
@@ -1080,9 +1047,9 @@ static void dasdview_print_format1_8_no_head(format1_label_t *f1)
char s6[7], s13[14], s44[45];
int i;
bzero(s6, 7);
bzero(s13, 14);
bzero(s44, 45);
memset(s6, 0, 7);
memset(s13, 0, 14);
memset(s44, 0, 45);
strncpy(s44, f1->DS1DSNAM, 44);
printf("DS1DSNAM : ascii '%44s'\n", s44);
@@ -1865,7 +1832,7 @@ static void dasdview_view_standard(dasdview_info_t *info)
/* seek in SEEK_STEP steps */
for (i = 1; i <= j; i++) {
rc = lseek64(fd, SEEK_STEP, SEEK_CUR);
rc = lseek(fd, SEEK_STEP, SEEK_CUR);
if (rc == -1) {
printf("*** rc: %d (%d) ***\n", rc, errno);
printf("*** j: %llu ***\n", j);
@@ -1918,7 +1885,7 @@ static void dasdview_view_standard(dasdview_info_t *info)
count = info->begin;
for (i = 1; i <= j; i++) {
bzero(dumpstr, DUMP_STRING_SIZE);
memset(dumpstr, 0, DUMP_STRING_SIZE);
rc = read(fd, &dumpstr, DUMP_STRING_SIZE);
if (rc != DUMP_STRING_SIZE) {
close(fd);
@@ -1937,7 +1904,7 @@ static void dasdview_view_standard(dasdview_info_t *info)
}
if (k > 0) {
bzero(dumpstr, DUMP_STRING_SIZE);
memset(dumpstr, 0, DUMP_STRING_SIZE);
rc = read(fd, &dumpstr, k);
if (rc != (int)k) {
close(fd);
@@ -1976,8 +1943,8 @@ static void dasdview_print_format_raw(unsigned int size, char *dumpstr)
while (residual) {
/* we handle at most 16 bytes per line */
count = MIN(residual, 16u);
bzero(asc, 17);
bzero(ebc, 17);
memset(asc, 0, 17);
memset(ebc, 0, 17);
printf("|");
memcpy(asc, data, count);
memcpy(ebc, data, count);
@@ -2066,7 +2033,7 @@ static void dasdview_print_raw_track(char *trackdata,
{
struct eckd_count *ecount;
char *data;
u_int32_t record;
uint32_t record;
record = 0;
data = trackdata;
@@ -2091,8 +2058,8 @@ static void dasdview_print_raw_track(char *trackdata,
static void dasdview_view_raw(dasdview_info_t *info)
{
u_int64_t residual, trckstart, trckend, track, trckbuffsize;
u_int64_t tracks_to_read, trckcount, i;
uint64_t residual, trckstart, trckend, track, trckbuffsize;
uint64_t tracks_to_read, trckcount, i;
char *trackdata;
char *data;
int rc;
@@ -2187,7 +2154,7 @@ int main(int argc, char *argv[])
util_prg_init(&prg);
util_opt_init(opt_vec, NULL);
bzero(&info, sizeof(info));
memset(&info, 0, sizeof(info));
while (1) {
oc = util_opt_getopt_long(argc, argv);

View File

@@ -11,6 +11,7 @@
#define DASDVIEW_H
#include <limits.h>
#include <stdint.h>
/********************************************************************************
* SECTION: Definitions needed for DASD-API (see dasd.h)
@@ -68,7 +69,7 @@ typedef struct dasdview_info
int dasd_info_version;
unsigned int blksize;
struct hd_geometry geo;
u_int32_t hw_cylinders;
uint32_t hw_cylinders;
unsigned long long begin;
unsigned long long size;

67
dasdview/dasdview_cli.h Normal file
View File

@@ -0,0 +1,67 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef DASDVIEW_CLI_H
#define DASDVIEW_CLI_H
#include "lib/util_opt.h"
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("DUMP OPTIONS"),
{
.option = { NULL, no_argument, NULL, '1' },
.desc = "Show DASD content in short Hex/EBCDIC/ASCII format",
.flags = UTIL_OPT_FLAG_NOLONG,
},
{
.option = { NULL, no_argument, NULL, '2' },
.desc = "Show DASD content in detailed Hex/EBCDIC/ASCII format",
.flags = UTIL_OPT_FLAG_NOLONG,
},
{
.option = { "begin", required_argument, NULL, 'b' },
.argument = "BEGIN",
.desc = "Specify start of dump in kilobytes (suffix k), "
"megabytes (m), blocks (b), tracks (t), or cylinders (c)",
},
{
.option = { "size", required_argument, NULL, 's' },
.argument = "SIZE",
.desc = "Specify size of dump in kilobytes (suffix k), "
"megabytes (m), blocks (b), tracks (t), or cylinders (c)",
},
UTIL_OPT_SECTION("MISC"),
{
.option = { "characteristic", no_argument, NULL, 'c' },
.desc = "Print the characteristics of a device",
},
{
.option = { "info", no_argument, NULL, 'i' },
.desc = "Print general DASD information and geometry",
},
{
.option = { "volser", no_argument, NULL, 'j' },
.desc = "Print the volume serial number",
},
{
.option = { "label", no_argument, NULL, 'l' },
.desc = "Print information about the volume label",
},
{
.option = { "vtoc", required_argument, NULL, 't' },
.argument = "SPEC",
.desc = "Print the table of content (VTOC)",
},
{
.option = { "extended", no_argument, NULL, 'x' },
.desc = "Print extended DASD information",
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
#endif

View File

@@ -0,0 +1,136 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef DUMP2TAR_CLI_H
#define DUMP2TAR_CLI_H
#include "lib/util_opt.h"
#define OPT_NOSHORT_BASE 256
#define OPT_DEREFERENCE (OPT_NOSHORT_BASE + 0)
#define OPT_NORECURSION (OPT_NOSHORT_BASE + 1)
#define OPT_EXCLUDETYPE (OPT_NOSHORT_BASE + 2)
/* Definition of command line options */
static struct util_opt dump2tar_opts[] = {
UTIL_OPT_SECTION("OUTPUT OPTIONS"),
{
.option = { "output-file", required_argument, NULL, 'o' },
.argument = "FILE",
.desc = "Write archive to FILE (default: standard output)",
},
#ifdef HAVE_ZLIB
{
.option = { "gzip", no_argument, NULL, 'z' },
.desc = "Write a gzip compressed archive",
},
#endif /* HAVE_ZLIB */
{
.option = { "max-size", required_argument, NULL, 'm' },
.argument = "N",
.desc = "Stop adding files when archive size exceeds N bytes",
},
{
.option = { "timeout", required_argument, NULL, 't' },
.argument = "SEC",
.desc = "Stop adding files after SEC seconds",
},
{
.option = { "no-eof", no_argument, NULL, 131 },
.desc = "Do not write an end-of-file marker",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "add-cmd-status", no_argument, NULL, 132 },
.desc = "Add status of commands as separate file",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "append", no_argument, NULL, 133 },
.desc = "Append output to end of file",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
UTIL_OPT_SECTION("INPUT OPTIONS"),
{
.option = { "files-from", required_argument, NULL, 'F' },
.argument = "FILE",
.desc = "Read filenames from FILE (- for standard input)",
},
{
.option = { "ignore-failed-read", no_argument, NULL, 'i' },
.desc = "Continue after read errors",
},
{
.option = { "buffer-size", required_argument, NULL, 'b' },
.argument = "N",
.desc = "Read data in chunks of N byte (default: 16384)",
},
{
.option = { "file-timeout", required_argument, NULL, 'T' },
.desc = "Stop reading file after SEC seconds",
.argument = "SEC",
},
{
.option = { "file-max-size", required_argument, NULL, 'M' },
.argument = "N",
.desc = "Stop reading file after N bytes",
},
{
.option = { "jobs", required_argument, NULL, 'j' },
.argument = "N",
.desc = "Read N files in parallel (default: 1)",
},
{
.option = { "jobs-per-cpu", required_argument, NULL, 'J' },
.argument = "N",
.desc = "Read N files per CPU in parallel",
},
{
.option = { "exclude", required_argument, NULL, 'x' },
.argument = "PATTERN",
.desc = "Don't add files matching PATTERN",
},
{
.option = { "exclude-from", required_argument, NULL, 'X' },
.argument = "FILE",
.desc = "Don't add files matching patterns in FILE",
},
{
.option = { "exclude-type", required_argument, NULL,
OPT_EXCLUDETYPE },
.argument = "TYPE",
.desc = "Don't add files of specified TYPE (one of: fdcbpls)",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "dereference", no_argument, NULL, OPT_DEREFERENCE },
.desc = "Add link targets instead of links",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "no-recursion", no_argument, NULL,
OPT_NORECURSION },
.desc = "Don't add files from sub-directories",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
UTIL_OPT_SECTION("MISC OPTIONS"),
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
{
.option = { "verbose", no_argument, NULL, 'V' },
.desc = "Print additional informational output",
},
{
.option = { "quiet", no_argument, NULL, 'q' },
.desc = "Suppress printing of informational output",
},
UTIL_OPT_END,
};
#endif

View File

@@ -1,6 +1,11 @@
# Common definitions
include ../../common.mak
zsh-completions = _dump2tar
bash-completions = dump2tar.bash
include ../../common_autocomp.mak
ALL_CPPFLAGS += -I../include -Wno-unused-parameter
LDLIBS += -lpthread -lrt
ifneq ($(HAVE_ZLIB),0)

View File

@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#include "lib/util_autocomp.h"
#include "../include/dump2tar_cli.h"
int main(void)
{
generate_autocomp(dump2tar_opts, "dump2tar");
return 0;
}

View File

@@ -30,7 +30,6 @@
#include "dref.h"
#include "dump.h"
#include "global.h"
#include "idcache.h"
#include "misc.h"
#include "tar.h"
@@ -656,16 +655,18 @@ static int read_symlink(struct task *task, const char *filename,
task->opts->read_chunk_size;
int rc = EXIT_OK;
/* If @relname is NULL, use @filename with AT_FDCWD. */
if (!relname) {
relname = filename;
dirfd = AT_FDCWD;
}
while (!is_aborted(task)) {
buffer_make_room(buffer, currlen, false,
task->opts->max_buffer_size);
cancel_enable();
if (relname)
actual = readlinkat(dirfd, relname, buffer->addr,
buffer->size);
else
actual = readlink(filename, buffer->addr, buffer->size);
actual = readlinkat(dirfd, relname, buffer->addr, buffer->size);
cancel_disable();
if (actual == -1) {

View File

@@ -21,6 +21,7 @@
#include "lib/util_prg.h"
#include "dump.h"
#include "dump2tar_cli.h"
#include "global.h"
#include "idcache.h"
#include "misc.h"
@@ -28,12 +29,6 @@
#define MIN_BUFFER_SIZE 4096
#define OPT_NOSHORT_BASE 256
#define OPT_DEREFERENCE (OPT_NOSHORT_BASE + 0)
#define OPT_NORECURSION (OPT_NOSHORT_BASE + 1)
#define OPT_EXCLUDETYPE (OPT_NOSHORT_BASE + 2)
/* Program description */
static const struct util_prg dump2tar_prg = {
.desc = "Use dump2tar to create a tar archive from the contents "
@@ -52,124 +47,6 @@ static const struct util_prg dump2tar_prg = {
},
};
/* Definition of command line options */
static struct util_opt dump2tar_opts[] = {
UTIL_OPT_SECTION("OUTPUT OPTIONS"),
{
.option = { "output-file", required_argument, NULL, 'o' },
.argument = "FILE",
.desc = "Write archive to FILE (default: standard output)",
},
#ifdef HAVE_ZLIB
{
.option = { "gzip", no_argument, NULL, 'z' },
.desc = "Write a gzip compressed archive",
},
#endif /* HAVE_ZLIB */
{
.option = { "max-size", required_argument, NULL, 'm' },
.argument = "N",
.desc = "Stop adding files when archive size exceeds N bytes",
},
{
.option = { "timeout", required_argument, NULL, 't' },
.argument = "SEC",
.desc = "Stop adding files after SEC seconds",
},
{
.option = { "no-eof", no_argument, NULL, 131 },
.desc = "Do not write an end-of-file marker",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "add-cmd-status", no_argument, NULL, 132 },
.desc = "Add status of commands as separate file",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "append", no_argument, NULL, 133 },
.desc = "Append output to end of file",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
UTIL_OPT_SECTION("INPUT OPTIONS"),
{
.option = { "files-from", required_argument, NULL, 'F' },
.argument = "FILE",
.desc = "Read filenames from FILE (- for standard input)",
},
{
.option = { "ignore-failed-read", no_argument, NULL, 'i' },
.desc = "Continue after read errors",
},
{
.option = { "buffer-size", required_argument, NULL, 'b' },
.argument = "N",
.desc = "Read data in chunks of N byte (default: 16384)",
},
{
.option = { "file-timeout", required_argument, NULL, 'T' },
.desc = "Stop reading file after SEC seconds",
.argument = "SEC",
},
{
.option = { "file-max-size", required_argument, NULL, 'M' },
.argument = "N",
.desc = "Stop reading file after N bytes",
},
{
.option = { "jobs", required_argument, NULL, 'j' },
.argument = "N",
.desc = "Read N files in parallel (default: 1)",
},
{
.option = { "jobs-per-cpu", required_argument, NULL, 'J' },
.argument = "N",
.desc = "Read N files per CPU in parallel",
},
{
.option = { "exclude", required_argument, NULL, 'x' },
.argument = "PATTERN",
.desc = "Don't add files matching PATTERN",
},
{
.option = { "exclude-from", required_argument, NULL, 'X' },
.argument = "FILE",
.desc = "Don't add files matching patterns in FILE",
},
{
.option = { "exclude-type", required_argument, NULL,
OPT_EXCLUDETYPE },
.argument = "TYPE",
.desc = "Don't add files of specified TYPE (one of: fdcbpls)",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "dereference", no_argument, NULL, OPT_DEREFERENCE },
.desc = "Add link targets instead of links",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
{
.option = { "no-recursion", no_argument, NULL,
OPT_NORECURSION },
.desc = "Don't add files from sub-directories",
.flags = UTIL_OPT_FLAG_NOSHORT,
},
UTIL_OPT_SECTION("MISC OPTIONS"),
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
{
.option = { "verbose", no_argument, NULL, 'V' },
.desc = "Print additional informational output",
},
{
.option = { "quiet", no_argument, NULL, 'q' },
.desc = "Suppress printing of informational output",
},
UTIL_OPT_END,
};
/* Split buffer size specification in @arg into two numbers to be stored in
* @from_ptr and @to_ptr. Return %EXIT_OK on success. */
static int parse_buffer_size(char *arg, size_t *from_ptr, size_t *to_ptr)

View File

@@ -4,3 +4,4 @@ pkey_pckmo
pkey_ep11
pkey_cca
paes_s390
phmac_s390

View File

@@ -0,0 +1,2 @@
SUBSYSTEM=="block", ACTION=="add", KERNEL=="vd*[!0-9]", TEST=="queue/rotational", ATTR{queue/rotational}="0"
SUBSYSTEM=="block", ACTION=="add", KERNEL=="vd*[!0-9]", TEST=="queue/scheduler", ATTR{queue/scheduler}="none"

View File

@@ -1,5 +1,10 @@
include ../common.mak
zsh-completions = _fdasd
bash-completions = fdasd.bash
include ../common_autocomp.mak
libs = $(rootdir)/libvtoc/libvtoc.a \
$(rootdir)/libzds/libzds.a \
$(rootdir)/libdasd/libdasd.a \

View File

@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#include "lib/util_autocomp.h"
#include "fdasd_cli.h"
int main(void)
{
generate_autocomp(opt_vec, "fdasd");
return 0;
}

View File

@@ -8,6 +8,7 @@
*/
#include <getopt.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/sysmacros.h>
@@ -20,6 +21,7 @@
#include "lib/zt_common.h"
#include "fdasd.h"
#include "fdasd_cli.h"
/* global variables */
static struct hd_geometry geo;
@@ -137,58 +139,6 @@ static const struct util_prg prg = {
}
};
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("NON-INTERACTIVE MODE"),
{
.option = { "auto", no_argument, NULL, 'a' },
.desc = "Create a single partition spanning the entire disk",
},
{
.option = { "config", required_argument, NULL, 'c' },
.argument = "FILE",
.desc = "Create partitions(s) based on content of FILE",
},
{
.option = { "keep_volser", no_argument, NULL, 'k' },
.desc = "Do not change the current volume serial",
},
{
.option = { "label", required_argument, NULL, 'l' },
.argument = "VOLSER",
.desc = "Set the volume serial to VOLSER",
},
UTIL_OPT_SECTION("MISC"),
{
.option = { "check_host_count", no_argument, NULL, 'C' },
.desc = "Check if device is in use by other hosts",
},
{
.option = { "force", optional_argument, NULL, 'f' },
.argument = "TYPE,SIZE",
.desc = "Force fdasd to work on non DASD devices with assumed "
"TYPE (3390, 3380, or 9345) and blocksize SIZE",
},
{
.option = { "volser", no_argument, NULL, 'i' },
.desc = "Print volume serial",
},
{
.option = { "table", no_argument, NULL, 'p' },
.desc = "Print partition table",
},
{
.option = { "verbose", no_argument, NULL, 'r' },
.desc = "Provide more verbose output",
},
{
.option = { "silent", no_argument, NULL, 's' },
.desc = "Suppress messages",
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
static int getpos(fdasd_anchor_t *anc, int dsn)
{
return anc->partno[dsn];
@@ -211,9 +161,9 @@ static void setpos(fdasd_anchor_t *anc, int dsn, int pos)
anc->partno[dsn] = pos;
}
static u_int32_t get_usable_cylinders(fdasd_anchor_t *anc)
static uint32_t get_usable_cylinders(fdasd_anchor_t *anc)
{
u_int32_t cyl;
uint32_t cyl;
/* large volume */
if (anc->f4->DS4DEVCT.DS4DSCYL == LV_COMPAT_CYL &&
@@ -221,7 +171,7 @@ static u_int32_t get_usable_cylinders(fdasd_anchor_t *anc)
return anc->f4->DS4DCYL;
/* normal volume */
if (anc->f4->DS4DEVCT.DS4DEVFG & ALTERNATE_CYLINDERS_USED)
cyl = anc->f4->DS4DEVCT.DS4DSCYL - (u_int16_t)anc->f4->DS4DEVAC;
cyl = anc->f4->DS4DEVCT.DS4DSCYL - (uint16_t)anc->f4->DS4DEVAC;
else
cyl = anc->f4->DS4DEVCT.DS4DSCYL;
@@ -230,7 +180,7 @@ static u_int32_t get_usable_cylinders(fdasd_anchor_t *anc)
static void get_addr_of_highest_f1_f8_label(fdasd_anchor_t *anc, cchhb_t *addr)
{
u_int8_t record;
uint8_t record;
/* We have to count the following labels:
* one format 4
* one format 5
@@ -406,7 +356,7 @@ static void fdasd_error(fdasd_anchor_t *anc, enum fdasd_failure why, char *str)
*/
static int read_line(void)
{
bzero(line_buffer, LINE_LENGTH);
memset(line_buffer, 0, LINE_LENGTH);
line_ptr = line_buffer;
if (!fgets(line_buffer, LINE_LENGTH, stdin)) {
clearerr(stdin);
@@ -437,20 +387,28 @@ static int yes_no(char *question_str)
ssize_t bytes_read;
char *answer;
size_t size;
int rc;
size = 0;
answer = NULL;
while (1) {
printf("%s (y/n): ", question_str);
bytes_read = getline(&answer, &size, stdin);
if (bytes_read < 0)
return -1;
if (answer[0] == 'y')
return 0;
if (answer[0] == 'n')
return 1;
if (bytes_read < 0) {
rc = -1;
break;
}
if (answer[0] == 'y') {
rc = 0;
break;
}
if (answer[0] == 'n') {
rc = 1;
break;
}
}
free(answer);
return rc;
}
static char *fdasd_partition_type(char *dsname)
@@ -493,7 +451,7 @@ static void fdasd_initialize_anchor(fdasd_anchor_t *anc)
volume_label_t *vlabel;
int i;
bzero(anc, sizeof(fdasd_anchor_t));
memset(anc, 0, sizeof(fdasd_anchor_t));
for (i = 0; i < USABLE_PARTITIONS; i++)
setpos(anc, i, -1);
@@ -519,17 +477,17 @@ static void fdasd_initialize_anchor(fdasd_anchor_t *anc)
fdasd_error(anc, malloc_failed,
"FMT9 DSCB memory allocation failed.");
bzero(anc->f4, sizeof(format4_label_t));
bzero(anc->f5, sizeof(format5_label_t));
bzero(anc->f7, sizeof(format7_label_t));
bzero(anc->f9, sizeof(format9_label_t));
memset(anc->f4, 0, sizeof(format4_label_t));
memset(anc->f5, 0, sizeof(format5_label_t));
memset(anc->f7, 0, sizeof(format7_label_t));
memset(anc->f9, 0, sizeof(format9_label_t));
vtoc_init_format9_label(anc->f9);
vlabel = malloc(sizeof(volume_label_t));
if (vlabel == NULL)
fdasd_error(anc, malloc_failed,
"Volume label memory allocation failed.");
bzero(vlabel, sizeof(volume_label_t));
memset(vlabel, 0, sizeof(volume_label_t));
anc->vlabel = vlabel;
for (i = 1; i <= USABLE_PARTITIONS; i++) {
@@ -551,7 +509,7 @@ static void fdasd_initialize_anchor(fdasd_anchor_t *anc)
if (part_info->f1 == NULL)
fdasd_error(anc, malloc_failed,
"FMT1 DSCB memory allocation failed.");
bzero(part_info->f1, sizeof(format1_label_t));
memset(part_info->f1, 0, sizeof(format1_label_t));
if (prev_part_info) {
prev_part_info->next = part_info;
@@ -975,7 +933,7 @@ static void fdasd_verify_device(fdasd_anchor_t *anc, char *name)
* Note:
* - 'version' and 'help' are priority options.
* All other parameters are ignored in that case.
* - 'silent' and 'verbose' are allways allowed in any
* - 'silent' and 'verbose' are always allowed in any
* combination.
*
*/
@@ -1052,10 +1010,10 @@ static void fdasd_show_mapping(fdasd_anchor_t *anc)
int i = 0, j = 0, dev_len;
printf("\ndevice .........: %s\n", options.device);
bzero(str, sizeof(str));
memset(str, 0, sizeof(str));
vtoc_volume_label_get_label(anc->vlabel, str);
printf("volume label ...: %.4s\n", str);
bzero(str, sizeof(str));
memset(str, 0, sizeof(str));
vtoc_volume_label_get_volser(anc->vlabel, str);
printf("volume serial ..: %s\n\n", str);
@@ -1080,7 +1038,7 @@ static void fdasd_show_mapping(fdasd_anchor_t *anc)
if (part_info->used != 0x01)
continue;
bzero(dsname, sizeof(dsname));
memset(dsname, 0, sizeof(dsname));
strncpy(dsname, part_info->f1->DS1DSNAM, 44);
vtoc_ebcdic_dec(dsname, dsname, 44);
@@ -1103,7 +1061,7 @@ static void fdasd_print_volser(fdasd_anchor_t *anc)
{
char volser[VOLSER_LENGTH + 1];
bzero(volser, VOLSER_LENGTH);
memset(volser, 0, VOLSER_LENGTH);
vtoc_ebcdic_dec(anc->vlabel->volid, volser, VOLSER_LENGTH);
printf("%6.6s\n", volser);
}
@@ -1372,7 +1330,7 @@ static void fdasd_write_vtoc_labels(fdasd_anchor_t *anc)
}
/* write empty labels to the rest of the blocks */
bzero(&emptyf1, sizeof(emptyf1));
memset(&emptyf1, 0, sizeof(emptyf1));
while (blk < maxblk) {
vtoc_write_label(options.device, blk, &emptyf1, NULL,
NULL, NULL, NULL);
@@ -1425,7 +1383,7 @@ static void fdasd_recreate_vtoc_unconditional(fdasd_anchor_t *anc)
anc->formatted_cylinders, geo.heads);
while (part_info != NULL) {
bzero(part_info->f1, sizeof(format1_label_t));
memset(part_info->f1, 0, sizeof(format1_label_t));
if (part_info->used == 0x01) {
part_info->used = 0x00;
@@ -1826,7 +1784,7 @@ static void fdasd_process_valid_vtoc(fdasd_anchor_t *anc, unsigned long blk)
/* go through remaining labels, f4 label already done */
for (i = 1; i < geo.sectors; i++) {
bzero(&f1_label, f1_size);
memset(&f1_label, 0, f1_size);
vtoc_read_label(options.device, blk, &f1_label, NULL, NULL,
NULL);
@@ -2470,9 +2428,9 @@ static int fdasd_get_partition_data(fdasd_anchor_t *anc, extent_t *part_extent,
unsigned long start, stop, limit;
partition_info_t *part_tmp;
cchh_t llimit, ulimit;
u_int16_t hh, head;
u_int32_t cc, cyl;
u_int8_t b1, b2;
uint16_t hh, head;
uint32_t cc, cyl;
uint8_t b1, b2;
char mesg[48];
start = FIRST_USABLE_TRK;
@@ -2675,7 +2633,7 @@ static void fdasd_dequeue_old_partition(fdasd_anchor_t *anc,
part_info->start_trk = 0x0;
part_info->end_trk = 0x0;
part_info->fspace_trk = 0x0;
bzero(part_info->f1, sizeof(format1_label_t));
memset(part_info->f1, 0, sizeof(format1_label_t));
}
/*
@@ -2758,7 +2716,7 @@ static void fdasd_remove_partition(fdasd_anchor_t *anc)
if (anc->used_partitions != 0)
get_addr_of_highest_f1_f8_label(anc, &hf1);
else
bzero(&hf1, sizeof(struct cchhb));
memset(&hf1, 0, sizeof(struct cchhb));
vtoc_update_format4_label(anc->f4, &hf1, anc->f4->DS4DSREC + 1);
vtoc_set_freespace(anc->f4, anc->f5, anc->f7, '+', anc->verbose,
@@ -2777,8 +2735,8 @@ static void fdasd_auto_partition(fdasd_anchor_t *anc)
{
partition_info_t *part_info = anc->first;
cchh_t llimit, ulimit;
u_int16_t head;
u_int32_t cyl;
uint16_t head;
uint32_t cyl;
extent_t ext;
cchhb_t hf1;

View File

@@ -10,6 +10,8 @@
#ifndef FDASD_H
#define FDASD_H
#include <stdint.h>
/*****************************************************************************
* SECTION: Definitions needed for DASD-API (see dasd.h) *
*****************************************************************************/
@@ -67,7 +69,7 @@ static struct fdasd_options options = {
};
typedef struct partition_info {
u_int8_t used;
uint8_t used;
unsigned long start_trk;
unsigned long end_trk;
unsigned long len_trk;
@@ -100,7 +102,7 @@ typedef struct fdasd_anchor {
int option_reuse;
int option_recreate;
int partno[USABLE_PARTITIONS];
u_int16_t dev_type;
uint16_t dev_type;
unsigned int used_partitions;
unsigned long label_pos;
unsigned int blksize;
@@ -113,8 +115,8 @@ typedef struct fdasd_anchor {
partition_info_t *last;
volume_label_t *vlabel;
config_data_t confdata[USABLE_PARTITIONS];
u_int32_t hw_cylinders;
u_int32_t formatted_cylinders;
uint32_t hw_cylinders;
uint32_t formatted_cylinders;
} fdasd_anchor_t;
enum offset {lower, upper};

64
fdasd/fdasd_cli.h Normal file
View File

@@ -0,0 +1,64 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef FDASD_CLI_H
#define FDASD_CLI_H
#include "lib/util_opt.h"
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("NON-INTERACTIVE MODE"),
{
.option = { "auto", no_argument, NULL, 'a' },
.desc = "Create a single partition spanning the entire disk",
},
{
.option = { "config", required_argument, NULL, 'c' },
.argument = "FILE",
.desc = "Create partitions(s) based on content of FILE",
},
{
.option = { "keep_volser", no_argument, NULL, 'k' },
.desc = "Do not change the current volume serial",
},
{
.option = { "label", required_argument, NULL, 'l' },
.argument = "VOLSER",
.desc = "Set the volume serial to VOLSER",
},
UTIL_OPT_SECTION("MISC"),
{
.option = { "check_host_count", no_argument, NULL, 'C' },
.desc = "Check if device is in use by other hosts",
},
{
.option = { "force", optional_argument, NULL, 'f' },
.argument = "TYPE,SIZE",
.desc = "Force fdasd to work on non DASD devices with assumed "
"TYPE (3390, 3380, or 9345) and blocksize SIZE",
},
{
.option = { "volser", no_argument, NULL, 'i' },
.desc = "Print volume serial",
},
{
.option = { "table", no_argument, NULL, 'p' },
.desc = "Print partition table",
},
{
.option = { "verbose", no_argument, NULL, 'r' },
.desc = "Provide more verbose output",
},
{
.option = { "silent", no_argument, NULL, 's' },
.desc = "Suppress messages",
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
#endif

View File

@@ -514,7 +514,7 @@ static int hmcdrv_path_copy(struct hmcdrv_fuse_file *fp, char *dest)
char *src = HMCDRV_FUSE_PATH(fp);
int len = 0;
while ((len < (HMCDRV_FUSE_MAXPATH - 1)) &&
while ((len < (HMCDRV_FUSE_MAXPATH - 2)) &&
(*src != '\0')) {
*dest = *src;

View File

@@ -7,6 +7,11 @@
include ../common.mak
zsh-completions = _hsavmcore
bash-completions = hsavmcore.bash
include ../common_autocomp.mak
ALL_CPPFLAGS += -D_FILE_OFFSET_BITS=64
ifeq (${HAVE_FUSE},0)
@@ -41,7 +46,7 @@ endif
ALL_CFLAGS += $(FUSE_CFLAGS) $(SYSTEMD_CFLAGS)
LDLIBS += $(FUSE_LDLIBS) $(SYSTEMD_LDLIBS) -lpthread
sources := $(wildcard *.c)
sources := $(filter-out %_host.c, $(wildcard *.c))
objects := $(patsubst %.c,%.o,$(sources))
libs = $(rootdir)/libutil/libutil.a

View File

@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#include "lib/util_autocomp.h"
#include "hsavmcore_cli.h"
int main(void)
{
generate_autocomp(opt_vec, "hsavmcore");
return 0;
}

View File

@@ -16,6 +16,7 @@
#include "lib/util_log.h"
#include "cmdline_options.h"
#include "hsavmcore_cli.h"
static const struct util_prg prg = {
.desc = "hsavmcore is designed to make the dump process with kdump more "
@@ -32,91 +33,6 @@ static const struct util_prg prg = {
}
};
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("CONFIGURATION"),
{
.option = { "config", required_argument, NULL, 'c' },
.argument = "CONFIGFILE",
.desc = "Path to the configuration file.\n"
"Default: no configuration file is used",
},
{
.option = { "vmcore", required_argument, NULL, 'C' },
.argument = "VMCOREFILE",
.desc = "Path to the vmcore file.\n"
"Default: " PROC_VMCORE,
},
{
.option = { "hsa", required_argument, NULL, 'H' },
.argument = "ZCOREHSAFILE",
.desc = "Path to the zcore HSA file.\n"
"Default: " ZCORE_HSA,
},
{
.option = { "workdir", required_argument, NULL, 'W' },
.argument = "WORKDIR",
.desc = "Path to the work directory where temporary files can be "
"stored.\nDefault: " WORKDIR,
},
{
.option = { "bmvmcore", required_argument, NULL, 'B' },
.argument = "VMCOREFILE",
.desc = "Path to the target of the bind mount for the vmcore "
"replacement.\nDefault: " PROC_VMCORE,
},
{
.option = { "swap", required_argument, NULL, 'S' },
.argument = "PATH",
.desc = "Path to a swap device or file. The specified swap "
"device or file must exist and have the proper swap "
"format.\nDefault: no swap device or file is activated",
},
{
.option = { "hsasize", required_argument, NULL, 'T' },
.argument = "HSASIZE",
.desc = "HSA size in bytes.\n"
"Default: -1 (read from the zcore HSA file)",
},
{
.option = { "dbgfsmnt", no_argument, NULL, 'D' },
.desc = "Mount the debug file system.\n"
"Default: the debug file system is not mounted",
},
{
.option = { "hsamem", no_argument, NULL, 'F' },
.desc = "Cache the HSA memory in regular memory.\n"
"Default: the HSA memory is cached as a file within "
"WORKDIR",
},
{
.option = { "norelhsa", no_argument, NULL, 'R' },
.desc = "Do NOT release the HSA memory after caching.\n"
"Default: the HSA memory is released",
},
{
.option = { "nobindmnt", no_argument, NULL, 'N' },
.desc = "Do NOT replace the system's vmcore.\n"
"Default: the system's vmcore is replaced",
},
UTIL_OPT_SECTION("LOGGING"),
{
.option = { "verbose", no_argument, NULL, 'V' },
.desc = "Print verbose messages to stdout. Repeat this option "
"for increased verbosity from just error messages to "
"also include warning, information, debug, and trace "
"messages. This option is intended for debugging",
},
{
.option = { "fusedbg", no_argument, NULL, 'G' },
.desc = "Enable FUSE debugging.\n"
"Default: FUSE debugging is disabled",
},
UTIL_OPT_SECTION("GENERAL OPTIONS"),
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
void parse_cmdline_options(int argc, char *argv[], struct config *config)
{
int opt, ret;

99
hsavmcore/hsavmcore_cli.h Normal file
View File

@@ -0,0 +1,99 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef HSAVMCORE_CLI_H
#define HSAVMCORE_CLI_H
#include "lib/util_opt.h"
#include "common.h"
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("CONFIGURATION"),
{
.option = { "config", required_argument, NULL, 'c' },
.argument = "CONFIGFILE",
.desc = "Path to the configuration file.\n"
"Default: no configuration file is used",
},
{
.option = { "vmcore", required_argument, NULL, 'C' },
.argument = "VMCOREFILE",
.desc = "Path to the vmcore file.\n"
"Default: " PROC_VMCORE,
},
{
.option = { "hsa", required_argument, NULL, 'H' },
.argument = "ZCOREHSAFILE",
.desc = "Path to the zcore HSA file.\n"
"Default: " ZCORE_HSA,
},
{
.option = { "workdir", required_argument, NULL, 'W' },
.argument = "WORKDIR",
.desc = "Path to the work directory where temporary files can be "
"stored.\nDefault: " WORKDIR,
},
{
.option = { "bmvmcore", required_argument, NULL, 'B' },
.argument = "VMCOREFILE",
.desc = "Path to the target of the bind mount for the vmcore "
"replacement.\nDefault: " PROC_VMCORE,
},
{
.option = { "swap", required_argument, NULL, 'S' },
.argument = "PATH",
.desc = "Path to a swap device or file. The specified swap "
"device or file must exist and have the proper swap "
"format.\nDefault: no swap device or file is activated",
},
{
.option = { "hsasize", required_argument, NULL, 'T' },
.argument = "HSASIZE",
.desc = "HSA size in bytes.\n"
"Default: -1 (read from the zcore HSA file)",
},
{
.option = { "dbgfsmnt", no_argument, NULL, 'D' },
.desc = "Mount the debug file system.\n"
"Default: the debug file system is not mounted",
},
{
.option = { "hsamem", no_argument, NULL, 'F' },
.desc = "Cache the HSA memory in regular memory.\n"
"Default: the HSA memory is cached as a file within "
"WORKDIR",
},
{
.option = { "norelhsa", no_argument, NULL, 'R' },
.desc = "Do NOT release the HSA memory after caching.\n"
"Default: the HSA memory is released",
},
{
.option = { "nobindmnt", no_argument, NULL, 'N' },
.desc = "Do NOT replace the system's vmcore.\n"
"Default: the system's vmcore is replaced",
},
UTIL_OPT_SECTION("LOGGING"),
{
.option = { "verbose", no_argument, NULL, 'V' },
.desc = "Print verbose messages to stdout. Repeat this option "
"for increased verbosity from just error messages to "
"also include warning, information, debug, and trace "
"messages. This option is intended for debugging",
},
{
.option = { "fusedbg", no_argument, NULL, 'G' },
.desc = "Enable FUSE debugging.\n"
"Default: FUSE debugging is disabled",
},
UTIL_OPT_SECTION("GENERAL OPTIONS"),
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
#endif

View File

@@ -365,6 +365,13 @@ function add_hsci {
fi
fi
#### Set MTU for the veth pair
ndev_mtu="$(cat /sys/class/net/${ndev}/mtu)"
hsdev_mtu="$(cat /sys/class/net/${hsdev}/mtu)"
hsci_mtu=$(( ndev_mtu < hsdev_mtu ? ndev_mtu : hsdev_mtu ))
ip link set dev $hscibp mtu $hsci_mtu
ip link set dev $hsci mtu $hsci_mtu
#### Set veth pair to UP
ip link set dev $hscibp up >/dev/null 2>&1
if [ $? -ne 0 ]; then

View File

@@ -16,10 +16,10 @@
#define DBFS_WAIT_TIME_US 10000
extern int dg_debugfs_init(int exit_on_err);
extern int dg_debugfs_vm_init(void);
extern int dg_debugfs_lpar_init(void);
extern int dg_debugfs_open(const char *file);
int dg_debugfs_init(int exit_on_err);
int dg_debugfs_vm_init(void);
int dg_debugfs_lpar_init(void);
int dg_debugfs_open(const char *file);
/*
* z/VM diag 0C prototypes

View File

@@ -26,6 +26,7 @@
#define CPU_TYPE_LEN 16
#define DEBUGFS_FILE "diag_204"
static struct sd_sys *l_cur_lpar;
static u64 l_update_time_us;
static long l_204_buf_size;
@@ -36,7 +37,8 @@ static long l_204_buf_size;
struct l_x_info_blk_hdr {
u8 npar;
u8 flags;
u8 reserved1[6];
u8 reserved1[4];
u16 this_part;
u64 curtod1;
u64 curtod2;
u8 reserved[40];
@@ -158,6 +160,21 @@ static void *l_sd_sys_fill(struct sd_sys *lpar, struct l_x_sys_hdr *sys_hdr)
return cpu_info;
}
/*
* Calculate the time delta between samples using current partition's
* online time.
*/
static u64 l_sd_cur_lpar_delta_time_get(void)
{
struct sd_cpu *cpu;
cpu = sd_cpu_get(l_cur_lpar, "0");
if (!cpu->d_prev || !cpu->d_cur)
return 0;
return l_sub_64(cpu->d_cur->online_time_us,
cpu->d_prev->online_time_us);
}
/*
* Fill one physical CPU with data
*/
@@ -241,9 +258,9 @@ static void l_read_debugfs(struct l_debugfs_d204_hdr **hdr,
*/
static void l_sd_sys_root_fill(struct sd_sys *sys)
{
struct l_x_sys_hdr *sys_hdr, *this_part;
struct l_x_info_blk_hdr *time_hdr;
struct l_debugfs_d204_hdr *hdr;
struct l_x_sys_hdr *sys_hdr;
struct sd_sys *lpar;
char lpar_id[10];
int i;
@@ -262,18 +279,23 @@ static void l_sd_sys_root_fill(struct sd_sys *sys)
usleep(DBFS_WAIT_TIME_US);
} while (1);
sys_hdr = ((void *) time_hdr) + sizeof(struct l_x_info_blk_hdr);
this_part = ((void *)time_hdr) + time_hdr->this_part;
for (i = 0; i < time_hdr->npar; i++) {
l_sys_hdr__sys_name(sys_hdr, lpar_id);
lpar = sd_sys_get(sys, lpar_id);
if (!lpar)
lpar = sd_sys_new(sys, lpar_id);
if (sys_hdr == this_part)
l_cur_lpar = lpar;
lpar->threads_per_core = l_thread_cnt(sys_hdr);
sys_hdr = l_sd_sys_fill(lpar, sys_hdr);
sd_sys_commit(lpar);
}
if (time_hdr->flags & LPAR_PHYS_FLG)
if (time_hdr->flags & LPAR_PHYS_FLG) {
l_sd_sys_root_cpu_phys_fill(sys, (void *) sys_hdr);
sd_phys_delta_time_us_set(sys, l_sd_cur_lpar_delta_time_get());
}
ht_free(hdr);
sd_sys_commit(sys);
}
@@ -290,6 +312,16 @@ static void l_sd_update(void)
sd_sys_update_end(root, l_update_time_us);
}
/*
* Supported physical information items
*/
static struct sd_sys_item *l_phys_item_vec[] = {
&sd_sys_item_core_cnt,
&sd_sys_item_phys_mgm_diff,
&sd_sys_item_mgm,
NULL,
};
/*
* Supported system items
*/
@@ -364,6 +396,7 @@ static struct sd_cpu_type *l_cpu_type_vec[] = {
static struct sd_dg l_sd_dg = {
.update_sys = l_sd_update,
.cpu_type_vec = l_cpu_type_vec,
.phys_item_vec = l_phys_item_vec,
.sys_item_vec = l_sys_item_vec,
.sys_item_enable_vec = l_sys_item_enable_vec,
.cpu_item_vec = l_cpu_item_vec,
@@ -383,6 +416,6 @@ int dg_debugfs_lpar_init(void)
return fh;
else
close(fh);
sd_dg_register(&l_sd_dg, 1);
sd_dg_register(&l_sd_dg, 1, 1);
return 0;
}

View File

@@ -358,6 +358,6 @@ int dg_debugfs_vm_init(void)
close(fh);
l_2fc_buf_size = sizeof(struct l_debugfs_d2fc_hdr);
l_guest_name_init();
sd_dg_register(&dg_debugfs_vm_dg, 0);
sd_dg_register(&dg_debugfs_vm_dg, 0, 0);
return 0;
}

View File

@@ -15,7 +15,6 @@
#include <iconv.h>
#include <limits.h>
#include <mntent.h>
#include <mntent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -25,6 +24,10 @@
#include <time.h>
#include <unistd.h>
#ifndef _PATH_MOUNTED
#define _PATH_MOUNTED "/etc/mtab"
#endif
#include "lib/util_fmt.h"
#include "lib/util_libc.h"

View File

@@ -18,6 +18,7 @@
#include "lib/util_base.h"
#include "lib/util_libc.h"
#include "lib/util_time.h"
#include "lib/zt_common.h"
#define G0(x) MAX(0, (s64) (x))
@@ -25,23 +26,23 @@
/*
* Helper Prototypes
*/
extern void hyptop_helper_init(void);
extern char *ht_strstrip(char *str);
extern char *ht_strdup(const char *str);
extern void ht_print_head(const char *sys);
extern void ht_print_help_icon(void);
extern void ht_ebcdic_to_ascii(char *in, char *out, size_t len);
extern char *ht_mount_point_get(const char *fs_type);
extern u64 ht_ext_tod_2_us(void *tod_ext);
extern void ht_print_time(void);
extern s64 ht_calculate_smt_util(u64 core_us, u64 thr_us, u64 mgm_us, int thread_per_core);
void hyptop_helper_init(void);
char *ht_strstrip(char *str);
char *ht_strdup(const char *str);
void ht_print_head(const char *sys);
void ht_print_help_icon(void);
void ht_ebcdic_to_ascii(char *in, char *out, size_t len);
char *ht_mount_point_get(const char *fs_type);
u64 ht_ext_tod_2_us(void *tod_ext);
void ht_print_time(void);
s64 ht_calculate_smt_util(u64 core_us, u64 thr_us, u64 mgm_us, int thread_per_core);
/*
* Memory alloc functions
*/
extern void *ht_zalloc(size_t size);
extern void *ht_alloc(size_t size);
extern void *ht_realloc(void *ptr, size_t size);
void *ht_zalloc(size_t size);
void *ht_alloc(size_t size);
void *ht_realloc(void *ptr, size_t size);
static inline void ht_free(void *ptr)
{
free(ptr);

View File

@@ -62,11 +62,11 @@ shown.
Select sort field for current window. To reverse the sort order, specify the
option twice. See FIELDS below for definitions.
.TP
.BR "\-t <TYPE>,..." " or " "\-\-cpu_types=<TYPE>,..."
.BR "\-t <TYPE>,..." " or " "\-\-cpu-types=<TYPE>,..."
Select CPU types that are used for CPU time calculations. See CPU TYPES
below for definitions.
.TP
.BR "\-b" " or " "\-\-batch_mode"
.BR "\-b" " or " "\-\-batch-mode"
Use batch mode (no curses). This can be useful for sending output from hyptop
to another program, a file, or a line mode terminal.
In this mode no user input is accepted.
@@ -96,6 +96,17 @@ with an ASCII Record Separator character (0x1e) and suffixed with an ASCII Line
Feed character (0x0a) in accordance with RFC7464.
.BR
See section "OUTPUT FORMAT" for more details.
.BR
.PP
.IP \(bu 3
.B jsonl:
Line-delimited JSON data structures
Data for each iteration is formatted as a separate JSON data structure
separated by ASCII Line Feed character (0x0a, LF).
.BR
See section "OUTPUT FORMAT" for more details.
.BR
.PP
@@ -113,13 +124,20 @@ All values are enclosed in double quotation marks and separated by commas. The
first line of output contains a list of headings. Subsequent lines each
represent data for one system in one iteration.
.PP
This option implies the "\-\-batch_mode" option.
This option implies the "\-\-batch-mode" option.
.RE
.BR "\-\-all"
.RS
Use this option with the "--format" option to include fields without valid
values in the output. Fields without valid values are omitted from the output
by default. When you use the "--all" option, the invalid values are included
and shown as "null".
.RE
.TP
.BR "\-d <SECONDS>" " or " "\-\-delay=<SECONDS>"
Specifies the delay between screen updates.
.TP
.BR "\-m <FACTOR>" " or " "\-\-smt_factor=<FACTOR>"
.BR "\-m <FACTOR>" " or " "\-\-smt-factor=<FACTOR>"
Specifies a workload dependent SMT speedup factor.
For IBM z15 servers, the default value is 1.3. If the workload benefits
from SMT, you can specify a higher value. If the workload does not benefit
@@ -239,7 +257,7 @@ The following units are supported:
.SH CPU TYPES
Depending on the hypervisor different CPU types are supported. These CPU
types can be selected either interactively or with the "--cpu_types"
types can be selected either interactively or with the "--cpu-types"
command line option. The calculation of the CPU data only uses CPUs of
the specified types.
@@ -451,6 +469,14 @@ Subsequent objects each represent performance data for one iteration
.br
.PP
.SS jsonl
The jsonl output format is a data streaming variation of the JSON output format
described above with the same properties as the json\-seq output with the
difference that JSON data is separated only by an ASCII Line Feed character
(0x0a, LF).
.SH EXAMPLES
To start hyptop with the "sys_list" window in interactive mode, enter:
.br

View File

@@ -112,7 +112,7 @@ static enum hyptop_win_action l_sleep(time_t time_s, long time_us)
struct timespec ts;
ts.tv_sec = time_s;
ts.tv_nsec = time_us * 1000;
ts.tv_nsec = util_usecs_to_nsecs(time_us);
nanosleep(&ts, NULL);
return WIN_KEEP;
@@ -231,7 +231,9 @@ static void l_fmt_init(void)
return;
if (g.o.format == FMT_CSV)
flags |= FMT_QUOTEALL;
if (g.o.format == FMT_JSON || g.o.format == FMT_JSONSEQ)
if (g.o.format == FMT_CSV || g.o.format_all)
flags |= FMT_KEEPINVAL;
if (util_fmt_is_json(g.o.format))
flags |= FMT_HANDLEINT;
util_fmt_init(stdout, g.o.format, flags, 1);
}

View File

@@ -55,6 +55,7 @@ struct hyptop_opts {
unsigned int win_specified;
unsigned int batch_mode_specified;
unsigned int format_specified;
unsigned int format_all;
enum util_fmt_t format;
unsigned int iterations_specified;
unsigned int iterations;
@@ -183,10 +184,10 @@ enum hyptop_win_action {
WIN_KEEP,
};
extern enum hyptop_win_action hyptop_process_input_timeout(void);
extern enum hyptop_win_action hyptop_process_input(void);
extern enum hyptop_win_action win_switch(struct hyptop_win *w);
extern enum hyptop_win_action win_back(void);
enum hyptop_win_action hyptop_process_input_timeout(void);
enum hyptop_win_action hyptop_process_input(void);
enum hyptop_win_action win_switch(struct hyptop_win *w);
enum hyptop_win_action win_back(void);
struct hyptop_win;
struct hyptop_win {
@@ -205,25 +206,25 @@ struct hyptop_win {
* Window sys_list
*/
extern struct hyptop_win win_sys_list;
extern void win_sys_list_init(void);
void win_sys_list_init(void);
/*
* Window sys
*/
extern struct hyptop_win win_sys;
extern void win_sys_set(const char *sys_id);
extern void win_sys_init(void);
void win_sys_set(const char *sys_id);
void win_sys_init(void);
/*
* Window cpu_types
*/
extern void win_cpu_types_init(void);
void win_cpu_types_init(void);
/*
* Misc functions
*/
extern void hyptop_update_term(void);
extern void __noreturn hyptop_exit(int rc);
extern void hyptop_text_mode(void);
void hyptop_update_term(void);
void __noreturn hyptop_exit(int rc);
void hyptop_text_mode(void);
#endif /* HYPTOP_H */

View File

@@ -39,17 +39,20 @@ static char HELP_TEXT[] =
"-s, --sys SYSTEM[,..] Systems for current window\n"
"-f, --fields LETTER[:UNIT][,..] Fields and units for current window\n"
"-S, --sort LETTER Sort field for current window\n"
"-t, --cpu_types TYPE[,..] CPU types used for time calculations\n"
"-b, --batch_mode Use batch mode (no curses)\n"
"-t, --cpu-types TYPE[,..] CPU types used for time calculations\n"
"-b, --batch-mode Use batch mode (no curses)\n"
" --format FORMAT Output format (" FMT_TYPE_NAMES "), implies -b\n"
" --all Include omitted fields (with values of null)\n"
" in the output of --format.\n"
"-d, --delay SECONDS Delay time between screen updates\n"
"-m, --smt_factor FACTOR Machine generation dependent SMT speedup factor.\n"
"-m, --smt-factor FACTOR Machine generation dependent SMT speedup factor.\n"
"-n, --iterations NUMBER Number of iterations before ending\n";
/*
* Options with long-name only
*/
#define OPT_FORMAT 256 /* --format */
#define OPT_FORMAT_ALL 261 /* --all*/
/*
* Initialize default settings
@@ -213,7 +216,7 @@ static void l_fields_set(char *str)
}
/*
* Set the "--sort_field" option
* Set the "--sort" option
*/
static void l_sort_field_set(char *str)
{
@@ -313,6 +316,15 @@ static void l_format_set(const char *str)
g.o.format = fmt;
}
/*
* Set the "--all" option to display omitted null values
* while using "--format"
*/
static void l_format_all_set(void)
{
g.o.format_all = 1;
}
/*
* Make option consisteny checks at end of command line parsing
*/
@@ -320,6 +332,8 @@ static void l_parse_finish(void)
{
if (g.o.iterations_specified && g.o.iterations == 0)
hyptop_exit(0);
if (!g.o.format_specified && g.o.format_all)
ERR_EXIT("The --all option requires the -format option\n");
if (g.o.cur_win != &win_sys)
return;
if (!win_sys.opts.sys.specified)
@@ -339,14 +353,18 @@ void opts_parse(int argc, char *argv[])
static struct option long_options[] = {
{ "version", no_argument, NULL, 'v'},
{ "help", no_argument, NULL, 'h'},
{ "batch-mode", no_argument, NULL, 'b'},
{ "batch_mode", no_argument, NULL, 'b'},
{ "all", no_argument, NULL, OPT_FORMAT_ALL },
{ "delay", required_argument, NULL, 'd'},
{ "smt-factor", required_argument, NULL, 'm'},
{ "smt_factor", required_argument, NULL, 'm'},
{ "window", required_argument, NULL, 'w'},
{ "sys", required_argument, NULL, 's'},
{ "iterations", required_argument, NULL, 'n'},
{ "fields", required_argument, NULL, 'f'},
{ "sort_field", required_argument, NULL, 'S'},
{ "sort", required_argument, NULL, 'S'},
{ "cpu-types", required_argument, NULL, 't'},
{ "cpu_types", required_argument, NULL, 't'},
{ "format", required_argument, NULL, OPT_FORMAT },
{ NULL, 0, NULL, 0 }
@@ -396,6 +414,9 @@ void opts_parse(int argc, char *argv[])
case OPT_FORMAT:
l_format_set(optarg);
break;
case OPT_FORMAT_ALL:
l_format_all_set();
break;
default:
l_std_usage_exit();
}

View File

@@ -14,9 +14,9 @@
#include "hyptop.h"
extern void opts_parse(int argc, char *argv[]);
extern void opts_iterations_next(void);
extern int opts_sys_specified(struct hyptop_win *win, const char* sys_name);
extern void opt_verify_systems(void);
void opts_parse(int argc, char *argv[]);
void opts_iterations_next(void);
int opts_sys_specified(struct hyptop_win *win, const char *sys_name);
void opt_verify_systems(void);
#endif /* OPTS_H */

View File

@@ -19,6 +19,7 @@
#define SD_DG_INIT_INTERVAL_SEC 1
#define SD_SYS_ID_SIZE 9
#define SD_SYS_DEFAULT_ID "PHYSICAL"
/*
* CPU info
@@ -77,6 +78,7 @@ struct sd_sys {
struct util_list_node list;
struct sd_info i;
u64 update_time_us;
u64 phys_delta_us;
u32 child_cnt;
u32 child_cnt_active;
struct util_list child_list;
@@ -134,6 +136,11 @@ static inline void sd_sys_update_time_us_set(struct sd_sys *sys, u64 value)
sys->update_time_us = value;
}
static inline void sd_phys_delta_time_us_set(struct sd_sys *sys, u64 value)
{
sys->phys_delta_us = value;
}
/*
* CPU type
*/
@@ -301,8 +308,8 @@ struct sd_cpu_item {
#define sd_cpu_item_type(x) ((x)->type)
#define sd_cpu_item_table_col(item) (&(item)->table_col)
extern int sd_cpu_item_available(struct sd_cpu_item *item);
extern int sd_cpu_item_cnt(void);
int sd_cpu_item_available(struct sd_cpu_item *item);
int sd_cpu_item_cnt(void);
/*
* Item access functions
@@ -370,8 +377,8 @@ struct sd_sys_item {
#define sd_sys_item_table_col(item) (&item->table_col)
#define sd_sys_item_type(item) (item->type)
extern int sd_sys_item_available(struct sd_sys_item *item);
extern int sd_sys_item_cnt(void);
int sd_sys_item_available(struct sd_sys_item *item);
int sd_sys_item_cnt(void);
/*
* Item access functions
@@ -437,19 +444,23 @@ extern struct sd_sys_item sd_sys_item_os_name;
extern struct sd_sys_item sd_sys_item_samples_total;
extern struct sd_sys_item sd_sys_item_samples_cpu_using;
extern struct sd_sys_item sd_sys_item_phys_mgm_diff;
/*
* Data gatherer backend
*/
struct sd_dg {
void (*update_sys)(void);
struct sd_cpu_type **cpu_type_vec;
struct sd_sys_item **phys_item_vec;
struct sd_sys_item **sys_item_vec;
struct sd_sys_item **sys_item_enable_vec;
struct sd_cpu_item **cpu_item_vec;
struct sd_cpu_item **cpu_item_enable_vec;
};
void sd_dg_register(struct sd_dg *, int);
void sd_dg_register(struct sd_dg *, int, int);
int sd_dg_has_phys_data(void);
int sd_dg_has_core_data(void);
/*
@@ -461,6 +472,9 @@ int sd_dg_has_core_data(void);
#define sd_cpu_iterate(parent, cpu) \
util_list_iterate(&parent->cpu_list, cpu)
#define sd_phys_item_iterate(ptr, i) \
for (i = 0; (ptr = sd.dg->phys_item_vec[i]); i++)
#define sd_sys_item_iterate(ptr, i) \
for (i = 0; (ptr = sd.dg->sys_item_vec[i]); i++)
@@ -506,7 +520,7 @@ static inline s64 l_cpu_info_s64(struct sd_cpu_info *info,
* Misc
*/
void sd_update(void);
extern void sd_init(void);
void sd_init(void);
static inline u64 l_sub_64(u64 x, u64 y)
{

View File

@@ -26,6 +26,7 @@ static int l_cpu_type_cnt;
static int l_sys_item_cnt;
static int l_cpu_item_cnt;
static int l_has_core_data;
static int l_has_phys_data;
static struct sd_sys *l_root_sys;
/*
@@ -148,7 +149,7 @@ void sd_update(void)
/*
* Register a data gatherer
*/
void sd_dg_register(struct sd_dg *dg, int has_core_data)
void sd_dg_register(struct sd_dg *dg, int has_core_data, int has_phys_data)
{
struct timespec ts = {SD_DG_INIT_INTERVAL_SEC, 0};
struct sd_sys_item *sys_item;
@@ -156,6 +157,7 @@ void sd_dg_register(struct sd_dg *dg, int has_core_data)
unsigned int i;
l_has_core_data = has_core_data;
l_has_phys_data = has_phys_data;
sd.dg = dg;
for (i = 0; dg->cpu_type_vec[i]; i++)
dg->cpu_type_vec[i]->idx = (1UL << i);
@@ -172,6 +174,14 @@ void sd_dg_register(struct sd_dg *dg, int has_core_data)
l_cpu_types_init();
}
/*
* Does backend has physical CPUs data?
*/
int sd_dg_has_phys_data(void)
{
return l_has_phys_data;
}
/*
* Does backend has core data?
*/
@@ -419,7 +429,7 @@ int sd_cpu_item_cnt(void)
*/
void sd_init(void)
{
l_root_sys = sd_sys_new(NULL, "root");
l_root_sys = sd_sys_new(NULL, SD_SYS_DEFAULT_ID);
}
/*

View File

@@ -48,7 +48,7 @@ static double l_cpu_diff(struct sd_cpu_item *item, struct sd_cpu *cpu, int sign)
if (online_time_diff_us == 0)
return 0;
factor = ((double) online_time_diff_us) / 1000000 * cpu->cnt;
factor = util_usecs_to_secs(online_time_diff_us) * cpu->cnt;
if (sign)
diff_us = l_cpu_info_s64(cpu->d_cur, item->offset) -
l_cpu_info_s64(cpu->d_prev, item->offset);

View File

@@ -171,7 +171,7 @@ static double l_cpu_info_diff_u64(struct sd_sys_item *item, struct sd_cpu *cpu,
diff_us = l_sub_64(l_cpu_info_u64(cpu->d_cur, item->offset),
l_cpu_info_u64(cpu->d_prev, item->offset));
}
factor = ((double) online_time_diff_us) / 1000000;
factor = util_usecs_to_secs(online_time_diff_us);
diff_us /= factor;
return diff_us;
}
@@ -220,9 +220,56 @@ static u64 l_sys_smt_util(struct sd_sys_item *item, struct sd_sys *sys)
return ht_calculate_smt_util(core_us, thr_us, mgm_us, sys->threads_per_core);
}
/*
* value = (value_current - value_prev) / online_time_diff
*/
static double l_phys_cpu_info_diff_u64(struct sd_sys_item *item,
struct sd_cpu *cpu,
u64 time_diff_us)
{
double factor, diff_us;
if (!sd_cpu_type_selected(cpu->type))
return 0;
if (sd_cpu_state(cpu) == SD_CPU_STATE_STOPPED)
return 0;
if (time_diff_us == 0)
return 0;
diff_us = l_sub_64(l_cpu_info_u64(cpu->d_cur, item->offset),
l_cpu_info_u64(cpu->d_prev, item->offset));
factor = util_usecs_to_secs(time_diff_us);
diff_us /= factor;
return diff_us;
}
/*
* SUM over all CPUs: value = (value_current - value_prev) / online_time_diff
*/
static u64 l_sys_phys_cpu_info_diff_u64(struct sd_sys_item *item, struct sd_sys *sys)
{
struct sd_cpu *cpu;
u64 rc = 0;
sd_cpu_iterate(sys, cpu) {
if (!cpu->d_prev || !cpu->d_cur)
return 0;
rc += l_phys_cpu_info_diff_u64(item, cpu, sys->phys_delta_us);
}
return rc;
}
/*
* System item definitions
*/
struct sd_sys_item sd_sys_item_phys_mgm_diff = {
.table_col = TABLE_COL_TIME_DIFF_SUM(table_col_unit_perc, 'm', "mgm"),
.offset = SD_CPU_INFO_OFFSET(mgm_time_us),
.type = SD_TYPE_U64,
.desc = "Management time per second",
.fn_set = l_sys_cpu_info_set,
.fn_u64 = l_sys_phys_cpu_info_diff_u64,
};
struct sd_sys_item sd_sys_item_core_cnt = {
.table_col = TABLE_COL_CNT_SUM('#', "#core"),
.type = SD_TYPE_U32,

View File

@@ -260,6 +260,10 @@ void table_row_del_all(struct table *t)
util_list_remove(&t->row_list, row);
table_row_free(row);
}
if (t->row_physical) {
table_row_free(t->row_physical);
t->row_physical = NULL;
}
l_row_last_init(t);
t->row_cnt_marked = 0;
t->ready = 0;
@@ -418,6 +422,8 @@ static void l_row_last_calc(struct table *t)
*/
void table_finish(struct table *t)
{
if (t->row_physical)
l_row_format(t, t->row_physical);
l_row_last_calc(t);
t->ready = 1;
}
@@ -463,6 +469,8 @@ void table_rebuild(struct table *t)
l_col_max_width_init(t, col);
util_list_iterate(&t->row_list, row)
l_row_format(t, row);
if (t->row_physical)
l_row_format(t, t->row_physical);
l_row_format(t, t->row_last);
}
@@ -921,6 +929,10 @@ static void l_table_print_curses(struct table *t)
}
ht_reverse_on();
l_row_print(t, t->row_last);
if (t->row_physical) {
hyptop_print_nl();
l_row_print(t, t->row_physical);
}
hyptop_print_seek_back(0);
ht_reverse_off();
#ifdef WITH_SCROLL_BAR
@@ -952,6 +964,10 @@ static void l_table_print_all(struct table *t)
}
l_row_print(t, t->row_last);
hyptop_print_nl();
if (t->row_physical) {
l_row_print(t, t->row_physical);
hyptop_print_nl();
}
hyptop_printf("------------------------------------------------------"
"-------------------------\n");
}
@@ -972,10 +988,15 @@ static void l_row_print_formatted(struct table *t, struct table_row *row)
unsigned int flags = 0;
struct table_entry *e = &row->entries[col_nr];
if (row == t->row_last && col_nr == 0)
if (row == t->row_last && col_nr == 0) {
if (g.o.format == FMT_CSV)
util_fmt_pair(FMT_QUOTE, col->head, "SUM", e->str);
continue;
}
if (table_col_needs_quotes(col))
flags = FMT_QUOTE;
if (strcmp(e->str, "-") == 0 || strcmp(e->str, "") == 0)
flags |= FMT_INVAL;
util_fmt_pair(flags, col->head, "%s", e->str);
}
}
@@ -991,6 +1012,11 @@ static void l_table_print_all_formatted(struct table *t)
util_fmt_pair(FMT_PERSIST, "iteration", "%u", g.o.iterations_act);
ht_fmt_time();
ht_fmt_cpu_types();
if (t->row_physical) {
util_fmt_obj_start(FMT_ROW, "physical_information");
l_row_print_formatted(t, t->row_physical);
util_fmt_obj_end(); /* physical_information{} */
}
if (strcmp(g.o.cur_win->id, "sys_list") == 0)
util_fmt_obj_start(FMT_LIST, "systems");
else
@@ -1011,7 +1037,7 @@ void table_fmt_start(void)
{
if (!g.o.format_specified)
return;
if (g.o.format != FMT_JSONSEQ)
if (!util_fmt_is_json_stream(g.o.format))
util_fmt_obj_start(FMT_LIST, "hyptop");
}
@@ -1019,7 +1045,7 @@ void table_fmt_end(void)
{
if (!g.o.format_specified)
return;
if (g.o.format != FMT_JSONSEQ)
if (!util_fmt_is_json_stream(g.o.format))
util_fmt_obj_end(); /* hyptop[] */
}

View File

@@ -324,6 +324,7 @@ struct table {
struct table_col **col_vec;
struct table_col *col_selected;
struct table_row *row_last;
struct table_row *row_physical;
int row_cnt;
int row_cnt_marked;
int row_cnt_extra;
@@ -361,37 +362,37 @@ enum table_scroll_unit {
*/
extern struct table *table_new(int extra_rows, int sorted, int first_bold,
int with_units);
extern void table_reset(struct table *t);
extern void table_rebuild(struct table *t);
extern void table_finish(struct table *t);
extern void table_print(struct table *t);
extern void table_process_input(struct table *t, int c);
void table_reset(struct table *t);
void table_rebuild(struct table *t);
void table_finish(struct table *t);
void table_print(struct table *t);
void table_process_input(struct table *t, int c);
extern void table_col_unit_next(struct table *t, char hotkey);
extern void table_col_unit_prev(struct table *t, char hotkey);
extern int table_col_unit_set(struct table *t, char hotkey, const char *unit);
extern void table_col_add(struct table *t, struct table_col *col);
extern int table_col_select(struct table *t, char hotkey);
extern void table_col_select_next(struct table *t);
extern void table_col_select_prev(struct table *t);
extern void table_col_enable_toggle(struct table *t, char hotkey);
void table_col_unit_next(struct table *t, char hotkey);
void table_col_unit_prev(struct table *t, char hotkey);
int table_col_unit_set(struct table *t, char hotkey, const char *unit);
void table_col_add(struct table *t, struct table_col *col);
int table_col_select(struct table *t, char hotkey);
void table_col_select_next(struct table *t);
void table_col_select_prev(struct table *t);
void table_col_enable_toggle(struct table *t, char hotkey);
extern void table_row_del_all(struct table *t);
extern void table_row_add(struct table *t, struct table_row *row);
extern void table_row_mark(struct table *t, struct table_row *row);
extern void table_row_mark_del_all(struct table *t);
extern void table_row_mark_toggle(struct table *t, struct table_row *row);
extern void table_row_mark_toggle_by_key(struct table *t, const char *mark_key);
extern void table_row_select_down(struct table *t, enum table_scroll_unit unit);
extern void table_row_select_up(struct table *t, enum table_scroll_unit unit);
extern void table_row_select_key_get(struct table *t, char str[TABLE_STR_MAX]);
extern struct table_row *table_row_alloc(struct table *t);
void table_row_del_all(struct table *t);
void table_row_add(struct table *t, struct table_row *row);
void table_row_mark(struct table *t, struct table_row *row);
void table_row_mark_del_all(struct table *t);
void table_row_mark_toggle(struct table *t, struct table_row *row);
void table_row_mark_toggle_by_key(struct table *t, const char *mark_key);
void table_row_select_down(struct table *t, enum table_scroll_unit unit);
void table_row_select_up(struct table *t, enum table_scroll_unit unit);
void table_row_select_key_get(struct table *t, char str[TABLE_STR_MAX]);
struct table_row *table_row_alloc(struct table *t);
extern void table_scroll_down(struct table *t, enum table_scroll_unit unit);
extern void table_scroll_up(struct table *t, enum table_scroll_unit unit);
void table_scroll_down(struct table *t, enum table_scroll_unit unit);
void table_scroll_up(struct table *t, enum table_scroll_unit unit);
extern void table_fmt_start(void);
extern void table_fmt_end(void);
void table_fmt_start(void);
void table_fmt_end(void);
/*
* Entry add functions

View File

@@ -153,7 +153,7 @@ struct table_col_unit table_col_unit_us = {
*/
static int l_unit_ms(struct table_col *col, struct table_entry *e)
{
return l_unit_raw_div(col, e, 1000, L_COL_FMT_STR_2);
return l_unit_raw_div(col, e, USEC_PER_MSEC, L_COL_FMT_STR_2);
}
struct table_col_unit table_col_unit_ms = {
@@ -167,7 +167,7 @@ struct table_col_unit table_col_unit_ms = {
*/
static int l_unit_perc(struct table_col *col, struct table_entry *e)
{
return l_unit_raw_div(col, e, 10000, L_COL_FMT_STR_2);
return l_unit_raw_div(col, e, (USEC_PER_SEC / 100), L_COL_FMT_STR_2);
}
struct table_col_unit table_col_unit_perc = {
@@ -182,7 +182,7 @@ struct table_col_unit table_col_unit_perc = {
*/
static int l_unit_s(struct table_col *col, struct table_entry *e)
{
return l_unit_raw_div(col, e, 1000000, L_COL_FMT_STR_2);
return l_unit_raw_div(col, e, USEC_PER_SEC, L_COL_FMT_STR_2);
}
struct table_col_unit table_col_unit_s = {
@@ -197,7 +197,7 @@ struct table_col_unit table_col_unit_s = {
*/
static int l_unit_m(struct table_col *col, struct table_entry *e)
{
return l_unit_raw_div(col, e, 1000000 * 60, L_COL_FMT_STR_0);
return l_unit_raw_div(col, e, USEC_PER_SEC * 60, L_COL_FMT_STR_0);
}
static struct table_col_unit table_col_unit_m = {
@@ -214,7 +214,7 @@ static int l_unit_hm_u64(char *str, u64 v1, int negative)
{
u64 time_tmp, time_h, time_m;
time_tmp = v1 / (1000000 * 60);
time_tmp = v1 / (USEC_PER_SEC * 60);
time_h = time_tmp / 60;
time_m = time_tmp - time_h * 60;
@@ -259,7 +259,7 @@ static int l_unit_dhm_u64(char *str, u64 v1, int negative)
{
u64 time_tmp, time_d, time_h, time_m;
time_tmp = v1 / (1000000 * 60);
time_tmp = v1 / (USEC_PER_SEC * 60);
time_d = time_tmp / (60 * 24);
time_h = time_tmp / 60 - time_d * 24;
time_m = time_tmp - time_h * 60 - time_d * 60 * 24;
@@ -312,10 +312,8 @@ static int l_unit_vis(struct table_col *col, struct table_entry *e)
assert(col->type == TABLE_COL_TYPE_U64);
sprintf(e->str, "|");
val1_perc = e->d.u64.v1;
val1_perc /= 1000000;
val2_perc = e->d.u64.v2;
val2_perc /= 1000000;
val1_perc = util_usecs_to_secs(e->d.u64.v1);
val2_perc = util_usecs_to_secs(e->d.u64.v2);
val1_nr = (val1_perc * L_VISUAL_ROW_CNT) + 0.5;
val2_nr = (val2_perc * L_VISUAL_ROW_CNT) + 0.5;

View File

@@ -23,6 +23,6 @@ struct win_cpu_types {
struct hyptop_win *win_help;
};
extern struct hyptop_win *win_cpu_types_new(void);
struct hyptop_win *win_cpu_types_new(void);
#endif /* WIN_CPU_TYPES_H */

View File

@@ -162,6 +162,22 @@ static void l_sys_item_add(struct table_row *table_row, struct sd_sys *sys,
}
}
static void l_row_add_physical(struct table *t, struct sd_sys *sys)
{
struct sd_sys_item *item;
struct table_row *row;
unsigned int i;
row = table_row_alloc(t);
table_row_entry_str_add(row, &l_col_sys, sd_sys_id(sys));
sd_phys_item_iterate(item, i) {
if (!sd_sys_item_set(sys, item))
continue;
l_sys_item_add(row, sys, item);
}
t->row_physical = row;
}
/*
* Add system to table
*/
@@ -196,6 +212,8 @@ static void l_table_create(void)
continue;
l_sys_add(guest);
}
if (sd_dg_has_phys_data())
l_row_add_physical(l_t, parent);
table_finish(l_t);
}
@@ -324,6 +342,11 @@ static void l_run(struct hyptop_win *win)
}
}
static void win_sys_list_set_phys_table_cols(void)
{
sd_sys_item_phys_mgm_diff.table_col = sd_sys_item_mgm_diff.table_col;
}
/*
* Initialize window
*/
@@ -337,7 +360,7 @@ void win_sys_list_init(void)
int item_cnt;
/* Alloc table and add columns */
l_t = table_new(1, 1, 1, 1);
l_t = table_new(2, 1, 1, 1);
table_col_add(l_t, &l_col_sys);
item_cnt = sd_sys_item_cnt() + 1;
@@ -351,6 +374,8 @@ void win_sys_list_init(void)
col_vec[i] = col;
col_desc_vec[i] = item->desc;
}
if (sd_dg_has_phys_data())
win_sys_list_set_phys_table_cols();
/* Enable fields */
if (win_sys_list.opts.fields.specified)
l_fields_enable_cmdline();

View File

@@ -29,6 +29,7 @@
#define UNPACK_FACILITY _AC(161, U)
#ifndef __ASSEMBLER__
#include <asm/types.h>
#include <stdint.h>
/*
@@ -380,18 +381,6 @@ static __always_inline int is_zvm(void)
return cpuid.version == 0xff;
}
/* To avoid conflicts add a macro guard since __vector128 is also
* defined in 'linux/asm/types.h'.
*/
#ifndef _S390_TYPES_H
/*
* Vector register definition
*/
typedef struct {
uint32_t u[4];
} __vector128;
#endif
/*
* Save vector registers
*/

View File

@@ -379,6 +379,25 @@ int ekmf_generate_ss_cert(const struct ekmf_config *config,
const char *cert_pem_filename,
const struct ekmf_ext_lib *ext_lib, bool verbose);
/**
* Validates that a certificate has the same public key as the secure identity
* key (field identity_secure_key in config structure) .
*
* @param config the configuration structure. Only field
* identity_secure_key must be specified, all others
* are optional.
* @param x509_cert the X509 certificate object to validate
* @param ext_lib External secure key crypto library to use
* @param verbose if true, verbose messages are printed
*
* @returns a negative errno in case of an error, 0 if success.
* -EINVAL: invalid parameter, or certificate is not valid
* -ENOMEM: Failed to allocate memory
* any other errno from file I/O routines
*/
int ekmf_validate_cert(const struct ekmf_config *config, const X509 *x509_cert,
const struct ekmf_ext_lib *ext_lib, bool verbose);
/**
* Retrieves settings from the EKMFWeb server, such as the template names for
* generating keys in EKMFWeb.

View File

@@ -17,6 +17,9 @@
#include "util_list.h"
#define PCI_BDF_LEN 13 /* DDDD:BB:dd.f\0 */
#define PCI_VENDOR_ID_IBM 0x1014
enum zpci_pft {
ZPCI_PFT_UNCLASSIFIED = 0x00,
@@ -65,6 +68,9 @@ struct zpci_dev {
bool uid_is_unique;
/* Configuration state 0 - Standby, 1 Configured */
bool conf;
/* Common PCI attributes */
uint16_t subsystem_vendor;
uint16_t subsystem_device;
/* Associated netdevs if any */
int num_netdevs;
@@ -96,4 +102,6 @@ operstate_t zpci_operstate_from_str(const char *oper_str);
struct zpci_dev *zpci_find_by_netdev(struct util_list *zpci_list, char *netdev_name,
struct zpci_netdev **netdev);
char *zpci_get_nvme_device_node(const char *pci_addr);
#endif /* LIB_ZPCI_PCI_LIST_H */

View File

@@ -21,9 +21,11 @@
#define SCLP_ERRNOTIFY_AQ_DECONF 1
#define SCLP_ERRNOTIFY_AQ_REPORT_ERR 2
#define SCLP_ERRNOTIFY_AQ_OPTICS_DATA 3
#define SCLP_ERRNOTIFY_AQ_NVME_SMART_DATA 4
#define SCLP_ERRNOTIFY_ID_ZPCICTL 0x4713
#define SCLP_ERRNOTIFY_ID_OPTICSMON 0x4714
#define SCLP_ERRNOTIFY_ID_NVMEMON 0x4715
#define SCLP_ERRNOTIFY_DATA_SIZE 4054

View File

@@ -0,0 +1,14 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright IBM Corp.
*/
#ifndef LIB_UTIL_AUTOCOMP_H
#define LIB_UTIL_AUTOCOMP_H
#include "lib/util_opt.h"
void generate_autocomp(struct util_opt *opt_vec, char *tool_name);
#endif

View File

@@ -45,12 +45,13 @@
#define FMT_DEFAULT 0
/* Names of supported output format types. */
#define FMT_TYPE_NAMES "json json-seq pairs csv"
#define FMT_TYPE_NAMES "json json-seq jsonl pairs csv"
/**
* enum util_fmt_t - Output format types.
* @FMT_JSON: JavaScript Object Notation output data structure
* @FMT_JSONSEQ: Sequence of JSON data structures according to RFC7464
* @FMT_JSONL: Line-delimited JSON
* @FMT_PAIRS: Textual key=value pairs
* @FMT_CSV: Comma-separated-values output
*
@@ -59,6 +60,7 @@
enum util_fmt_t {
FMT_JSON,
FMT_JSONSEQ,
FMT_JSONL,
FMT_PAIRS,
FMT_CSV,
};
@@ -155,6 +157,16 @@ void util_fmt_exit(void);
*/
bool util_fmt_name_to_type(const char *name, enum util_fmt_t *type);
/**
* util_fmt_type_to_name() - Get name of given format type identifier.
* @type: Format type identifier
*
* Get the name corresponding to the given format type identifier.
*
* Return: name of the format type
*/
const char *util_fmt_type_to_name(enum util_fmt_t type);
/**
* util_fmt_set_indent() - Set indentation parameters.
* @base : Base indentation level to apply to all output lines (default 0)
@@ -232,4 +244,23 @@ void util_fmt_obj_end(void);
*/
void util_fmt_pair(unsigned int mflags, const char *key, const char *fmt, ...);
/**
* util_fmt_is_json() - Determine whether format is JSON.
* @type: Format type identifier.
*
* Return: %true if type is JSON, %false otherwise.
*/
bool util_fmt_is_json(enum util_fmt_t type);
/**
* util_fmt_is_json_stream() - Determine whether format is JSON stream.
* @type: Format type identifier.
*
* Determine whether a given format @type represents a JSON streaming format
* such as json-seq (@FMT_JSONSEQ) or jsonl (@FMT_JSONL).
*
* Return: %true if type is either @FMT_JSONSEQ or @FMT_JSONL, %false otherwise.
*/
bool util_fmt_is_json_stream(enum util_fmt_t type);
#endif /* LIB_UTIL_FMT_H */

View File

@@ -12,6 +12,7 @@
#ifndef LIB_UTIL_LIBC_H
#define LIB_UTIL_LIBC_H
#include <fcntl.h>
#include <stdio.h>
#ifdef __cplusplus
@@ -45,7 +46,7 @@ void *__util_zalloc(const char *func, const char *file, int line, size_t size);
/**
* Re-allocate memory or exit in case of failure
*
* @param[in] ptr Pointer ot old memory buffer
* @param[in] ptr Pointer to old memory buffer
* @param[in] size Number of bytes to be allocated
*
* @returns Pointer to memory buffer created with realloc()
@@ -124,6 +125,29 @@ do { \
va_end(ap); \
} while (0)
/**
* Reads the target of a symbolic link at the given path.
*
* @param[in] path Path to the symbolic link
* @return Newly allocated string with the link target, or NULL on error
*/
#define util_readlink(path) __util_readlinkat(__func__, __FILE__, __LINE__, AT_FDCWD, path)
/**
* Reads the target of a symbolic link relative to a directory file descriptor.
*
* Semantics:
* - If path is absolute, dirfd is ignored, per readlinkat semantics.
* - If path is relative, it is resolved relative to dirfd.
*
* @param[in] dirfd Directory file descriptor or AT_FDCWD
* @param[in] path Path to the symbolic link
* @return Newly allocated string with the link target, or NULL on error
*/
#define util_readlinkat(dirfd, path) __util_readlinkat(__func__, __FILE__, __LINE__, dirfd, path)
char *__util_readlinkat(const char *func, const char *file, int line, int dirfd, const char *path);
int __util_vsprintf(const char *func, const char *file, int line,
char *str, const char *fmt, va_list ap);
char *util_strcat_realloc(char *str1, const char *str2);

58
include/lib/util_parse.h Normal file
View File

@@ -0,0 +1,58 @@
/* SPDX-License-Identifier: MIT */
/*
* util - Utility function library
*
* String parsing utility functions
*
* Copyright IBM Corp. 2026
*/
#ifndef LIB_UTIL_PARSE_H
#define LIB_UTIL_PARSE_H
#include <stdbool.h>
#include <stddef.h>
struct util_range {
size_t start;
size_t end;
};
/*
* Parse a boolean input string into a boolean value
* Accepts: "0"/"1", "n"/"y", "no"/"yes", "f"/"t", "false"/"true", "off"/"on"
* Case-insensitive
* @param input: Input string to parse
* @return: 1 for true, 0 for false, -EINVAL for invalid input
*/
int util_parse_bool(const char *input);
/*
* Parse byte sizes with optional unit suffixes
* Supports: K/KiB, M/MiB, G/GiB, T/TiB, P/PiB, E/EiB
* K/M/G/T/P/E use 1000-based multipliers
* KiB/MiB/GiB/TiB/PiB/EiB use 1024-based multipliers
* @param input: Input string to parse
* @param bytes: Pointer to store parsed byte size
* @return: 0 on success, negative error code on failure
*/
int util_parse_byte_size(const char *input, size_t *bytes);
/*
* Parse numeric ranges in the format "start-end"
* @param input: Input string to parse (format: "start-end")
* @param range: Pointer to util_range struct to store result
* @return: 0 on success, negative error code on failure
*/
int util_parse_range(const char *input, struct util_range *range);
/*
* Parse integers with support for different bases
* Supports: decimal, hex (0x prefix), binary (0b prefix), octal (0o prefix)
* @param input: Input string to parse
* @param value: Pointer to store parsed integer value
* @return: 0 on success, negative error code on failure
*/
int util_parse_int(const char *input, size_t *value);
#endif

View File

@@ -13,5 +13,7 @@
#define LIB_UTIL_STR_H
void util_str_rm_whitespace(const char *src, char *dest);
const char *util_startswith(const char *s, const char *prefix);
const char *util_startswith_no_case(const char *s, const char *prefix);
#endif /** LIB_UTIL_STR_H @} */

View File

@@ -13,6 +13,7 @@
#define LIB_UTIL_SYS_H
#include <stdbool.h>
#include <sys/types.h>
int util_sys_get_dev_addr(const char *dev, char *addr);
bool util_sys_dev_is_partition(dev_t dev);

204
include/lib/util_time.h Normal file
View File

@@ -0,0 +1,204 @@
/*
* util_time - Time related helper functions and definitions
*
* Copyright IBM Corp. 2025
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#ifndef LIB_UTIL_TIME_H
#define LIB_UTIL_TIME_H
#define NSEC_PER_USEC 1000L
#define NSEC_PER_MSEC 1000000L
#define NSEC_PER_SEC 1000000000L
#define USEC_PER_MSEC 1000L
#define USEC_PER_SEC 1000000L
#define MSEC_PER_SEC 1000L
#define SEC_PER_DAY (24 * 60 * 60)
/**
* Convert nanoseconds to microseconds
*
* Convert value from nanoseconds to microseconds by dividing the
* value to NSEC_PER_USEC constant.
*
* @param[in] val Time value in nanoseconds
*
* @returns Time value in microseconds
*/
static inline double util_nsecs_to_usecs(double val)
{
return val / NSEC_PER_USEC;
}
/**
* Convert nanoseconds to milliseconds
*
* Convert value from nanoseconds to milliseconds by dividing the
* value to NSEC_PER_MSEC constant.
*
* @param[in] val Time value in nanoseconds
*
* @returns Time value in milliseconds
*/
static inline double util_nsecs_to_msecs(double val)
{
return val / NSEC_PER_MSEC;
}
/**
* Convert nanoseconds to seconds
*
* Convert value from nanoseconds to seconds by dividing the
* value to NSEC_PER_SEC constant.
*
* @param[in] val Time value in nanoseconds
*
* @returns Time value in seconds
*/
static inline double util_nsecs_to_secs(double val)
{
return val / NSEC_PER_SEC;
}
/**
* Convert microseconds to nanoseconds
*
* Convert value from microseconds to nanoseconds by multiplying the
* value with NSEC_PER_USEC constant.
*
* @param[in] val Time value in microseconds
*
* @returns Time value in nanoseconds
*/
static inline double util_usecs_to_nsecs(double val)
{
return val * NSEC_PER_USEC;
}
/**
* Convert microseconds to milliseconds
*
* Convert value from microseconds to milliseconds by dividing the
* value to USEC_PER_MSEC constant.
*
* @param[in] val Time value in microseconds
*
* @returns Time value in milliseconds
*/
static inline double util_usecs_to_msecs(double val)
{
return val / USEC_PER_MSEC;
}
/**
* Convert microseconds to seconds
*
* Convert value from microseconds to seconds by dividing the
* value to USEC_PER_SEC constant.
*
* @param[in] val Time value in nanoseconds
*
* @returns Time value in seconds
*/
static inline double util_usecs_to_secs(double val)
{
return val / USEC_PER_SEC;
}
/**
* Convert milliseconds to nanoseconds
*
* Convert value from milliseconds to nanoseconds by multiplying the
* value with NSEC_PER_MSEC constant.
*
* @param[in] val Time value in milliseconds
*
* @returns Time value in nanoseconds
*/
static inline double util_msecs_to_nsecs(double val)
{
return val * NSEC_PER_MSEC;
}
/**
* Convert milliseconds to microseconds
*
* Convert value from milliseconds to microseconds by multiplying the
* value with USEC_PER_MSEC constant.
*
* @param[in] val Time value in milliseconds
*
* @returns Time value in microseconds
*/
static inline double util_msecs_to_usecs(double val)
{
return val * USEC_PER_MSEC;
}
/**
* Convert milliseconds to seconds
*
* Convert value from milliseconds to seconds by dividing the
* value to MSEC_PER_SEC constant.
*
* @param[in] val Time value in milliseconds
*
* @returns Time value in seconds
*/
static inline double util_msecs_to_secs(double val)
{
return val / MSEC_PER_SEC;
}
/**
* Convert seconds to nanoseconds
*
* Convert value from seconds to nanoseconds by multiplying the
* value with NSEC_PER_SEC constant.
*
* @param[in] val Time value in seconds
*
* @returns Time value in nanoseconds
*/
static inline double util_secs_to_nsecs(double val)
{
return val * NSEC_PER_SEC;
}
/**
* Convert seconds to microseconds
*
* Convert value from seconds to microseconds by multiplying the
* value with USEC_PER_SEC constant.
*
* @param[in] val Time value in seconds
*
* @returns Time value in microseconds
*/
static inline double util_secs_to_usecs(double val)
{
return val * USEC_PER_SEC;
}
/**
* Convert seconds to milliseconds
*
* Convert value from seconds to milliseconds by multiplying the
* value with MSEC_PER_SEC constant.
*
* @param[in] val Time value in seconds
*
* @returns Time value in milliseconds
*/
static inline double util_secs_to_msecs(double val)
{
return val * MSEC_PER_SEC;
}
#endif /* LIB_UTIL_TIME_H */

View File

@@ -11,6 +11,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -44,27 +45,27 @@
typedef struct ttr
{
u_int16_t tt;
u_int8_t r;
uint16_t tt;
uint8_t r;
} __attribute__ ((packed)) ttr_t;
typedef struct cchhb
{
u_int16_t cc;
u_int16_t hh;
u_int8_t b;
uint16_t cc;
uint16_t hh;
uint8_t b;
} __attribute__ ((packed)) cchhb_t;
typedef struct cchh
{
u_int16_t cc;
u_int16_t hh;
uint16_t cc;
uint16_t hh;
} __attribute__ ((packed)) cchh_t;
typedef struct labeldate
{
u_int8_t year;
u_int16_t day;
uint8_t year;
uint16_t day;
} __attribute__ ((packed)) labeldate_t;
/*
@@ -84,7 +85,7 @@ typedef struct volume_label
char volkey[4]; /* volume key = volume label */
char vollbl[4]; /* volume label */
char volid[6]; /* volume identifier */
u_int8_t security; /* security byte */
uint8_t security; /* security byte */
cchhb_t vtoc; /* VTOC address */
char res1[5]; /* reserved */
char cisize[4]; /* CI-size for FBA,... */
@@ -118,8 +119,8 @@ static inline int is_vol1(char *this)
typedef struct extent
{
u_int8_t typeind; /* extent type indicator */
u_int8_t seqno; /* extent sequence number */
uint8_t typeind; /* extent type indicator */
uint8_t seqno; /* extent sequence number */
cchh_t llimit; /* starting point of this extent */
cchh_t ulimit; /* ending point of this extent */
} __attribute__ ((packed)) extent_t;
@@ -127,16 +128,16 @@ typedef struct extent
typedef struct dev_const
{
u_int16_t DS4DSCYL; /* number of logical cyls */
u_int16_t DS4DSTRK; /* number of tracks in a logical cylinder */
u_int16_t DS4DEVTK; /* device track length */
u_int8_t DS4DEVI; /* non-last keyed record overhead */
u_int8_t DS4DEVL; /* last keyed record overhead */
u_int8_t DS4DEVK; /* non-keyed record overhead differential */
u_int8_t DS4DEVFG; /* flag byte */
u_int16_t DS4DEVTL; /* device tolerance */
u_int8_t DS4DEVDT; /* number of DSCB's per track */
u_int8_t DS4DEVDB; /* number of directory blocks per track */
uint16_t DS4DSCYL; /* number of logical cyls */
uint16_t DS4DSTRK; /* number of tracks in a logical cylinder */
uint16_t DS4DEVTK; /* device track length */
uint8_t DS4DEVI; /* non-last keyed record overhead */
uint8_t DS4DEVL; /* last keyed record overhead */
uint8_t DS4DEVK; /* non-keyed record overhead differential */
uint8_t DS4DEVFG; /* flag byte */
uint16_t DS4DEVTL; /* device tolerance */
uint8_t DS4DEVDT; /* number of DSCB's per track */
uint8_t DS4DEVDB; /* number of directory blocks per track */
} __attribute__ ((packed)) dev_const_t;
/*
@@ -146,33 +147,33 @@ typedef struct dev_const
typedef struct format1_label
{
char DS1DSNAM[44]; /* data set name */
u_int8_t DS1FMTID; /* format identifier */
uint8_t DS1FMTID; /* format identifier */
unsigned char DS1DSSN[6];/* data set serial number */
u_int16_t DS1VOLSQ; /* volume sequence number */
uint16_t DS1VOLSQ; /* volume sequence number */
labeldate_t DS1CREDT; /* creation date: ydd */
labeldate_t DS1EXPDT; /* expiration date */
u_int8_t DS1NOEPV; /* number of extents on volume */
u_int8_t DS1NOBDB; /* no. of bytes used in last direction blk */
u_int8_t DS1FLAG1; /* flag 1 */
uint8_t DS1NOEPV; /* number of extents on volume */
uint8_t DS1NOBDB; /* no. of bytes used in last direction blk */
uint8_t DS1FLAG1; /* flag 1 */
unsigned char DS1SYSCD[13]; /* system code */
labeldate_t DS1REFD; /* date last referenced */
u_int8_t DS1SMSFG; /* system managed storage indicators */
u_int8_t DS1SCXTF; /* sec. space extension flag byte */
u_int16_t DS1SCXTV; /* secondary space extension value */
u_int8_t DS1DSRG1; /* data set organisation byte 1 */
u_int8_t DS1DSRG2; /* data set organisation byte 2 */
u_int8_t DS1RECFM; /* record format */
u_int8_t DS1OPTCD; /* option code */
u_int16_t DS1BLKL; /* block length */
u_int16_t DS1LRECL; /* record length */
u_int8_t DS1KEYL; /* key length */
u_int16_t DS1RKP; /* relative key position */
u_int8_t DS1DSIND; /* data set indicators */
u_int8_t DS1SCAL1; /* secondary allocation flag byte */
uint8_t DS1SMSFG; /* system managed storage indicators */
uint8_t DS1SCXTF; /* sec. space extension flag byte */
uint16_t DS1SCXTV; /* secondary space extension value */
uint8_t DS1DSRG1; /* data set organisation byte 1 */
uint8_t DS1DSRG2; /* data set organisation byte 2 */
uint8_t DS1RECFM; /* record format */
uint8_t DS1OPTCD; /* option code */
uint16_t DS1BLKL; /* block length */
uint16_t DS1LRECL; /* record length */
uint8_t DS1KEYL; /* key length */
uint16_t DS1RKP; /* relative key position */
uint8_t DS1DSIND; /* data set indicators */
uint8_t DS1SCAL1; /* secondary allocation flag byte */
char DS1SCAL3[3]; /* secondary allocation quantity */
ttr_t DS1LSTAR; /* last used track and block on track */
u_int16_t DS1TRBAL; /* space remaining on last used track */
u_int16_t res1; /* reserved */
uint16_t DS1TRBAL; /* space remaining on last used track */
uint16_t res1; /* reserved */
extent_t DS1EXT1; /* first extent description */
extent_t DS1EXT2; /* second extent description */
extent_t DS1EXT3; /* third extent description */
@@ -184,7 +185,7 @@ typedef struct format3_label
{
char DS3KEYID[4]; /* key identifier */
extent_t DS3EXTNT[4]; /* first 4 extent descriptions */
u_int8_t DS3FMTID; /* format identifier */
uint8_t DS3FMTID; /* format identifier */
extent_t DS3ADEXT[9]; /* last 9 extent description */
cchhb_t DS3PTRDS; /* pointer to next format3 DSCB */
} __attribute__ ((packed)) format3_label_t;
@@ -193,15 +194,15 @@ typedef struct format3_label
typedef struct format4_label
{
char DS4KEYCD[44]; /* key code for VTOC labels: 44 times 0x04 */
u_int8_t DS4IDFMT; /* format identifier */
uint8_t DS4IDFMT; /* format identifier */
cchhb_t DS4HPCHR; /* highest address of a format 1 DSCB */
u_int16_t DS4DSREC; /* number of available DSCB's */
uint16_t DS4DSREC; /* number of available DSCB's */
cchh_t DS4HCCHH; /* CCHH of next available alternate track */
u_int16_t DS4NOATK; /* number of remaining alternate tracks */
u_int8_t DS4VTOCI; /* VTOC indicators */
u_int8_t DS4NOEXT; /* number of extents in VTOC */
u_int8_t DS4SMSFG; /* system managed storage indicators */
u_int8_t DS4DEVAC; /* number of alternate cylinders.
uint16_t DS4NOATK; /* number of remaining alternate tracks */
uint8_t DS4VTOCI; /* VTOC indicators */
uint8_t DS4NOEXT; /* number of extents in VTOC */
uint8_t DS4SMSFG; /* system managed storage indicators */
uint8_t DS4DEVAC; /* number of alternate cylinders.
Subtract from first two bytes of
DS4DEVSZ to get number of usable
cylinders. can be zero. valid
@@ -214,21 +215,21 @@ typedef struct format4_label
char DS4F6PTR[5]; /* pointer to first format 6 DSCB */
extent_t DS4VTOCE; /* VTOC extent description */
char res2[10]; /* reserved */
u_int8_t DS4EFLVL; /* extended free-space management level */
uint8_t DS4EFLVL; /* extended free-space management level */
cchhb_t DS4EFPTR; /* pointer to extended free-space info */
char res3; /* reserved */
u_int32_t DS4DCYL; /* number of logical cyls */
uint32_t DS4DCYL; /* number of logical cyls */
char res4[2]; /* reserved */
u_int8_t DS4DEVF2; /* device flags */
uint8_t DS4DEVF2; /* device flags */
char res5; /* reserved */
} __attribute__ ((packed)) format4_label_t;
typedef struct ds5ext
{
u_int16_t t; /* RTA of the first track of free extent */
u_int16_t fc; /* number of whole cylinders in free ext. */
u_int8_t ft; /* number of remaining free tracks */
uint16_t t; /* RTA of the first track of free extent */
uint16_t fc; /* number of whole cylinders in free ext. */
uint8_t ft; /* number of remaining free tracks */
} __attribute__ ((packed)) ds5ext_t;
@@ -237,7 +238,7 @@ typedef struct format5_label
char DS5KEYID[4]; /* key identifier */
ds5ext_t DS5AVEXT; /* first available (free-space) extent. */
ds5ext_t DS5EXTAV[7]; /* seven available extents */
u_int8_t DS5FMTID; /* format identifier */
uint8_t DS5FMTID; /* format identifier */
ds5ext_t DS5MAVET[18]; /* eighteen available extents */
cchhb_t DS5PTRDS; /* pointer to next format5 DSCB */
} __attribute__ ((packed)) format5_label_t;
@@ -245,8 +246,8 @@ typedef struct format5_label
typedef struct ds7ext
{
u_int32_t a; /* starting RTA value */
u_int32_t b; /* ending RTA value + 1 */
uint32_t a; /* starting RTA value */
uint32_t b; /* ending RTA value + 1 */
} __attribute__ ((packed)) ds7ext_t;
@@ -254,7 +255,7 @@ typedef struct format7_label
{
char DS7KEYID[4]; /* key identifier */
ds7ext_t DS7EXTNT[5]; /* space for 5 extent descriptions */
u_int8_t DS7FMTID; /* format identifier */
uint8_t DS7FMTID; /* format identifier */
ds7ext_t DS7ADEXT[11]; /* space for 11 extent descriptions */
char res1[2]; /* reserved */
cchhb_t DS7PTRDS; /* pointer to next FMT7 DSCB */
@@ -263,12 +264,12 @@ typedef struct format7_label
typedef struct format9_label
{
u_int8_t DS9KEYID; /* key code for format 9 labels (0x09) */
u_int8_t DS9SUBTY; /* subtype (0x01) */
u_int8_t DS9NUMF9; /* number of F9 datasets */
u_int8_t res1[41]; /* reserved */
u_int8_t DS9FMTID; /* format identifier */
u_int8_t res2[90]; /* reserved */
uint8_t DS9KEYID; /* key code for format 9 labels (0x09) */
uint8_t DS9SUBTY; /* subtype (0x01) */
uint8_t DS9NUMF9; /* number of F9 datasets */
uint8_t res1[41]; /* reserved */
uint8_t DS9FMTID; /* format identifier */
uint8_t res2[90]; /* reserved */
cchhb_t DS9PTRDS; /* pointer to next DSCB */
} __attribute__ ((packed)) format9_label_t;
@@ -276,31 +277,31 @@ char * vtoc_ebcdic_enc (char *source, char *target, int l);
char * vtoc_ebcdic_dec (char *source, char *target, int l);
void vtoc_set_extent (
extent_t * ext,
u_int8_t typeind,
u_int8_t seqno,
uint8_t typeind,
uint8_t seqno,
cchh_t * lower,
cchh_t * upper);
void vtoc_set_cchh (
cchh_t * addr,
u_int32_t cc,
u_int16_t hh);
u_int32_t vtoc_get_cyl_from_cchh(cchh_t *addr);
u_int16_t vtoc_get_head_from_cchh(cchh_t *addr);
uint32_t cc,
uint16_t hh);
uint32_t vtoc_get_cyl_from_cchh(cchh_t *addr);
uint16_t vtoc_get_head_from_cchh(cchh_t *addr);
void vtoc_set_cchhb (
cchhb_t * addr,
u_int32_t cc,
u_int16_t hh,
u_int8_t b);
u_int32_t vtoc_get_cyl_from_cchhb(cchhb_t *addr);
u_int16_t vtoc_get_head_from_cchhb(cchhb_t *addr);
u_int64_t cchhb2blk(cchhb_t *p, struct hd_geometry *geo);
u_int64_t cchh2blk (cchh_t *p, struct hd_geometry *geo);
u_int32_t cchh2trk (cchh_t *p, struct hd_geometry *geo);
uint32_t cc,
uint16_t hh,
uint8_t b);
uint32_t vtoc_get_cyl_from_cchhb(cchhb_t *addr);
uint16_t vtoc_get_head_from_cchhb(cchhb_t *addr);
uint64_t cchhb2blk(cchhb_t *p, struct hd_geometry *geo);
uint64_t cchh2blk (cchh_t *p, struct hd_geometry *geo);
uint32_t cchh2trk (cchh_t *p, struct hd_geometry *geo);
void vtoc_set_date (
labeldate_t * d,
u_int8_t year,
u_int16_t day);
uint8_t year,
uint16_t day);
void vtoc_volume_label_init (
volume_label_t *vlabel);
@@ -365,12 +366,12 @@ void vtoc_init_format4_label (
unsigned int tracks,
unsigned int blocks,
unsigned int blksize,
u_int16_t dev_type);
uint16_t dev_type);
void vtoc_update_format4_label (
format4_label_t *f4,
cchhb_t *highest_f1,
u_int16_t unused_update);
uint16_t unused_update);
void vtoc_init_format5_label (
format5_label_t *f5);
@@ -379,17 +380,17 @@ void vtoc_update_format5_label_add (
format5_label_t *f5,
int verbose,
int trk,
u_int16_t a,
u_int16_t b,
u_int8_t c);
uint16_t a,
uint16_t b,
uint8_t c);
void vtoc_update_format5_label_del (
format5_label_t *f5,
int verbose,
int trk,
u_int16_t a,
u_int16_t b,
u_int8_t c);
uint16_t a,
uint16_t b,
uint8_t c);
void vtoc_init_format7_label (
format7_label_t *f7);
@@ -397,14 +398,14 @@ void vtoc_init_format7_label (
void vtoc_update_format7_label_add (
format7_label_t *f7,
int verbose,
u_int32_t a,
u_int32_t b);
uint32_t a,
uint32_t b);
void vtoc_update_format7_label_del (
format7_label_t *f7,
int verbose,
u_int32_t a,
u_int32_t b);
uint32_t a,
uint32_t b);
void vtoc_init_format8_label (
unsigned int blksize,
@@ -424,9 +425,9 @@ void vtoc_set_freespace(
format7_label_t *f7,
char ch,
int verbose,
u_int32_t start,
u_int32_t stop,
u_int32_t cyl,
u_int32_t trk);
uint32_t start,
uint32_t stop,
uint32_t cyl,
uint32_t trk);
#endif /* LIB_VTOC_H */

View File

@@ -64,6 +64,7 @@
#define TOOLS_BINDIR STRINGIFY (S390_TOOLS_BINDIR)
#define TOOLS_DATADIR STRINGIFY (S390_TOOLS_DATADIR)
#define __used __attribute__((used))
#define __noreturn __attribute__((noreturn))
#define __packed __attribute__((packed))
#define __aligned(x) __attribute__((aligned(x)))
@@ -71,6 +72,11 @@
#define __section(x) __attribute__((__section__(#x)))
#define __noinline __attribute__((__noinline__))
#define __big_endian
#ifdef __CHECKER__
# define __force __attribute__((force))
#else
# define __force
#endif
/* The Linux kernel (in stddef.h) and glibc (sys/cdefs.h) define
* __always_inline. Therefore undefine it first to allow the headers
* to be included first.
@@ -101,6 +107,9 @@
_x > _y ? _x : _y; \
})
#ifdef __SIZEOF_INT128__
typedef unsigned __int128 u128 __aligned(16);
#endif
typedef unsigned long long u64;
typedef signed long long s64;
typedef unsigned int u32;

View File

@@ -26,7 +26,7 @@
#define BOOTPARMS_NSS_MAX 56
#define BOOTPARMS_CCW_MAX 64
#define BOOTPARMS_FCP_MAX 3452
#define BOOTPARMS_SCPDATA_MAX 3452
#define OPT_BRCHR 0x80
@@ -835,6 +835,12 @@ static void chreipl_eckd(void)
ERR_EXIT("Could not find DASD ECKD device \"%s\"", l.busid);
}
check_exists("reipl/eckd/device", "\"eckd\" re-IPL target");
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_SCPDATA_MAX) {
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
strlen(l.bootparms), BOOTPARMS_SCPDATA_MAX);
}
if (l.reipl_clear >= 0) {
check_exists("reipl/eckd/clear", "ECKD re-IPL clear attribute");
write_str(l.reipl_clear ? "1" : "0", "reipl/eckd/clear");
@@ -848,6 +854,8 @@ static void chreipl_eckd(void)
write_str(l.bootprog, "reipl/eckd/bootprog");
write_str(l.busid, "reipl/eckd/device");
write_str_optional(l.loadparm, "reipl/eckd/loadparm", l.loadparm_set, "loadparm");
write_str_optional(l.bootparms, "reipl/eckd/scp_data", l.bootparms_set,
"boot parameters");
write_str("eckd", "reipl/reipl_type");
print_eckd(0, "eckd");
}
@@ -862,9 +870,9 @@ static void chreipl_fcp(void)
ERR_EXIT("Could not find FCP device \"%s\"", l.busid);
}
check_exists("reipl/fcp/device", "\"fcp\" re-IPL target");
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_FCP_MAX) {
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_SCPDATA_MAX) {
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
strlen(l.bootparms), BOOTPARMS_FCP_MAX);
strlen(l.bootparms), BOOTPARMS_SCPDATA_MAX);
}
if (l.reipl_clear >= 0) {
@@ -905,9 +913,9 @@ static void chreipl_nvme(void)
}
check_exists("reipl/nvme/fid", "\"nvme\" re-IPL target");
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_FCP_MAX) {
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_SCPDATA_MAX) {
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
strlen(l.bootparms), BOOTPARMS_FCP_MAX);
strlen(l.bootparms), BOOTPARMS_SCPDATA_MAX);
}
if (l.reipl_clear >= 0) {

View File

@@ -157,6 +157,7 @@ void print_eckd(int show_ipl, const char *name)
{
char *dir = show_ipl ? "ipl" : "reipl/eckd";
char *path_loadparm = util_path_sysfs("firmware/%s/loadparm", dir);
char *path_reipl_clear = util_path_sysfs("firmware/reipl/eckd/clear");
char *path_secure_boot = util_path_sysfs("firmware/ipl/secure");
char *loadparm;
@@ -172,7 +173,7 @@ void print_eckd(int show_ipl, const char *name)
printf("Loadparm: \"%s\"\n", loadparm);
free(loadparm);
}
if (!show_ipl)
if (!show_ipl && access(path_reipl_clear, R_OK) == 0)
print_fw_str("clear: %s\n", dir, "clear");
if (access(path_secure_boot, R_OK) == 0)
print_fw_str("Secure boot: %s\n", "ipl", "secure");

View File

@@ -11,6 +11,7 @@
#include <sys/types.h>
#include <dirent.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
@@ -99,7 +100,7 @@ static int next_entry(DIR *dir, char *in_path, char *out_path,
static int nvme_getdev_by_fid(char *fidstr, char *devpath)
{
char temp_path[PATH_MAX + 19], real_path[PATH_MAX];
u_int64_t target_fid, curfid;
uint64_t target_fid, curfid;
char *sys_path;
DIR *dir;
char *end;
@@ -140,7 +141,7 @@ static int nvme_getdev_by_nsid(char *nsid_str, char *path, char *dev_path)
{
char full_path[NVME_PATH_MAX+1], nsid_path[sizeof(full_path)+5];
char *end;
u_int64_t nsid, curnsid;
uint64_t nsid, curnsid;
DIR *dir;
nsid = strtoul(nsid_str, &end, 10);

Some files were not shown because too many files have changed in this diff Show More