Freeing AP queues for KVM guests
![]()
By default, the zcrypt device driver controls all AP queues on a Linux® instance. Free AP queues from zcrypt to make them available to alternative device drivers, such as vfio_ap.
The vfio_ap device driver controls AP queues on behalf of KVM guests. While vfio_ap is the only eligible alternative device driver, freeing an AP queue from zcrypt makes it available to vfio_ap.Before you begin
Free AP queues only if your Linux instance is a KVM host that needs to provide these AP queues to its KVM guests.
Do not change the settings for adapters or domains that are in use or reserved for another exploiter. In particular, do not bring already freed adapters or queues back under control of the zcrypt device driver while they are assigned to a KVM guest.
About this task
Two masks rule which AP queues are controlled by the zcrypt device driver and which are available to alternative device drivers, such as vfio_ap.
- Adapter mask
- The adapter mask is a 256-bit value, each bit representing a cryptographic adapter. The leftmost
bit represents the adapter with ID
0x00. In sysfs, the mask is available as the value of attribute /sys/bus/ap/apmask. If an adapter bit is set to 0, all AP queues on this adapter are available to alternative device drivers, across all domains. - Domain mask
- The domain mask is a 256-bit value, each bit representing a cryptographic domain. The leftmost
bit represents the domain with ID
0x0000. In sysfs, the mask is available as the value of attribute /sys/bus/ap/aqmask. If a domain bit is set to 0, all AP queues with this domain are available to alternative device drivers, across all adapters.
- For an adapter mask
0x8000..., the bit for adapter0x00is 1 and all others are 0. - For a adapter mask
0xFF00..., bits for adapters0x00to0x07are 1 and all others are 0.
zcrypt controls all AP queues for which both the adapter bit and the domain bit
are set to 1. The default for both masks is 1 for all bits. Hence, the default
value for both masks in sysfs is
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff and
zcrypt is the default device driver for all AP queues. To free an AP queue for alternative device drivers, the corresponding adapter bit, or the corresponding
domain bit, or both must be set to 0.You can use kernel parameters to set the mask. On a running Linux instance, you can write to the respective sysfs attribute to change the masks.
Procedure
Results
0x01, across all domains, and domains 0x0001 and
0x0002, across all adapters, are ignored by the zcrypt device
driver and thus, free for alternative device
drivers.# cat /sys/bus/ap/apmask 0xbfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff # cat /sys/bus/ap/aqmask 0x9fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff