Skip to contentSkip to conversation

vixen: port of shadow PV console's page for L2 DomU

PATCH Superseded Sarah Newman 2 participants 3 messages Jan 10, 2018 – Jan 11, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vixen: port of shadow PV console's page for L2 DomU

The current version of vixen handles console output from the guest but not console input to the guest. This adds guest input as in

0d50a85f x86/pv-shim: shadow PV console's page for L2 DomU,

but with read_smb moved up in guest_tx.

---
 xen/arch/x86/guest/vixen.c        | 42 +++++++++++++++++++++++++++++++++++++++
 xen/drivers/char/console.c        |  6 +++++-
 xen/include/asm-x86/guest/vixen.h |  1 +
 3 files changed, 48 insertions(+), 1 deletion(-)
xen/arch/x86/guest/vixen.c +42 -0
index 08619d1..4491d82 100644
@@ -245,6 +245,48 @@ static void vixen_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
     vixen_upcall(smp_processor_id());
 }
 
+static void notify_guest(void)
+{
+    struct evtchn *chn;
+    chn = evtchn_from_port(hardware_domain, vixen_xencons_port);
+    evtchn_port_set_pending(hardware_domain, chn->notify_vcpu_id, chn);
+}
+
+size_t vixen_guest_tx(char c)
+{
+    size_t sent = 0;
+    volatile struct xencons_interface *r = vixen_xencons_iface;
+    XENCONS_RING_IDX cons, prod;
+
+    if (r == NULL)
+        return 0;
+
+    cons = ACCESS_ONCE(r->in_cons);
+    prod = r->in_prod;
+    /* Update pointers before accessing the ring */
+    smp_rmb();
+
+    ASSERT((prod - cons) <= sizeof(r->in));
+
+    /* Is the ring out of space? */
+    if ( sizeof(r->in) - (prod - cons) == 0 )
+        goto notify;
+
+
+    r->in[MASK_XENCONS_IDX(prod++, r->in)] = c;
+    sent++;
+
+    /* Write to the ring before updating the pointer */
+    smp_wmb();
+    ACCESS_ONCE(r->in_prod) = prod;
+
+ notify:
+    /* Always notify the guest: prevents receive path from getting stuck. */
+    notify_guest();
+
+    return sent;
+}
+
 bool vixen_ring_process(uint16_t port)
 {
     volatile struct xencons_interface *r = vixen_xencons_iface;
xen/drivers/char/console.c +5 -1
index a83aeb2..be5875e 100644
@@ -30,6 +30,7 @@
 #include <xen/hypercall.h> /* for do_console_io */
 #include <xen/early_printk.h>
 #include <xen/warning.h>
+#include <asm/guest/vixen.h>
 
 /* console: comma-separated list of console outputs. */
 static char __initdata opt_console[30] = OPT_CONSOLE_STR;
@@ -406,13 +407,16 @@ static void __serial_rx(char c, struct cpu_user_regs *regs)
         serial_rx_ring[SERIAL_RX_MASK(serial_rx_prod++)] = c;
     /* Always notify the guest: prevents receive path from getting stuck. */
     send_global_virq(VIRQ_CONSOLE);
+
+    if ( is_vixen())
+        vixen_guest_tx(c);
 }
 
 static void serial_rx(char c, struct cpu_user_regs *regs)
 {
     static int switch_code_count = 0;
 
-    if ( switch_code && (c == switch_code) )
+    if (!is_vixen() && switch_code && (c == switch_code) )
     {
         /* We eat CTRL-<switch_char> in groups of 3 to switch console input. */
         if ( ++switch_code_count == 3 )
xen/include/asm-x86/guest/vixen.h +1 -0
index eca263a..2e2666e 100644
@@ -86,5 +86,6 @@ vixen_transform(struct domain *dom0,
                 xen_pfn_t *pconsole_mfn, uint32_t *pconsole_evtchn);
 
 bool vixen_ring_process(uint16_t port);
+size_t vixen_guest_tx(char c);
 
 #endif
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 8 lines · Sarah Newman

The current version of vixen handles console output from the guest but not console input to the guest. This adds guest input as in

0d50a85f x86/pv-shim: shadow PV console's page for L2 DomU,

but with read_smb moved up in guest_tx.

Ian Jackson wrote a sidecar loading script to redirect console to QEMU serial. Have you checked that out?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Sarah Newman

Hi Sarah

Quoted 8 lines · Sarah Newman

The current version of vixen handles console output from the guest but not console input to the guest. This adds guest input as in

0d50a85f x86/pv-shim: shadow PV console's page for L2 DomU,

but with read_smb moved up in guest_tx.

I was wrong about Ian's script would make the console work for guest input.

This patch looks OK, but please add back Sergey's SoB on the patch when you submit it the next time.

Note that this patch has been since updated, but the meat of the guest_tx should be the same, so you shouldn't worry about that.

Quoted 17 lines
xen/drivers/char/console.c +2 -0
index a83aeb2..be5875e 100644
@@ -30,6 +30,7 @@
 #include <xen/hypercall.h> /* for do_console_io */
 #include <xen/early_printk.h>
 #include <xen/warning.h>
+#include <asm/guest/vixen.h>
 
 /* console: comma-separated list of console outputs. */
 static char __initdata opt_console[30] = OPT_CONSOLE_STR;
@@ -406,13 +407,16 @@ static void __serial_rx(char c, struct cpu_user_regs *regs)
         serial_rx_ring[SERIAL_RX_MASK(serial_rx_prod++)] = c;
     /* Always notify the guest: prevents receive path from getting stuck. */
     send_global_virq(VIRQ_CONSOLE);
+

xen/drivers/char/console.c static void __serial_rx(char c, struct cpu_user_regs *regs) · line 419

Quoted 10 lines
xen/drivers/char/console.c +3 -1
+    if ( is_vixen())
+        vixen_guest_tx(c);
 }
 
 static void serial_rx(char c, struct cpu_user_regs *regs)
 {
     static int switch_code_count = 0;
 
-    if ( switch_code && (c == switch_code) )
+    if (!is_vixen() && switch_code && (c == switch_code) )

Oh... :-)

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel