clear-pkgs-linux-iot-lts2018/0516-HVLog-reserve-memory-f...

133 lines
4.7 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From a0abc4c932ef39a83b6ecdaf7538d30e95b13d60 Mon Sep 17 00:00:00 2001
From: "Li, Fei1" <fei1.li@intel.com>
Date: Fri, 31 Aug 2018 10:58:58 +0800
Subject: [PATCH 516/743] HVLog: reserve memory for ACRN HVLog
Change-Id: Ic87c83510d1405c791ce9c47872b960f801d45c2
Tracked-On: 220304
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
---
drivers/acrn/Kconfig | 7 ++++
drivers/acrn/Makefile | 3 +-
drivers/acrn/acrn_hvlog.c | 83 +++++++++++++++++++++++++++++++++++++++
3 files changed, 92 insertions(+), 1 deletion(-)
create mode 100644 drivers/acrn/acrn_hvlog.c
diff --git a/drivers/acrn/Kconfig b/drivers/acrn/Kconfig
index 08b24a168167..9056a4f1f20a 100644
--- a/drivers/acrn/Kconfig
+++ b/drivers/acrn/Kconfig
@@ -11,3 +11,10 @@ config ACRN_TRACE
This is the Trace driver for the Intel ACRN hypervisor.
You can say y to build it into the kernel, or m to build
it as a module.
+
+config ACRN_HVLOG
+ bool "Intel ACRN Hypervisor Logmsg support"
+ select ACRN_SHARED_BUFFER
+ ---help---
+ This is the Trace driver for the Intel ACRN hypervisor log.
+ You can say y to build it into the kernel.
diff --git a/drivers/acrn/Makefile b/drivers/acrn/Makefile
index 5430f4fa06fd..05dd698e8171 100644
--- a/drivers/acrn/Makefile
+++ b/drivers/acrn/Makefile
@@ -1,2 +1,3 @@
obj-$(CONFIG_ACRN_SHARED_BUFFER) += sbuf.o
-obj-$(CONFIG_ACRN_TRACE) += acrn_trace.o
\ No newline at end of file
+obj-$(CONFIG_ACRN_TRACE) += acrn_trace.o
+obj-$(CONFIG_ACRN_HVLOG) += acrn_hvlog.o
diff --git a/drivers/acrn/acrn_hvlog.c b/drivers/acrn/acrn_hvlog.c
new file mode 100644
index 000000000000..9c30fba58faf
--- /dev/null
+++ b/drivers/acrn/acrn_hvlog.c
@@ -0,0 +1,83 @@
+/*
+ * ACRN Hypervisor logmsg
+ *
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright (c) 2017 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * Contact Information: Li Fei <fei1.li@intel.com>
+ *
+ * BSD LICENSE
+ *
+ * Copyright (C) 2017 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Li Fei <fei1.li@intel.com>
+ *
+ */
+#include <linux/memblock.h>
+#include <linux/kernel.h>
+
+static unsigned long long hvlog_buf_size;
+static unsigned long long hvlog_buf_base;
+
+static int __init early_hvlog(char *p)
+{
+ int ret;
+
+ pr_debug("%s(%s)\n", __func__, p);
+ hvlog_buf_size = memparse(p, &p);
+ if (*p != '@')
+ return 0;
+ hvlog_buf_base = memparse(p + 1, &p);
+
+ if (!!hvlog_buf_base && !!hvlog_buf_size) {
+ ret = memblock_reserve(hvlog_buf_base, hvlog_buf_size);
+ if (ret) {
+ pr_err("%s: Error reserving hvlog memblock\n",
+ __func__);
+ hvlog_buf_base = 0;
+ hvlog_buf_size = 0;
+ return ret;
+ }
+ }
+ return 0;
+}
+early_param("hvlog", early_hvlog);
--
2.19.2