mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-03-05 11:17:46 +07:00
More power management updates for 5.7-rc1
Rework compat ioctl handling in the user space hibernation interface (Christoph Hellwig) and fix a typo in a function name in the cpuidle haltpoll driver (Yihao Wu). -----BEGIN PGP SIGNATURE----- iQJFBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAl6QPXkSHHJqd0Byand5 c29ja2kubmV0AAoJEILEb/54YlRx918P+NU9lM++pMi2Ng4wHmtRtHW9mH4M6L54 /LTjDNZ4IE/v6JlK6hzaFUAhrFViI23gmUat8a7TT/o1NUsPS0QHxatFK+nGbjEk blB/rBHWpC5vGo8SZbqmvI0hbRn0Q6Ah5I+iV+KAk9Z76mDEMNHZKpP2CfiqSVQE QYsUIJOSUo/CMT1SZRE/xDrvoU418Y1Ed6a6Kn9Ki5uXvqDTPHoAyETZ9M6tLphP kGBpbnbkHx3FyYZ3EyjVEd8O6cDsxS2gIWu6YUCB31N4G7v3bJ6rfgperTCN999J 8eQY9rNVlaAWIP9t0ObC3xOpoaNUcZC+V+yaHev3LU/6LP4Sued8cNBxQn26/RWN vyM5M6K0OphjPll9QfVfZFRUcuoBMyAtgVYw8mwT64GVJt3ukbd2QYDQHORXBQEC ziTtfLQEuAiUw/DRoTGo2XYDTlnd2nu9mFoTRU6juOawOwgwPbQldOtSJiMtCDoR cyaQH/t528w10jGCa+mIJZToTIet+gN6ui83M3kQdxMTa5ulgPClU8Kujn1wPgKX 6jFrf+NJ6SNm6A/EhPk9t/soe7hhzyGwqx351aMQpZGX6UH4hQQPXgC0tyZ71Uj5 UJ7Ys5RHcXg4kub/FJsfhv/3wdSPiekwe+U89UCQY5lxXC2x3iVjp50B4auCjW23 tQVHpAvegWg= =h4ud -----END PGP SIGNATURE----- Merge tag 'pm-5.7-rc1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull more power management updates from Rafael Wysocki: "Rework compat ioctl handling in the user space hibernation interface (Christoph Hellwig) and fix a typo in a function name in the cpuidle haltpoll driver (Yihao Wu)" * tag 'pm-5.7-rc1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: cpuidle-haltpoll: Fix small typo PM / sleep: handle the compat case in snapshot_set_swap_area() PM / sleep: move SNAPSHOT_SET_SWAP_AREA handling into a helper
This commit is contained in:
commit
bbec2a2dc3
@ -94,7 +94,7 @@ static void haltpoll_uninit(void)
|
||||
haltpoll_cpuidle_devices = NULL;
|
||||
}
|
||||
|
||||
static bool haltpool_want(void)
|
||||
static bool haltpoll_want(void)
|
||||
{
|
||||
return kvm_para_has_hint(KVM_HINTS_REALTIME) || force;
|
||||
}
|
||||
@ -110,7 +110,7 @@ static int __init haltpoll_init(void)
|
||||
|
||||
cpuidle_poll_state_init(drv);
|
||||
|
||||
if (!kvm_para_available() || !haltpool_want())
|
||||
if (!kvm_para_available() || !haltpoll_want())
|
||||
return -ENODEV;
|
||||
|
||||
ret = cpuidle_register_driver(drv);
|
||||
|
@ -196,6 +196,50 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
|
||||
return res;
|
||||
}
|
||||
|
||||
struct compat_resume_swap_area {
|
||||
compat_loff_t offset;
|
||||
u32 dev;
|
||||
} __packed;
|
||||
|
||||
static int snapshot_set_swap_area(struct snapshot_data *data,
|
||||
void __user *argp)
|
||||
{
|
||||
sector_t offset;
|
||||
dev_t swdev;
|
||||
|
||||
if (swsusp_swap_in_use())
|
||||
return -EPERM;
|
||||
|
||||
if (in_compat_syscall()) {
|
||||
struct compat_resume_swap_area swap_area;
|
||||
|
||||
if (copy_from_user(&swap_area, argp, sizeof(swap_area)))
|
||||
return -EFAULT;
|
||||
swdev = new_decode_dev(swap_area.dev);
|
||||
offset = swap_area.offset;
|
||||
} else {
|
||||
struct resume_swap_area swap_area;
|
||||
|
||||
if (copy_from_user(&swap_area, argp, sizeof(swap_area)))
|
||||
return -EFAULT;
|
||||
swdev = new_decode_dev(swap_area.dev);
|
||||
offset = swap_area.offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* User space encodes device types as two-byte values,
|
||||
* so we need to recode them
|
||||
*/
|
||||
if (!swdev) {
|
||||
data->swap = -1;
|
||||
return -EINVAL;
|
||||
}
|
||||
data->swap = swap_type_of(swdev, offset, NULL);
|
||||
if (data->swap < 0)
|
||||
return -ENODEV;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long snapshot_ioctl(struct file *filp, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
@ -351,34 +395,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
|
||||
break;
|
||||
|
||||
case SNAPSHOT_SET_SWAP_AREA:
|
||||
if (swsusp_swap_in_use()) {
|
||||
error = -EPERM;
|
||||
} else {
|
||||
struct resume_swap_area swap_area;
|
||||
dev_t swdev;
|
||||
|
||||
error = copy_from_user(&swap_area, (void __user *)arg,
|
||||
sizeof(struct resume_swap_area));
|
||||
if (error) {
|
||||
error = -EFAULT;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* User space encodes device types as two-byte values,
|
||||
* so we need to recode them
|
||||
*/
|
||||
swdev = new_decode_dev(swap_area.dev);
|
||||
if (swdev) {
|
||||
offset = swap_area.offset;
|
||||
data->swap = swap_type_of(swdev, offset, NULL);
|
||||
if (data->swap < 0)
|
||||
error = -ENODEV;
|
||||
} else {
|
||||
data->swap = -1;
|
||||
error = -EINVAL;
|
||||
}
|
||||
}
|
||||
error = snapshot_set_swap_area(data, (void __user *)arg);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -393,12 +410,6 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
|
||||
}
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
|
||||
struct compat_resume_swap_area {
|
||||
compat_loff_t offset;
|
||||
u32 dev;
|
||||
} __packed;
|
||||
|
||||
static long
|
||||
snapshot_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
@ -409,33 +420,13 @@ snapshot_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
case SNAPSHOT_AVAIL_SWAP_SIZE:
|
||||
case SNAPSHOT_ALLOC_SWAP_PAGE:
|
||||
case SNAPSHOT_CREATE_IMAGE:
|
||||
case SNAPSHOT_SET_SWAP_AREA:
|
||||
return snapshot_ioctl(file, cmd,
|
||||
(unsigned long) compat_ptr(arg));
|
||||
|
||||
case SNAPSHOT_SET_SWAP_AREA: {
|
||||
struct compat_resume_swap_area __user *u_swap_area =
|
||||
compat_ptr(arg);
|
||||
struct resume_swap_area swap_area;
|
||||
mm_segment_t old_fs;
|
||||
int err;
|
||||
|
||||
err = get_user(swap_area.offset, &u_swap_area->offset);
|
||||
err |= get_user(swap_area.dev, &u_swap_area->dev);
|
||||
if (err)
|
||||
return -EFAULT;
|
||||
old_fs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
err = snapshot_ioctl(file, SNAPSHOT_SET_SWAP_AREA,
|
||||
(unsigned long) &swap_area);
|
||||
set_fs(old_fs);
|
||||
return err;
|
||||
}
|
||||
|
||||
default:
|
||||
return snapshot_ioctl(file, cmd, arg);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_COMPAT */
|
||||
|
||||
static const struct file_operations snapshot_fops = {
|
||||
|
Loading…
Reference in New Issue
Block a user