summaryrefslogtreecommitdiffstats
path: root/patches/jailhouse/jailhouse_0004.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/jailhouse/jailhouse_0004.patch')
-rw-r--r--patches/jailhouse/jailhouse_0004.patch155
1 files changed, 0 insertions, 155 deletions
diff --git a/patches/jailhouse/jailhouse_0004.patch b/patches/jailhouse/jailhouse_0004.patch
deleted file mode 100644
index be612ff..0000000
--- a/patches/jailhouse/jailhouse_0004.patch
+++ /dev/null
@@ -1,155 +0,0 @@
1From 8ba0c10a0b7fd44efe2e17462bb39732498b6d9b Mon Sep 17 00:00:00 2001
2From: Jan Kiszka <jan.kiszka@siemens.com>
3Date: Sun, 11 Sep 2016 23:30:04 +0200
4Subject: [PATCH] jailhouse: Add simple debug console via the hypervisor
5
6Jailhouse allows explicitly configured cells to write character-wise
7messages to the hypervisor debug console. Make use of this for a
8platform-agnostic boot diagnosis channel, specifically for non-root
9cells. It also comes with earlycon support.
10
11Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12---
13 drivers/virt/Kconfig | 11 +++++
14 drivers/virt/Makefile | 1 +
15 drivers/virt/jailhouse_dbgcon.c | 99 +++++++++++++++++++++++++++++++++++++++++
16 3 files changed, 111 insertions(+)
17 create mode 100644 drivers/virt/jailhouse_dbgcon.c
18
19diff --git a/drivers/virt/Kconfig b/drivers/virt/Kconfig
20index 99ebdde..baf04bb 100644
21--- a/drivers/virt/Kconfig
22+++ b/drivers/virt/Kconfig
23@@ -30,4 +30,15 @@ config FSL_HV_MANAGER
24 4) A kernel interface for receiving callbacks when a managed
25 partition shuts down.
26
27+config JAILHOUSE_DBGCON
28+ tristate "Jailhouse console driver"
29+ depends on X86 || ARM || ARM64
30+ help
31+ The Jailhouse hypervisor provides a simple write-only console for
32+ debugging the bootstrap process of its cells. This driver registers
33+ a console with the kernel to make use of it.
34+
35+ Note that Jailhouse has to be configured to permit a cell the usage
36+ of the console interface.
37+
38 endif
39diff --git a/drivers/virt/Makefile b/drivers/virt/Makefile
40index c47f04d..abd4baa 100644
41--- a/drivers/virt/Makefile
42+++ b/drivers/virt/Makefile
43@@ -3,3 +3,4 @@
44 #
45
46 obj-$(CONFIG_FSL_HV_MANAGER) += fsl_hypervisor.o
47+obj-$(CONFIG_JAILHOUSE_DBGCON) += jailhouse_dbgcon.o
48diff --git a/drivers/virt/jailhouse_dbgcon.c b/drivers/virt/jailhouse_dbgcon.c
49new file mode 100644
50index 0000000..5a8a8fb
51--- /dev/null
52+++ b/drivers/virt/jailhouse_dbgcon.c
53@@ -0,0 +1,99 @@
54+/*
55+ * Console driver for running over the Jailhouse partitioning hypervisor
56+ *
57+ * Copyright (c) Siemens AG, 2016
58+ *
59+ * Authors:
60+ * Jan Kiszka <jan.kiszka@siemens.com>
61+ *
62+ * This work is licensed under the terms of the GNU GPL, version 2. See
63+ * the COPYING file in the top-level directory.
64+ */
65+
66+#include <linux/module.h>
67+#include <linux/console.h>
68+#include <linux/serial_core.h>
69+#ifdef CONFIG_X86
70+#include <asm/alternative.h>
71+#endif
72+#ifdef CONFIG_ARM
73+#include <asm/opcodes-virt.h>
74+#endif
75+
76+#define JAILHOUSE_HC_DEBUG_CONSOLE_PUTC 8
77+
78+static void hypervisor_putc(char c)
79+{
80+#if defined(CONFIG_X86)
81+ int result;
82+
83+ asm volatile(
84+ ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9",
85+ X86_FEATURE_VMMCALL)
86+ : "=a" (result)
87+ : "a" (JAILHOUSE_HC_DEBUG_CONSOLE_PUTC), "D" (c)
88+ : "memory");
89+#elif defined(CONFIG_ARM)
90+ register u32 num_res asm("r0") = JAILHOUSE_HC_DEBUG_CONSOLE_PUTC;
91+ register u32 arg1 asm("r1") = c;
92+
93+ asm volatile(
94+ __HVC(0x4a48)
95+ : "=r" (num_res)
96+ : "r" (num_res), "r" (arg1)
97+ : "memory");
98+#elif defined(CONFIG_ARM64)
99+ register u64 num_res asm("x0") = JAILHOUSE_HC_DEBUG_CONSOLE_PUTC;
100+ register u64 arg1 asm("x1") = c;
101+
102+ asm volatile(
103+ "hvc #0x4a48\n\t"
104+ : "=r" (num_res)
105+ : "r" (num_res), "r" (arg1)
106+ : "memory");
107+#endif
108+}
109+
110+static void jailhouse_dbgcon_write(struct console *con, const char *s,
111+ unsigned count)
112+{
113+ while (count > 0) {
114+ hypervisor_putc(*s);
115+ count--;
116+ s++;
117+ }
118+}
119+
120+static int __init early_jailhouse_dbgcon_setup(struct earlycon_device *device,
121+ const char *options)
122+{
123+ device->con->write = jailhouse_dbgcon_write;
124+ return 0;
125+}
126+
127+EARLYCON_DECLARE(jailhouse, early_jailhouse_dbgcon_setup);
128+
129+static struct console jailhouse_dbgcon = {
130+ .name = "jailhouse",
131+ .write = jailhouse_dbgcon_write,
132+ .flags = CON_PRINTBUFFER | CON_ANYTIME,
133+ .index = -1,
134+};
135+
136+static int __init jailhouse_dbgcon_init(void)
137+{
138+ register_console(&jailhouse_dbgcon);
139+ return 0;
140+}
141+
142+static void __exit jailhouse_dbgcon_exit(void)
143+{
144+ unregister_console(&jailhouse_dbgcon);
145+}
146+
147+module_init(jailhouse_dbgcon_init);
148+module_exit(jailhouse_dbgcon_exit);
149+
150+MODULE_LICENSE("GPL v2");
151+MODULE_DESCRIPTION("Jailhouse debug console driver");
152+MODULE_AUTHOR("Jan Kiszka <jan.kiszka@siemens.com>");
153--
1542.1.4
155