clear-pkgs-linux-iot-lts2018/1064-ACRN-hvlog-check-wheth...

46 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Yin Fengwei <fengwei.yin@intel.com>
Date: Fri, 12 Apr 2019 13:23:19 +0800
Subject: [PATCH] ACRN: hvlog: check whether it's ACRN before init hvlog
We need to make sure ACRN hvlog is running under ACRN hypervisor.
Otherwise, hypercall will trigger invalid instruction and trigger
kernel crash
Tracked-On: projectacrn/acrn-hypervisor#2848
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Tracked-On: PKT-2115
---
drivers/acrn/acrn_hvlog.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/acrn/acrn_hvlog.c b/drivers/acrn/acrn_hvlog.c
index da04aeb2e829..87b1cb23ddc9 100644
--- a/drivers/acrn/acrn_hvlog.c
+++ b/drivers/acrn/acrn_hvlog.c
@@ -65,6 +65,8 @@
#include <linux/vhm/vhm_hypercall.h>
#include <linux/vhm/acrn_hv_defs.h>
+#include <asm/hypervisor.h>
+
#include "sbuf.h"
#define LOG_ENTRY_SIZE 80
@@ -348,6 +350,11 @@ static int __init acrn_hvlog_init(void)
struct acrn_hw_info hw_info;
uint64_t cur_logbuf, last_logbuf;
+ if (x86_hyper_type != X86_HYPER_ACRN) {
+ pr_err("acrn_hvlog: not running under acrn hypervisor!\n");
+ return -EINVAL;
+ }
+
if (!hvlog_buf_base || !hvlog_buf_size) {
pr_warn("no fixed memory reserve for hvlog.\n");
return 0;
--
https://clearlinux.org