Message ID | 20240815122500.71946-1-papaluri@amd.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Herbert Xu |
Headers | show |
Series | crypto: ccp: Properly unregister /dev/sev on sev PLATFORM_STATUS failure | expand |
On 8/15/2024 7:25 AM, Pavan Kumar Paluri wrote: > In case of sev PLATFORM_STATUS failure, sev_get_api_version() fails > resulting in sev_data field of psp_master nulled out. This later becomes > a problem when unloading the ccp module because the device has not been > unregistered (via misc_deregister()) before clearing the sev_data field > of psp_master. As a result, on reloading the ccp module, a duplicate > device issue is encountered as can be seen from the dmesg log below. > > on reloading ccp module via modprobe ccp > > Call Trace: > <TASK> > dump_stack_lvl+0xd7/0xf0 > dump_stack+0x10/0x20 > sysfs_warn_dup+0x5c/0x70 > sysfs_create_dir_ns+0xbc/0xd > kobject_add_internal+0xb1/0x2f0 > kobject_add+0x7a/0xe0 > ? srso_alias_return_thunk+0x5/0xfbef5 > ? get_device_parent+0xd4/0x1e0 > ? __pfx_klist_children_get+0x10/0x10 > device_add+0x121/0x870 > ? srso_alias_return_thunk+0x5/0xfbef5 > device_create_groups_vargs+0xdc/0x100 > device_create_with_groups+0x3f/0x60 > misc_register+0x13b/0x1c0 > sev_dev_init+0x1d4/0x290 [ccp] > psp_dev_init+0x136/0x300 [ccp] > sp_init+0x6f/0x80 [ccp] > sp_pci_probe+0x2a6/0x310 [ccp] > ? srso_alias_return_thunk+0x5/0xfbef5 > local_pci_probe+0x4b/0xb0 > work_for_cpu_fn+0x1a/0x30 > process_one_work+0x203/0x600 > worker_thread+0x19e/0x350 > ? __pfx_worker_thread+0x10/0x10 > kthread+0xeb/0x120 > ? __pfx_kthread+0x10/0x10 > ret_from_fork+0x3c/0x60 > ? __pfx_kthread+0x10/0x10 > ret_from_fork_asm+0x1a/0x30 > </TASK> > kobject: kobject_add_internal failed for sev with -EEXIST, don't try to register things with the same name in the same directory. > ccp 0000:22:00.1: sev initialization failed > ccp 0000:22:00.1: psp initialization failed > ccp 0000:a2:00.1: no command queues available > ccp 0000:a2:00.1: psp enabled > > Address this issue by unregistering the /dev/sev before clearing out > sev_data in case of PLATFORM_STATUS failure. > > Fixes: 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support") > Cc: stable@vger.kernel.org > Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com> > --- > drivers/crypto/ccp/sev-dev.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c > index 9810edbb272d..5f63d2018649 100644 > --- a/drivers/crypto/ccp/sev-dev.c > +++ b/drivers/crypto/ccp/sev-dev.c > @@ -2410,6 +2410,8 @@ void sev_pci_init(void) > return; > > err: > + sev_dev_destroy(psp_master); > + > psp_master->sev_data = NULL; > } > > > base-commit: b8c7cbc324dc17b9e42379b42603613580bec2d8 A gentle reminder, Thanks, Pavan
On Thu, Aug 22, 2024 at 10:17:34AM -0500, Paluri, PavanKumar wrote: > > A gentle reminder, I'd like to see an ack from Tom. Thanks,
On 8/15/24 07:25, Pavan Kumar Paluri wrote: > In case of sev PLATFORM_STATUS failure, sev_get_api_version() fails > resulting in sev_data field of psp_master nulled out. This later becomes > a problem when unloading the ccp module because the device has not been > unregistered (via misc_deregister()) before clearing the sev_data field > of psp_master. As a result, on reloading the ccp module, a duplicate > device issue is encountered as can be seen from the dmesg log below. > > on reloading ccp module via modprobe ccp > ... > > Address this issue by unregistering the /dev/sev before clearing out > sev_data in case of PLATFORM_STATUS failure. > > Fixes: 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support") > Cc: stable@vger.kernel.org > Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> > ---
On Thu, Aug 15, 2024 at 07:25:00AM -0500, Pavan Kumar Paluri wrote: > In case of sev PLATFORM_STATUS failure, sev_get_api_version() fails > resulting in sev_data field of psp_master nulled out. This later becomes > a problem when unloading the ccp module because the device has not been > unregistered (via misc_deregister()) before clearing the sev_data field > of psp_master. As a result, on reloading the ccp module, a duplicate > device issue is encountered as can be seen from the dmesg log below. > > on reloading ccp module via modprobe ccp > > Call Trace: > <TASK> > dump_stack_lvl+0xd7/0xf0 > dump_stack+0x10/0x20 > sysfs_warn_dup+0x5c/0x70 > sysfs_create_dir_ns+0xbc/0xd > kobject_add_internal+0xb1/0x2f0 > kobject_add+0x7a/0xe0 > ? srso_alias_return_thunk+0x5/0xfbef5 > ? get_device_parent+0xd4/0x1e0 > ? __pfx_klist_children_get+0x10/0x10 > device_add+0x121/0x870 > ? srso_alias_return_thunk+0x5/0xfbef5 > device_create_groups_vargs+0xdc/0x100 > device_create_with_groups+0x3f/0x60 > misc_register+0x13b/0x1c0 > sev_dev_init+0x1d4/0x290 [ccp] > psp_dev_init+0x136/0x300 [ccp] > sp_init+0x6f/0x80 [ccp] > sp_pci_probe+0x2a6/0x310 [ccp] > ? srso_alias_return_thunk+0x5/0xfbef5 > local_pci_probe+0x4b/0xb0 > work_for_cpu_fn+0x1a/0x30 > process_one_work+0x203/0x600 > worker_thread+0x19e/0x350 > ? __pfx_worker_thread+0x10/0x10 > kthread+0xeb/0x120 > ? __pfx_kthread+0x10/0x10 > ret_from_fork+0x3c/0x60 > ? __pfx_kthread+0x10/0x10 > ret_from_fork_asm+0x1a/0x30 > </TASK> > kobject: kobject_add_internal failed for sev with -EEXIST, don't try to register things with the same name in the same directory. > ccp 0000:22:00.1: sev initialization failed > ccp 0000:22:00.1: psp initialization failed > ccp 0000:a2:00.1: no command queues available > ccp 0000:a2:00.1: psp enabled > > Address this issue by unregistering the /dev/sev before clearing out > sev_data in case of PLATFORM_STATUS failure. > > Fixes: 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support") > Cc: stable@vger.kernel.org > Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com> > --- > drivers/crypto/ccp/sev-dev.c | 2 ++ > 1 file changed, 2 insertions(+) Patch applied. Thanks.
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 9810edbb272d..5f63d2018649 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -2410,6 +2410,8 @@ void sev_pci_init(void) return; err: + sev_dev_destroy(psp_master); + psp_master->sev_data = NULL; }
In case of sev PLATFORM_STATUS failure, sev_get_api_version() fails resulting in sev_data field of psp_master nulled out. This later becomes a problem when unloading the ccp module because the device has not been unregistered (via misc_deregister()) before clearing the sev_data field of psp_master. As a result, on reloading the ccp module, a duplicate device issue is encountered as can be seen from the dmesg log below. on reloading ccp module via modprobe ccp Call Trace: <TASK> dump_stack_lvl+0xd7/0xf0 dump_stack+0x10/0x20 sysfs_warn_dup+0x5c/0x70 sysfs_create_dir_ns+0xbc/0xd kobject_add_internal+0xb1/0x2f0 kobject_add+0x7a/0xe0 ? srso_alias_return_thunk+0x5/0xfbef5 ? get_device_parent+0xd4/0x1e0 ? __pfx_klist_children_get+0x10/0x10 device_add+0x121/0x870 ? srso_alias_return_thunk+0x5/0xfbef5 device_create_groups_vargs+0xdc/0x100 device_create_with_groups+0x3f/0x60 misc_register+0x13b/0x1c0 sev_dev_init+0x1d4/0x290 [ccp] psp_dev_init+0x136/0x300 [ccp] sp_init+0x6f/0x80 [ccp] sp_pci_probe+0x2a6/0x310 [ccp] ? srso_alias_return_thunk+0x5/0xfbef5 local_pci_probe+0x4b/0xb0 work_for_cpu_fn+0x1a/0x30 process_one_work+0x203/0x600 worker_thread+0x19e/0x350 ? __pfx_worker_thread+0x10/0x10 kthread+0xeb/0x120 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x3c/0x60 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> kobject: kobject_add_internal failed for sev with -EEXIST, don't try to register things with the same name in the same directory. ccp 0000:22:00.1: sev initialization failed ccp 0000:22:00.1: psp initialization failed ccp 0000:a2:00.1: no command queues available ccp 0000:a2:00.1: psp enabled Address this issue by unregistering the /dev/sev before clearing out sev_data in case of PLATFORM_STATUS failure. Fixes: 200664d5237f ("crypto: ccp: Add Secure Encrypted Virtualization (SEV) command support") Cc: stable@vger.kernel.org Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com> --- drivers/crypto/ccp/sev-dev.c | 2 ++ 1 file changed, 2 insertions(+) base-commit: b8c7cbc324dc17b9e42379b42603613580bec2d8