Compare commits

..

265 Commits

Author SHA1 Message Date
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
Jörn Siglen
940ce67900 New release s390-tools-2.39.0
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 10:32:38 +02:00
Peter Oberparleiter
c12faf0128 zdev/dracut: Prevent loading of unused kernel modules
zdev provides dracut logic for configuring devices early during boot via
kernel command line parameters rd.dasd and rd.zfcp. A copy of resulting
configuration directives is made available to the booted Linux using
chzdev's export function.

The use of command line option --all in this export step results in
chzdev loading all kernel modules required by supported types, even if
no device of that type exists on the booted system, or if no zdev kernel
parameter was specified.

Loading unused kernel modules during boot increases memory usage,
prolongs boot time, and expands the kernel's attack surface
unnecessarily.

Fix this by replacing command line option --all with --configured to
instruct chzdev to export only data for devices with a persistent
configuration, while not loading any kernel modules.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:57:06 +02:00
Shalini Chellathurai Saroja
a3d50487ed systemd: Suppress cpi service error message on SEL guests
On SEL guests, the default configuration does not permit the
Control-Program Identifiation (CPI) data to be sent by the cpi
service, resulting in a failure message in systemctl/log output
on start of the cpi service.

This is not a failure because it is expected behavior and the
cpi service is a one-shot service whose function is already
performed when the exit code is returned. Prevent the error log
by filtering the associated exit code in systemd.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:57:06 +02:00
Shalini Chellathurai Saroja
b1d8e40bfe scripts/cpictl: Modify name of the exit code 6
Modify the symbolic name of the exit code 6 to
EXIT_NOTCONFIGURED, which is according to the Linux Standard Base
(LSB) specification.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Suggested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:57:06 +02:00
Steffen Eiden
8d3949f77b rust: Cargo.lock Update crate dependencies
cargo update -p openssl -p curl -p usafe-libyaml

By default users of the libs will use the version tagged in the
lockfile. Let make things easier for them and update the lock entries
with versins that have some CVEs fixed.

Note that this does not affect code shipped by distros as they ignore the
lockfile.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:57:06 +02:00
Jan Polensky
2f49025d49 cpumf/man: Unify parameter case
Normalize parameter casing in man pages to improve consistency.

Reviewed-by:  Thomas Richter <tmricht@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>
2025-10-14 09:57:06 +02:00
Jan Polensky
4c9ceeeb64 cpumf/lshwc: Add command line flag to specify individual counters
Add command-line option --counters "AAA,BBB,...,ZZZ" to specify a
comma-separated list of counter names to display. Counter names must
match exactly, ignoring case. All counters not listed are excluded
from output.

Reviewed-by:  Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:57:06 +02:00
Jan Polensky
3a0c394fa2 libcpumf: Relocate ctr_in_list() for shared use
Move ctr_in_list() from cpumf/lspai.c to a shared location to enable
reuse in other binaries that require counter list filtering.

Reviewed-by:  Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:57:06 +02:00
Richie Buturla
20a4ebd83c zipl/boot: Fix undefined behaviour logic in menu
The code within 'menu_param()' previously assumed that a read from sclp
will never fail.

If 'sclp_param()' fails then 'endptr' is never initialised and
'loadparm' is compared with 'endptr' which is undefined behvaiour.

If a sclp read fails, an undefined 'endptr' is never accessed, and upon
a failed read, will return a new error code 'SCLP_ERROR' instead of
returning 'NUMBER_FOUND' which is incorrect logic wise.

Remove compare conditions and assignments of 0 in 'value', as 'value'
is initialised with 0 ('DEFAULT_MENU_ENTRY') and cannot be non zero,
only in the case where a number is found and we go to boot.

Logic:

Check if we got a number and boot from it.

If 'PRINT_PROMPT', break out to menu print logic.

If an 'SCLP_ERROR' occurs, print an error message and boot the default
since 'value' is initialised with 'DEFAULT_MENU_ENTRY'.

If 'NOTHING_FOUND', check if the menu is disabled. If disabled, go to
default boot. Otherwise break out to print logic.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Richie Buturla <richie@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:57:06 +02:00
Richie Buturla
4a9f66fc31 zipl/boot: Change error codes to enums
Change error codes returned from menu_param to enums.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Richie Buturla <richie@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:57:06 +02:00
Jan Polensky
35d68b2101 dasdinfo: Fix memory leak by freeing readbuf
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-10-14 09:57:06 +02:00
Jan Polensky
522c67a2c3 dasdinfo: Fix format-overflow warning
Use snprintf() instead of sprintf() to avoid buffer overflow.
Also change the integer type from signed to unsigned.

Error:
	dasdinfo.c: In function 'dinfo_create_devnode':
	dasdinfo.c:297:52: warning: '%04d' directive writing between 4 and 11
	bytes into a region of size 5 [-Wformat-overflow=]
	  297 |                         sprintf(filename, "dasdinfo%04d", retry);
	      |                                                    ^~~~

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-10-14 09:57:06 +02:00
Jan Polensky
f4ee6c2c8d dasdinfo: Remove unused util_base.h include
The util_base.h header is no longer required in dasdinfo.c and can be
safely removed to reduce unnecessary dependencies.

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-10-14 09:57:06 +02:00
Jan Polensky
377f2a59f5 dasdinfo: Replace hardcoded /sys with util_path_sysfs()
The sysfs path is now constructed dynamically in an allocated buffer to
avoid potential buffer overflows. The default is '/sys', until the
SYSFS_ROOT environment variable is defined.

These modifications significantly improve testability by allowing sysfs
read and write operations to be redirected to an alternative file path,
which enables testing without affecting the active system state.

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-10-14 09:57:06 +02:00
Jan Polensky
176f0405b8 .pre-commit-config.yaml: Add check-yaml, check-json and check-toml hooks
These hooks validate syntax of YAML, JSON and TOML files using
pre-commit-hooks.

Link: https://github.com/pre-commit/pre-commit-hooks
Reviewed-by: Marc Hartmayer <mhartmay@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>
2025-10-14 09:56:50 +02:00
Jan Polensky
839d34e758 .pre-commit-config.yaml: Bump pre-commit-hooks
Command:

	$ pre-commit autoupdate

Reviewed-by: Marc Hartmayer <mhartmay@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>
2025-10-14 09:39:15 +02:00
Jan Polensky
a68d1e323b libccw/ccw.c: Include strings.h instead of string.h
Including string.h is incorrect as it doesn't provide the required
function prototype for strncasecmp() used in this file. Note that
the missing function prototype doesn't cause a compilation error
at the moment as the declaration is provided indirectly.

Use strings.h to provide the declaration for strncasecmp() directly,
avoiding unnecessary include dependencies and improving clarity.

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-10-14 09:39:15 +02:00
Jan Polensky
549c7ef9e7 zkey/kms.c: Use correct variable in warnx()
The variable filename was freed inside the loop and then incorrectly
used in the subsequent warnx() call. Replacing it with directory
reflects the indented context and avoids use after free.

Fixes: f25aaf32b8 ("zkey: Add support for key management system plugins")
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Jan Polensky
103c9444c9 zkey/kms.c: Fix typos
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
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>
2025-10-14 09:39:15 +02:00
Jan Polensky
fe7bef3f09 cpumf/pai.c: Fix memory use after free
Preventing a race condition by freeing the pmuname variable only after
its last usage.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Jan Polensky
8a88ada9c5 dasdinfo/dasdinfo.c: Fix string termination
Use correct buffer and index to terminate string returned by readlink().

Reviewed-by: Juergen Christ <jchrist@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Jan Polensky
538bc7b4e8 dasdinfo/dasdinfo.c: Replace buffer size magic number with anonymous enum
Use a local anonymous enum to define the buffer size constant, replacing
the hardcoded magic number and improving readability.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Juergen Christ <jchrist@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Jan Polensky
b56451e5a4 cpumf/lspai.c: Use util_str_toupper() instead of str2uc()
Replace the custom str2uc() implementation with util_str_toupper() to
reduce code duplication and improve maintainability.

Acked-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Thomas Richter
63f9a672d0 cpumf/lspai: Add command line flag to specify individual counters
Add command line option --counters XXX,YYY to specify a comma
separated list of counter names to be displayed. The counter names
have to match exactly beside case sensitivity.
All counters not listed in the list specified by the --counters option
are not shown.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Co-developed-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Thomas Richter
2c5c5ef4b4 cpumf/lspai: Add command line flags for all cpus
Add a command line flag '-a' to include the counter set values
from each individual CPU. Up to now only the total sum from
all CPUs was printed.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Thomas Richter
5a3ffc2036 cpumf/lspai: Add command line flag for delta values
Add command line flag -d to display the counter value in form of
a delta value. This format shows the increase of that counter value
compared to the previous value.
The first line is the base for the delta calculation and always
shows 'Total'. The remaining lines show 'Delta' in the third
column.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Thomas Richter
e576443859 cpumf/lspai: Add command line flag for short counter names
Add command line flag -s to display the counter name in an
abbreviated form. The abbreviated form is a character for the
PAI counter set followed by a number.
PAI crypto counter set is abbreviated to 'C'.
PAI NNPA counter set is abbreviated to 'N'.
The number refers to the defined counter number ranging from
1 to X.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Thomas Richter
43067df78e cpumf/lspai: Add command line flags for hexadecimal output
Add command line flags -x and -X to print counter values in
hexadecimal format with leading 0x prefix (-X) and without (-x).

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Jan Polensky
973059438f cpumf/lspai: Show counter values
Add command line flags -i (read interval) and -l (loops) to
show the counter values for the specified number of iterations.
The CPUs to read the counter values from can be specified
on the command line. If none are specified, all online CPUs
are used.

For example the command '# lspai -l 2 -i 10 -t nnpa'
displays all PAI NNPA counter values two times with 10 second
interval.

Acked-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.ibm.com>
Co-developed-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Jan Polensky
9d3567d9ce libutil/util_libc.c: Move remove_whitespace() to util_str_rm_whitespace()
Relocate remove_whitespace() from zdsfs to libutil/util_str.c, renaming
it to util_str_rm_whitespace() to make the helper available
project-wide.

Acked-by: Thomas Richter <tmricht@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>
2025-10-14 09:39:15 +02:00
Jan Polensky
7687b0fcda cpumf/lspai: Fix whitespace alignment
Acked-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Jan Polensky
6f70f34b79 cpumf/lspai: Rename show_format() -> format_painode()
Renamed the function show_format() to format_painode() to better reflect
its purpose.

Acked-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:15 +02:00
Jan Polensky
37aed81745 cpumf/lspai: Rename show_painode() -> list_painode()
Renamed the function show_painode() to list_painode() to better reflect
its purpose.

Acked-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:14 +02:00
Jan Polensky
5aa1824eef libcpumf: Move perf_event_open to reduce code duplication
Relocated the perf_event_open logic into a shared helper to eliminate
redundant implementations across multiple files. Enhances consistency,
reduces maintenance overhead, and lowers structural complexity.

Acked-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:14 +02:00
Jan Polensky
82603e589a libcpumf: Fix typo
Acked-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:14 +02:00
Jan Polensky
3ba897a1be cpumf/lscpumf.c: Fix typos
Acked-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:14 +02:00
Alexander Egorenkov
fa92a7f7c9 README.md: Update dependencies for zipl
Update Dependencies section for zipl with the information of
required tools/packages for stand-alone NVMe and list-directed DASD
dump.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Jan Höppner <hoeppner@linux.ibm.com>
Acked-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-10-14 09:39:14 +02:00
Thomas Huth
f569849e57 zipl/boot: Fix EBCDIC code page 500 conversion and decrease size by 200 bytes
The tables ebcdic_037 and ebcdic_500 are currently exactly the same, though
the 500 should differ at 7 entries (see the tables in the Linux kernel or
https://www.ibm.com/docs/en/db2-for-zos/12.0.0?topic=ebcdic-code-point-differences-between-ccsids
for example). Fix it by removing the ebcdic_500 table and by patching
the other table during start() if necessary. That way we can safe also
about 200 bytes in the stage3.bin binary.

Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/125
Closes: https://github.com/ibm-s390-linux/s390-tools/pull/190
Suggested-by: Euan Bourke <euan@linux.ibm.com>
Tested-by: Euan Bourke <euan@linux.ibm.com>
Reviewed-by: Euan Bourke <euan@linux.ibm.com>
Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:33 +02:00
Ingo Franzki
458c27a0e1 zkey-ekmfweb: Fix a potential compile error
Fix a potential compile error when symbol
EKMF_SUPPORTS_RSA_PSS_CERTIFICATES is defined. With this symbol support
for RSA-PSS can be enabled for the EKMFWeb plugin. Currently this symbol
is never defined.

Fixes: c570f51f5f ("zkey-ekmfweb: Generate certificate or CSR with identity key")
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:33 +02:00
Ingo Franzki
e4dcf084c5 libekmfweb: Fix generation of certificate or CSR with RSA-PSS instead of RSA
Currently a certificate or certificate signing request generated by the
zkey EKMFWeb library erroneously always uses RSA-PSS as signing algorithm,
although EKMFWeb does not support RSA-PSS certificates in all versions.

This bug was introduced with the rework to use libseckey for secure
key crypto operations.

Fixes: 26c34a49b1 ("libekmfweb: Make use of the new libseckey")
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:33 +02:00
Richie Buturla
bed1bc8676 zipl/boot/stage3.c: Fix [-Wnull-dereference] warning
Fix 'volatile' qualifier warning,
indirection of non-volatile null pointer will be deleted, not trap.

Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Acked-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Richie Buturla <richie@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:33 +02:00
Richie Buturla
8e315c4401 zipl/src/scan.c: Fix [-Wparentheses] warning
Fix warning of redundant parentheses.

Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Richie Buturla <richie@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Marc Hartmayer
ae8fa4371f pvimg: Update manpage
This update adds documentation for the new CLI option '--image-key',
updates the '--cck' description, and escapes dashes.

Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Marc Hartmayer
29ff9408e0 rust/pvimg: Add support for '--image-key'
Add support for '--image-key'. This new option can be used to select the
components encryption key (e.g. kernel, initrd, and kernel command
line). Previously, this was only available as an experimental
option ('--x-comp-key').

Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Marc Hartmayer
a24be25779 pvimg: Add CLI tests for '--x-comp-key'
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Marc Hartmayer
58337d7f90 rust/pvimg: Refactor keys arguments into own struct
This makes it easier to add new user keys related CLI options.

Acked-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Marc Hartmayer
fcaad5a8e2 pvimg: Improve phrasing of '--cck' option documentation
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Ingo Franzki
4d598ade86 zkey: Add support for generating and importing exportable secure keys
Normally, secure keys generated by zkey are intentionally export
restricted. Export restricted keys can not be wrapped with a key
encrypting key (KEK).

However, keys that are generated inside a Secure Execution for Linux
guest that shall also be used outside of the Secure Execution for Linux
guest can only be transported to outside the Secure Execution for Linux
guest by wrapping them with a KEK and unwrapping them outside of the
Secure Execution for Linux guest. For that such keys must be exportable.

Add an option to generate and import exportable secure keys, which then
can be wrapped, and thus transported to outside of a Secure Execution for
Linux guest.

This applies to keys of type 'CCA-AESCIPHER' and 'EP11-AES'. Keys of type
'CCA-AESDATA' are always exportable, and can not be export restricted.

For keys of type 'EP11-AES' additionally allow to set the
'wrap-with-trusted' attribute. This restricts the key so that it only can
be wrapped with a trusted key encrypting key.

For keys of type 'EP11-AES' to be exportable, the access control point
(ACP) XCP_CPB_ALLOW_COMBINED_EXTRACT must be 'ON' on all APQNs used. This
access control point is only supported on newer EP11 firmware levels. If
the access control point is 'OFF' or not supported by the EP11 firmware,
then the IOCTL to generate the key fails with a generic error
(Input/output error - EIO). The zkey tool prints an appropriate error
message in that case.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Ingo Franzki
b455ee9a31 zkey: Fix typo in error message
Fixes: bb6a47db55 ("Add KMS support for 'zkey generate' command")
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Vineeth Vijayan
82b9328e48 zdev: Fix double device configuration with rd.dasd
While parsing the rd.dasd kernel parameter, the dracut module
currently creates two separate udev rules for a single DASD — one
for ECKD type and one for FBA type. Because the kernel parameter
alone does not provide enough information to reliably determine the
DASD type, this dual configuration can lead to inconsistencies.

Update the logic to determine the DASD type dynamically by parsing
the modalias of available devices. If a device is not present during
boot, both udev rules will be generated.

Also add --no-module-load to the chzdev functions, because during this
time, we do not want chzdev to load the dasd module. The goal here is
to generate the right udev-rules only.

Suggested-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Vineeth Vijayan
f45a45c38c zdev: Fix double device configuration on DPM systems
During autoconfig, DPM systems currently configures DASD devices twice:
once for dasd-eckd and once for dasd-fba. Because the firmware
configuration file does not provide the DASD type, this can lead
to inconsistent and redundant configurations.

For example, lszdev may show two devices with the same ID:

    TYPE       ID        ON   PERS  NAMES
    dasd-eckd  0.0.f001  yes  auto  dasda
    dasd-fba   0.0.f001  no   auto

However, only dasd-eckd is actually present on the machine, and
the dasd-fba entry is incorrect.

Modify this configuration logic to determine the DASD type dynamically
by parsing the modalias for each device-ID, and configures only the
correct dasd-type. The resulting lszdev output accurately reflects
the actual DASD devices present.

Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Vineeth Vijayan
d1bf9e68c6 zdev: Introduce --no-module-load option for chzdev
When called with a device parameter, chzdev tries to load the kernel
module of the corresponding device type. This might not be desired in
certain situations like early initial RAM-disk processing.

To support this use cases, add a new command-line option
--no-module-load to prevent the loading of any kernel module by chzdev.

Suggested-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Vineeth Vijayan
0356d78bc2 zdev: Allow dynamic control of module load
module_load_suppress() currently ignores the state parameter. Modify
it to respect the state parameter, so that the module load suppress
can be both enabled or disabled.

Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Marc Hartmayer
a4f48415a0 zipl/boot: Fix typo found by codespell
Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Marc Hartmayer
c9f0e3accf zipl/boot: menu: Reset the buffer before doing a retry
The 'temp_area' buffer was not zeroed out for a retry in case of an
invalid input to select a boot menu entry.

Before:

  zIPL v2.38.0-build-20250822 interactive boot menu

   0. default (1TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

   1. 1TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
   2. 2TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
   3. 3TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
  Note: VM users please use '#cp vi vmsg <input>'

  Please choose (default will boot in 3 seconds):111
  Error: undefined configuration

  Please choose:1
  Error: undefined configuration

After:

  zIPL v2.38.0-build-20250822 interactive boot menu

   0. default (1TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

   1. 1TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
   2. 2TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
   3. 3TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...
  Note: VM users please use '#cp vi vmsg <input>'

  Please choose (default will boot in 3 seconds):111
  Error: undefined configuration

  Please choose:1
  Booting 1TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT...

Acked-by: Eduard Shishkin <edward6@linux.ibm.com>
Acked-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Marc Hartmayer
9dd432ca94 zipl/boot: Remove useless cast
'temp_area' is already a 'char *' no reason to cast it to 'char *'.

Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Acked-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-09-15 11:47:32 +02:00
Eduard Shishkin
179bc57cdf zipl/src: Use a matrix of component ranges instead of an array
Fix a design mistake leading to IPL programs corruption.
Use a matrix of component ranges to locate the added components in the
body of bootmap file instead of an array.
Earlier an array of NR_PROGRAM_COMPONENTS was used, which is incorrect
Now a matrix of (NR_PROGRAM_COMPONENTS X BOOT_MENU_ENTRIES) is used.

Don't duplicate environment block for each menu entry. Instead, reuse
the one that was added when processing the first menu entry.

Tested-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reported-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:32 +02:00
Finn Callies
e1d1c6df9c rust-utils: remove unused renameat2 rust wrapper
Remove the unused rust wrapper function renameat2 which calls renameat2
from linux' libc implementation.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:47:29 +02:00
Finn Callies
e894fb61d8 rust-utils: use exists/rename instead of renameat2
Use exists and rename instead of renameat2 which is only available in the
linux implementation of libc. To enable compilation of pvsecret on macos
the rust wrapper function renameat2 which calls the libc renameat2 function
is replaced with rust native std::fs::exists ad std::fs::rename functions
because macos' implementation of libc does not have the renameat2 function.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:41:00 +02:00
Finn Callies
c3a84109b7 rust-utils: add PartialEq for AtomicFileOperation
Derive PartialEq for the AtomicFileOperation enum to allow comparison with
== operator.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:16 +02:00
Eduard Shishkin
1ca5f63dee zipl/src: Use generic infrastructure when adding environment block
Apply previously introduced generic infrastructure to add an
environment block as a "buffer component".


Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:16 +02:00
Eduard Shishkin
60bc1e38d0 zipl/src: Reuse data of buffer components in bootmap
Don't duplicate data of components added via add_component_buffer()
and friends to bootmap file. Instead, reuse data that were previously
added when preparing a program table for the first mirror to create
metadata (block lists, program tables, etc) specific for other mirrors.


Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:16 +02:00
Eduard Shishkin
431e4542ca zipl/src: Reuse data of file components in bootmap
If the option '--add-files' is specified, don't duplicate data of
components added via add_component_file() and friends to bootmap
file for each mirror. Instead, reuse the data that were added when
preparing a program table for the first mirror to create metadata
(block lists, program tables, etc) specific for other mirrors.


Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:16 +02:00
Eduard Shishkin
731f00202c zipl/src: Enable heterogeneous mirrors support
Drop limitations on identical target parameters of base disks per
logical device;

Fix verbose zipl output to include geometry of each mirror and
component load addresses that would be used when booting from each
mirror.


Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:16 +02:00
Eduard Shishkin
2945593991 zipl/src: Support (create/boot-with) different program tables per target
Replace struct install_set with a new type containing multiple
program tables and program components. Refactor the code accordingly.

When retrieving device INFO, for each mirror complete a respective
structure disk_info in the INFO.BASE array.

When building a bootmap, for each mirror create a separate program
table (or a pair of tables in case of DASD - for CCW-TYPE IPL and
for LD-IPL), using respective components in the arrays INFO.BASE and
BIS.MIRRORS

Make data of program components added via get_component_buffer() and
get_component_file() be duplicated per each mirror.

Make boot record on each mirror point out to a respective program
table in the bootmap (when booting from different mirrors, different
program tables in the bootmap are used).

This patch doesn't make functional changes. However, test cases
comparing boot meta-data dumps of different mirrors may fail (since
boot records on different mirrors now refer different copies of boot
data). This will be fixed by the next patches in the series which
allow boot data to be reused.


Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:15 +02:00
Eduard Shishkin
f375327085 zipl/src: Support multiple disk_info structures per logical device
Replace struct disk_info with new 2 types.

Old type:

struct disk_info {
  A; /* logical device info */
  B; /* basedisk info */
};

New types:

struct disk_info {
  B; /* basedisk info */
};

and

struct device_info {
  A; /* logical device info */
  struct disk_info C [MAX_TARGETS]; /* array of base disks */
};

Here A (logical device info) is the following:

dev_t device;     /* logical device for bootmap creation */
char *name;       /* name of logical device as reetrieved from
                     "/proc/partitions" */
char *drv_name;   /* name of the driver managing the logical
                     device  as retrieved from "/proc/devices",
                     or evaluated */
int fs_block_size;

Refactor the code respectively, to use only the first element of
the array C, so that this patch represents an equivalent transform.


Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:15 +02:00
Peter Oberparleiter
338bea49c2 chpstat: Clarify scope of --scale option
Add a man page note to clarify that BPS value scaling only applies to
human-readable output format.

Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:15 +02:00
Peter Oberparleiter
d15e36cf24 chpstat: Add options to select IEC units for scaling
Add options to select power-of-two based IEC units such as KiB/s
(1024 B/s) for scaling throughput values in human readable reports.

Option            Scaling factor
================================
--scale ki        1024
--scale mi        1048576
--scale gi        1073741824
--scale auto-iec  IEC units

Reviewed-by: Jimmy Brisson <jbrisson@linux.ibm.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:15 +02:00
Peter Oberparleiter
4b76530788 chpstat: Use SI units for default scaling
chpstat uses power-of-two based IEC units such as KiB/s (1024 B/s) when
scaling throughput values in human readable reports. A user interpreting
these numbers can easily be confused by chpstat's default column header
("B/s") to assume that numbers are scaled using power-of-ten based SI
units such as kB/s (1000 B/s).

In addition, users that have worked with similar z/OS tooling to display
channel path activity are used to SI-based scaling, which increases the
chance of chpstat reports being misinterpreted.

To reduce this confusion, use SI units for throughput scaling:

Option          Old factor      New factor
==========================================
--scale k       1024            1000
--scale m       1048576         1000000
--scale g       1073741824      1000000000
--scale auto    IEC units       SI units

Note that machine-readable format produced via option --format is not
affected by scaling.

Reviewed-by: Jimmy Brison <jbrisson@linux.ibm.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:15 +02:00
Peter Oberparleiter
cb1c002bed chpstat: Ensure consistent table group spacing
In tabular output, chpstat adds an additional space between columns
of different groups (e.g. between READ and WRITE data). Currently this
is done by increasing the column width of the first column in a group.

Depending on the value displayed in this first column of a group, the
spacing may vanish, and under certain circumstances, the precision of
auto-scaled *_PART columns may be higher than the precision of the
related *_TOTAL columns, resulting in a confusing view.

Example:

DPU   READ(B/s)  WRITE(B/s)
 ID  PART TOTAL  PART TOTAL
  6 10.7M 10.7M 10.8M 10.8M
  6  0.00 11.3K  0.00  0.00
   ^^          ^^

Fix this by consistently adding padding between column groups without
increasing the column width of the first column of a group. Also ensure
the same width for *_PART and *_TOTAL columns.

Reviewed-by: Jimmy Brisson <jbrisson@linux.ibm.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:15 +02:00
Eduard Shishkin
d6f7eff5b5 zipl_helper.device-mapper: Fix segmentation fault in an error path
Fix segmentation fault when trying to process not supported dm-targets
Release allocated memory in error paths

Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-09-15 11:12:15 +02:00
Peter Oberparleiter
e1692b7079 chpstat: Fix scaling of DPU utilization calculation
chpstat incorrectly reports DPU utilization as fraction instead of
percent. Fix this by scaling utilization values to 100%.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-08-13 13:52:23 +02:00
Mikhail Zaslonko
54b3c9ef24 zipl/ngdump: Bail out if ngdump meta could not be saved
Bail out if the ngdump meta file could not be updated.
Save the boot log also for normal exit.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Acked-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-08-13 13:52:23 +02:00
Marc Hartmayer
48743aa28b zpwr: Use 'LDLIBS' for specifying the math library
Use 'LDLIBS' to specify the libraries that the tool is linked against.
If it is specified as a dependency, the build system may attempt to
build it and fail.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-08-13 13:52:23 +02:00
Mete Durlu
7ce988ac59 zconf/chccwdev: Fix example descriptions
Match "chccwdev --online" example's description with its function
and improve "--safeoffline" example's wording.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-08-13 13:52:23 +02:00
Marc Hartmayer
f4fec5f120 rust/pvimg/boot: Use 'PVIMG_PKGDATADIR'
Use 'PVIMG_PKGDATADIR' as it is used by the 'pvimg_pkg_data' macro rule.
The problem only shows up if someone changes 'PVIMG_PKGDATADIR' to
something different than the default.

Fixes: f4cf4ae6eb ("rust: Add a new tool called 'pvimg'")
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-07-29 18:23:49 +02:00
Steffen Eiden
2739b8a488 pv/examples: Add example for calculating host-key hashes
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-07-29 18:23:49 +02:00
Shalini Chellathurai Saroja
ce9c518b97 cpi: Disable CPI for SEL guests by default
The cpictl utility sends control-program identification data
from protected virtualization guests to hosts by default.
This behaviour leaks the below potentially sensitive
information to untrusted hosts.
- system_type
- system_level
- sysplex_name
- system_name

To prevent this behaviour, enhance the cpictl utility to stop
setting CPI information on protected virtualization guests by
default. If the user chooses to set the CPI information, it
could be set by one of the below options
- use the command line option --permit-cpi
- set the environment variable CPI_PERMIT_ON_PVGUEST to 1 to
control the CPI service behaviour during boot

Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-07-29 18:23:49 +02:00
Jörn Siglen
bd2a2cc6a1 dbginfo.sh: Enhance logging on timeout triggered
Rework command type selection and timeout trigger.
Add log entry when the timeout stopps a command or a non "zero" rc happens.

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-07-29 18:23:49 +02:00
Mikhail Zaslonko
6547d1ae4c zdump/ngdump: Add error messages and debug trace logs
Add debug trace logs for ngdump_read_meta_from_device().

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-07-29 18:23:49 +02:00
Jörn Siglen
650265e296 AUTHORS.md: Remove duplication
Same name written in two versions

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-07-29 18:23:49 +02:00
Jan Höppner
b122acb422 iucvterm: Install symlink for lsiucvallow.8 man page
lsiucvallow is just a symlink to chiucvallow for 'chiucvallow --list'.
Only a man page for chiucvallow is provided though. A corresponding man
page for lsiucvallow could be expected by the user. Certain linter such
as linitan warn about the missing man page, too.

Install lsiucvallow.8 as a symlink to chiucvallow.8 to make the
documentation of these tools more accessible.

Github-ID: https://github.com/ibm-s390-linux/s390-tools/issues/170
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-07-09 16:59:09 +02:00
Dan Horák
9710f29770 man: Use CR for constant width font
With version 1.23 groff/troff disabled the non-portable font CW and
started to complain about a missing CW font when previewing some of the
man pages, with messages like

$ man --warnings cpumf/man/pai.8 > /dev/null
troff:<standard input>:244: warning: cannot select font 'CW'

Use CR to replace CW.

Closes: https://github.com/ibm-s390-linux/s390-tools/pull/187
[hoeppner@linux.ibm.com: Adapt commit message]
Signed-off-by: Dan Horák <dan@danny.cz>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-07-08 10:23:08 +02:00
Nikita Dubrovskii
ed01bac8e2 zipl/src: Fix typos
Closes: https://github.com/ibm-s390-linux/s390-tools/pull/186
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-07-08 10:23:08 +02:00
Nikita Dubrovskii
66d3aa849a zipl/src: remove global sync() call on exit
Remove the final sync(2), as zipl(8) already uses fsync(2), syncfs(2)
and ioctl(BLKFLSBUF) to flush all performed modifications.

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/186
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-07-08 10:23:08 +02:00
Eduard Shishkin
95e4b3413a zipl/src: Prepare for global sync(2) removal
zipl tool calls sync(2) before exit, which may hang on attempts to
flush not relevant problematic mounts (e.g. nfs) [1].

Complete any modification performed by zipl(8) tool with calling
fsync(2), or syncfs(2). This allows to get rid of the mentioned
sync(2) call.

[1] https://github.com/openshift/os/issues/1720
Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/186
Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-07-08 10:23:08 +02:00
Steffen Eiden
06e0d569f1 Prepare for next release
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2025-06-25 11:43:27 +02:00
336 changed files with 12812 additions and 3487 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

17
.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,8 +35,20 @@ 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
dasdview/dasdview
dump2tar/src/dump2tar
@@ -63,7 +76,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
@@ -119,7 +132,7 @@ 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

View File

@@ -2,7 +2,7 @@
exclude: \.(bin|crl|crt|key)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v6.0.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
@@ -11,6 +11,9 @@ repos:
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
exclude_types: ['rust']
- id: check-yaml
- id: check-json
- id: check-toml
- repo: local
hooks:
- id: git-clang-format
@@ -24,7 +27,7 @@ repos:
minimum_pre_commit_version: "2.9.0"
types_or: [c++, c]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.1
rev: v2.4.1
hooks:
- id: codespell
exclude_types: ['rust']

View File

@@ -1,13 +1,16 @@
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
@@ -23,11 +26,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 +54,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
@@ -72,12 +77,13 @@ List of all individuals having contributed content to s390-tools
- 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
@@ -110,6 +116,7 @@ List of all individuals having contributed content to s390-tools
- Raimund Schroeder
- Ralph Wuerthner
- Rene Trumpp
- Richie Buturla
- Rolf Schaefer
- Sa Liu
- Sascha Silbe
@@ -132,6 +139,7 @@ List of all individuals having contributed content to s390-tools
- Sven Schnelle
- Sven Schuetz
- Swen Schillig
- Szabina Korbai
- Taraka R. Bodireddy
- Thomas Heidrich
- Thomas Huth
@@ -148,7 +156,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,102 @@
Release history for s390-tools (MIT version)
--------------------------------------------
* __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
Changes of existing tools:
- chpstat: Add options to select IEC units for scaling (SI units are default)
- chzdev: Introduce --no-module-load option
- cpi: Disable CPI for SEL guests by default
- dbginfo.sh: Enhance logging on timeout triggered
- iucvterm: Install symlink for lsiucvallow.8 man page
- lshwc: Add command line flag to specify individual counters
- lspai: Add command line flag for delta values
- lspai: Add command line flag for short counter names
- lspai: Add command line flag to specify individual counters
- lspai: Add command line flags for all cpus
- lspai: Add command line flags for hexadecimal output
- man: Use CR for constant width font
- pvimg: Add '--image-key' option
- zdev: Allow dynamic control of module load
- zipl/boot: Fix EBCDIC code page 500 conversion and decrease size by 200 bytes
- zipl: Add support of heterogeneous mirrors (remove technical limitations
on mirrored targets, thus allowing mirrored devices consist of partitions
at different offsets on disks of different types and geometry).
- zkey: Add support for generating and importing exportable secure keys
Bug Fixes:
- chpstat: Fix scaling of DPU utilization calculation
- zdev/dracut: Prevent loading of unused kernel modules
- zdev: Fix double device configuration on DPM systems
- zdev: Fix double device configuration with rd.dasd
- zipl_helper.device-mapper: Fix segfault in an error path
* __v2.38.0 (2025-06-25)__
For Linux kernel version: 6.14 / 6.15

View File

@@ -21,7 +21,7 @@ TOOL_DIRS = zipl zdump fdasd dasdfmt dasdview tunedasd \
else
BASELIB_DIRS =
LIB_DIRS = libpv
TOOL_DIRS = rust
TOOL_DIRS = netboot rust
endif
SUB_DIRS = $(BASELIB_DIRS) $(LIB_DIRS) $(TOOL_DIRS)

View File

@@ -414,6 +414,19 @@ the different tools are provided:
dumping).
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 and prepare a dump partition:
- cat
- cut
- findmnt
- logsave
- makedumpfile
- mount
- poweroff
- sha256sum
- sync
- umount
- mkfs.ext4
* zgetdump
For building zgetdump you need OpenSSL version 1.1.0 or newer
@@ -505,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

@@ -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 := 38
RELEASE := 41
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

@@ -22,7 +22,7 @@ ALL_CPPFLAGS += -DVERSION=$(VERSION)
all: check_dep cpacfstats cpacfstatsd
cpacfstatsd: cpacfstatsd.o stats_sock.o perf_crypto.o cpacfstats_common.o \
$(rootdir)/libutil/libutil.a
$(rootdir)/libcpumf/libcpumf.a $(rootdir)/libutil/libutil.a
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -ludev -lpthread -o $@
cpacfstats: cpacfstats.o stats_sock.o cpacfstats_common.o

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

@@ -30,6 +30,7 @@
#include <libudev.h>
#include "cpacfstats.h"
#include "lib/libcpumf.h"
#include "../include/lib/zt_common.h"
/* correlation between counter and perf counter string */
@@ -123,16 +124,6 @@ static struct percpucounter *findcpu(unsigned int cpunum, int unlinkflag)
return NULL;
}
static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
int cpu, int group_fd, unsigned long flags)
{
int ret;
ret = syscall(__NR_perf_event_open, hw_event, pid, cpu,
group_fd, flags);
return ret;
}
static int perf_supported(void)
{
return !access("/proc/sys/kernel/perf_event_paranoid", R_OK);
@@ -150,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;
@@ -168,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;
}
@@ -242,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);
@@ -407,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,
@@ -483,6 +480,7 @@ int perf_init(unsigned int *supported_counters)
};
unsigned long maxfd;
struct rlimit rlim;
int cpumf_state;
int i, num;
FILE *f;
@@ -496,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,28 @@
// SPDX-License-Identifier: MIT
/*
* Autocompletion generation - for cpumf family of tools
*
* 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.
*/
#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())

