clear-pkgs-linux-iot-lts2018/0367-VHM-check-HV-api-versi...

52 lines
1.6 KiB
Diff

From 209211d53a25123335a3d851fbb15eb69d2fe779 Mon Sep 17 00:00:00 2001
From: Jason Chen CJ <jason.cj.chen@intel.com>
Date: Fri, 31 Aug 2018 10:58:57 +0800
Subject: [PATCH 367/550] VHM: check HV api version for VHM module init
Change-Id: I8d49db28e235fe643380b4e8b82fb629e89accaf
Tracked-On: 218802
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
---
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) {
--
2.19.1