diff options
| author | Harald Freudenberger <freude@linux.ibm.com> | 2025-11-19 16:27:38 +0100 |
|---|---|---|
| committer | Heiko Carstens <hca@linux.ibm.com> | 2025-11-24 11:43:06 +0100 |
| commit | 46030379f13c3f07c699dcaf034a50f023f77925 (patch) | |
| tree | 82660a12358e3d7cff11f5c2a2e9e20318086d86 /drivers/s390/crypto/ap_queue.c | |
| parent | 8babcc2b6a75d1eced723a78cb67b3ff6abac8b0 (diff) | |
s390/ap: Restrict driver_override versus apmask and aqmask use
Introduce a restriction for the driver_override feature versus apmask
and aqmask:
- driver_override is only allowed when the apmask and aqmask values
both are default (=0xffff..ffff).
- apmask and aqmask modifications are only allowed when there is no
driver_override on any AP device active.
So in the end the user is restricted to choose to either use
apmask/apmask to divide the AP devices into host owned and vfio owned
or use the driver_override feature but not mix these two approaches.
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'drivers/s390/crypto/ap_queue.c')
| -rw-r--r-- | drivers/s390/crypto/ap_queue.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/s390/crypto/ap_queue.c b/drivers/s390/crypto/ap_queue.c index f05ff54f4c4b..4fe443d30f9b 100644 --- a/drivers/s390/crypto/ap_queue.c +++ b/drivers/s390/crypto/ap_queue.c @@ -755,13 +755,30 @@ static ssize_t driver_override_store(struct device *dev, { struct ap_queue *aq = to_ap_queue(dev); struct ap_device *ap_dev = &aq->ap_dev; - int rc; + int rc = -EINVAL; + bool old_value; + + if (mutex_lock_interruptible(&ap_attr_mutex)) + return -ERESTARTSYS; + + /* Do not allow driver override if apmask/aqmask is in use */ + if (ap_apmask_aqmask_in_use) + goto out; + old_value = ap_dev->driver_override ? true : false; rc = driver_set_override(dev, &ap_dev->driver_override, buf, count); if (rc) - return rc; + goto out; + if (old_value && !ap_dev->driver_override) + --ap_driver_override_ctr; + else if (!old_value && ap_dev->driver_override) + ++ap_driver_override_ctr; - return count; + rc = count; + +out: + mutex_unlock(&ap_attr_mutex); + return rc; } static DEVICE_ATTR_RW(driver_override); |