40
cpumf/chcpumf_cli.h Normal file
View File

@@ -0,0 +1,40 @@
/* SPDX-License-Identifier: MIT */
/*
* Command line utilities - for chcpumf
*
* 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 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
@@ -39,7 +40,7 @@
static bool actions[ACTION_SAMPLE + 1]; /* Specified command line options */
/* This defines the number of pages a Sample Data Buffer Table (SDBT) can hold
* as payload data. Each SDBT is one PAGE (4096 bytes) and continas 512 eight
* as payload data. Each SDBT is one PAGE (4096 bytes) and contains 512 eight
* byte data pointers to Sample Data Buffers (SDB). The last entry of a SDBT
* points to another SDBT and can not store payload.
*/
@@ -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 = {
@@ -139,7 +113,7 @@ static struct samples { /* Sample definition for all machines */
* The CPU Measurement facility has a first and second version number.
*
* The first version number governs basic counter set and the
* problem state counter set. Currently used are first verion numbers 1 and 3.
* problem state counter set. Currently used are first version numbers 1 and 3.
* The counter numbers are identifical for version number 1 and 3, but
* have different purpose and description.
*
@@ -627,7 +601,7 @@ static struct counters cpumcf_z10_counters[] = {
.ctrset = CPUMF_CTRSET_EXTENDED,
.name = "L1D_L3_LOCAL_WRITES",
.desc = "A directory write to the Level-1 D-Cache directory"
"\n\t\twhere the installtion cache line was source from"
"\n\t\twhere the installation cache line was source from"
"\n\t\tthe Level-3 cache that is on the same book as the"
"\n\t\tData cache (Local L2 cache)",
},
@@ -1916,7 +1890,7 @@ static struct counters cpumcf_z14_counters[] = {
.ctrset = CPUMF_CTRSET_EXTENDED,
.name = "L1I_ONCHIP_L3_SOURCED_WRITES",
.desc = "A directory write to the Level-1 Instruction cache"
"\n\t\tdirectory where the returned cache ine was sourced"
"\n\t\tdirectory where the returned cache line was sourced"
"\n\t\tfrom an On-Chip Level-3 cache without intervention",
},
{
@@ -1924,7 +1898,7 @@ static struct counters cpumcf_z14_counters[] = {
.ctrset = CPUMF_CTRSET_EXTENDED,
.name = "L1I_ONCHIP_MEMORY_SOURCED_WRITES",
.desc = "A directory write to the Level-1 Instruction cache"
"\n\t\tdirectory where the returned cache ine was sourced"
"\n\t\tdirectory where the returned cache line was sourced"
"\n\t\tfrom On-Chip memory",
},
{
@@ -1932,7 +1906,7 @@ static struct counters cpumcf_z14_counters[] = {
.ctrset = CPUMF_CTRSET_EXTENDED,
.name = "L1I_ONCHIP_L3_SOURCED_WRITES_IV",
.desc = "A directory write to the Level-1 Instruction cache"
"\n\t\tdirectory where the returned cache ine was sourced"
"\n\t\tdirectory where the returned cache line was sourced"
"\n\t\tfrom an On-Chip Level-3 cache with intervention",
},
{
@@ -2342,7 +2316,7 @@ static struct counters cpumcf_z15_counters[] = {
.ctrset = CPUMF_CTRSET_EXTENDED,
.name = "L1I_ONCHIP_L3_SOURCED_WRITES",
.desc = "A directory write to the Level-1 Instruction cache"
"\n\t\tdirectory where the returned cache ine was sourced"
"\n\t\tdirectory where the returned cache line was sourced"
"\n\t\tfrom an On-Chip Level-3 cache without intervention",
},
{
@@ -2350,7 +2324,7 @@ static struct counters cpumcf_z15_counters[] = {
.ctrset = CPUMF_CTRSET_EXTENDED,
.name = "L1I_ONCHIP_MEMORY_SOURCED_WRITES",
.desc = "A directory write to the Level-1 Instruction cache"
"\n\t\tdirectory where the returned cache ine was sourced"
"\n\t\tdirectory where the returned cache line was sourced"
"\n\t\tfrom On-Chip memory",
},
{
@@ -2358,7 +2332,7 @@ static struct counters cpumcf_z15_counters[] = {
.ctrset = CPUMF_CTRSET_EXTENDED,
.name = "L1I_ONCHIP_L3_SOURCED_WRITES_IV",
.desc = "A directory write to the Level-1 Instruction cache"
"\n\t\tdirectory where the returned cache ine was sourced"
"\n\t\tdirectory where the returned cache line was sourced"
"\n\t\tfrom an On-Chip Level-3 cache with intervention",
},
{
@@ -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)

44
cpumf/lscpumf_cli.h Normal file
View File

@@ -0,0 +1,44 @@
/* SPDX-License-Identifier: MIT */
/*
* Command line utilities - for lscpumf
*
* 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 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

@@ -37,12 +37,13 @@
#include "lib/util_base.h"
#include "lib/util_path.h"
#include "lib/util_scandir.h"
#include "lib/util_libc.h"
#include "lib/util_str.h"
#include "lib/util_file.h"
#include "lib/util_fmt.h"
#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"
@@ -61,6 +62,7 @@ static bool hideundef;
static bool delta, firstread;
static int output_format = FMT_CSV;
static bool quote_all;
static char *ctrlist; /* Comma separated list of counter to extract */
static unsigned int max_possible_cpus; /* No of possible CPUs */
static struct ctrname { /* List of defined counters */
@@ -151,6 +153,8 @@ static bool read_counternames(void)
return false;
}
for (i = 0; i < count && ctr >= 0; i++) {
if (!ctr_in_list(namelist[i]->d_name, ctrlist))
continue;
util_asprintf(&ctrpath, "%s/%s", path, namelist[i]->d_name);
if (util_file_read_va(ctrpath, "event=%x", &ctr) == 1)
ctrname[ctr].name = mk_name(ctr, namelist[i]->d_name);
@@ -729,61 +733,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 ")"
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
};
static const struct util_prg prg = {
.desc = "Read CPU Measurement facility counter sets",
.copyright_vec = {
@@ -814,7 +763,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) {
@@ -892,6 +841,12 @@ int main(int argc, char **argv)
errx(EXIT_FAILURE, "Supported formats:" FMT_TYPE_NAMES);
output_format = fmt;
break;
case 'c':
hideundef = true;
ctrlist = util_strdup(optarg);
util_str_rm_whitespace(optarg, ctrlist);
util_str_toupper(ctrlist);
break;
}
}
@@ -927,5 +882,6 @@ int main(int argc, char **argv)
free_counternames();
free(check);
free(ioctlbuffer);
free(ctrlist);
return ch;
}

78
cpumf/lshwc_cli.h Normal file
View File

@@ -0,0 +1,78 @@
/* SPDX-License-Identifier: MIT */
/*
* Command line utilities - for lshwc
*
* 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 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

@@ -6,7 +6,6 @@
/* List available Processor Assist Instrumentation (PAI) counters. */
#include <ctype.h>
#include <dirent.h>
#include <err.h>
#include <errno.h>
@@ -17,7 +16,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <linux/perf_event.h>
#include "lib/util_base.h"
#include "lib/util_file.h"
@@ -28,30 +32,10 @@
#include "lib/util_path.h"
#include "lib/util_prg.h"
#include "lib/util_scandir.h"
#include "lib/util_str.h"
#include "lib/libcpumf.h"
#define OPT_FORMAT 256 /* --format XXX option */
static struct util_opt opt_vec[] = {
UTIL_OPT_SECTION("OPTIONS"),
{
.option = { "format", required_argument, NULL, OPT_FORMAT },
.argument = "FORMAT",
.flags = UTIL_OPT_FLAG_NOSHORT,
.desc = "List counters in specified FORMAT (" FMT_TYPE_NAMES ")"
},
{
.option = { "numeric", no_argument, NULL, 'n' },
.desc = "Sort PAI counters by counter number"
},
{
.option = { "type", required_argument, NULL, 't' },
.argument = "TYPE",
.desc = "Type of PAI counters to show: crypto, nnpa"
},
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",
@@ -59,14 +43,24 @@ static const struct util_prg prg = {
{
.owner = "IBM Corp.",
.pub_first = 2023,
.pub_last = 2023,
.pub_last = 2025,
},
UTIL_PRG_COPYRIGHT_END
}
};
static bool allcpu; /* Show counter values per CPU */
static bool numsort; /* If true sort counter numerically */
static bool shortname; /* Use abbreviated counter names */
static bool delta, firstread; /* Display delta values */
static int output_format = -1; /* Generate style if >= 0 */
static unsigned int max_cpus; /* # of CPUs to read counter values from */
static unsigned int max_fds; /* # of file descriptor to read counter values */
static unsigned long loops; /* # loops */
static unsigned long read_interval = DEFAULT_LOOP_INTERVAL;
static cpu_set_t cpu_online_mask;
static char *ctrformat = "%ld"; /* Default counter output format */
static char *ctrlist; /* Comma separated list of counter to extract */
#define PAI_PATH "/bus/event_source/devices/%s"
@@ -78,9 +72,18 @@ enum pai_types { /* Bit mask for supported PAI counters */
static int pai_types_show;
struct pai_cpudata { /* Event data per CPU */
int fd; /* Event file descriptor */
int cpu; /* CPU number */
unsigned long value; /* Event value */
unsigned long prev_value; /* Previous value for deltas */
};
struct pai_ctrname { /* List of defined counters */
char *name; /* Counter name */
unsigned long nr; /* Counter number */
unsigned long total; /* Total count on all CPus */
struct pai_cpudata *data; /* Counter data per CPU */
};
struct pai_node { /* Head for PAI counter sets */
@@ -113,6 +116,20 @@ static unsigned long pai_type_base(enum pai_types t)
return 0;
}
/* Return character for this counter set. */
static char pai_type_char(enum pai_types t)
{
switch (t) {
case pai_type_crypto:
return 'C';
case pai_type_nnpa:
return 'N';
case pai_type_max:
break;
}
return 'U';
}
/* Test PAI counter name from command line option. */
static const char *pai_type_name(enum pai_types t)
{
@@ -154,16 +171,6 @@ static int pai_ctrcmp(const void *p1, const void *p2)
return l->nr > r->nr ? 1 : -1;
}
/* Convert string to upper case. */
static char *str2uc(const char *s)
{
char *uc = util_strdup(s), *old_uc = uc;
for (; *uc; ++uc)
*uc = toupper(*uc);
return old_uc;
}
/* Read counter names and assigned event number from sysfs file tree.
* Exit when sysfs directory can not be scanned.
*/
@@ -171,7 +178,7 @@ static void read_counternames(struct pai_node *node)
{
int i, more = 0, ctr = 0, count = 0;
struct dirent **namelist = NULL;
char *path, *ctrpath;
char *path, *ctrpath, sname[128];
/* Read counter names and assigned event number. */
path = util_path_sysfs(PAI_PATH "/events", node->sysfs_name);
@@ -184,9 +191,18 @@ static void read_counternames(struct pai_node *node)
for (i = 0; i < count && ctr >= 0; i++) {
util_asprintf(&ctrpath, "%s/%s", path, namelist[i]->d_name);
if (util_file_read_va(ctrpath, "event=%x", &ctr) == 1) {
snprintf(sname, sizeof(sname), "%c%ld",
pai_type_char(node->type), ctr - node->base);
if (!ctr_in_list(sname, ctrlist) &&
!ctr_in_list(namelist[i]->d_name, ctrlist)) {
/* Counter not listed in --counters option */
continue;
}
node->ctrlist[node->ctridx].data = NULL;
node->ctrlist[node->ctridx].name = util_strdup(namelist[i]->d_name);
node->ctrlist[node->ctridx++].nr = ctr;
more++;
max_fds++;
} else {
warnx("Cannot parse %s", ctrpath);
}
@@ -199,7 +215,7 @@ static void read_counternames(struct pai_node *node)
qsort(node->ctrlist, more, sizeof(*node->ctrlist), pai_ctrcmp);
}
static void show_format(enum util_fmt_t fmt)
static void format_painode(enum util_fmt_t fmt)
{
struct pai_node *node;
@@ -214,9 +230,12 @@ static void show_format(enum util_fmt_t fmt)
for (int i = 0; i < node->ctridx; ++i) {
util_fmt_obj_start(FMT_ROW, "counter");
util_fmt_pair(FMT_QUOTE, "name", "%s", node->ctrlist[i].name);
if (shortname)
util_fmt_pair(FMT_QUOTE, "name", "%c%d",
pai_type_char(node->type),
node->ctrlist[i].nr - node->base);
util_fmt_pair(FMT_DEFAULT, "config", "%d", node->ctrlist[i].nr);
util_fmt_pair(FMT_DEFAULT, "number", "%d",
node->ctrlist[i].nr - node->base);
util_fmt_pair(FMT_DEFAULT, "id", "%d", node->ctrlist[i].nr - node->base);
util_fmt_obj_end();
}
util_fmt_obj_end(); /* Counters */
@@ -226,14 +245,14 @@ static void show_format(enum util_fmt_t fmt)
util_fmt_exit();
}
static void show_painode(void)
static void list_painode(void)
{
struct pai_node *node;
int indent = 0;
int offset = 0;
if (output_format != -1) {
show_format(output_format);
format_painode(output_format);
return;
}
@@ -264,8 +283,10 @@ static void free_painode(void)
util_list_iterate_safe(&pai_list, node, next) {
free(node->name_uc);
for (int i = 0; i < node->ctridx; ++i)
for (int i = 0; i < node->ctridx; ++i) {
free(node->ctrlist[i].name);
free(node->ctrlist[i].data);
}
free(node->ctrlist);
free(node);
}
@@ -279,7 +300,8 @@ static void make_painode(enum pai_types t)
node->type = t;
node->sysfs_name = pai_type_sysfs(t);
node->name = pai_type_name(t);
node->name_uc = str2uc(node->name);
node->name_uc = util_strdup(node->name);
util_str_toupper(node->name_uc);
node->filter_name = pai_type_filter(t);
node->base = pai_type_base(t);
@@ -308,6 +330,267 @@ static void sort_painode(void)
util_list_sort(&pai_list, painode_cmp, NULL);
}
/* Read counter value. */
static unsigned long event_read(int fd)
{
unsigned long count;
int rc;
rc = read(fd, &count, sizeof(count));
if (rc != sizeof(count))
err(EXIT_FAILURE, "Failed to read counter value");
return count;
}
/* Write header. */
static void line_header(void)
{
struct pai_node *node;
static bool header;
bool comma = false;
if (header)
return; /* Printed already */
printf("Date,Time,CPU,"); /* Print counter name and number */
util_list_iterate(&pai_list, node) {
for (int i = 0; i < node->ctridx; ++i) {
if (comma)
putchar(',');
if (shortname) {
printf("%c%ld", pai_type_char(node->type),
node->ctrlist[i].nr - node->base);
} else {
printf("%s(%ld)", node->ctrlist[i].name ?: node->name_uc,
node->ctrlist[i].nr - node->base);
}
comma = true;
}
}
putchar('\n');
header = true;
}
/* Print CPU specific counter values. */
static void line_cpu(char *header)
{
struct pai_cpudata *data;
struct pai_node *node;
bool comma;
char txt[16];
for (unsigned int h = 0; h < max_cpus; ++h) {
comma = false;
util_list_iterate(&pai_list, node) {
for (int i = 0; i < node->ctridx; ++i) {
data = &node->ctrlist[i].data[h];
if (!comma) {
snprintf(txt, sizeof(txt), "CPU%d,", data->cpu);
printf("%s,%s", header, txt);
} else {
putchar(',');
}
printf(ctrformat, data->value);
comma = true;
}
}
putchar('\n');
}
}
/* Write an output line. */
static void line_out(char *header)
{
struct pai_node *node;
bool comma;
line_header();
if (allcpu)
line_cpu(header);
/* Print total count of all CPUs */
printf("%s,%s,", header, delta && !firstread ? "Delta" : "Total");
comma = false;
util_list_iterate(&pai_list, node) {
for (int i = 0; i < node->ctridx; ++i) {
if (comma)
putchar(',');
printf(ctrformat, node->ctrlist[i].total);
comma = true;
}
}
putchar('\n');
}
/* Write a formatted line. */
static void format_line_out(time_t now, char *now_text)
{
static unsigned int called;
struct pai_node *node;
char cpuid[16];
if (!called) {
util_fmt_init(stdout, output_format, FMT_DEFAULT | FMT_HANDLEINT, 1);
util_fmt_obj_start(FMT_DEFAULT, NULL);
util_fmt_obj_start(FMT_LIST, "measurements");
}
util_list_iterate(&pai_list, node) {
if (!node->ctridx) /* Counter set not selected */
continue;
util_fmt_obj_start(FMT_DEFAULT, "entry");
util_fmt_pair(FMT_PERSIST, "iteration", "%d", called++);
util_fmt_pair(FMT_PERSIST, "time_epoch", "%d", now);
util_fmt_pair(FMT_QUOTE | FMT_PERSIST, "time", "%s", now_text);
util_fmt_pair(FMT_QUOTE | FMT_PERSIST, "valuetype",
(delta && !firstread) ? "delta" : "total");
util_fmt_obj_start(FMT_LIST, "counters");
for (int i = 0; i < node->ctridx; ++i) {
util_fmt_obj_start(FMT_ROW, "counter");
util_fmt_pair(FMT_QUOTE, "name", "%s", node->ctrlist[i].name);
if (shortname)
util_fmt_pair(FMT_QUOTE, "shortname", "%c%d",
pai_type_char(node->type),
node->ctrlist[i].nr - node->base);
util_fmt_pair(FMT_DEFAULT, "config", "%d", node->ctrlist[i].nr);
util_fmt_pair(FMT_DEFAULT, "id", "%d", node->ctrlist[i].nr - node->base);
util_fmt_pair(FMT_DEFAULT, "value", ctrformat, node->ctrlist[i].total);
if (allcpu) {
for (unsigned int j = 0; j < max_cpus; ++j) {
snprintf(cpuid, sizeof(cpuid), "cpu%d", j);
util_fmt_pair(FMT_DEFAULT, cpuid, ctrformat,
node->ctrlist[i].data[j].value);
}
}
util_fmt_obj_end();
}
util_fmt_obj_end(); /* Counters */
util_fmt_obj_end(); /* Entry */
}
}
/* Terminate formatted output. */
static void format_line_end(void)
{
util_fmt_obj_end(); /* Iteration */
util_fmt_obj_end(); /* Default */
util_fmt_exit();
}
/* Display counter values. */
static void show_values(void)
{
time_t now = time(NULL);
struct tm *now_tm;
char now_text[32];
now_tm = localtime(&now);
if (output_format != -1) {
strftime(now_text, sizeof(now_text), "%F %T%z", now_tm);
format_line_out(now, now_text);
} else {
strftime(now_text, sizeof(now_text), "%F,%T", now_tm);
line_out(now_text);
}
}
/* Read each counter value. */
static void read_painode(void)
{
struct pai_cpudata *data;
struct pai_node *node;
unsigned long value;
util_list_iterate(&pai_list, node) {
for (int i = 0; i < node->ctridx; ++i) {
node->ctrlist[i].total = 0;
for (size_t j = 0; j < max_cpus; ++j) {
data = &node->ctrlist[i].data[j];
value = event_read(data->fd);
if (delta) {
data->value = value - data->prev_value;
data->prev_value = value;
} else {
data->value = value;
}
node->ctrlist[i].total += data->value;
}
}
}
}
static void wait_painode(void)
{
for (unsigned long i = 0; i < loops; ++i) {
read_painode();
show_values();
if (i + 1 < loops)
sleep(read_interval);
firstread = false;
}
format_line_end();
}
/* Install one event. */
static int event_add(int cpu, int idx, struct pai_node *node)
{
struct perf_event_attr attr;
int fd;
memset(&attr, 0, sizeof(attr));
attr.size = sizeof(attr);
attr.config = node->ctrlist[idx].nr;
attr.type = node->pmu;
fd = perf_event_open(&attr, -1, cpu, -1, 0);
if (fd == -1)
err(EXIT_FAILURE, "Failed to open perf event: file descriptor not available");
return fd;
}
/* Increase number of file descriptors this process can open. */
static void event_fdlimit(void)
{
unsigned int needed = 3 + max_fds * max_cpus;
struct rlimit rlimit;
if (getrlimit(RLIMIT_NOFILE, &rlimit) == -1)
err(EXIT_FAILURE, "Failed to read RLIMIT_NOFILE");
if (needed > rlimit.rlim_cur)
rlimit.rlim_cur = needed;
if (setrlimit(RLIMIT_NOFILE, &rlimit) == -1)
err(EXIT_FAILURE, "Failed to set RLIMIT_NOFILE");
}
/* Install all events and iterate over requested read operations. */
static void event_painode(void)
{
size_t pai_cpudata_sz = sizeof(struct pai_cpudata) * max_cpus;
struct pai_cpudata *data;
struct pai_node *node;
event_fdlimit();
util_list_iterate(&pai_list, node) {
for (int i = 0; i < node->ctridx; ++i) {
node->ctrlist[i].data = util_malloc(pai_cpudata_sz);
data = node->ctrlist[i].data;
for (unsigned int j = 0; j < CPU_SETSIZE; ++j) {
if (CPU_ISSET(j, &cpu_online_mask)) {
data->cpu = j;
data->fd = event_add(j, i, node);
data->value = 0;
data->prev_value = 0;
++data;
}
}
}
}
wait_painode();
util_list_iterate(&pai_list, node) {
for (int i = 0; i < node->ctridx; ++i) {
for (unsigned int j = 0; j < max_cpus; ++j)
close(node->ctrlist[i].data[j].fd);
}
}
}
/* Check for hardware support and return false if not available. */
static bool have_support(enum pai_types t)
{
@@ -344,20 +627,60 @@ static void check_type_name(const char *type)
errx(EXIT_FAILURE, "Invalid argument for -t %s", type);
}
/*
* Get list of specified CPUs from command line. Check if these CPUs
* exist and are online. Ignore those CPUs which are not available and
* issue one warning when CPUs have been specified but are not online.
*/
static void get_cpulist(char *parm)
{
bool warned = false;
cpu_set_t cpulist;
int i, rc;
CPU_ZERO(&cpulist);
rc = libcpumf_cpuset(parm, &cpulist);
if (rc)
err(EXIT_FAILURE, "Cannot parse cpulist %s", parm);
for (i = 0; i < CPU_SETSIZE; ++i) {
if (CPU_ISSET(i, &cpulist) && !CPU_ISSET(i, &cpu_online_mask)) {
if (!warned) {
warnx("some CPU(s) are offline, ignored");
warned = true;
}
}
if (!CPU_ISSET(i, &cpulist) && CPU_ISSET(i, &cpu_online_mask))
CPU_CLR(i, &cpu_online_mask);
}
}
int main(int argc, char **argv)
{
bool list_only = true;
enum util_fmt_t fmt;
bool i_flag = false;
bool l_flag = false;
char *endchar;
int ch;
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) {
default:
util_opt_print_parse_error(ch, argv);
return EXIT_FAILURE;
case 'a':
allcpu = true;
list_only = false;
break;
case 'd':
delta = true;
firstread = true;
list_only = false;
break;
case 'h':
util_prg_print_help();
util_opt_print_help();
@@ -365,21 +688,80 @@ int main(int argc, char **argv)
case 'v':
util_prg_print_version();
return EXIT_SUCCESS;
case 'i':
i_flag = true;
list_only = false;
errno = 0;
read_interval = strtoul(optarg, &endchar, 0);
if (errno || *endchar)
errx(EXIT_FAILURE, "Invalid argument for -%c", ch);
break;
case 'l':
l_flag = true;
list_only = false;
errno = 0;
loops = strtoul(optarg, &endchar, 0);
if (errno || *endchar)
errx(EXIT_FAILURE, "Invalid argument for -%c", ch);
break;
case 'n':
numsort = true;
break;
case 's':
list_only = false;
shortname = true;
break;
case 't':
check_type_name(optarg);
break;
case 'x':
list_only = false;
ctrformat = "%lx";
break;
case 'X':
list_only = false;
ctrformat = "%#lx";
break;
case OPT_FORMAT:
if (!util_fmt_name_to_type(optarg, &fmt))
errx(EXIT_FAILURE, "Supported formats:" FMT_TYPE_NAMES);
output_format = fmt;
break;
case 'c':
ctrlist = util_strdup(optarg);
util_str_rm_whitespace(optarg, ctrlist);
util_str_toupper(ctrlist);
break;
}
}
/* Nothing specified, show all PAI counters */
if (i_flag && !l_flag) {
util_prg_print_help();
util_opt_print_help();
return EXIT_FAILURE;
}
/*
* Read currently online CPUs and create a bit mask.
* This bitmap of online CPUs is used to check command line parameter
* for valid CPUs
* When any of the flags which set variable list_only to false have
* be specified, lets also show the counter value, not just list them.
*/
if (optind < argc) /* List of CPUs on command line */
list_only = false;
if (!list_only) { /* Show counter values */
ch = libcpumf_cpuset_fn(S390_CPUS_ONLINE, &cpu_online_mask);
if (ch)
err(EXIT_FAILURE, "Cannot read file /sys/" S390_CPUS_ONLINE);
while (optind < argc)
get_cpulist(argv[optind++]);
max_cpus = CPU_COUNT(&cpu_online_mask);
if (!loops)
loops = 1;
}
/* Nothing specified, use all PAI counters */
if (!pai_types_show)
pai_types_show = (1 << pai_type_crypto) | (1 << pai_type_nnpa);
@@ -393,7 +775,12 @@ int main(int argc, char **argv)
}
}
sort_painode();
show_painode();
ch = EXIT_SUCCESS;
if (!list_only)
event_painode();
else
list_painode();
free_painode();
free(ctrlist);
return ch;
}

81
cpumf/lspai_cli.h Normal file
View File

@@ -0,0 +1,81 @@
/* SPDX-License-Identifier: MIT */
/*
* Command line utilities - for lspai
*
* 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 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

@@ -17,9 +17,9 @@ chcpumf \- manage the CPU-measurement facilities support
.SH SYNOPSIS
.B chcpumf
.RB [ \-m | \-\-min
.IR num_sdb ]
.IR NUM_SDB ]
.RB [ \-x | \-\-max
.IR num_sdb ]
.IR NUM_SDB ]
.RB [ \-V | \-\-verbose ]
.br
.B chcpumf
@@ -36,14 +36,14 @@ facilities for Linux on System z.
.
.SH OPTIONS
.TP
.BR \-m ", " \-\-min " \fInum_sdb\fP"
.BR \-m ", " \-\-min " \fINUM_SDB\fP"
Specifies the minimum sampling facility buffer size in sample-data-blocks
(SDB). A sample-data-block consumes about 4 kilobytes.
This is the initial buffer size when you start the sampling facility.
.
.TP
.BR \-x ", " \-\-max " \fInum_sdb\fP"
.BR \-x ", " \-\-max " \fINUM_SDB\fP"
Specifies the maximum sampling facility buffer size in sample-data-blocks
(SDB). A sample-data-block consumes about 4 kilobytes.

View File

@@ -16,14 +16,16 @@ lshwc \- extract CPU Measurement Facilities counter sets
\*c
.RB [ \-a ][ \-d ][ \-H ][ \-s ][ \-x ][ \-X ][ \-q ]
.RB [ \-l
.IR count ]
.IR COUNT ]
.RB [ \-i
.IR interval ]
.IR INTERVAL ]
.RB [ \-t
.IR time ]
.IR TIME ]
.RB [ \-f
.IR format ]
\fR[\fIcpulist\fR][:\fIsets\fR]\fP
.IR FORMAT ]
.RB [ \-c
.IR LIST ]
\fR[\fICPULIST\fR][:\fISETS\fR]\fP
.br
\*c
.BR \-h | \-\-help
@@ -62,13 +64,13 @@ Without this flag the total value of each counter is displayed.
See Examples.
.
.TP
.BR \-i ", " \-\-interval \fI\ seconds\fP
.BR \-i ", " \-\-interval \fI\ SECONDS\fP
Specifies a time interval, in seconds,
that the command waits between read operations.
The default is 60 seconds.
.
.TP
.BR \-l ", " \-\-loop \fI\ count\fP
.BR \-l ", " \-\-loop \fI\ COUNT\fP
Performs the specified number of read operations.
.
.TP
@@ -134,7 +136,7 @@ Displays counter values as hexadecimal values with a leading 0x prefix.
Apply quoting to every output element, regardless of content or format.
.
.TP
.BR \-f ", " \-\-format \fI\ format\fP
.BR \-f ", " \-\-format \fI\ FORMAT\fP
Retrieve output in one of the following formats:
JSON, CSV, JSON-SEQ or PAIRS.
If no format is specified, the output defaults to CSV.
@@ -173,7 +175,12 @@ and \fBvalue\fP.
.RE
.
.TP
\fR[\fIcpulist\fR][:\fIsets\fR]\fP
.BR \-c ", " \-\-counters \fI\ LIST\fP
Specify a comma-separated list of counter names to be printed.
If a counter name does not match any valid counter name, it is omitted. (Implies -H)
.
.TP
\fR[\fICPULIST\fR][:\fISETS\fR]\fP
A comma-separated list of CPUs.
Each CPU can optionally be followed by characters that specify the counter set.
See below for details.
@@ -206,7 +213,7 @@ Two read operations are performed and a summary line is printed for each
read operation.
.sp 1
.nf
.ft CW
.ft CR
# lshwc -l2 0-1:BP
Date,Time,CPU,CPU_CYCLES(0),INSTRUCTIONS(1),L1I_DIR_WRITES(2),L1I_PENALTY_CYCLES(3),L1D_DIR_WRITES(4),
L1D_PENALTY_CYCLES(5),PROBLEM_STATE_CPU_CYCLES(32),PROBLEM_STATE_INSTRUCTIONS(33)
@@ -220,7 +227,7 @@ Date,Time,CPU,CPU_CYCLES(0),INSTRUCTIONS(1),L1I_DIR_WRITES(2),L1I_PENALTY_CYCLES
This example shows the counter values of the problem state counter set per CPU.
CPU 0 and CPU 1 are selected.
.nf
.ft CW
.ft CR
.sp 1
# lshwc -l3 -a 0-1:P
Date,Time,CPU,PROBLEM_STATE_CPU_CYCLES(32),PROBLEM_STATE_INSTRUCTIONS(33)
@@ -239,7 +246,7 @@ Date,Time,CPU,PROBLEM_STATE_CPU_CYCLES(32),PROBLEM_STATE_INSTRUCTIONS(33)
This example shows the counter values of the basic counter set
using delta output format.
.nf
.ft CW
.ft CR
.sp 1
# lshwc -d -l 10 -i 5 -s :b
Date,Time,CPU,B0,B1,B2,B3,B4,B5
@@ -259,7 +266,7 @@ Date,Time,CPU,B0,B1,B2,B3,B4,B5
This example shows the counter values of the problem state counter set with
CPU 3 selected.
.nf
.ft CW
.ft CR
.sp 1
# lshwc -l2 -a 3:P -H --format json
{

View File

@@ -10,7 +10,7 @@
.TH \*c "8" "August 2023" "s390-tools" "CPU-MF management programs"
.
.SH NAME
lspai \- list Processor Activity Instrumentation (PAI) counters
\*c \- list Processor Activity Instrumentation (PAI) counters and values
.
.SH SYNOPSIS
\*c
@@ -18,7 +18,22 @@ lspai \- list Processor Activity Instrumentation (PAI) counters
.IR FORMAT ]
.RB [ \-n ]
.RB [ \-t
.IR TYPE ]
.br
\*c
.RB [ \-\-format
.IR FORMAT ]
.RB [ \-n ]
.RB [ \-t
.IR "\ TYPE" ]
.RB [ \-a ][ \-d ][ \-i
.IR SECONDS ]
.RB [ \-l
.IR COUNT ]
.RB [ \-s ][ \-x ][ \-x ]
.RB [ \-c
.IR LIST ]
.RI [ CPULIST ]
.br
\*c
.BR \-h | \-\-help
@@ -28,10 +43,34 @@ lspai \- list Processor Activity Instrumentation (PAI) counters
.
.
.SH DESCRIPTION
On the first line
\*c displays the Processor Activity Instrumentation (PAI) counters
for Linux on IBM Z.
The output is a human-readable list of available PAI counter
names and numbers.
The output lists the available PAI counter names
and numbers in various formats.
If
.I CPULIST
is specified or any of the options
.BR \-a ,
.BR \-d ,
.BR \-s ,
.BR \-x ,
.BR \-X ,
.B \-l
or
.BR \-i,
are present on the command line,
\*c command extracts counter values from the
specified PAI counter sets.
Counter sets can be specified and extracted for individual CPUs.
By default the output is a comma-separated list of values.
Each line starts with a timestamp
followed by the extracted counter values.
A header line shows each counter name and the
counter number in parenthesis.
For other formats, use the
.B \-\-format
option.
.SH OPTIONS
.TP
.BR \-h ", " \-\-help
@@ -42,7 +81,44 @@ Displays help information, then exits.
Displays version information, then exits.
.
.TP
.BR \-t ", " \-\-type "\ TYPE"
.BR \-a ", " \-\-allcpu
Displays counter values from each CPU.
The default is a total summary line of all counters from all CPUs.
.
.TP
.BR \-d ", " \-\-delta
Displays counter values in form of deltas.
Each counter value shows the increment to the previous output line.
Without this flag the total value of each counter is displayed.
.
.TP
.BR \-c ", " \-\-counters \fI\ LIST\fP
Specify a comma separated list of counter names to
be printed.
If a counter name does not match any valid counter
name, it is omitted.
.
.TP
.BR \-s ", " \-\-short
Displays counter names as short names in the heading.
A short name consists of
a letter for the counter set followed by a number.
For example,
this flag displays counter number 0 in the PAI crypto counter
set as
.B C0
instead of
.BR CRYPTO_ALL .
Valid counter set letters are:
.RS
.IP C
PAI crypto counter set
.IP N
PAI NNPA counter set
.RE
.
.TP
.BR \-t ", " \-\-type "\ \fITYPE\fP"
Specifies the PAI counter set to list.
Valid counter set values are
.I crypto
@@ -63,6 +139,26 @@ Retrieve output in one of the following formats:
JSON, csv, json-seq or pairs.
If no format is specified,
the output defaults to a human-readable format.
.
.TP
.BR \-i ", " \-\-interval \fI\ SECONDS\fP
Specifies a time interval, in seconds,
that the command waits between read operations.
The default is 60 seconds.
.
.TP
.BR \-l ", " \-\-loop \fI\ COUNT\fP
Performs the specified number of read operations.
The default is one.
.
.TP
.BR \-x ", " \-\-hex
Displays counter values as hexadecimal values.
.
.TP
.BR \-X ", " \-\-hex0x
Displays counter values as hexadecimal values with a leading 0x prefix.
.
.SH "EXAMPLE"
The \*c invocation lists all PAI Neural Network Processing Assist Facility
(NNPA) counters in numeric order:
@@ -83,6 +179,58 @@ suitable for
.IR perf "(8)"
event specification by name.
The third gives a short explanation, if available.
.sp 1
The \*c invocation displays all PAI Neural Network Processing Assist Facility
(NNPA) counters values.
Ten iterations with a two second delay in between
is printed on the screen.
.nf
# lspai -i 2 -l 10 -t nnpa -n
Date,Time,CPU,NNPA_ALL(0),NNPA_ADD(1),NNPA_SUB(2),NNPA_MUL(3),NNPA_DIV(4),
NNPA_MIN(5),NNPA_MAX(6),NNPA_LOG(7),NNPA_EXP(8),NNPA_IBM_RESERVED_9(9),
NNPA_RELU(10),NNPA_TANH(11),NNPA_SIGMOID(12),NNPA_SOFTMAX(13),NNPA_BATCHNORM(14),
NNPA_MAXPOOL2D(15),NNPA_AVGPOOL2D(16),NNPA_LSTMACT(17),NNPA_GRUACT(18),
NNPA_CONVOLUTION(19),NNPA_MATMUL_OP(20),NNPA_MATMUL_OP_BCAST23(21),
NNPA_SMALLBATCH(22),NNPA_LARGEDIM(23),NNPA_SMALLTENSOR(24),NNPA_1MFRAME(25),
NNPA_2GFRAME(26),NNPA_ACCESSEXCEPT(27)
2025-05-13,08:18:27,Total,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2025-05-13,08:18:29,Total,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2025-05-13,08:18:31,Total,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2025-05-13,08:18:33,Total,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2025-05-13,08:18:35,Total,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2025-05-13,08:18:37,Total,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2025-05-13,08:18:39,Total,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2025-05-13,08:18:41,Total,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2025-05-13,08:18:43,Total,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2025-05-13,08:18:45,Total,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
#
.fi
.sp 1
This \*c example displays the value of PAI crypto counter number 7.
It is field number 116 in the output.
This counter is incremented after \*c is started and
the table shows the delta values for PAI crypto counter 7.
.nf
# lspai -d -s -i 5 -l3 -t crypto | \
awk -F , '{ print $1 "," $2 "," $3 "," $4 "," $116; }'
Date,Time,CPU,C0,C7
2025-06-24,13:02:24,Total,0,0
2025-06-24,13:02:29,Delta,77122286,77122284
2025-06-24,13:02:34,Delta,92574403,92574403
#
.fi
.sp 1
The following table shows the total value for PAI crypto counter 7
after \*c is started.
.nf
# lspai -s -i 5 -l3 -t crypto | \
awk -F , '{ print $1 "," $2 "," $3 "," $4 "," $116; }'
Date,Time,CPU,C0,C7
2025-06-24,13:03:01,Total,0,0
2025-06-24,13:03:06,Total,72550754,72566121
2025-06-24,13:03:11,Total,164633982,164650377
#
.fi
.SH "SEE ALSO"
.BR pai (8)
.BR lscpumf (8)

View File

@@ -15,24 +15,24 @@ pai \- record and report Processor Activity Instrumentation (PAI) counters
.SH SYNOPSIS
\*c
.RB [ \-V ][ \-m | \-\-mapsize
.IR size ]
.IR SIZE ]
.RB [ \-i | \-\-interval
.IR ms ]
.IR MS ]
.RB [ \-R | \-\-realtime
.IR prio ]
.BR \-c | \-\-crypto [ \fIcpulist ][: \fIdata\fR "] [" \fIloops\fP ]
.IR PRIO ]
.BR \-c | \-\-crypto [ \fICPULIST ][: \fIDATA\fR "] [" \fILOOPS\fP ]
.br
\*c
.RB [ \-V ][ \-m | \-\-mapsize
.IR size ]
.IR SIZE ]
.RB [ \-i | \-\-interval
.IR ms ]
.IR MS ]
.RB [ \-R | \-\-realtime
.IR prio ]
.BR \-n | \-\-nnpa [ \fIcpulist ][: \fIdata\fR "] [" \fIloops\fP ]
.IR PRIO ]
.BR \-n | \-\-nnpa [ \fICPULIST ][: \fIDATA\fR "] [" \fILOOPS\fP ]
.br
\*c
.RB [ \-V ][ \-H | \-\-humantime ][ \-S | \-\-summary "] " \-r | \-\-report " [" \fIfiles\fP ]
.RB [ \-V ][ \-H | \-\-humantime ][ \-S | \-\-summary "] " \-r | \-\-report " [" \fIFILES\fP ]
.br
\*c
.BR \-h | \-\-help
@@ -73,7 +73,7 @@ Reporting evaluates files that are created by recording.
.SH OPTIONS
.TP
.BR \-c ", " \-\-crypto "\fR[\fIcpulist\fR][:\fIdata\fR]"
.BR \-c ", " \-\-crypto "\fR[\fICPULIST\fR][:\fIDATA\fR]"
Records data for all (default) or a specified list of CPUs.
The CPU list is a comma-separated list of CPU numbers and ranges.
In a range, a hyphen separates the first CPU number
@@ -106,7 +106,7 @@ execution.
.RE
.
.TP
.BR \-n ", " \-\-nnpa "\fR[\fIcpulist\fR][:\fIdata\fR]"
.BR \-n ", " \-\-nnpa "\fR[\fICPULIST\fR][:\fIDATA\fR]"
Records data for all (default) or a specified list of CPUs.
The CPU list is a comma-separated list of CPU numbers and ranges.
In a range, a hyphen separates the first CPU number
@@ -241,7 +241,7 @@ The program runs for 10 seconds
(10 intervals of 1000 milliseconds).
.sp 1
.nf
.ft CW
.ft CR
# \*c -c0 10
.ft R
.fi
@@ -256,7 +256,7 @@ and a comma-separated list of counter number, colon (:),
and the counter value n hexadecimal notation.
.sp 1
.nf
.ft CW
.ft CR
# \*c -r
0x62a668f2fa 0 event 4096 sample pid 4956/4956 9:0xa7,73:0x8,74:0x18
0x6319c75653 0 event 4096 sample pid 4972/4972 32:0x1

View File

@@ -40,7 +40,9 @@
#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
@@ -59,14 +61,6 @@ static struct util_list list_pai_event;
static struct util_list list_pmu_event;
static bool summary;
/* System call to perf_event_open(2) */
static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
int cpu, int group_fd, unsigned long flags)
{
return syscall(__NR_perf_event_open, hw_event, pid, cpu,
group_fd, flags);
}
static void ev_dealloc(void)
{
struct pai_event *next, *p;
@@ -509,7 +503,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;
@@ -520,6 +514,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));
@@ -743,8 +739,8 @@ static int add_events(int type)
}
if (rc) {
free(pmuname);
warnx("failed building event list for %s", pmuname);
free(pmuname);
}
return rc;
}
@@ -841,7 +837,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);
@@ -933,54 +929,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 = {
@@ -1046,7 +994,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

65
cpumf/pai_cli.h Normal file
View File

@@ -0,0 +1,65 @@
/* SPDX-License-Identifier: MIT */
/*
* Command line utilities - for pai
*
* 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 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,20 @@
// SPDX-License-Identifier: MIT
/*
* Autocompletion generation - for dasdfmt tool
*
* 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.
*/
#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, ...)
{

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;

123
dasdfmt/dasdfmt_cli.h Normal file
View File

@@ -0,0 +1,123 @@
/* SPDX-License-Identifier: MIT */
/*
* Command line utilities - for dasdfmt
*
* 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 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

@@ -23,16 +23,21 @@
#include <unistd.h>
#include "lib/dasd_base.h"
#include "lib/util_base.h"
#include "lib/util_file.h"
#include "lib/util_libc.h"
#include "lib/util_opt.h"
#include "lib/util_prg.h"
#include "lib/util_path.h"
#include "lib/zt_common.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",
@@ -212,7 +217,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 +225,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);
@@ -283,7 +288,7 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
char filename[] = "dasdinfo0000";
mode_t mode;
unsigned int path;
int retry;
unsigned int retry;
int rc;
int fd;
@@ -294,7 +299,7 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
if (pathname[path] == NULL)
continue;
for (retry = 0; retry < TEMP_DEV_MAX_RETRIES; retry++) {
sprintf(filename, "dasdinfo%04d", retry);
snprintf(filename, sizeof(filename), "dasdinfo%04d", retry);
result = dinfo_make_path(pathname[path], filename);
if (result == NULL)
return -1;
@@ -334,7 +339,7 @@ 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) {
@@ -354,18 +359,26 @@ static int dinfo_extract_dev(dev_t *dev, char *str)
static int dinfo_get_dev_from_blockdev(char *blockdev, dev_t *dev)
{
char *readbuf = NULL;
char *path;
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
if (!readbuf) {
warnx("Error: Not enough memory to allocate readbuffer");
return -1;
}
if (util_file_read_line(readbuf, RD_BUFFER_SIZE,
"/sys/block/%s/dev", blockdev) < 0)
path = util_path_sysfs("block/%s/dev", blockdev);
if (util_file_read_line(readbuf, RD_BUFFER_SIZE, path) < 0) {
free(path);
free(readbuf);
return -1;
if (dinfo_extract_dev(dev, readbuf) != 0)
}
free(path);
if (dinfo_extract_dev(dev, readbuf) != 0) {
free(readbuf);
return -1;
}
free(readbuf);
return 0;
}
@@ -374,8 +387,7 @@ dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
int tflag, struct FTW *ftwbuf)
{
char *tempdir;
char linkdir[128];
ssize_t i;
char *linkdir;
if (tflag != FTW_D || (strncmp((fpath + ftwbuf->base), searchbusid,
strlen(searchbusid)) != 0))
@@ -387,14 +399,13 @@ dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
*/
if (asprintf(&tempdir, "%s/driver", fpath) < 0)
return -1;
i = readlink(tempdir, linkdir, 128);
linkdir = util_readlink(tempdir);
free(tempdir);
if ((i < 0) || (i >= 128))
return -1;
/* append '\0' because readlink returns non zero terminated string */
tempdir[i + 1] = '\0';
if (strstr(linkdir, "dasd") == NULL)
if (strstr(linkdir, "dasd") == NULL) {
free(linkdir);
return FTW_CONTINUE;
}
free(linkdir);
free(busiddir);
busiddir = strdup(fpath);
if (busiddir == NULL)
@@ -439,7 +450,7 @@ dinfo_get_blockdev_from_busid(char *busid, char **blkdev)
char *tempdir = NULL;
char *result = NULL;
char *sysfsdir = "/sys/devices/";
char *sysfsdir = util_path_sysfs("devices/");
/* dinfo_is_devnode needs to know the busid */
searchbusid = busid;
@@ -475,6 +486,7 @@ out:
out2:
free(busiddir);
free(result);
free(sysfsdir);
return rc;
}
@@ -486,6 +498,7 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
DIR *directory = NULL;
struct dirent *dir_entry = NULL;
int rc = 0;
char *path;
if (stat(devnode, &stat_buffer) != 0) {
warnx("Error: could not stat %s", devnode);
@@ -495,32 +508,34 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
sprintf(stat_dev, "%d:%d", major(stat_buffer.st_rdev),
minor(stat_buffer.st_rdev));
directory = opendir("/sys/block/");
path = util_path_sysfs("block/");
directory = opendir(path);
if (directory == NULL) {
warnx("Error: could not open directory /sys/block");
warnx("Error: could not open directory %s", path);
free(path);
return -1;
}
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
if (!readbuf) {
warnx("Error: Not enough memory to allocate readbuffer");
free(path);
return -1;
}
while ((dir_entry = readdir(directory)) != NULL) {
if (util_file_read_line(readbuf, RD_BUFFER_SIZE,
"/sys/block/%s/dev",
if (util_file_read_line(readbuf, RD_BUFFER_SIZE, "%s%s/dev", path,
dir_entry->d_name) < 0)
continue;
if (strncmp(stat_dev, readbuf,
MAX(strlen(stat_dev), strlen(readbuf) - 1)) == 0) {
rc = snprintf(*uidfile, RD_BUFFER_SIZE,
"/sys/block/%s/device/uid",
rc = snprintf(*uidfile, RD_BUFFER_SIZE, "%s%s/device/uid", path,
dir_entry->d_name);
if (rc >= RD_BUFFER_SIZE) {
fprintf(stderr,
"Error: Device name was truncated\n");
free(path);
return -1;
}
@@ -529,6 +544,7 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
}
closedir(directory);
free(path);
return 0;
}
@@ -626,16 +642,18 @@ int main(int argc, char *argv[])
}
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
uidfile = dinfo_malloc(RD_BUFFER_SIZE);
if (!(readbuf && uidfile))
if (!readbuf)
exit(1);
/* try to read the uid attribute */
if (busid) {
sprintf(uidfile, "/sys/bus/ccw/devices/%s/uid", busid);
uidfile = util_path_sysfs("bus/ccw/devices/%s/uid", busid);
} else if (blockdev) {
sprintf(uidfile, "/sys/block/%s/device/uid", blockdev);
uidfile = util_path_sysfs("block/%s/device/uid", blockdev);
} else if (devnode) {
uidfile = dinfo_malloc(RD_BUFFER_SIZE);
if (!uidfile)
exit(1);
if (dinfo_get_uid_from_devnode(&uidfile, devnode) != 0)
goto error;
}

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>
@@ -428,7 +428,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 +466,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 +476,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 +486,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 +509,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 +519,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 +529,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 +539,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 +549,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 +559,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 +574,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 +592,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 +630,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 +652,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 +669,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 +768,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 +858,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 +1092,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 +1101,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 +1886,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 +1939,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 +1958,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 +1997,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 +2087,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 +2112,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 +2208,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;

View File

@@ -22,7 +22,7 @@
. ds pfont \\n[.f]
. nh
. na
. ft CW
. ft CR
\\$*
. ft \\*[pfont]
. ad

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

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

View File

@@ -18,3 +18,17 @@ CPI_SYSTEM_NAME=""
# CPI sysplex name
#
CPI_SYSPLEX_NAME=""
#
# CPI permit on protected virtualization guests
#
# Important: Set CPI_PERMIT_ON_PVGUEST=1 only if you trust the host system.
# Enabling these options allows the host to receive potentially sensitive
# Control-Program Identification (CPI) data from the protected virtualization
# guest, including:
# - system_type
# - system_level
# - sysplex_name
# - system_name
#
CPI_PERMIT_ON_PVGUEST=

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

@@ -8,6 +8,7 @@
*/
#include <getopt.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/sysmacros.h>
@@ -211,9 +212,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 +222,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 +231,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 +407,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);
@@ -493,7 +494,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 +520,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 +552,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 +976,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 +1053,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 +1081,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 +1104,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 +1373,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 +1426,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 +1827,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 +2471,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 +2676,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 +2759,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 +2778,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};

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.
@@ -113,13 +113,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 +246,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.

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,6 +231,8 @@ static void l_fmt_init(void)
return;
if (g.o.format == FMT_CSV)
flags |= FMT_QUOTEALL;
if (g.o.format == FMT_CSV || g.o.format_all)
flags |= FMT_KEEPINVAL;
if (g.o.format == FMT_JSON || g.o.format == FMT_JSONSEQ)
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,28 @@ 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*/
/*
* Options with underscore to keep compatibility
*/
#define OPT_BATCH_MODE 257 /* --batch_mode */
#define OPT_SORT_FIELD 258 /* --sort | --sort_field */
#define OPT_CPU_TYPES 259 /* --cpu_types */
#define OPT_SMT_FACTOR 260 /* --smt_factor */
/*
* Initialize default settings
@@ -313,6 +324,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 +340,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,15 +361,20 @@ 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'},
{ "batch_mode", no_argument, NULL, OPT_BATCH_MODE},
{ "all", no_argument, NULL, OPT_FORMAT_ALL },
{ "delay", required_argument, NULL, 'd'},
{ "smt_factor", required_argument, NULL, 'm'},
{ "smt-factor", required_argument, NULL, 'm'},
{ "smt_factor", required_argument, NULL, OPT_SMT_FACTOR},
{ "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'},
{ "cpu_types", required_argument, NULL, 't'},
{ "sort-field", required_argument, NULL, 'S'},
{ "sort_field", required_argument, NULL, OPT_SORT_FIELD},
{ "cpu-types", required_argument, NULL, 't'},
{ "cpu_types", required_argument, NULL, OPT_CPU_TYPES},
{ "format", required_argument, NULL, OPT_FORMAT },
{ NULL, 0, NULL, 0 }
};
@@ -366,12 +393,14 @@ void opts_parse(int argc, char *argv[])
case 'h':
l_usage();
hyptop_exit(0);
case OPT_BATCH_MODE:
case 'b':
l_batch_mode_set();
break;
case 'd':
l_delay_set(optarg);
break;
case OPT_SMT_FACTOR:
case 'm':
l_factor_set(optarg);
break;
@@ -384,18 +413,23 @@ void opts_parse(int argc, char *argv[])
case 'n':
l_iterations_set(optarg);
break;
case OPT_CPU_TYPES:
case 't':
l_cpu_types_set(optarg);
break;
case 'f':
l_fields_set(optarg);
break;
case OPT_SORT_FIELD:
case 'S':
l_sort_field_set(optarg);
break;
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

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

@@ -9,6 +9,8 @@
#include <sched.h>
#include <stdbool.h>
#include <asm/unistd.h>
#include <linux/perf_event.h>
#define S390_CPUMF_CF "devices/cpum_cf/"
#define S390_CPUMF_CFDIAG "devices/cpum_cf_diag/"
@@ -115,7 +117,7 @@ bool libcpumf_have_cpumcf(void);
*
* @param[out] min Minimum supported sampling interval
* @param[out] max Maximum supported sampling interval
* @param[out] speed Current CPU speed, number of CPU cylces per
* @param[out] speed Current CPU speed, number of CPU cycles per
* microsecond
* @param[out] basic_sz Basic sample size in bytes
* @param[out] diag_sz Diagnostic sample size in bytes
@@ -182,4 +184,37 @@ bool libcpumf_have_pai_ext(void);
* @retval false PAI_NNPA counter Facility is not available
*/
bool libcpumf_have_pai_nnpa(void);
/**
* Wrapper for the perf_event_open syscall used to configure performance events.
* This function simplifies usage of perf_event_open and provides a consistent
* interface for libcpumf internals.
*
* @param hw_event Pointer to perf_event_attr structure describing the event
* @param pid Target process ID (0 for current process)
* @param cpu Target CPU (-1 for all CPUs)
* @param group_fd File descriptor of event group leader, or -1 if none
* @param flags Additional flags (usually 0)
*
* @return File descriptor for the opened event on success
* @return -1 on failure, errno is set appropriately
*/
long perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd,
unsigned long flags);
/**
* Check if a counter name is present in a comma-separated list of counters.
*
* This function checks whether the given counter name appears in the
* provided list. If the list is NULL, the function assumes all counters
* are allowed and returns true.
*
* @param name Name of the counter to search for
* @param ctrlist Comma-separated list of counter names, or NULL
*
* @return true if the counter is in the list or list is NULL
* @return false otherwise
*/
bool ctr_in_list(char *name, char *ctrlist);
#endif

View File

@@ -0,0 +1,22 @@
/* SPDX-License-Identifier: MIT */
/*
* autocomp - command line autocompletion
*
* Generating autocompletion scripts for bash and zsh
* based on util_opt struct
*
* 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_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

@@ -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

19
include/lib/util_str.h Normal file
View File

@@ -0,0 +1,19 @@
/**
* @defgroup util_str_h util_str: String functions
* @{
* @brief Manipulate and work with strings
*
* 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_STR_H
#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);

202
include/lib/util_time.h Normal file
View File

@@ -0,0 +1,202 @@
/*
* 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
/**
* 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)))

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);

View File

@@ -15,6 +15,7 @@ install-man: $(MANS)
msection=`echo $$man |sed 's/.*\.\([1-9]\)$$/man\1/'` ; \
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 644 -D $$man $(DESTDIR)$(MANDIR)/$$msection/$$man ; \
done
ln -f -s chiucvallow.8 $(DESTDIR)$(MANDIR)/man8/lsiucvallow.8
clean:

View File

@@ -66,7 +66,7 @@ terminal application
To connect to the first z/VM IUCV HVC terminal device on the z/VM guest virtual
machine "LNX1234", run:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
iucvconn LNX1234 lnxhvc0
@@ -215,7 +215,7 @@ For each HVC terminal device, a \fBgetty\fP program must be started.
To configure and start \fBgetty\fP on a HVC terminal, open
.BR /etc/inittab (5),
and add a new entry similar to this one:
.ft CW
.ft CR
.in +0.25in
.nf
@@ -261,7 +261,7 @@ IUCV HVC terminal:
.IP "1." 4
To display the current terminal name, issue the command:
.ft CW
.ft CR
.in +0.25in
.nf
user@host:~$ echo $TERM
@@ -275,7 +275,7 @@ To connect to a z/VM IUCV HVC terminal, run
.BR iucvconn (1)
and log in as usual:
.ft CW
.ft CR
.in +0.25in
.nf
user@host:~$ iucvconn MYLNX01 lnxhvc0
@@ -289,7 +289,7 @@ user@MYLNX01:~$
To assign the terminal name from step 1. to the terminal environment variable,
issue the following command:
.ft CW
.ft CR
.in +0.25in
.nf
user@MYLNX01:~$ export TERM=xterm
@@ -304,7 +304,7 @@ environment variable.
.PP
For getty programs, a sample terminal environment configuration might look like:
.ft CW
.ft CR
.in +0.25in
.nf
h0:2345:respawn:/sbin/agetty -L 9600 hvc0 linux

View File

@@ -123,7 +123,7 @@ the characters to the connected terminal.
To access the "lnxterm" terminal on the Linux instance in
z/VM guest virtual machine LNXSYS01:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
iucvconn LNXSYS01 lnxterm
@@ -134,7 +134,7 @@ iucvconn LNXSYS01 lnxterm
To access the first z/VM IUCV HVC terminal on the Linux instance in
z/VM guest virtual machine LNXSYS02:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
iucvconn LNXSYS02 lnxhvc0
@@ -145,7 +145,7 @@ iucvconn LNXSYS02 lnxhvc0
To create a transcript of the terminal session to the Linux instance in
z/VM guest virtual machine LNXSYS99:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
iucvconn -s ~/transcripts/lnxsys99 LNXSYS99 lnxhvc0

View File

@@ -94,7 +94,7 @@ additional options.
.SH EXAMPLES
To allow remote logins using the terminal identifier "lnxterm":
.PP
.ft CW
.ft CR
.in +0.25in
.nf
iucvtty lnxterm
@@ -104,7 +104,7 @@ iucvtty lnxterm
To only allow users from LNXSYS01 to connect to terminal "lnxterm":
.PP
.ft CW
.ft CR
.in +0.25in
.nf
iucvtty -a LNXSYS01 lnxterm
@@ -115,7 +115,7 @@ iucvtty -a LNXSYS01 lnxterm
To only allow users from LNXSYS10 through LNXSYS19 to connect to terminal
"lnxterm":
.PP
.ft CW
.ft CR
.in +0.25in
.nf
iucvtty -a "LNXSYS1[0-9]" lnxterm
@@ -125,7 +125,7 @@ iucvtty -a "LNXSYS1[0-9]" lnxterm
To use \fB/sbin/sulogin\fP instead of \fB/bin/login\fP for terminal "suterm":
.PP
.ft CW
.ft CR
.in +0.25in
.nf
iucvtty suterm -- /sbin/sulogin
@@ -136,7 +136,7 @@ iucvtty suterm -- /sbin/sulogin
An entry in \fB/etc/inittab\fP to facilitate user logins on terminal "lnxterm"
with \fB/bin/login\fP could be:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
t1:2345:respawn:/usr/bin/iucvtty lnxterm
@@ -147,7 +147,7 @@ t1:2345:respawn:/usr/bin/iucvtty lnxterm
An entry in \fB/etc/inittab\fP to facilitate user logins on terminal "suterm"
with \fB/sbin/sulogin\fP in single user mode could be:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
s1:S:respawn:/usr/bin/iucvtty suterm -- /sbin/sulogin

View File

@@ -79,7 +79,7 @@ users".
The output for "list" authorization is a list of z/VM guest virtual machines,
for example:
.ft CW
.ft CR
.in +0.25i
.nf
@@ -94,7 +94,7 @@ guest5
.ft
The output for "regex" authorization is a list of one or more
regular expressions, for example:
.ft CW
.ft CR
.in +0.25i
.nf
@@ -109,7 +109,7 @@ Regular expressions for your authorization:
If \fBts-shell\fP is configured to connect to particular z/VM guest virtual
machines only, the output for "regex" authorization is followed by a list of
the user IDs that match at least one of the regular expressions:
.ft CW
.ft CR
.in +0.25i
.nf
@@ -139,7 +139,7 @@ To change the default terminal identifier, use the \fBterminal\fP command.
In the following example, a user opens a terminal connection to the Linux
instance in z/VM guest virtual machine LNXSYS01:
.ft CW
.ft CR
.in +0.25i
.nf
@@ -164,7 +164,7 @@ If \fBterminal\fP is called with the \fIidentifier\fP being specified,
If \fIidentifier\fP is not specified, the current default terminal identifier
is displayed:
.ft CW
.ft CR
.in +0.25i
.nf
user@ts-shell> terminal
@@ -212,7 +212,7 @@ guest virtual machines.
A typical \fBIUCV\fP authorization statement in the z/VM directory entry of the
terminal server z/VM guest virtual machine might be:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
IUCV ANY
@@ -301,7 +301,7 @@ instance.
For example, to create a list of all z/VM guest virtual machines with names that
start with "LINUX" and are followed by digits, use:
.ft CW
.ft CR
.in +0.25in
.nf
@@ -373,7 +373,7 @@ group name and prefixed with "@".
Here is an example of a Linux user and group authorization:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
alice = list:guest01,guest02
@@ -395,7 +395,7 @@ name on a separate line.
.PP
The following example shows the usage of the \fIfile:\fP prefix:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
@testgrp = file:/etc/iucvterm/auth/test-systems.list
@@ -427,7 +427,7 @@ To authorize user bob for all z/VM guest virtual machines with names that
start with "lnx" and are followed with at least three but not more than five
alphanumeric characters, use:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
bob = regex:lnx\\w{3,5}
@@ -441,7 +441,7 @@ test or production environment: authorize all users in the "testgrp" group for
all systems in the test environment; and respectively, authorize all users in
the "prodgrp" group for all systems in the production environment:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
@testgrp = regex:test\\w+
@@ -461,7 +461,7 @@ of the other type are ignored.
Example:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
@users = list:guest01,guest03,guest05
@@ -484,7 +484,7 @@ To use the \fBts-shell\fP as the login shell for Linux users, follow these steps
Add the path of the \fBts-shell\fP program to the \fI/etc/shells\fP file that
contains the list of valid login shells:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
echo $(which ts-shell) >> /etc/shells
@@ -498,7 +498,7 @@ Change the login shell of a particular Linux user using the
.BR chsh (1)
program:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
chsh -s $(which ts-shell) alice

View File

@@ -116,7 +116,7 @@ specifies an exit status in this range.
.SS inittab
To start \fB/sbin/agetty\fP on terminal device "hvc1", specify:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
h1:2345:respawn:/sbin/\*s hvc1 /sbin/agetty -L 9600 %t linux
@@ -128,7 +128,7 @@ h1:2345:respawn:/sbin/\*s hvc1 /sbin/agetty -L 9600 %t linux
To start \fB/sbin/agetty\fP on terminal device "hvc1", add the following
settings to the job file:
.PP
.ft CW
.ft CR
.in +0.25in
.nf
respawn

View File

@@ -10,7 +10,7 @@
*/
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include "lib/ccw.h"

View File

@@ -14,6 +14,7 @@
#include "lib/libcpumf.h"
#include "lib/util_path.h"
#include "lib/util_libc.h"
#define SERVICELEVEL "/proc/service_levels"
@@ -169,3 +170,31 @@ bool libcpumf_have_pai_nnpa(void)
{
return libcpumf_have_pai_sysfs(S390_SYSFS_PAI_NNPA);
}
long perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd,
unsigned long flags)
{
return syscall(__NR_perf_event_open, hw_event, pid, cpu, group_fd, flags);
}
bool ctr_in_list(char *name, char *ctrlist)
{
char *token;
char *list;
if (!ctrlist) /* No --counters means all counters */
return true;
list = util_strdup(ctrlist);
token = strtok(list, ",");
while (token) {
if (strcmp(token, name) == 0) {
free(list);
return true;
}
token = strtok(NULL, ",");
}
free(list);
return false;
}

