[PATCH 0/5] Configurable debug console & cleanups

8 views
Skip to first unread message

Jan Kiszka

unread,
Jan 26, 2016, 7:13:49 AM1/26/16
to jailho...@googlegroups.com, Daniel Sangorrin
See patches for details.

Jan

Jan Kiszka (5):
x86: Remove redundant typecast
x86: Pull usage check out of vga_write
config: Set .debug_console for x86 targets
core: Initialize system_config earlier
x86: Make debug UART port configurable via system config

configs/f2a88xm-hd3.c | 3 ++
configs/h87i.c | 3 ++
configs/imb-a180.c | 3 ++
configs/qemu-vm.c | 3 ++
hypervisor/arch/x86/dbg-write.c | 61 +++++++++++++++++++++--------------------
hypervisor/paging.c | 2 --
hypervisor/setup.c | 7 +++--
tools/root-cell-config.c.tmpl | 3 ++
8 files changed, 52 insertions(+), 33 deletions(-)

--
2.1.4

Jan Kiszka

unread,
Jan 26, 2016, 7:13:49 AM1/26/16
to jailho...@googlegroups.com, Daniel Sangorrin
debug_console_base is a void pointer.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/x86/dbg-write.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hypervisor/arch/x86/dbg-write.c b/hypervisor/arch/x86/dbg-write.c
index 77f7256..0fb4fc8 100644
--- a/hypervisor/arch/x86/dbg-write.c
+++ b/hypervisor/arch/x86/dbg-write.c
@@ -74,7 +74,7 @@ static u16 *vga_mem;

static void vga_init(void)
{
- vga_mem = (u16 *)hypervisor_header.debug_console_base;
+ vga_mem = hypervisor_header.debug_console_base;
}

static void vga_scroll(void)
--
2.1.4

Jan Kiszka

unread,
Jan 26, 2016, 7:13:49 AM1/26/16
to jailho...@googlegroups.com, Daniel Sangorrin
We already allow to enable a VGA console via the system config, so let's
make the UART port configurable this way as well: phys_start will hold
the port, and flags must not have JAILHOUSE_MEM_IO set, in order to
differentiate us from the memory-mapped VGA console. And by leaving
phys_start at 0, we can even turn off the console now.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/x86/dbg-write.c | 49 ++++++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/hypervisor/arch/x86/dbg-write.c b/hypervisor/arch/x86/dbg-write.c
index cdb6b85..df6f459 100644
--- a/hypervisor/arch/x86/dbg-write.c
+++ b/hypervisor/arch/x86/dbg-write.c
@@ -12,35 +12,39 @@
* the COPYING file in the top-level directory.
*/

+#include <jailhouse/control.h>
#include <jailhouse/entry.h>
#include <jailhouse/printk.h>
#include <jailhouse/processor.h>
#include <asm/io.h>

-#ifdef CONFIG_UART_OXPCIE952
-#define UART_BASE 0xe010
-#else
-#define UART_BASE 0x3f8
-#endif
-#define UART_TX 0x0
-#define UART_DLL 0x0
-#define UART_DLM 0x1
-#define UART_LCR 0x3
-#define UART_LCR_8N1 0x03
-#define UART_LCR_DLAB 0x80
-#define UART_LSR 0x5
-#define UART_LSR_THRE 0x20
+#define UART_TX 0x0
+#define UART_DLL 0x0
+#define UART_DLM 0x1
+#define UART_LCR 0x3
+#define UART_LCR_8N1 0x03
+#define UART_LCR_DLAB 0x80
+#define UART_LSR 0x5
+#define UART_LSR_THRE 0x20
+
+static u16 uart_base;

static void uart_init(void)
{
- outb(UART_LCR_DLAB, UART_BASE + UART_LCR);
+ if (system_config->debug_console.phys_start == 0 ||
+ system_config->debug_console.flags & JAILHOUSE_MEM_IO)
+ return;
+
+ uart_base = system_config->debug_console.phys_start;
+
+ outb(UART_LCR_DLAB, uart_base + UART_LCR);
#ifdef CONFIG_UART_OXPCIE952
- outb(0x22, UART_BASE + UART_DLL);
+ outb(0x22, uart_base + UART_DLL);
#else
- outb(1, UART_BASE + UART_DLL);
+ outb(1, uart_base + UART_DLL);
#endif
- outb(0, UART_BASE + UART_DLM);
- outb(UART_LCR_8N1, UART_BASE + UART_LCR);
+ outb(0, uart_base + UART_DLM);
+ outb(UART_LCR_8N1, uart_base + UART_LCR);
}

