cxl/memdev: Improve sanitize ABI descriptions
Subsystems (3)
PATCH 1/3 cxl/memdev: Improve sanitize ABI descriptions
From: Davidlohr Bueso <[email protected]>
Be more detailed about the CPU cache management situation. The same goes for both sanitize and secure erase.
--- Documentation/ABI/testing/sysfs-bus-cxl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
Documentation/ABI/testing/sysfs-bus-cxl +11 -2
@@ -82,7 +82,11 @@ Description: whether it resides in persistent capacity, volatile capacity, or the LSA, is made permanently unavailable by whatever means is appropriate for the media type. This functionality requires - the device to be not be actively decoding any HPA ranges. + the device to be disabled, that is, not actively decoding any + HPA ranges. This permits avoiding explicit global CPU cache + management, relying instead for it to be done when a region + transitions between software programmed and hardware committed + states. What /sys/bus/cxl/devices/memX/security/erase
@@ -92,7 +96,12 @@ Contact: [email protected] Description: (WO) Write a boolean 'true' string value to this attribute to secure erase user data by changing the media encryption keys for - all user data areas of the device. + all user data areas of the device. This functionality requires + the device to be disabled, that is, not actively decoding any + HPA ranges. This permits avoiding explicit global CPU cache + management, relying instead for it to be done when a region + transitions between software programmed and hardware committed + states. What: /sys/bus/cxl/devices/memX/firmware/
Signature · 1 line
2.34.1
PATCH 1/1 drivers: base: Free devm resources when unregistering a device
From: David Gow <[email protected]>
In the current code, devres_release_all() only gets called if the device has a bus and has been probed.
This leads to issues when using bus-less or driver-less devices where the device might never get freed if a managed resource holds a reference to the device. This is happening in the DRM framework for example.
We should thus call devres_release_all() in the device_del() function to make sure that the device-managed actions are properly executed when the device is unregistered, even if it has neither a bus nor a driver.
This is effectively the same change than commit 2f8d16a996da ("devres:
release resources on device_del()") that got reverted by commit a525a3ddeaca ("driver core: free devres in device_release") over memory leaks concerns.
This patch effectively combines the two commits mentioned above to release the resources both on device_del() and device_release() and get the best of both worlds.
--- drivers/base/core.c | 11 +++++++++++ drivers/base/test/platform-device-test.c | 2 -- drivers/base/test/root-device-test.c | 2 -- 3 files changed, 11 insertions(+), 4 deletions(-)
drivers/base/core.c +11 -0
@@ -3817,6 +3817,17 @@ void device_del(struct device *dev)device_platform_notify_remove (dev);device_links_purge (dev); +/* +* If a device does not have a driver attached, we need to clean +* up any managed resources. We do this in device_release(), but +* it's never called (and we leak the device) if a managed +* resource holds a reference to the device. So release all +* managed resources here, like we do in driver_detach(). We +* still need to do so again in device_release() in case someone +* adds a new resource after this point, though. +*/ +devres_release_all (dev); +bus_notify (dev,BUS_NOTIFY_REMOVED_DEVICE );kobject_uevent (&dev->kobj,KOBJ_REMOVE ); glue_dir =get_glue_dir (dev);
drivers/base/test/platform-device-test.c +0 -2
@@ -87,8 +87,6 @@ static void platform_device_devm_register_get_unregister_with_devm_test(struct kstruct test_priv *priv = test->priv;int ret; -kunit_skip (test,"This needs to be fixed in the core." ); - pdev =platform_device_alloc (DEVICE_NAME ,PLATFORM_DEVID_NONE );KUNIT_ASSERT_NOT_ERR_OR_NULL (test, pdev);
drivers/base/test/root-device-test.c +0 -2
@@ -78,8 +78,6 @@ static void root_device_devm_register_get_unregister_with_devm_test(struct kunitstruct test_priv *priv = test->priv;int ret; -kunit_skip (test,"This needs to be fixed in the core." ); - priv->dev =root_device_register (DEVICE_NAME );KUNIT_ASSERT_NOT_ERR_OR_NULL (test, priv->dev);
Signature · 1 line
2.34.1
PATCH 2/3 cxl/memdev: Document security state in kern-doc
In reply to Dongsheng YangFrom: Davidlohr Bueso <[email protected]>
... as is the case with all members of struct cxl_memdev_state.
--- drivers/cxl/cxlmem.h | 1 + 1 file changed, 1 insertion(+)
drivers/cxl/cxlmem.h +1 -0
@@ -434,6 +434,7 @@ struct cxl_dev_state {* @next_persistent_bytes: persistent capacity change pending device reset * @event: event log driver state * @poison: poison driver state info +* @security: security driver state info * @fw: firmware upload / activation state * @mbox_send: @dev specific transport for transmitting mailbox commands *
Signature · 1 line
2.34.1
PATCH 3/3 cxl/memdev: Only show sanitize sysfs files when supported
In reply to Dongsheng YangFrom: Davidlohr Bueso <[email protected]>
If the device does not support Sanitize or Secure Erase commands, hide the respective sysfs interfaces such that the operation can never be attempted.
In order to be generic, keep track of the enabled security commands found in the CEL - the driver does not support Security Passthrough.
--- Documentation/ABI/testing/sysfs-bus-cxl | 6 ++-- drivers/cxl/core/mbox.c | 45 ++++++++++++++++++++++++- drivers/cxl/core/memdev.c | 19 +++++++++++ drivers/cxl/cxlmem.h | 15 +++++++++ 4 files changed, 82 insertions(+), 3 deletions(-)
Documentation/ABI/testing/sysfs-bus-cxl +4 -2
@@ -86,7 +86,8 @@ Description: HPA ranges. This permits avoiding explicit global CPU cache management, relying instead for it to be done when a region transitions between software programmed and hardware committed - states. + states. If this file is not present, then there is no hardware + support for the operation. What /sys/bus/cxl/devices/memX/security/erase
@@ -101,7 +102,8 @@ Description: HPA ranges. This permits avoiding explicit global CPU cache management, relying instead for it to be done when a region transitions between software programmed and hardware committed - states. + states. If this file is not present, then there is no hardware + support for the operation. What: /sys/bus/cxl/devices/memX/firmware/
drivers/cxl/core/mbox.c +44 -1
63 lines not on this page · raw message
drivers/cxl/core/memdev.c +19 -0
@@ -477,9 +477,28 @@ static struct attribute_group cxl_memdev_pmem_attribute_group = { .attrs = cxl_memdev_pmem_attributes, }; +static umode_t cxl_memdev_security_visible (struct kobject *kobj, +struct attribute *a,int n) +{ +struct device *dev =kobj_to_dev (kobj); +struct cxl_memdev *cxlmd =to_cxl_memdev (dev); +struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlmd->cxlds); + +if (a == &dev_attr_security_sanitize.attr && + !test_bit (CXL_SEC_ENABLED_SANITIZE , mds->security.enabled_cmds)) +return 0 ; + +if (a == &dev_attr_security_erase.attr && + !test_bit (CXL_SEC_ENABLED_SECURE_ERASE , mds->security.enabled_cmds)) +return 0 ; + +return a->mode; +} +static struct attribute_group cxl_memdev_security_attribute_group = { .name ="security" , .attrs = cxl_memdev_security_attributes, + .is_visible = cxl_memdev_security_visible, };static const struct attribute_group *cxl_memdev_attribute_groups[] = {
drivers/cxl/cxlmem.h +15 -0
@@ -244,6 +244,19 @@ enum poison_cmd_enabled_bits { CXL_POISON_ENABLED_MAX }; +/* Device enabled security commands */ +enum security_cmd_enabled_bits { +CXL_SEC_ENABLED_SANITIZE , +CXL_SEC_ENABLED_SECURE_ERASE , +CXL_SEC_ENABLED_GET_SECURITY_STATE , +CXL_SEC_ENABLED_SET_PASSPHRASE , +CXL_SEC_ENABLED_DISABLE_PASSPHRASE , +CXL_SEC_ENABLED_UNLOCK , +CXL_SEC_ENABLED_FREEZE_SECURITY , +CXL_SEC_ENABLED_PASSPHRASE_SECURE_ERASE , +CXL_SEC_ENABLED_MAX +}; +/** * struct cxl_poison_state - Driver poison state info *
@@ -346,6 +359,7 @@ struct cxl_fw_state {* struct cxl_security_state - Device security state * * @state: state of last security operation +* @enabled_cmds: All security commands enabled in the CEL * @poll: polling for sanitization is enabled, device has no mbox irq support * @poll_tmo_secs: polling timeout * @poll_dwork: polling work item
@@ -353,6 +367,7 @@ struct cxl_fw_state {*/ struct cxl_security_state {unsigned long state; + DECLARE_BITMAP(enabled_cmds, CXL_SEC_ENABLED_MAX);bool poll;int poll_tmo_secs;struct delayed_work poll_dwork;
Signature · 1 line
2.34.1
PATCH 1/1 cxl/memdev: Only show sanitize sysfs files when supported
In reply to Dongsheng YangFrom: Davidlohr Bueso <[email protected]>
If the device does not support Sanitize or Secure Erase commands, hide the respective sysfs interfaces such that the operation can never be attempted.
In order to be generic, keep track of the enabled security commands found in the CEL - the driver does not support Security Passthrough.
--- Documentation/ABI/testing/sysfs-bus-cxl | 6 ++-- drivers/cxl/core/mbox.c | 45 ++++++++++++++++++++++++- drivers/cxl/core/memdev.c | 19 +++++++++++ drivers/cxl/cxlmem.h | 15 +++++++++ 4 files changed, 82 insertions(+), 3 deletions(-)
Documentation/ABI/testing/sysfs-bus-cxl +4 -2
@@ -86,7 +86,8 @@ Description: HPA ranges. This permits avoiding explicit global CPU cache management, relying instead for it to be done when a region transitions between software programmed and hardware committed - states. + states. If this file is not present, then there is no hardware + support for the operation. What /sys/bus/cxl/devices/memX/security/erase
@@ -101,7 +102,8 @@ Description: HPA ranges. This permits avoiding explicit global CPU cache management, relying instead for it to be done when a region transitions between software programmed and hardware committed - states. + states. If this file is not present, then there is no hardware + support for the operation. What: /sys/bus/cxl/devices/memX/firmware/
drivers/cxl/core/mbox.c +44 -1
63 lines not on this page · raw message
drivers/cxl/core/memdev.c +19 -0
@@ -477,9 +477,28 @@ static struct attribute_group cxl_memdev_pmem_attribute_group = { .attrs = cxl_memdev_pmem_attributes, }; +static umode_t cxl_memdev_security_visible (struct kobject *kobj, +struct attribute *a,int n) +{ +struct device *dev =kobj_to_dev (kobj); +struct cxl_memdev *cxlmd =to_cxl_memdev (dev); +struct cxl_memdev_state *mds =to_cxl_memdev_state (cxlmd->cxlds); + +if (a == &dev_attr_security_sanitize.attr && + !test_bit (CXL_SEC_ENABLED_SANITIZE , mds->security.enabled_cmds)) +return 0 ; + +if (a == &dev_attr_security_erase.attr && + !test_bit (CXL_SEC_ENABLED_SECURE_ERASE , mds->security.enabled_cmds)) +return 0 ; + +return a->mode; +} +static struct attribute_group cxl_memdev_security_attribute_group = { .name ="security" , .attrs = cxl_memdev_security_attributes, + .is_visible = cxl_memdev_security_visible, };static const struct attribute_group *cxl_memdev_attribute_groups[] = {
drivers/cxl/cxlmem.h +15 -0
@@ -244,6 +244,19 @@ enum poison_cmd_enabled_bits { CXL_POISON_ENABLED_MAX }; +/* Device enabled security commands */ +enum security_cmd_enabled_bits { +CXL_SEC_ENABLED_SANITIZE , +CXL_SEC_ENABLED_SECURE_ERASE , +CXL_SEC_ENABLED_GET_SECURITY_STATE , +CXL_SEC_ENABLED_SET_PASSPHRASE , +CXL_SEC_ENABLED_DISABLE_PASSPHRASE , +CXL_SEC_ENABLED_UNLOCK , +CXL_SEC_ENABLED_FREEZE_SECURITY , +CXL_SEC_ENABLED_PASSPHRASE_SECURE_ERASE , +CXL_SEC_ENABLED_MAX +}; +/** * struct cxl_poison_state - Driver poison state info *
@@ -346,6 +359,7 @@ struct cxl_fw_state {* struct cxl_security_state - Device security state * * @state: state of last security operation +* @enabled_cmds: All security commands enabled in the CEL * @poll: polling for sanitization is enabled, device has no mbox irq support * @poll_tmo_secs: polling timeout * @poll_dwork: polling work item
@@ -353,6 +367,7 @@ struct cxl_fw_state {*/ struct cxl_security_state {unsigned long state; + DECLARE_BITMAP(enabled_cmds, CXL_SEC_ENABLED_MAX);bool poll;int poll_tmo_secs;struct delayed_work poll_dwork;
Signature · 1 line
2.34.1