* [PATCH] vixen: port of shadow PV console's page for L2 DomU
@ 2018-01-10 17:15 Sarah Newman
2018-01-11 10:04 ` Wei Liu
2018-01-11 19:22 ` Wei Liu
0 siblings, 2 replies; 3+ messages in thread
From: Sarah Newman @ 2018-01-10 17:15 UTC (permalink / raw)
To: xen-devel; +Cc: sergey.dyasli, anthony, 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.
Signed-off-by: Sarah Newman <srn@prgmr.com>
---
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(-)
diff --git a/xen/arch/x86/guest/vixen.c b/xen/arch/x86/guest/vixen.c
index 08619d1..4491d82 100644
--- a/xen/arch/x86/guest/vixen.c
+++ b/xen/arch/x86/guest/vixen.c
@@ -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;
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index a83aeb2..be5875e 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -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 )
diff --git a/xen/include/asm-x86/guest/vixen.h b/xen/include/asm-x86/guest/vixen.h
index eca263a..2e2666e 100644
--- a/xen/include/asm-x86/guest/vixen.h
+++ b/xen/include/asm-x86/guest/vixen.h
@@ -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
--
1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vixen: port of shadow PV console's page for L2 DomU
2018-01-10 17:15 [PATCH] vixen: port of shadow PV console's page for L2 DomU Sarah Newman
@ 2018-01-11 10:04 ` Wei Liu
2018-01-11 19:22 ` Wei Liu
1 sibling, 0 replies; 3+ messages in thread
From: Wei Liu @ 2018-01-11 10:04 UTC (permalink / raw)
To: Sarah Newman; +Cc: sergey.dyasli, Wei Liu, anthony, xen-devel
On Wed, Jan 10, 2018 at 09:15:52AM -0800, Sarah Newman wrote:
> 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: Sarah Newman <srn@prgmr.com>
Ian Jackson wrote a sidecar loading script to redirect console to QEMU
serial. Have you checked that out?
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vixen: port of shadow PV console's page for L2 DomU
2018-01-10 17:15 [PATCH] vixen: port of shadow PV console's page for L2 DomU Sarah Newman
2018-01-11 10:04 ` Wei Liu
@ 2018-01-11 19:22 ` Wei Liu
1 sibling, 0 replies; 3+ messages in thread
From: Wei Liu @ 2018-01-11 19:22 UTC (permalink / raw)
To: Sarah Newman; +Cc: sergey.dyasli, Wei Liu, anthony, xen-devel
Hi Sarah
On Wed, Jan 10, 2018 at 09:15:52AM -0800, Sarah Newman wrote:
> 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: Sarah Newman <srn@prgmr.com>
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.
> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
> index a83aeb2..be5875e 100644
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -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) )
Oh... :-)
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-11 19:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-10 17:15 [PATCH] vixen: port of shadow PV console's page for L2 DomU Sarah Newman
2018-01-11 10:04 ` Wei Liu
2018-01-11 19:22 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).