View File

@@ -1,6 +1,6 @@
include ../common.mak
VERSION = 1.0
VERSION = 1.1
VERM = $(shell echo $(VERSION) | cut -d '.' -f 1)
ifneq (${HAVE_OPENSSL},0)
@@ -91,13 +91,13 @@ libekmfweb.so.$(VERSION): ALL_LDFLAGS += -shared -Wl,--version-script=libekmfweb
-Wl,-z,defs,-Bsymbolic -Wl,-soname,libekmfweb.so.$(VERM)
libekmfweb.so.$(VERSION): ekmfweb.o utilities.o cca.o $(libs)
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
ln -srf libekmfweb.so.$(VERSION) libekmfweb.so.$(VERM)
ln -srf libekmfweb.so.$(VERSION) libekmfweb.so
ln -sf libekmfweb.so.$(VERSION) libekmfweb.so.$(VERM)
ln -sf libekmfweb.so.$(VERSION) libekmfweb.so
install-libekmfweb.so.$(VERSION): libekmfweb.so.$(VERSION)
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 -T libekmfweb.so.$(VERSION) $(DESTDIR)$(SOINSTALLDIR)/libekmfweb.so.$(VERSION)
ln -srf $(DESTDIR)$(SOINSTALLDIR)/libekmfweb.so.$(VERSION) $(DESTDIR)$(SOINSTALLDIR)/libekmfweb.so.$(VERM)
ln -srf $(DESTDIR)$(SOINSTALLDIR)/libekmfweb.so.$(VERSION) $(DESTDIR)$(SOINSTALLDIR)/libekmfweb.so
ln -sf libekmfweb.so.$(VERSION) $(DESTDIR)$(SOINSTALLDIR)/libekmfweb.so.$(VERM)
ln -sf libekmfweb.so.$(VERSION) $(DESTDIR)$(SOINSTALLDIR)/libekmfweb.so
$(INSTALL) -d -m 755 $(DESTDIR)$(USRINCLUDEDIR)/ekmfweb
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 644 $(rootdir)include/ekmfweb/ekmfweb.h $(DESTDIR)$(USRINCLUDEDIR)/ekmfweb

