diff mbox series

[XTF,v2,v2,3/4] Enabled serial writing for hvm guests

Message ID 20200423101955.13761-4-wipawel@amazon.de (mailing list archive)
State New, archived
Headers show
Series Small fixes and improvements | expand

Commit Message

Wieczorkiewicz, Pawel April 23, 2020, 10:19 a.m. UTC
From: Paul Semel <phentex@amazon.de>

setup.c: PV console writing is not working in Xen 4.2 for hvm
guests, so we make xtf write to COM1 serial port to get its output

Signed-off-by: Paul Semel <phentex@amazon.de>
Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
---
Changed since v1:
  * Increase callbacks array

 arch/x86/setup.c | 14 ++++++++++++++
 common/console.c |  3 ++-
 2 files changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/x86/setup.c b/arch/x86/setup.c
index 3c84e96..f6fa4df 100644
--- a/arch/x86/setup.c
+++ b/arch/x86/setup.c
@@ -238,6 +238,13 @@  static void qemu_console_write(const char *buf, size_t len)
                  : "d" (0x12));
 }
 
+static void com1_write(const char *buf, size_t len)
+{
+    asm volatile("rep; outsb"
+                 : "+S" (buf), "+c" (len)
+                 : "d" (0x3f8));
+}
+
 static void xen_console_write(const char *buf, size_t len)
 {
     hypercall_console_write(buf, len);
@@ -246,7 +253,14 @@  static void xen_console_write(const char *buf, size_t len)
 void arch_setup(void)
 {
     if ( IS_DEFINED(CONFIG_HVM) && !pvh_start_info )
+    {
         register_console_callback(qemu_console_write);
+    }
+
+    if ( IS_DEFINED(CONFIG_HVM) )
+    {
+        register_console_callback(com1_write);
+    }
 
     register_console_callback(xen_console_write);
 
diff --git a/common/console.c b/common/console.c
index 0724fc9..00dbbca 100644
--- a/common/console.c
+++ b/common/console.c
@@ -13,8 +13,9 @@ 
  * - Xen hypervisor console
  * - PV console
  * - Qemu debug console
+ * - COM1 serial console
  */
-static cons_output_cb output_fns[3];
+static cons_output_cb output_fns[4];
 static unsigned int nr_cons_cb;
 
 /* Guest PV console details. */