mirror of
https://github.com/openharmony/kernel_linux_common_modules.git
synced 2026-08-26 17:16:37 -04:00
32位机适配修改
Signed-off-by: Hu Zhaodong <huzhaodong@huawei.com> Signed-off-by: Ywenrui44091 <yaowenrui2@huawei.com>
This commit is contained in:
@@ -27,9 +27,9 @@
|
||||
#include "qos_ctrl.h"
|
||||
#endif
|
||||
|
||||
typedef long (*auth_ctrl_func)(struct file *file, void __user *arg);
|
||||
typedef long (*auth_ctrl_func)(int abi, void __user *arg);
|
||||
|
||||
static long ctrl_auth_basic_operation(struct file *file, void __user *uarg);
|
||||
static long ctrl_auth_basic_operation(int abi, void __user *uarg);
|
||||
|
||||
static auth_ctrl_func g_func_array[AUTH_CTRL_MAX_NR] = {
|
||||
NULL, /* reserved */
|
||||
@@ -386,14 +386,33 @@ static long do_auth_manipulate(struct auth_ctrl_data *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ctrl_auth_basic_operation(struct file *file, void __user *uarg)
|
||||
static long ctrl_auth_basic_operation(int abi, void __user *uarg)
|
||||
{
|
||||
struct auth_ctrl_data auth_data;
|
||||
long ret;
|
||||
long ret = -1;
|
||||
|
||||
if (copy_from_user(&auth_data, uarg, sizeof(struct auth_ctrl_data))) {
|
||||
pr_err("[AUTH_CTRL] BASIC_AUTH_CTRL_OPERATION copy data failed\n");
|
||||
return -ARG_INVALID;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
|
||||
|
||||
switch (abi) {
|
||||
case AUTH_IOCTL_ABI_ARM32:
|
||||
ret = copy_from_user(&auth_data,
|
||||
(void __user *)compat_ptr((compat_uptr_t)uarg),
|
||||
sizeof(struct auth_ctrl_data));
|
||||
break;
|
||||
case AUTH_IOCTL_ABI_AARCH64:
|
||||
ret = copy_from_user(&auth_data, uarg, sizeof(struct auth_ctrl_data));
|
||||
break;
|
||||
default:
|
||||
pr_err("[AUTH_CTRL] abi format error\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
if (ret) {
|
||||
pr_err("[AUTH_RTG] %s copy user data failed\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = do_auth_manipulate(&auth_data);
|
||||
@@ -402,15 +421,34 @@ static long ctrl_auth_basic_operation(struct file *file, void __user *uarg)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (copy_to_user(uarg, &auth_data, sizeof(struct auth_ctrl_data))) {
|
||||
pr_err("[AUTH_CTRL] BASIC_AUTH_CTRL_OPERATION send data failed\n");
|
||||
return -ARG_INVALID;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
|
||||
|
||||
switch (abi) {
|
||||
case AUTH_IOCTL_ABI_ARM32:
|
||||
ret = copy_to_user((void __user *)compat_ptr((compat_uptr_t)uarg),
|
||||
&auth_data,
|
||||
sizeof(struct auth_ctrl_data));
|
||||
break;
|
||||
case AUTH_IOCTL_ABI_AARCH64:
|
||||
ret = copy_to_user(uarg, &auth_data, sizeof(struct auth_ctrl_data));
|
||||
break;
|
||||
default:
|
||||
pr_err("[AUTH_CTRL] abi format error\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
if (ret) {
|
||||
pr_err("[AUTH_RTG] %s copy user data failed\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
long auth_ctrl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
long do_auth_ctrl_ioctl(int abi, struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
void __user *uarg = (void __user *)arg;
|
||||
unsigned int func_cmd = _IOC_NR(cmd);
|
||||
@@ -433,7 +471,7 @@ long auth_ctrl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
}
|
||||
|
||||
if (g_func_array[func_cmd])
|
||||
return (*g_func_array[func_cmd])(file, uarg);
|
||||
return (*g_func_array[func_cmd])(abi, uarg);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -539,10 +577,25 @@ struct auth_struct *get_authority(struct task_struct *p)
|
||||
return auth;
|
||||
}
|
||||
|
||||
long proc_auth_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
return do_auth_ctrl_ioctl(AUTH_IOCTL_ABI_AARCH64, file, cmd, arg);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
long proc_auth_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
return do_auth_ctrl_ioctl(AUTH_IOCTL_ABI_ARM32, file, cmd,
|
||||
(unsigned long)(compat_ptr((compat_uptr_t)arg)));
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct file_operations auth_ctrl_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.unlocked_ioctl = auth_ctrl_ioctl,
|
||||
.compat_ioctl = auth_ctrl_ioctl,
|
||||
.unlocked_ioctl = proc_auth_ioctl,
|
||||
#ifdef CONFIG_COMPAT
|
||||
.compat_ioctl = proc_auth_compat_ioctl,
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct miscdevice auth_ctrl_device = {
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
#include "auth_ctrl.h"
|
||||
#include "qos_ctrl.h"
|
||||
|
||||
typedef long (*qos_ctrl_func)(struct file *file, void __user *uarg);
|
||||
typedef long (*qos_ctrl_func)(int abi, void __user *uarg);
|
||||
|
||||
static long ctrl_qos_operation(struct file *file, void __user *uarg);
|
||||
static long ctrl_qos_policy(struct file *file, void __user *uarg);
|
||||
static long ctrl_qos_operation(int abi, void __user *uarg);
|
||||
static long ctrl_qos_policy(int abi, void __user *uarg);
|
||||
|
||||
static qos_ctrl_func g_func_array[QOS_CTRL_MAX_NR] = {
|
||||
NULL, /* reserved */
|
||||
@@ -452,13 +452,33 @@ static long do_qos_manipulate(struct qos_ctrl_data *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ctrl_qos_operation(struct file *file, void __user *uarg)
|
||||
static long ctrl_qos_operation(int abi, void __user *uarg)
|
||||
{
|
||||
struct qos_ctrl_data qos_data;
|
||||
int ret = -1;
|
||||
|
||||
if (copy_from_user(&qos_data, uarg, sizeof(struct qos_ctrl_data))) {
|
||||
pr_err("[QOS_CTRL] CMD_ID_QOS_APPLY copy data failed\n");
|
||||
return -ARG_INVALID;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagonstic ignored "-Wpointer-to-int-cast"
|
||||
|
||||
switch (abi) {
|
||||
case QOS_IOCTL_ABI_ARM32:
|
||||
ret = copy_from_user(&qos_data,
|
||||
(void __user *)compat_ptr((compat_uptr_t)uarg),
|
||||
sizeof(struct qos_ctrl_data));
|
||||
break;
|
||||
case QOS_IOCTL_ABI_AARCH64:
|
||||
ret = copy_from_user(&qos_data, uarg, sizeof(struct qos_ctrl_data));
|
||||
break;
|
||||
default:
|
||||
pr_err("[QOS_CTRL] abi format error\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
if (ret) {
|
||||
pr_err("[QOS_CTRL] %s copy user data failed\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* transfer user space qos level to kernel space qos level */
|
||||
@@ -595,19 +615,39 @@ out_failed:
|
||||
return -ARG_INVALID;
|
||||
}
|
||||
|
||||
static long ctrl_qos_policy(struct file *file, void __user *uarg)
|
||||
static long ctrl_qos_policy(int abi, void __user *uarg)
|
||||
{
|
||||
struct qos_policy_datas policy_datas;
|
||||
long ret = -1;
|
||||
|
||||
if (copy_from_user(&policy_datas, uarg, sizeof(struct qos_policy_datas))) {
|
||||
pr_err("[QOS_CTRL] CMD_ID_QOS_APPLY copy data failed\n");
|
||||
return -ARG_INVALID;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpointer-to-int-cast"
|
||||
|
||||
switch (abi) {
|
||||
case QOS_IOCTL_ABI_ARM32:
|
||||
ret = copy_from_user(&policy_datas,
|
||||
(void __user *)compat_ptr((compat_uptr_t)uarg),
|
||||
sizeof(struct qos_policy_datas));
|
||||
break;
|
||||
case QOS_IOCTL_ABI_AARCH64:
|
||||
ret = copy_from_user(&policy_datas, uarg, sizeof(struct qos_policy_datas));
|
||||
break;
|
||||
default:
|
||||
pr_err("[QOS_CTRL] abi format error\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
if (ret) {
|
||||
pr_err("[QOS_RTG] %s copy user data failed\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return do_qos_policy_change(&policy_datas);
|
||||
}
|
||||
|
||||
long do_qos_ctrl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
long do_qos_ctrl_ioctl(int abi, struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
void __user *uarg = (void __user *)arg;
|
||||
unsigned int func_cmd = _IOC_NR(cmd);
|
||||
@@ -637,7 +677,7 @@ long do_qos_ctrl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
#endif
|
||||
|
||||
if (g_func_array[func_cmd])
|
||||
return (*g_func_array[func_cmd])(file, uarg);
|
||||
return (*g_func_array[func_cmd])(abi, uarg);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
#define SUPER_UID SYSTEM_UID
|
||||
#define super_uid(uid) (uid == ROOT_UID || uid == SYSTEM_UID)
|
||||
|
||||
enum ioctl_abi_format_auth{
|
||||
AUTH_IOCTL_ABI_ARM32,
|
||||
AUTH_IOCTL_ABI_AARCH64,
|
||||
};
|
||||
|
||||
enum auth_ctrl_cmdid {
|
||||
BASIC_AUTH_CTRL = 1,
|
||||
AUTH_CTRL_MAX_NR
|
||||
@@ -106,7 +111,7 @@ enum auth_status {
|
||||
};
|
||||
|
||||
struct auth_struct;
|
||||
long auth_ctrl_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
|
||||
long auth_ctrl_ioctl(int abi, struct file *file, unsigned int cmd, unsigned long arg);
|
||||
void get_auth_struct(struct auth_struct *auth);
|
||||
void put_auth_struct(struct auth_struct *auth);
|
||||
struct auth_struct *get_authority(struct task_struct *p);
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
#include <linux/sched.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
enum ioctl_abi_format_qos{
|
||||
QOS_IOCTL_ABI_ARM32,
|
||||
QOS_IOCTL_ABI_AARCH64,
|
||||
};
|
||||
|
||||
enum qos_ctrl_cmdid {
|
||||
QOS_CTRL = 1,
|
||||
QOS_POLICY,
|
||||
@@ -113,7 +118,7 @@ void init_task_qos(struct task_struct *p);
|
||||
void sched_exit_qos_list(struct task_struct *p);
|
||||
void remove_qos_tasks(struct auth_struct *auth);
|
||||
|
||||
long do_qos_ctrl_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
|
||||
long do_qos_ctrl_ioctl(int abi, struct file *file, unsigned int cmd, unsigned long arg);
|
||||
|
||||
#endif /* _QOS_CTRL_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user