Loading drivers/soc/qcom/hab/hab.c +36 −5 Original line number Diff line number Diff line Loading @@ -521,14 +521,18 @@ static int hab_initialize_pchan_entry(struct hab_device *mmid_device, ret = habhyp_commdev_alloc((void **)&pchan, is_be, pchan_name, vmid_remote, mmid_device); if (ret == 0) { pr_debug("pchan %s added, vmid local %d, remote %d, is_be %d, total %d\n", pchan_name, vmid_local, vmid_remote, is_be, mmid_device->pchan_cnt); } else { if (ret) { pr_err("failed %d to allocate pchan %s, vmid local %d, remote %d, is_be %d, total %d\n", ret, pchan_name, vmid_local, vmid_remote, is_be, mmid_device->pchan_cnt); } else { /* local/remote id setting should be kept in lower level */ pchan->vmid_local = vmid_local; pchan->vmid_remote = vmid_remote; pr_debug("pchan %s mmid %s local %d remote %d role %d\n", pchan_name, mmid_device->name, pchan->vmid_local, pchan->vmid_remote, pchan->dom_id); } return ret; Loading Loading @@ -780,10 +784,12 @@ static long hab_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) struct hab_close *close_param; struct hab_recv *recv_param; struct hab_send *send_param; struct hab_info *info_param; struct hab_message *msg; void *send_data; unsigned char data[256] = { 0 }; long ret = 0; char names[30]; if (_IOC_SIZE(cmd) && (cmd & IOC_IN)) { if (_IOC_SIZE(cmd) > sizeof(data)) Loading Loading @@ -873,6 +879,31 @@ static long hab_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) case IOCTL_HAB_VC_UNIMPORT: ret = hab_mem_unimport(ctx, (struct hab_unimport *)data, 0); break; case IOCTL_HAB_VC_QUERY: info_param = (struct hab_info *)data; if (!info_param->names || !info_param->namesize || info_param->namesize > sizeof(names)) { pr_err("wrong vm info vcid %X, names %llX, sz %d\n", info_param->vcid, info_param->names, info_param->namesize); ret = -EINVAL; break; } ret = hab_vchan_query(ctx, info_param->vcid, (uint64_t *)&info_param->ids, names, info_param->namesize, 0); if (!ret) { if (copy_to_user((void __user *)info_param->names, names, info_param->namesize)) { pr_err("copy_to_user failed: vc=%x size=%d\n", info_param->vcid, info_param->namesize*2); info_param->namesize = 0; ret = -EFAULT; } } break; default: ret = -ENOIOCTLCMD; } Loading drivers/soc/qcom/hab/hab.h +7 −0 Original line number Diff line number Diff line Loading @@ -194,6 +194,10 @@ struct physical_channel { void *hyp_data; int dom_id; int vmid_local; int vmid_remote; char vmname_local[12]; char vmname_remote[12]; int closed; spinlock_t rxbuf_lock; Loading Loading @@ -504,6 +508,9 @@ int fill_default_gvm_settings(struct local_vmid *settings, bool hab_is_loopback(void); int hab_vchan_query(struct uhab_context *ctx, int32_t vcid, uint64_t *ids, char *names, size_t name_size, uint32_t flags); /* Global singleton HAB instance */ extern struct hab_driver hab_driver; Loading drivers/soc/qcom/hab/hab_vchan.c +17 −1 Original line number Diff line number Diff line /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -211,3 +211,19 @@ void hab_vchan_put(struct virtual_channel *vchan) if (vchan) kref_put(&vchan->refcount, hab_vchan_schedule_free); } int hab_vchan_query(struct uhab_context *ctx, int32_t vcid, uint64_t *ids, char *names, size_t name_size, uint32_t flags) { struct virtual_channel *vchan = hab_get_vchan_fromvcid(vcid, ctx); if (!vchan || vchan->otherend_closed) return -ENODEV; *ids = vchan->pchan->vmid_local | ((uint64_t)vchan->pchan->vmid_remote) << 32; names[0] = 0; names[name_size/2] = 0; return 0; } drivers/soc/qcom/hab/khab.c +22 −1 Original line number Diff line number Diff line /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -138,3 +138,24 @@ int32_t habmm_unimport(int32_t handle, return hab_mem_unimport(hab_driver.kctx, ¶m, 1); } EXPORT_SYMBOL(habmm_unimport); int32_t habmm_socket_query(int32_t handle, struct hab_socket_info *info, uint32_t flags) { int ret; uint64_t ids; char nm[sizeof(info->vmname_remote) + sizeof(info->vmname_local)]; ret = hab_vchan_query(hab_driver.kctx, handle, &ids, nm, sizeof(nm), 1); if (!ret) { info->vmid_local = ids & 0xFFFFFFFF; info->vmid_remote = (ids & 0xFFFFFFFF00000000UL) > 32; strlcpy(info->vmname_local, nm, sizeof(info->vmname_local)); strlcpy(info->vmname_remote, &nm[sizeof(info->vmname_local)], sizeof(info->vmname_remote)); } return ret; } EXPORT_SYMBOL(habmm_socket_query); include/linux/habmm.h +12 −1 Original line number Diff line number Diff line /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -35,4 +35,15 @@ int32_t habmm_import(int32_t handle, void **buff_shared, uint32_t size_bytes, int32_t habmm_unimport(int32_t handle, uint32_t export_id, void *buff_shared, uint32_t flags); struct hab_socket_info { int32_t vmid_remote; /* habmm's vmid */ int32_t vmid_local; /* name from hypervisor framework if available */ char vmname_remote[12]; char vmname_local[12]; }; int32_t habmm_socket_query(int32_t handle, struct hab_socket_info *info, uint32_t flags); #endif Loading
drivers/soc/qcom/hab/hab.c +36 −5 Original line number Diff line number Diff line Loading @@ -521,14 +521,18 @@ static int hab_initialize_pchan_entry(struct hab_device *mmid_device, ret = habhyp_commdev_alloc((void **)&pchan, is_be, pchan_name, vmid_remote, mmid_device); if (ret == 0) { pr_debug("pchan %s added, vmid local %d, remote %d, is_be %d, total %d\n", pchan_name, vmid_local, vmid_remote, is_be, mmid_device->pchan_cnt); } else { if (ret) { pr_err("failed %d to allocate pchan %s, vmid local %d, remote %d, is_be %d, total %d\n", ret, pchan_name, vmid_local, vmid_remote, is_be, mmid_device->pchan_cnt); } else { /* local/remote id setting should be kept in lower level */ pchan->vmid_local = vmid_local; pchan->vmid_remote = vmid_remote; pr_debug("pchan %s mmid %s local %d remote %d role %d\n", pchan_name, mmid_device->name, pchan->vmid_local, pchan->vmid_remote, pchan->dom_id); } return ret; Loading Loading @@ -780,10 +784,12 @@ static long hab_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) struct hab_close *close_param; struct hab_recv *recv_param; struct hab_send *send_param; struct hab_info *info_param; struct hab_message *msg; void *send_data; unsigned char data[256] = { 0 }; long ret = 0; char names[30]; if (_IOC_SIZE(cmd) && (cmd & IOC_IN)) { if (_IOC_SIZE(cmd) > sizeof(data)) Loading Loading @@ -873,6 +879,31 @@ static long hab_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) case IOCTL_HAB_VC_UNIMPORT: ret = hab_mem_unimport(ctx, (struct hab_unimport *)data, 0); break; case IOCTL_HAB_VC_QUERY: info_param = (struct hab_info *)data; if (!info_param->names || !info_param->namesize || info_param->namesize > sizeof(names)) { pr_err("wrong vm info vcid %X, names %llX, sz %d\n", info_param->vcid, info_param->names, info_param->namesize); ret = -EINVAL; break; } ret = hab_vchan_query(ctx, info_param->vcid, (uint64_t *)&info_param->ids, names, info_param->namesize, 0); if (!ret) { if (copy_to_user((void __user *)info_param->names, names, info_param->namesize)) { pr_err("copy_to_user failed: vc=%x size=%d\n", info_param->vcid, info_param->namesize*2); info_param->namesize = 0; ret = -EFAULT; } } break; default: ret = -ENOIOCTLCMD; } Loading
drivers/soc/qcom/hab/hab.h +7 −0 Original line number Diff line number Diff line Loading @@ -194,6 +194,10 @@ struct physical_channel { void *hyp_data; int dom_id; int vmid_local; int vmid_remote; char vmname_local[12]; char vmname_remote[12]; int closed; spinlock_t rxbuf_lock; Loading Loading @@ -504,6 +508,9 @@ int fill_default_gvm_settings(struct local_vmid *settings, bool hab_is_loopback(void); int hab_vchan_query(struct uhab_context *ctx, int32_t vcid, uint64_t *ids, char *names, size_t name_size, uint32_t flags); /* Global singleton HAB instance */ extern struct hab_driver hab_driver; Loading
drivers/soc/qcom/hab/hab_vchan.c +17 −1 Original line number Diff line number Diff line /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -211,3 +211,19 @@ void hab_vchan_put(struct virtual_channel *vchan) if (vchan) kref_put(&vchan->refcount, hab_vchan_schedule_free); } int hab_vchan_query(struct uhab_context *ctx, int32_t vcid, uint64_t *ids, char *names, size_t name_size, uint32_t flags) { struct virtual_channel *vchan = hab_get_vchan_fromvcid(vcid, ctx); if (!vchan || vchan->otherend_closed) return -ENODEV; *ids = vchan->pchan->vmid_local | ((uint64_t)vchan->pchan->vmid_remote) << 32; names[0] = 0; names[name_size/2] = 0; return 0; }
drivers/soc/qcom/hab/khab.c +22 −1 Original line number Diff line number Diff line /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -138,3 +138,24 @@ int32_t habmm_unimport(int32_t handle, return hab_mem_unimport(hab_driver.kctx, ¶m, 1); } EXPORT_SYMBOL(habmm_unimport); int32_t habmm_socket_query(int32_t handle, struct hab_socket_info *info, uint32_t flags) { int ret; uint64_t ids; char nm[sizeof(info->vmname_remote) + sizeof(info->vmname_local)]; ret = hab_vchan_query(hab_driver.kctx, handle, &ids, nm, sizeof(nm), 1); if (!ret) { info->vmid_local = ids & 0xFFFFFFFF; info->vmid_remote = (ids & 0xFFFFFFFF00000000UL) > 32; strlcpy(info->vmname_local, nm, sizeof(info->vmname_local)); strlcpy(info->vmname_remote, &nm[sizeof(info->vmname_local)], sizeof(info->vmname_remote)); } return ret; } EXPORT_SYMBOL(habmm_socket_query);
include/linux/habmm.h +12 −1 Original line number Diff line number Diff line /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -35,4 +35,15 @@ int32_t habmm_import(int32_t handle, void **buff_shared, uint32_t size_bytes, int32_t habmm_unimport(int32_t handle, uint32_t export_id, void *buff_shared, uint32_t flags); struct hab_socket_info { int32_t vmid_remote; /* habmm's vmid */ int32_t vmid_local; /* name from hypervisor framework if available */ char vmname_remote[12]; char vmname_local[12]; }; int32_t habmm_socket_query(int32_t handle, struct hab_socket_info *info, uint32_t flags); #endif