From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jason Chen CJ Date: Fri, 31 Aug 2018 10:58:57 +0800 Subject: [PATCH] VHM: check HV api version for VHM module init Change-Id: I8d49db28e235fe643380b4e8b82fb629e89accaf Tracked-On: 218802 Signed-off-by: Jason Chen CJ Signed-off-by: Yonghua Huang --- drivers/char/vhm/vhm_dev.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/char/vhm/vhm_dev.c b/drivers/char/vhm/vhm_dev.c index 7894297ca872..88fb0faf19fc 100644 --- a/drivers/char/vhm/vhm_dev.c +++ b/drivers/char/vhm/vhm_dev.c @@ -565,12 +565,30 @@ static const struct file_operations fops = { .poll = vhm_dev_poll, }; +#define SUPPORT_HV_API_VERSION_MAJOR 1 +#define SUPPORT_HV_API_VERSION_MINOR 0 static int __init vhm_init(void) { unsigned long flag; + struct hc_api_version api_version = {0, 0}; pr_info("vhm: initializing\n"); + if (hcall_get_api_version(virt_to_phys(&api_version)) < 0) { + pr_err("vhm: failed to get api version from Hypervisor !\n"); + return -EINVAL; + } + + if (api_version.major_version == SUPPORT_HV_API_VERSION_MAJOR && + api_version.minor_version == SUPPORT_HV_API_VERSION_MINOR) { + pr_info("vhm: hv api version %d.%d\n", + api_version.major_version, api_version.minor_version); + } else { + pr_err("vhm: not support hv api version %d.%d!\n", + api_version.major_version, api_version.minor_version); + return -EINVAL; + } + /* Try to dynamically allocate a major number for the device */ major = register_chrdev(0, DEVICE_NAME, &fops); if (major < 0) { -- https://clearlinux.org