vixen: port of shadow PV console's page for L2 DomU
PATCH v2 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.
Signed-off-by Sergey Dyasli <[email protected]>
Signed-off-by Sarah Newman <[email protected]>
--- 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
@@ -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
@@ -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
@@ -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