mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 01:05:29 +00:00
Arm FF-A fix for v6.13
A single fix to address a possible race around setting ffa_dev->properties in ffa_device_register() by updating ffa_device_register() to take all the partition information received from the firmware and updating the struct ffa_device accordingly before registering the device to the bus/driver model in the kernel. -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEunHlEgbzHrJD3ZPhAEG6vDF+4pgFAmdYDl0ACgkQAEG6vDF+ 4phJ0xAAmFDEmR1DXV8lZpAt+rNzdSgeVy5PhYYfMy4flc9iK2Ei5fguQmlwPNH5 L7qTS83jtwHu70S74bSySK9PoUhRGFmhTapPhJOZAn3tfyMXxU05CKxryBx5HQLZ loAr9GdQZUQJg36+naL//+1vs+SQsDA56ZXPKyAfxXnebEq2CYTqXG0aUgwIBypS 4qaihEhqUxz5hY1GKxr0o2cPqkuT9y/x2GvJpy6TT+W9WTo+Caz/oAUDuTEYjUxb ZH89ibtEB9+lH0SdR5crgRMQECnZFIJpKSh3PTXaFjfA7N3ajoc5EkZ7clREAnUB EQ4zxIUMYl1GxveOXxHHcKg+I92COdN5qEgtsgbFE8HkIzYUE5RmDRmUPZjT6RkG dTZJx4oiiHlHciCjmiZifiwXWVSmGo41tkuNdlSqEnUCEI05v0O11biffsoT7AcD Ya4J9cIClVrEQZRNCxgW3KloKyhMwplWjsaDr9b6wjfpQocDvPG1p5E5w4blbZKz /StWuVQwWoUjis7N6WZR7eq+1nBef6nUlb6y56okwmuleGJcS1GlOs5RWgmYiOZf Wx0MAKLZsvhZJ9j1P4/dbSV2P+VyD2cvsNY9T6QHTqQ1szxjDX0JTqz/37Fk5/Ns J4BxCMgzi58YUE0Eu1YbavUuUbNpbLAuEjNFJAXBiLAmAXTX1uI= =MYqY -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEiK/NIGsWEZVxh/FrYKtH/8kJUicFAmdcNgkACgkQYKtH/8kJ Uicrxg//X9jyjwlv5ow0c3qQw0zlipVnRKyLARVt7et+6k9j1EKM1qI/3K0tAJuI Lm8eOFclU3rNazkWXHt1LKnUgutre9XAKxrQyBMRF9yNSsKxjjIekVvnaWGFZ2TF eSz5DL4fEQy1j6EDxM6wCpw84s/Sc2ApAWLQ75tZy+FU39pevFedlQdQ2nEAOdU0 gUkuUBvhIe+2P+br9rVPpzW+8njJHiM0Cal9sBAxjWSeHHVy2TlUkVpGdMfo5wzV 3B7zQ++ocfew2DbmEOYhHJi2pWbkidHkasM4I3B2fRAHrOAQ4G3aBsATXkvin+6G pf40ZiXNd8CKER306yZ7y1Ii1BtwoFbrx6Qomll+IzIrSFlijffyleCtxxXK5nHr 9zQoJJjD+P8ks7BZvrCb/xesBFNe+bc1p9U+H216pUxL1MJgSctgZL6pSx6XFSZz K/qFS0S1YWuFmt0TEa7dYf+c3g5nRlN4iNHigm/t0S2ZRsVLUoK50tPZE87h/LXl Hizu/ajQMIQvXaYG5SaXnbCRE047+bCVnpyJ/1iUZe0vbWJYxQw8M0MemYF4jLvY LXvfFutSfRrzDF7k/dEOAkutDKi7RoCPe3qk0gyUb7Y9ydhTTR7aN17ParrjFkNa lVyZWFcpr0he8xjLx7/7M48GdxHfIawQMpTVgv3DeZE2F3jA5lI= =Gaz7 -----END PGP SIGNATURE----- Merge tag 'ffa-fix-6.13' of https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/fixes Arm FF-A fix for v6.13 A single fix to address a possible race around setting ffa_dev->properties in ffa_device_register() by updating ffa_device_register() to take all the partition information received from the firmware and updating the struct ffa_device accordingly before registering the device to the bus/driver model in the kernel. * tag 'ffa-fix-6.13' of https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux: firmware: arm_ffa: Fix the race around setting ffa_dev->properties Link: https://lore.kernel.org/r/20241210101113.3232602-1-sudeep.holla@arm.com Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
commit
f578281000
@ -187,13 +187,18 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev)
|
|||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
|
struct ffa_device *
|
||||||
const struct ffa_ops *ops)
|
ffa_device_register(const struct ffa_partition_info *part_info,
|
||||||
|
const struct ffa_ops *ops)
|
||||||
{
|
{
|
||||||
int id, ret;
|
int id, ret;
|
||||||
|
uuid_t uuid;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct ffa_device *ffa_dev;
|
struct ffa_device *ffa_dev;
|
||||||
|
|
||||||
|
if (!part_info)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
id = ida_alloc_min(&ffa_bus_id, 1, GFP_KERNEL);
|
id = ida_alloc_min(&ffa_bus_id, 1, GFP_KERNEL);
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -210,9 +215,11 @@ struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
|
|||||||
dev_set_name(&ffa_dev->dev, "arm-ffa-%d", id);
|
dev_set_name(&ffa_dev->dev, "arm-ffa-%d", id);
|
||||||
|
|
||||||
ffa_dev->id = id;
|
ffa_dev->id = id;
|
||||||
ffa_dev->vm_id = vm_id;
|
ffa_dev->vm_id = part_info->id;
|
||||||
|
ffa_dev->properties = part_info->properties;
|
||||||
ffa_dev->ops = ops;
|
ffa_dev->ops = ops;
|
||||||
uuid_copy(&ffa_dev->uuid, uuid);
|
import_uuid(&uuid, (u8 *)part_info->uuid);
|
||||||
|
uuid_copy(&ffa_dev->uuid, &uuid);
|
||||||
|
|
||||||
ret = device_register(&ffa_dev->dev);
|
ret = device_register(&ffa_dev->dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -1387,7 +1387,6 @@ static struct notifier_block ffa_bus_nb = {
|
|||||||
static int ffa_setup_partitions(void)
|
static int ffa_setup_partitions(void)
|
||||||
{
|
{
|
||||||
int count, idx, ret;
|
int count, idx, ret;
|
||||||
uuid_t uuid;
|
|
||||||
struct ffa_device *ffa_dev;
|
struct ffa_device *ffa_dev;
|
||||||
struct ffa_dev_part_info *info;
|
struct ffa_dev_part_info *info;
|
||||||
struct ffa_partition_info *pbuf, *tpbuf;
|
struct ffa_partition_info *pbuf, *tpbuf;
|
||||||
@ -1406,23 +1405,19 @@ static int ffa_setup_partitions(void)
|
|||||||
|
|
||||||
xa_init(&drv_info->partition_info);
|
xa_init(&drv_info->partition_info);
|
||||||
for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++) {
|
for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++) {
|
||||||
import_uuid(&uuid, (u8 *)tpbuf->uuid);
|
|
||||||
|
|
||||||
/* Note that if the UUID will be uuid_null, that will require
|
/* Note that if the UUID will be uuid_null, that will require
|
||||||
* ffa_bus_notifier() to find the UUID of this partition id
|
* ffa_bus_notifier() to find the UUID of this partition id
|
||||||
* with help of ffa_device_match_uuid(). FF-A v1.1 and above
|
* with help of ffa_device_match_uuid(). FF-A v1.1 and above
|
||||||
* provides UUID here for each partition as part of the
|
* provides UUID here for each partition as part of the
|
||||||
* discovery API and the same is passed.
|
* discovery API and the same is passed.
|
||||||
*/
|
*/
|
||||||
ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_drv_ops);
|
ffa_dev = ffa_device_register(tpbuf, &ffa_drv_ops);
|
||||||
if (!ffa_dev) {
|
if (!ffa_dev) {
|
||||||
pr_err("%s: failed to register partition ID 0x%x\n",
|
pr_err("%s: failed to register partition ID 0x%x\n",
|
||||||
__func__, tpbuf->id);
|
__func__, tpbuf->id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ffa_dev->properties = tpbuf->properties;
|
|
||||||
|
|
||||||
if (drv_info->version > FFA_VERSION_1_0 &&
|
if (drv_info->version > FFA_VERSION_1_0 &&
|
||||||
!(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC))
|
!(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC))
|
||||||
ffa_mode_32bit_set(ffa_dev);
|
ffa_mode_32bit_set(ffa_dev);
|
||||||
|
@ -166,9 +166,12 @@ static inline void *ffa_dev_get_drvdata(struct ffa_device *fdev)
|
|||||||
return dev_get_drvdata(&fdev->dev);
|
return dev_get_drvdata(&fdev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ffa_partition_info;
|
||||||
|
|
||||||
#if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT)
|
#if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT)
|
||||||
struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
|
struct ffa_device *
|
||||||
const struct ffa_ops *ops);
|
ffa_device_register(const struct ffa_partition_info *part_info,
|
||||||
|
const struct ffa_ops *ops);
|
||||||
void ffa_device_unregister(struct ffa_device *ffa_dev);
|
void ffa_device_unregister(struct ffa_device *ffa_dev);
|
||||||
int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
|
int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
|
||||||
const char *mod_name);
|
const char *mod_name);
|
||||||
@ -176,9 +179,9 @@ void ffa_driver_unregister(struct ffa_driver *driver);
|
|||||||
bool ffa_device_is_valid(struct ffa_device *ffa_dev);
|
bool ffa_device_is_valid(struct ffa_device *ffa_dev);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static inline
|
static inline struct ffa_device *
|
||||||
struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
|
ffa_device_register(const struct ffa_partition_info *part_info,
|
||||||
const struct ffa_ops *ops)
|
const struct ffa_ops *ops)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user