static void uart_write(const char *msg)
@@ -54,11 +58,11 @@ static void uart_write(const char *msg)
c = *msg++;
if (!c)
break;
- while (!(inb(UART_BASE + UART_LSR) & UART_LSR_THRE))
+ while (!(inb(uart_base + UART_LSR) & UART_LSR_THRE))
cpu_relax();
if (panic_in_progress && panic_cpu != phys_processor_id())
break;
- outb(c, UART_BASE + UART_TX);
+ outb(c, uart_base + UART_TX);
}
}

@@ -134,14 +138,13 @@ static void vga_write(const char *msg)
void arch_dbg_write_init(void)
{
vga_init();
- if (!vga_mem)
- uart_init();
+ uart_init();
}

void arch_dbg_write(const char *msg)
{
if (vga_mem)
vga_write(msg);
- else
+ else if (uart_base)
uart_write(msg);
}
--
2.1.4

Jan Kiszka

unread,
Jan 26, 2016, 7:13:49 AM1/26/16
to jailho...@googlegroups.com, Daniel Sangorrin
This makes the code more regular.

Account for the additional contributor at this chance.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/arch/x86/dbg-write.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hypervisor/arch/x86/dbg-write.c b/hypervisor/arch/x86/dbg-write.c
index 0fb4fc8..cdb6b85 100644
--- a/hypervisor/arch/x86/dbg-write.c
+++ b/hypervisor/arch/x86/dbg-write.c
@@ -1,10 +1,12 @@
/*
* Jailhouse, a Linux-based partitioning hypervisor
*
- * Copyright (c) Siemens AG, 2013
+ * Copyright (c) Siemens AG, 2013-2016
+ * Copyright (c) Toshiba, 2016
*
* Authors:
* Jan Kiszka <jan.k...@siemens.com>
+ * Daniel Sangorrin <daniel.s...@toshiba.co.jp>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
@@ -94,9 +96,6 @@ static void vga_write(const char *msg)
unsigned int pos;
u16 row, line;

- if (!vga_mem)
- return;
-
/* panic_printk avoids locking 'printk_lock' due to a potential
deadlock in case a crash occurs while holding it. For avoiding
a data race between printk and panic_printk we take a local
@@ -141,7 +140,8 @@ void arch_dbg_write_init(void)

void arch_dbg_write(const char *msg)
{
- vga_write(msg);
- if (!vga_mem)
+ if (vga_mem)
+ vga_write(msg);
+ else
uart_write(msg);
}
--
2.1.4

Jan Kiszka

unread,
Jan 26, 2016, 7:13:49 AM1/26/16
to jailho...@googlegroups.com, Daniel Sangorrin
We will make the debug console UART port configurable via the system
config. Set the corresponding values, they will be ignored so far.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
configs/f2a88xm-hd3.c | 3 +++
configs/h87i.c | 3 +++
configs/imb-a180.c | 3 +++
configs/qemu-vm.c | 3 +++
tools/root-cell-config.c.tmpl | 3 +++
5 files changed, 15 insertions(+)

diff --git a/configs/f2a88xm-hd3.c b/configs/f2a88xm-hd3.c
index 16f0aa0..545da80 100644
--- a/configs/f2a88xm-hd3.c
+++ b/configs/f2a88xm-hd3.c
@@ -37,6 +37,9 @@ struct {
.phys_start = 0x3b000000,
.size = 0x4000000,
},
+ .debug_console = {
+ .phys_start = 0x3f8,
+ },
.platform_info.x86 = {
.mmconfig_base = 0xe0000000,
.mmconfig_end_bus = 0xff,
diff --git a/configs/h87i.c b/configs/h87i.c
index 9b36702..521d274 100644
--- a/configs/h87i.c
+++ b/configs/h87i.c
@@ -32,6 +32,9 @@ struct {
.phys_start = 0x3b000000,
.size = 0x4000000,
},
+ .debug_console = {
+ .phys_start = 0xe010,
+ },
.platform_info.x86 = {
.mmconfig_base = 0xf8000000,
.mmconfig_end_bus = 0x3f,
diff --git a/configs/imb-a180.c b/configs/imb-a180.c
index ffcd5c7..45d7ca5 100644
--- a/configs/imb-a180.c
+++ b/configs/imb-a180.c
@@ -36,6 +36,9 @@ struct {
.phys_start = 0x3b000000,
.size = 0x4000000,
},
+ .debug_console = {
+ .phys_start = 0x3f8,
+ },
.platform_info.x86 = {
.mmconfig_base = 0xe0000000,
.mmconfig_end_bus = 0xff,
diff --git a/configs/qemu-vm.c b/configs/qemu-vm.c
index f95b1f6..1f9966e 100644
--- a/configs/qemu-vm.c
+++ b/configs/qemu-vm.c
@@ -46,6 +46,9 @@ struct {
.phys_start = 0x3b000000,
.size = 0x600000,
},
+ .debug_console = {
+ .phys_start = 0x3f8,
+ },
.platform_info.x86 = {
.mmconfig_base = 0xb0000000,
.mmconfig_end_bus = 0xff,
diff --git a/tools/root-cell-config.c.tmpl b/tools/root-cell-config.c.tmpl
index 69a2b78..a15fbfe 100644
--- a/tools/root-cell-config.c.tmpl
+++ b/tools/root-cell-config.c.tmpl
@@ -59,6 +59,9 @@ struct {
.phys_start = ${hex(hvmem[0])},
.size = ${hex(hvmem[1])},
},
+ .debug_console = {
+ .phys_start = 0x3f8,
+ },
.platform_info.x86 = {
.mmconfig_base = ${hex(mmconfig.base)},
.mmconfig_end_bus = ${hex(mmconfig.end_bus)},
--
2.1.4

Jan Kiszka

unread,
Jan 26, 2016, 7:13:50 AM1/26/16
to jailho...@googlegroups.com, Daniel Sangorrin
On x86, we want to make the debug UART configurable via the system
config. That means we will need this pointer in arch_dbg_write_init
already.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
hypervisor/paging.c | 2 --
hypervisor/setup.c | 7 +++++--
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hypervisor/paging.c b/hypervisor/paging.c
index d049df8..5f127d7 100644
--- a/hypervisor/paging.c
+++ b/hypervisor/paging.c
@@ -468,8 +468,6 @@ int paging_init(void)
per_cpu_pages = hypervisor_header.max_cpus *
sizeof(struct per_cpu) / PAGE_SIZE;

- system_config = (struct jailhouse_system *)
- (__page_pool + per_cpu_pages * PAGE_SIZE);
config_pages = PAGES(jailhouse_system_config_size(system_config));

page_offset = JAILHOUSE_BASE -
diff --git a/hypervisor/setup.c b/hypervisor/setup.c
index 79f5696..0fb9f68 100644
--- a/hypervisor/setup.c
+++ b/hypervisor/setup.c
@@ -31,11 +31,15 @@ static volatile int error;

static void init_early(unsigned int cpu_id)
{
- unsigned long core_and_percpu_size;
+ unsigned long core_and_percpu_size = hypervisor_header.core_size +
+ sizeof(struct per_cpu) * hypervisor_header.max_cpus;
struct jailhouse_memory hv_page;

master_cpu_id = cpu_id;

+ system_config = (struct jailhouse_system *)
+ (JAILHOUSE_BASE + core_and_percpu_size);
+
arch_dbg_write_init();

printk("\nInitializing Jailhouse hypervisor %s on CPU %d\n",
@@ -66,7 +70,6 @@ static void init_early(unsigned int cpu_id)
hv_page.virt_start = paging_hvirt2phys(&hypervisor_header);
hv_page.size = PAGE_SIZE;
hv_page.flags = JAILHOUSE_MEM_READ;
- core_and_percpu_size = (unsigned long)system_config - JAILHOUSE_BASE;
while (core_and_percpu_size > 0) {
error = arch_map_memory_region(&root_cell, &hv_page);
if (error)
--
2.1.4

Reply all
Reply to author
Forward
0 new messages