ANDROID: virt: geniezone: Refactoring vm capability to align with upstream v6
- Move the vm capability's definitions to uapi header file `gzvm.h` - Move the definitions of GZVM_CAP_ARM_PROTECTED_VM's subcommands to uapi header file `gzvm.h` - Rename, remove the substring containing `ARM`, and change "IPA" to "GPA" Change-Id: I89dd810d4bc3cd31ae7ff76e731ff62d7412fa9a Signed-off-by: kevenny hsieh <kevenny.hsieh@mediatek.com> Signed-off-by: Yingshiuan Pan <yingshiuan.pan@mediatek.com> Signed-off-by: Liju-Clr Chen <liju-clr.chen@mediatek.com> Signed-off-by: Yi-De Wu <yi-de.wu@mediatek.com> Bug: 301179926 Link: https://lore.kernel.org/all/20230919111210.19615-7-yi-de.wu@mediatek.com/
This commit is contained in:
parent
fb3444af07
commit
e348fe6d2d
@ -45,7 +45,7 @@ int gzvm_arch_set_memregion(u16 vm_id, size_t buf_size,
|
||||
buf_size, region, 0, 0, 0, 0, &res);
|
||||
}
|
||||
|
||||
static int gzvm_cap_arm_vm_ipa_size(void __user *argp)
|
||||
static int gzvm_cap_vm_gpa_size(void __user *argp)
|
||||
{
|
||||
__u64 value = CONFIG_ARM64_PA_BITS;
|
||||
|
||||
@ -57,26 +57,26 @@ static int gzvm_cap_arm_vm_ipa_size(void __user *argp)
|
||||
|
||||
int gzvm_arch_check_extension(struct gzvm *gzvm, __u64 cap, void __user *argp)
|
||||
{
|
||||
int ret = -EOPNOTSUPP;
|
||||
int ret;
|
||||
|
||||
switch (cap) {
|
||||
case GZVM_CAP_ARM_PROTECTED_VM: {
|
||||
case GZVM_CAP_PROTECTED_VM: {
|
||||
__u64 success = 1;
|
||||
|
||||
if (copy_to_user(argp, &success, sizeof(__u64)))
|
||||
return -EFAULT;
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
return 0;
|
||||
}
|
||||
case GZVM_CAP_ARM_VM_IPA_SIZE: {
|
||||
ret = gzvm_cap_arm_vm_ipa_size(argp);
|
||||
break;
|
||||
case GZVM_CAP_VM_GPA_SIZE: {
|
||||
ret = gzvm_cap_vm_gpa_size(argp);
|
||||
return ret;
|
||||
}
|
||||
default:
|
||||
ret = -EOPNOTSUPP;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,7 +167,7 @@ static int gzvm_vm_ioctl_get_pvmfw_size(struct gzvm *gzvm,
|
||||
}
|
||||
|
||||
/**
|
||||
* gzvm_vm_ioctl_cap_pvm() - Proceed GZVM_CAP_ARM_PROTECTED_VM's subcommands
|
||||
* gzvm_vm_ioctl_cap_pvm() - Proceed GZVM_CAP_PROTECTED_VM's subcommands
|
||||
* @gzvm: Pointer to struct gzvm.
|
||||
* @cap: Pointer to struct gzvm_enable_cap.
|
||||
* @argp: Pointer to struct gzvm_enable_cap in user space.
|
||||
@ -180,24 +180,23 @@ static int gzvm_vm_ioctl_cap_pvm(struct gzvm *gzvm,
|
||||
struct gzvm_enable_cap *cap,
|
||||
void __user *argp)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
struct arm_smccc_res res = {0};
|
||||
int ret;
|
||||
|
||||
switch (cap->args[0]) {
|
||||
case GZVM_CAP_ARM_PVM_SET_PVMFW_IPA:
|
||||
case GZVM_CAP_PVM_SET_PVMFW_GPA:
|
||||
fallthrough;
|
||||
case GZVM_CAP_ARM_PVM_SET_PROTECTED_VM:
|
||||
case GZVM_CAP_PVM_SET_PROTECTED_VM:
|
||||
ret = gzvm_vm_arch_enable_cap(gzvm, cap, &res);
|
||||
break;
|
||||
case GZVM_CAP_ARM_PVM_GET_PVMFW_SIZE:
|
||||
return ret;
|
||||
case GZVM_CAP_PVM_GET_PVMFW_SIZE:
|
||||
ret = gzvm_vm_ioctl_get_pvmfw_size(gzvm, cap, argp);
|
||||
break;
|
||||
return ret;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int gzvm_vm_ioctl_arch_enable_cap(struct gzvm *gzvm,
|
||||
@ -207,7 +206,7 @@ int gzvm_vm_ioctl_arch_enable_cap(struct gzvm *gzvm,
|
||||
int ret = -EINVAL;
|
||||
|
||||
switch (cap->cap) {
|
||||
case GZVM_CAP_ARM_PROTECTED_VM:
|
||||
case GZVM_CAP_PROTECTED_VM:
|
||||
ret = gzvm_vm_ioctl_cap_pvm(gzvm, cap, argp);
|
||||
break;
|
||||
default:
|
||||
|
@ -8,15 +8,6 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#define GZVM_CAP_ARM_VM_IPA_SIZE 165
|
||||
#define GZVM_CAP_ARM_PROTECTED_VM 0xffbadab1
|
||||
|
||||
/* sub-commands put in args[0] for GZVM_CAP_ARM_PROTECTED_VM */
|
||||
#define GZVM_CAP_ARM_PVM_SET_PVMFW_IPA 0
|
||||
#define GZVM_CAP_ARM_PVM_GET_PVMFW_SIZE 1
|
||||
/* GZVM_CAP_ARM_PVM_SET_PROTECTED_VM only sets protected but not load pvmfw */
|
||||
#define GZVM_CAP_ARM_PVM_SET_PROTECTED_VM 2
|
||||
|
||||
/*
|
||||
* Architecture specific registers are to be defined in arch headers and
|
||||
* ORed with the arch identifier.
|
||||
|
@ -50,8 +50,8 @@ int gzvm_err_to_errno(unsigned long err)
|
||||
* @args: Pointer in u64 from userspace
|
||||
*
|
||||
* Return:
|
||||
* * 0 - Support, no error
|
||||
* * -EOPNOTSUPP - Not support
|
||||
* * 0 - Supported, no error
|
||||
* * -EOPNOTSUPP - Unsupported
|
||||
* * -EFAULT - Failed to get data from userspace
|
||||
*/
|
||||
long gzvm_dev_ioctl_check_extension(struct gzvm *gzvm, unsigned long args)
|
||||
@ -67,22 +67,22 @@ long gzvm_dev_ioctl_check_extension(struct gzvm *gzvm, unsigned long args)
|
||||
static long gzvm_dev_ioctl(struct file *filp, unsigned int cmd,
|
||||
unsigned long user_args)
|
||||
{
|
||||
long ret = -ENOTTY;
|
||||
long ret;
|
||||
|
||||
switch (cmd) {
|
||||
case GZVM_CREATE_VM:
|
||||
ret = gzvm_dev_ioctl_create_vm(user_args);
|
||||
break;
|
||||
return ret;
|
||||
case GZVM_CHECK_EXTENSION:
|
||||
if (!user_args)
|
||||
return -EINVAL;
|
||||
ret = gzvm_dev_ioctl_check_extension(NULL, user_args);
|
||||
break;
|
||||
return ret;
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
static const struct file_operations gzvm_chardev_ops = {
|
||||
|
@ -18,6 +18,15 @@
|
||||
|
||||
#include <asm/gzvm_arch.h>
|
||||
|
||||
#define GZVM_CAP_VM_GPA_SIZE 0xa5
|
||||
#define GZVM_CAP_PROTECTED_VM 0xffbadab1
|
||||
|
||||
/* sub-commands put in args[0] for GZVM_CAP_PROTECTED_VM */
|
||||
#define GZVM_CAP_PVM_SET_PVMFW_GPA 0
|
||||
#define GZVM_CAP_PVM_GET_PVMFW_SIZE 1
|
||||
/* GZVM_CAP_PVM_SET_PROTECTED_VM only sets protected but not load pvmfw */
|
||||
#define GZVM_CAP_PVM_SET_PROTECTED_VM 2
|
||||
|
||||
/* GZVM ioctls */
|
||||
#define GZVM_IOC_MAGIC 0x92 /* gz */
|
||||
|
||||
@ -26,7 +35,7 @@
|
||||
|
||||
/*
|
||||
* Check if the given capability is supported or not.
|
||||
* The argument is capability. Ex. GZVM_CAP_ARM_PROTECTED_VM or GZVM_CAP_ARM_VM_IPA_SIZE
|
||||
* The argument is capability. Ex. GZVM_CAP_PROTECTED_VM or GZVM_CAP_VM_GPA_SIZE
|
||||
* return is 0 (supported, no error)
|
||||
* return is -EOPNOTSUPP (unsupported)
|
||||
* return is -EFAULT (failed to get the argument from userspace)
|
||||
@ -248,14 +257,13 @@ struct gzvm_vcpu_run {
|
||||
};
|
||||
};
|
||||
|
||||
/* for GZVM_ENABLE_CAP */
|
||||
/**
|
||||
* struct gzvm_enable_cap: The `capability support` on GenieZone hypervisor
|
||||
* @cap: `GZVM_CAP_ARM_PROTECTED_VM` or `GZVM_CAP_ARM_VM_IPA_SIZE`
|
||||
* @args: x3-x7 registers can be used for additional args
|
||||
*/
|
||||
struct gzvm_enable_cap {
|
||||
/* in */
|
||||
__u64 cap;
|
||||
/**
|
||||
* we have total 5 (8 - 3) registers can be used for
|
||||
* additional args
|
||||
*/
|
||||
__u64 args[5];
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user