From b17de6a7e67818bf928755d8098e1d6fe3cdb885 Mon Sep 17 00:00:00 2001 From: Sainath Grandhi Date: Thu, 16 Aug 2018 00:50:30 -0700 Subject: [PATCH] hv: Support HV console for multiple VMs - ACRN partition mode ACRN in partition mode provides vUART for all VMs. This patch adds support to add console redirection for multiple VMs. Signed-off-by: Sainath Grandhi --- hypervisor/debug/shell.c | 7 +++++++ hypervisor/debug/vuart.c | 14 ++++++++++++++ hypervisor/include/debug/vuart.h | 4 +++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 6e389a4eb..e8b5c161d 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -723,6 +723,13 @@ static int shell_to_sos_console(__unused int argc, __unused char **argv) struct vm *vm; struct vuart *vuart; +#ifdef CONFIG_PARTITION_MODE + if (argc == 2U) { + guest_no = atoi(argv[1]); + } + + vuart_vmid = guest_no; +#endif /* Get the virtual device node */ vm = get_vm_from_vmid(guest_no); if (vm == NULL) { diff --git a/hypervisor/debug/vuart.c b/hypervisor/debug/vuart.c index d45d7b13c..b37148b40 100644 --- a/hypervisor/debug/vuart.c +++ b/hypervisor/debug/vuart.c @@ -43,6 +43,10 @@ #define vm_vuart(vm) (vm->vuart) +#ifdef CONFIG_PARTITION_MODE +int8_t vuart_vmid = - 1; +#endif + static void fifo_reset(struct fifo *fifo) { fifo->rindex = 0U; @@ -349,7 +353,17 @@ void vuart_console_rx_chars(struct vuart *vu) struct vuart *vuart_console_active(void) { +#ifdef CONFIG_PARTITION_MODE + struct vm *vm; + + if (vuart_vmid == -1) { + return NULL; + } + + vm = get_vm_from_vmid(vuart_vmid); +#else struct vm *vm = get_vm_from_vmid(0U); +#endif if ((vm != NULL) && (vm->vuart != NULL)) { struct vuart *vu = vm->vuart; diff --git a/hypervisor/include/debug/vuart.h b/hypervisor/include/debug/vuart.h index 073e97be8..332be4633 100644 --- a/hypervisor/include/debug/vuart.h +++ b/hypervisor/include/debug/vuart.h @@ -59,7 +59,9 @@ struct vuart { struct vm *vm; spinlock_t lock; /* protects all softc elements */ }; - +#ifdef CONFIG_PARTITION_MODE +extern int8_t vuart_vmid; +#endif #ifdef HV_DEBUG void *vuart_init(struct vm *vm); struct vuart *vuart_console_active(void);