From 9766afdf511ad310a9d28beaf0f31fdb296ac600 Mon Sep 17 00:00:00 2001 From: Joshua Cha Date: Thu, 25 Aug 2022 01:21:35 +0900 Subject: [PATCH] misc: nvsciipc: support Inter-VM in auth APIs 1) nvsciipc KMD * use IVC KMD to query peer VMID (ivc_cdev_get_peer_vmid). * Support Inter-VM in NvSciIpcEndpointMapVuid(). * Added debugging ioctl cmds to debug in userspace level - validate auth token - map vuid * Add peer_vmid to config entry and endpoint DB. * Add IOCTL_GET_DB_SIZE cmd to return DB entry count 2) IVC KMD (ivc-cdev) * Add ivc_cdev_get_peer_vmid() to return peer_vmid of qid. * Add IOCTL_GET_VMID to return guest VM ID JIRA NVIPC-390 JIRA NVIPC-394 Change-Id: I14634fd2d17c4a28b09b9a3f9f2d42c9169e0dfb Signed-off-by: Joshua Cha Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2766220 Reviewed-by: Simon Je Reviewed-by: Kurt Yi Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert GVS: Gerrit_Virtual_Submit --- include/uapi/linux/nvsciipc_ioctl.h | 36 ++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/nvsciipc_ioctl.h b/include/uapi/linux/nvsciipc_ioctl.h index 3cdc3c18..1581530f 100644 --- a/include/uapi/linux/nvsciipc_ioctl.h +++ b/include/uapi/linux/nvsciipc_ioctl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved. * * This header is BSD licensed so anyone can use the definitions to implement * compatible drivers/servers. @@ -56,7 +56,7 @@ struct nvsciipc_config_entry { char remote_ip[NVSCIIPC_MAX_IP_NAME]; uint32_t remote_port; uint32_t local_port; - uint32_t reserved; + uint32_t peer_vmid; }; struct nvsciipc_db { @@ -81,6 +81,25 @@ struct nvsciipc_get_db_by_vuid { uint32_t idx; }; +/* for userspace level test, debugging purpose only */ +struct nvsciipc_validate_auth_token { + uint32_t auth_token; + uint64_t local_vuid; +}; + +/* NvSciIpcTopoId type */ +struct nvsciipc_topoid { + uint32_t socid; + uint32_t vmid; +}; + +/* for userspace level test, debugging purpose only */ +struct nvsciipc_map_vuid { + uint64_t vuid; + struct nvsciipc_topoid peer_topoid; + uint64_t peer_vuid; +}; + /* IOCTL magic number - seen available in ioctl-number.txt*/ #define NVSCIIPC_IOCTL_MAGIC 0xC3 @@ -96,6 +115,17 @@ struct nvsciipc_get_db_by_vuid { #define NVSCIIPC_IOCTL_GET_DB_BY_VUID \ _IOWR(NVSCIIPC_IOCTL_MAGIC, 4, struct nvsciipc_get_db_by_vuid) -#define NVSCIIPC_IOCTL_NUMBER_MAX 4 +#define NVSCIIPC_IOCTL_GET_DB_SIZE \ + _IOR(NVSCIIPC_IOCTL_MAGIC, 5, uint32_t) + +/* debugging purpose only */ +#define NVSCIIPC_IOCTL_VALIDATE_AUTH_TOKEN \ + _IOWR(NVSCIIPC_IOCTL_MAGIC, 6, struct nvsciipc_validate_auth_token) + +/* debugging purpose only */ +#define NVSCIIPC_IOCTL_MAP_VUID \ + _IOWR(NVSCIIPC_IOCTL_MAGIC, 7, struct nvsciipc_map_vuid) + +#define NVSCIIPC_IOCTL_NUMBER_MAX 7 #endif /* __NVSCIIPC_IOCTL_H__ */