Commit Graph

29 Commits

Author SHA1 Message Date
Szabina Korbai
a5af5bcf70 zcrypt: Implement zsh and bash autocompletion
Add generation of shell autocompletion scripts
to chzcrypt, lszcrypt and zcryptstats.

Acked-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Szabina Korbai <szkorbai@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-04-30 08:51:04 +02:00
Harald Freudenberger
d0046257b6 lszcrypt/chzcrypt: Warn if default domain is unavailable
Improvements for lszcrypt and chzcrypt:
* lszcrypt -b and lszcrypt -d now check for default domain
  available and gives a warning if the current default domain
  is not in the usage_domain_mask of the AP bus.
* lszcrypt without any further device also checks for the
  default domain and emits a warning string if the default
  domain is not available.
* chzcrypt --default-domain emits a warning if the newly
  set default domain is not enabled in the usage_domain_mask
  of the AP bus.

Suggested-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:25:25 +01:00
Holger Dengler
1afa6efb26 lszcrypt: Change exit code to 0 for empty device list
An empty device list is not an error case, if `lszcrypt` is called
without a specific device list or device filter. Return with rc == 0 in
such cases.

Remove the message about the empty device list on stderr.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-03-11 11:24:42 +01:00
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
Harald Freudenberger
300f8d23b5 lszcrypt: Fix wrong state showing up for removed AP queue within SE guest
When a queue is removed from a SE guest which was in a state other
than "usable" (for example "unbound") the state displayed by lszcrypt
switches to "usable" until the queue device is finally removed by the
AP bus scan running every 30s.

This intermediate state is caused by reading 0x00000000 on the
underlying /sys/devices/cardxx/xx.yyyy/ap_functions. lszcrypt only
extracts the BS bits from this value and maps these both bits to
string output
  0: "usable"
  1: "bound"
  2: "unbound"
  3: "illicit"
totally ignoring the fact that there is no AP function at all.

Now the code checks for a valid ap_functions value first, before
actually extracting and displaying the SE state. In case the
ap_functions reads as 0x00000000 lszcrypt now displays the string
"invalid".

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2024-10-25 11:57:44 +02:00
Harald Freudenberger
8235e025d4 zcrypt/lszcrypt: Improve lszcrypt output on SE guests
The AP queue states within a SE guest may have a so called asynchronous
error pending. When that's the case, the sysfs read of some AP queue
attributes fails with EIO. lszcrypt was not really prepared for this
and instead showed some incorrect output.

This patch fixes this oddity and now lszcrypt -c shows "error" in case
of ap_bound or ap_associate read errors and lszcrypt -V shows also
"error" if the BS bits could not get fetched.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2023-09-27 18:29:06 +02:00
Harald Freudenberger
f821f31a51 lszcrypt: Support for SE AP pass-through support
This patch adds support for Secure Execution with AP pass-through
support for lszcrypt.

lszcrypt details:
* extension to -b: list AP bus features
* extension to -c: now also valid for queue devices, shows
		   bind and assoicate state in SE environment;
		   shows MK states (only for current MKs).
* extension to -V: new column SESTAT within an SE guest, shows text
		   for the BS bits within an SE environment:
		   "usable", "bond", "avail", "unuse".

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2023-07-04 15:40:47 +02:00
Holger Dengler
c142bb0625 lszcrypt: use separate index for inner sub-device loop
The function show_devices_argv() iterates over all remaining
arguments. Each argument may specify a single device or a list of
sub-devices. Use a separate index for the inner sub-device loop. This
fixes a bug, that not all or wrong arguments are processed.

Also terminate the outer arguments loop based on the number of
remaining arguments.

Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2023-03-03 09:50:53 +01:00
Holger Dengler
ec04a1846e lszcrypt: use type-filter option also for sub-devices
The tools lszcrypt provides filter options for card types. Use these
options not only for devices (cards), but also for sub-devices
(domains).

Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2023-03-03 09:50:53 +01:00
Harald Freudenberger
8a878a0d61 lszcrypt: display hardware filtering support capability
The CEX8 card has in CCA mode a new capability 'stateless
hardware filtering support' which is now displayed as
'H' bit in the FUNCTIONS column and with the -c option.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2023-02-14 13:03:06 +01:00
Holger Dengler
538264a8cd lszcrypt: fix parameter handling for device list
lszcrypt allows the explicit definition of a list of devices. Continue
the parameter processing if multiple devices are specified.

Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-By: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2022-10-22 20:27:16 +02:00
Harald Freudenberger
46fd42af0c lszcrypt: new option to show the serial numbers of CCA and EP11 cards
The new option -s, long --serial shows the serial numbers of
CCA and EP11 cards.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2022-03-09 12:11:49 +01:00
Harald Freudenberger
a8b0d7ace8 lszcrypt: new options to filter cards/queues only
New options:
  --cardonly
  --queueonly
which filter the output to show only card or queue information.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2022-03-09 12:11:49 +01:00
Harald Freudenberger
a29b3c8997 lszcrypt: new options to show only accel, cca or ep11 cards/queues
New options:
  --accelonly
  --ccaonly
  --ep11only