View File

@@ -5099,14 +5099,15 @@ int ekmf_generate_csr(const struct ekmf_config *config,
}
}
_ekmf_copy_pss_params(rsa_pss_params, &pss_params);
if (rsa_pss_params != NULL)
_ekmf_copy_pss_params(rsa_pss_params, &pss_params);
rc = SK_OPENSSL_generate_csr(key_blob, key_blob_size,
subject_rdns, num_subject_rdns,
subject_utf8, cert,
extensions, num_extensions,
digest_nid, &pss_params, &req,
digest_nid, rsa_pss_params != NULL ?
&pss_params : NULL, &req,
&ext_lib_info.ext_lib, verbose);
if (rc != 0) {
pr_verbose(verbose, "SK_OPENSSL_generate_csr failed "
@@ -5245,14 +5246,16 @@ int ekmf_generate_ss_cert(const struct ekmf_config *config,
}
}
_ekmf_copy_pss_params(rsa_pss_params, &pss_params);
if (rsa_pss_params != NULL)
_ekmf_copy_pss_params(rsa_pss_params, &pss_params);
rc = SK_OPENSSL_generate_ss_cert(key_blob, key_blob_size,
subject_rdns, num_subject_rdns,
subject_utf8, rcert,
extensions, num_extensions,
validity_days, digest_nid,
&pss_params, &cert,
rsa_pss_params != NULL ?
&pss_params : NULL, &cert,
&ext_lib_info.ext_lib, verbose);
if (rc != 0) {
pr_verbose(verbose, "SK_OPENSSL_generate_ss_cert failed "
@@ -5280,6 +5283,85 @@ out:
return rc;
}
/**
* 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)
{
unsigned char key_blob[MAX_KEY_BLOB_SIZE];
size_t key_blob_size = sizeof(key_blob);
struct ext_lib_info ext_lib_info;
EVP_PKEY *pkey = NULL;
int rc;
if (config == NULL || ext_lib == NULL || x509_cert == NULL)
return -EINVAL;
if (config->identity_secure_key == NULL)
return -EINVAL;
_ekmf_copy_ext_lib(ext_lib, &ext_lib_info);
rc = SK_OPENSSL_init(verbose);
if (rc != 0) {
pr_verbose(verbose, "Failed to initialize secure key support: "
"%s", strerror(-rc));
return rc;
}
rc = read_key_blob(config->identity_secure_key, key_blob,
&key_blob_size);
if (rc != 0) {
pr_verbose(verbose, "Failed to read identity key from file "
"'%s': %s", config->identity_secure_key,
strerror(-rc));
goto out;
}
rc = SK_OPENSSL_get_secure_key_as_pkey(key_blob, key_blob_size,
false, &pkey,
&ext_lib_info.ext_lib, verbose);
if (rc != 0) {
pr_verbose(verbose, "Failed to get the PKEY from the identity "
"key: %s", strerror(-rc));
goto out;
}
#if !OPENSSL_VERSION_PREREQ(3, 0)
if (EVP_PKEY_cmp(pkey, X509_get0_pubkey(x509_cert)) != 1) {
#else
if (EVP_PKEY_eq(pkey, X509_get0_pubkey(x509_cert)) != 1) {
#endif
pr_verbose(verbose, "The certificate does not match with the "
"identity key");
rc = -EINVAL;
goto out;
}
pr_verbose(verbose, "Certificate successfully validated");
out:
if (pkey != NULL)
EVP_PKEY_free(pkey);
SK_OPENSSL_term();
return rc;
}
/**
* Close the connection to the EKMFWeb server by destroying the CURL handle.
*

View File

@@ -8,6 +8,7 @@ LIBEKMFWEB_1.0 {
ekmf_reencipher_identity_key;
ekmf_generate_csr;
ekmf_generate_ss_cert;
ekmf_validate_cert;
ekmf_get_public_key;
ekmf_get_settings;
ekmf_check_feature;
@@ -28,3 +29,9 @@ LIBEKMFWEB_1.0 {
ekmf_curl_destroy;
local: *;
};
LIBEKMFWEB_1.1 {
global:
ekmf_validate_cert;
local: *;
};

View File

@@ -113,13 +113,13 @@ libkmipclient.so.$(VERSION): ALL_LDFLAGS += -shared -Wl,--version-script=libkmip
libkmipclient.so.$(VERSION): kmip.o request.o response.o attribute.o key.o ttlv.o json.o \
xml.o https.o tls.o names.o utils.o
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
ln -srf libkmipclient.so.$(VERSION) libkmipclient.so.$(VERM)
ln -srf libkmipclient.so.$(VERSION) libkmipclient.so
ln -sf libkmipclient.so.$(VERSION) libkmipclient.so.$(VERM)
ln -sf libkmipclient.so.$(VERSION) libkmipclient.so
install-libkmipclient.so.$(VERSION): libkmipclient.so.$(VERSION)
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 -T libkmipclient.so.$(VERSION) $(DESTDIR)$(SOINSTALLDIR)/libkmipclient.so.$(VERSION)
ln -srf $(DESTDIR)$(SOINSTALLDIR)/libkmipclient.so.$(VERSION) $(DESTDIR)$(SOINSTALLDIR)/libkmipclient.so.$(VERM)
ln -srf $(DESTDIR)$(SOINSTALLDIR)/libkmipclient.so.$(VERSION) $(DESTDIR)$(SOINSTALLDIR)/libkmipclient.so
ln -sf libkmipclient.so.$(VERSION) $(DESTDIR)$(SOINSTALLDIR)/libkmipclient.so.$(VERM)
ln -sf libkmipclient.so.$(VERSION) $(DESTDIR)$(SOINSTALLDIR)/libkmipclient.so
$(INSTALL) -d -m 755 $(DESTDIR)$(USRINCLUDEDIR)/kmipclient
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 644 $(rootdir)include/kmipclient/kmipclient.h $(DESTDIR)$(USRINCLUDEDIR)/kmipclient

View File

@@ -233,7 +233,7 @@ out:
if (server_cert != NULL)
X509_free(server_cert);
return 0;
return rc;
}
/**

View File

@@ -1,13 +1,16 @@
include ../common.mak
include ../common_autocomp.mak
lib := libutil.a
sources := $(filter-out %_example.c,$(wildcard *.c))
sources := $(filter-out %_example.c %_host.c, $(wildcard *.c))
objects := $(patsubst %.c,%.o,$(sources))
autocomp-object := util_autocomp_host.o
examples := $(patsubst %.c,%,$(wildcard *_example.c))
all: $(lib)
all: $(lib) $(autocomp-object)
examples: $(examples)
$(examples): %: %.o $(lib)

View File

@@ -0,0 +1,299 @@
// SPDX-License-Identifier: MIT
/*
* autocomp - command line autocompletion
*
* Generating autocompletion scripts for bash and zsh
* based on util_opt struct
*
* 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.
*
*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "lib/util_autocomp.h"
#include "lib/util_opt.h"
static const char *bash_script_part1 = "() {\n\n\
\tlocal current_word previous_word options_array\n\n\
\tCOMPREPLY=()\n\n\
\tcurrent_word=\"${COMP_WORDS[COMP_CWORD]}\"\n\n\
\tprevious_word=\"${COMP_WORDS[COMP_CWORD-1]}\"\n\n\
\toptions_array=\"";
static const char *bash_script_part2 = "\tif [[ ${current_word} == -* || ${COMP_CWORD} -eq 1 ]] ; then\n\n\
\t\tCOMPREPLY=( $(compgen -W \"${options_array}\" -- ${current_word} ) )\n\n\
\t\treturn 0\n\n\
\tfi\n\n\
}\n\n\
complete -F ";
static char *format_name(const char *fmt, char *tool_name)
{
char *func_name;
if (asprintf(&func_name, fmt, tool_name) == -1)
return NULL;
return func_name;
}
/*
* The convention for a completion function name is to be the same
* as the command's name, but prefixed by '_'.
*/
static char *generate_func_name(char *tool_name)
{
return format_name("_%s", tool_name);
}
static char *generate_bash_filename(char *tool_name)
{
return format_name("%s.bash", tool_name);
}
static int init_scriptfile(char *file_path)
{
int fd;
fd = open(file_path, O_CREAT | O_WRONLY, 0644);
if (fd < 0)
return -EIO;
return fd;
}
static int start_bash_scriptfile(int fd, char *func_name)
{
int len, ret = 0;
char *str;
len = asprintf(&str, "%s%s", func_name, bash_script_part1);
if (len == -1)
return -EIO;
if (write(fd, str, len) != len)
ret = -EIO;
free(str);
return ret;
}
static int start_zsh_scriptfile(int fd, char *func_name, char *tool_name)
{
const char *part3 = " {\n\n\t_arguments -C \\\n";
const char *part2 = "\n\nfunction ";
const char *part1 = "#compdef ";
int len, ret = 0;
char *str;
len = asprintf(&str, "%s%s%s%s%s", part1, tool_name, part2, func_name, part3);
if (len == -1)
return -EIO;
if (write(fd, str, len) != len)
ret = -EIO;
free(str);
return ret;
}
static int write_bash_command_options(struct util_opt *opt_vec, int fd)
{
const char *prefix = " --";
char *str;
int len;
for (int i = 0; opt_vec[i].desc; i++) {
if (opt_vec[i].option.name) {
len = asprintf(&str, "%s%s", prefix, opt_vec[i].option.name);
if (len == -1)
return -EIO;
if (write(fd, str, len) != len) {
free(str);
return -EIO;
}
free(str);
}
}
if (write(fd, "\"\n\n", 3) != 3)
return -EIO;
return 0;
}
static int write_zsh_command_options(struct util_opt *opt_vec, int fd)
{
const char *name, *desc;
char *str;
int len;
for (int i = 0; opt_vec[i].desc; i++) {
if (opt_vec[i].option.name) {
name = opt_vec[i].option.name;
desc = opt_vec[i].desc;
len = asprintf(&str, "\t\t\"--%s[%s]\" \\\n", name, desc);
if (len == -1)
return -EIO;
if (write(fd, str, len) != len) {
free(str);
return -EIO;
}
free(str);
}
}
if (write(fd, "\n}\n", 3) != 3)
return -EIO;
return 0;
}
static int finish_bash_scriptfile(char *tool_name, int fd, char *func_name)
{
int len, ret = 0;
char *str;
len = asprintf(&str, "%s%s %s\n", bash_script_part2, func_name, tool_name);
if (len == -1)
return -EIO;
if (write(fd, str, len) != len)
ret = -EIO;
free(str);
return ret;
}
/*
* Adds tab completion in bash for a command.
* Works by generating an autocompletion
* script file at '/usr/share/bash-completion/completions'.
*
* The full script will be as follows, supposing the tool name is
* 'example' and it only has the options '--help' and
* '--version':
*
* _example() {
*
* local current_word previous_word options_array
*
* COMPREPLY=()
*
* current_word="${COMP_WORDS[COMP_CWORD]}"
*
* previous_word="${COMP_WORDS[COMP_CWORD-1]}"
*
* options_array="--version --help"
*
* if [[ ${current_word} == -* || ${COMP_CWORD} -eq 1 ]] ; then
*
* COMPREPLY=( $(compgen -W "${options_array}" -- ${current_word} ) )
*
* return 0
*
* fi
*
* }
*
* complete -F _example example
*
*/
static void generate_bash_autocomp(struct util_opt *opt_vec, char *tool_name)
{
char *func_name, *filename;
int fd, ret = 0;
func_name = generate_func_name(tool_name);
if (!func_name) {
ret = -ENOMEM;
goto end;
}
filename = generate_bash_filename(tool_name);
if (!filename) {
ret = -ENOMEM;
goto free_func;
}
fd = init_scriptfile(filename);
if (fd < 0) {
ret = fd;
goto free_file;
}
ret = start_bash_scriptfile(fd, func_name);
if (ret < 0)
goto close;
ret = write_bash_command_options(opt_vec, fd);
if (ret < 0)
goto close;
ret = finish_bash_scriptfile(tool_name, fd, func_name);
close:
close(fd);
if (ret)
remove(filename);
free_file:
free(filename);
free_func:
free(func_name);
end:
printf(" AUTOCOMP\t%s/%s.bash\n", tool_name, tool_name);
if (ret)
printf("%s.bash: error - %s\n", tool_name, strerror(abs(ret)));
}
/*
* Adds tab completion in zsh for a command.
* Works by generating an autocompletion
* script file at '/usr/share/zsh/site-functions'.
*
* The full script will be as follows, supposing the tool name is
* 'example' and it only has the options '--help', -h and
* '--version' (the descriptions, as well as the flags are
* taken from a util_opt struct):
*
* #compdef example_completion
*
* function _example_completion {
*
* _arguments -C \
* "-h[Show help information]" \
* "--help[Show help but long format]" \
* "--version[Show version]"
* }
*
*/
static void generate_zsh_autocomp(struct util_opt *opt_vec, char *tool_name)
{
char *func_name;
int fd, ret = 0;
func_name = generate_func_name(tool_name);
if (!func_name) {
ret = -ENOMEM;
goto end;
}
fd = init_scriptfile(func_name);
if (fd < 0) {
ret = fd;
goto free_func;
}
ret = start_zsh_scriptfile(fd, func_name, tool_name);
if (ret < 0)
goto close;
ret = write_zsh_command_options(opt_vec, fd);
close:
close(fd);
if (ret)
remove(func_name);
free_func:
free(func_name);
end:
printf(" AUTOCOMP\t%s/_%s\n", tool_name, tool_name);
if (ret)
printf("_%s: error - %s\n", tool_name, strerror(abs(ret)));
}
void generate_autocomp(struct util_opt *opt_vec, char *tool_name)
{
generate_bash_autocomp(opt_vec, tool_name);
generate_zsh_autocomp(opt_vec, tool_name);
}

View File

@@ -544,19 +544,6 @@ int util_file_read_va(const char *path, const char *fmt, ...)
return ret;
}
/**
* Print an error message indicating an out-of-memory situation and exit.
*/
static void oom(void)
{
fprintf(stderr, "Out of memory\n");
/* We can't rely on our clean-up routines to work reliably during an
* OOM situation, so just exit here.
*/
exit(UTIL_EXIT_OUT_OF_MEMORY);
}
/**
* Read all data from @fd and return address of resulting buffer in
* @buffer_ptr. If @size_ptr is non-zero, use it to store the size of the
@@ -576,9 +563,7 @@ util_exit_code_t util_file_read_fd_buf(FILE *fd, void **buffer_ptr,
size_t done = 0;
while (!feof(fd)) {
buffer = realloc(buffer, done + READ_CHUNK_SIZE);
if (!buffer)
oom();
buffer = util_realloc(buffer, done + READ_CHUNK_SIZE);
done += fread(&buffer[done], 1, READ_CHUNK_SIZE, fd);
if (ferror(fd)) {
free(buffer);
@@ -586,9 +571,7 @@ util_exit_code_t util_file_read_fd_buf(FILE *fd, void **buffer_ptr,
}
}
buffer = realloc(buffer, done);
if (!buffer && done > 0)
oom();
buffer = util_realloc(buffer, done);
*buffer_ptr = buffer;
if (size_ptr)
@@ -635,9 +618,7 @@ char *util_file_read_fd(FILE *fd, int chomp)
done--;
/* NULL-terminate. */
buffer = realloc(buffer, done + 1);
if (!buffer)
oom();
buffer = util_realloc(buffer, done + 1);
buffer[done] = 0;
return buffer;

Some files were not shown because too many files have changed in this diff Show More