which restrict the output to only cards/queues with the given mode.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2022-03-09 12:11:49 +01:00
Harald Freudenberger
27dce3317a lszcrypt: add support for checkstop state
Newer kernel show a sysfs attribute chkstop which displays
the checkstop state of a crypto card. This patch enables
support for lszcrypt to display the checkstop state.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2022-03-09 12:11:49 +01:00
Harald Freudenberger
4382901daa lszcrypt: show AP bus msg size limit capability
If there is a max_msg_size attribute for the card
the lszcrypt -c option will show this limit as
  AP bus max message size limit xx Kb

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2022-03-09 12:11:45 +01:00
Harald Freudenberger
b16a6d4fe1 lszcrypt: add CEX8S support
Recognize AP type 14 as CEX8S crypto express card.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2022-03-09 12:11:42 +01:00
Harald Freudenberger
890b15d158 lszcrypt: add support for vfio-ap status field
lszcrypt now evaluates and displays the 'status' in the
'STATUS' column if the vfio provides this sysfs attribute.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2021-09-30 17:20:52 +02:00
Harald Freudenberger
07677668a3 lszcrypt: online is status and now tracked as status
The 'STATUS' field was within the code used as 'online'
record because it showed the online state. But now it
displays some more info like 'deconfig' and maybe even
more in the future. So now the code also uses a 'status'
record for this info.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2021-09-30 17:20:52 +02:00
Harald Freudenberger
fde914fd1c lszcrypt: Improved output for deconfig cards and queues
Slight rework of the lszcrypt code with:
- a queue or card in deconfigured mode is displayed
  as 'deconfig' regardless which driver is bound to
  the device.
- a queue or card in 'deconfig' mode does not show
  any counters any more but displays a '-' instead.
- a queue not bound or bound to something else as
  the 'default' zcrypt dd does not show any counters
  but displays a '-' instead.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2021-09-30 17:20:52 +02:00
Ingo Franzki
3e818c53b2 zconf/zcrypt: Fix sparse warnings
A compile with sparse (make C=1) shows a couple of warnings:
like:

  chzcrypt.c:36:3: warning: symbol 'l' was not declared.
  Should it be static?

  lszcrypt.c: In function 'show_device':
  lszcrypt.c:556:9: warning: 'card' may be used uninitialized
  [-Wmaybe-uninitialized]

Fix those warnings.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2021-07-05 13:55:54 +02:00
Harald Freudenberger
6eddae9a8a zcrypt: Support new config state with lszcrypt and chzcrypt
lszcrypt now shows a card/queue which is in 'deconfigured' state as
'deconfig' in the STATE column (verbose and non verbose mode).

chzcrypt became two new options: --config-on and --config-off to
switch one or more card devices to 'configured' or 'deconfigured'
state.

Both applications are able to handle older kernels which do now
provide the config sysfs attribute required for this new feature.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-10-12 13:12:55 +02:00
Harald Freudenberger
4fc0c3cfef zcrypt: CEX7S exploitation support
This patch adds CEX7S exploitation support to lszcrypt and chzcrypt.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-09-18 12:55:17 +02:00
Jan Höppner
b631c74df5 lszcrypt: Replace sprintf() with util_asprintf()
Get rid of fixed buffers and avoid the following GCC8 compile warnings:

lszcrypt.c: In function ‘main’:
lszcrypt.c:642:28: warning: ‘%04x’ directive writing between 4 and 8
bytes into a region of size between 7 and 13 [-Wformat-overflow=]
     sprintf(sub_dev, "%02x.%04x", id, dom);
                            ^~~~
lszcrypt.c:642:22: note: directive argument in the range [0, 2147483647]
     sprintf(sub_dev, "%02x.%04x", id, dom);
                      ^~~~~~~~~~~
lszcrypt.c:642:5: note: ‘sprintf’ output between 8 and 18 bytes into a
destination of size 16
     sprintf(sub_dev, "%02x.%04x", id, dom);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Harald Freudenberger
0a0b4c3826 lszcrypt: support for alternate zcrypt device drivers
With kernel 4.19 there comes an extension to the existing
AP bus which supports alternate zcrypt drivers. For details
about this see kernel patch "s390/zcrypt: AP bus support for
alternate driver(s)". So now lszcrypt displays the driver
name in verbose mode. As some of the information displayed
by lszcrypt was based on sysfs attributes, which are only
available when the default zcrypt driver is bound to the
device, this also needed some rework. If a sysfs attribute
is not available because of an alternate driver binding
(or no driver) a question mark is printed into the field.

Together with this a slight rework of the displayed information
has been done. The two columns for pending requests and pending
replies has been merged to one pending column and the column
sizes have been adjusted.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-09-17 14:26:29 +02:00
Harald Freudenberger
31866fbfa4 lszcrypt: CEX6S exploitation
With z14 there comes a new crypto card 'CEX6S'.

This patch introduces the s390-tools changes needed
to list the new card and show the capabilities correctly.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-18 14:53:06 +02:00
Harald Freudenberger
6b8b336cf0 lszcrypt: Fix core dump caused by stack overwrite.
There was a too tight buffer allocated on the stack
which was overwritten by just one byte caused to
dump the application on function exit's stack check.
Reviewed all the buffer sizes and adapted them
to the need of the functions.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-06 13:03:31 +02:00
Harald Freudenberger
73d5e17026 lszcrypt: fix random domain printout when no config available
The sysfs files ap_control_domain_mask and ap_usage_domain_mask
may hold just a string "not supported" if there's no crypto
configuration available. However, lszcrypt always processed
the content of these files as hex number and so produced funny
output if there's no configuration data available.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-31 17:41:15 +02:00
Michael Holzheu
b627b8d8e1 Initial s390-tools-2.0.0 import
This commit is based on the s390-tools-1.39.0 version.

Changes on top of s390-tools-1.39.0:

 - Add MIT license to all source files
 - Add LICENSE file
 - Transform REAMDE to README.md (markdown)
 - Add AUTHORS.md file
 - Add CONTRIBUTING.md file
 - Move changelog from README to CHANGELOG.md file

Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-21 10:55:40 +02:00