debug: vuart: add guest break key support

The break key (key value 0x0) was used as switch key from guest serial
to hv console and guest serial could not receive break key. This blocked
some guest debugging features like KGDB/KDB, sysrq, etc.

This patch leverages escape sequence "<escape> + <break>" to send break to
guest and "<escape> + e" to switch from guest serial to hv console.

Tracked-On: #8583
Signed-off-by: Qiang Zhang <qiang4.zhang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Qiang Zhang
2024-04-17 15:05:50 +08:00
committed by acrnsi-robot
parent 01beb65527
commit c623e11125
3 changed files with 36 additions and 11 deletions

View File

@@ -22,7 +22,8 @@ struct hv_timer console_timer;
#define CONSOLE_KICK_TIMER_TIMEOUT 40UL /* timeout is 40ms*/
/* Switching key combinations for shell and uart console */
#define GUEST_CONSOLE_TO_HV_SWITCH_KEY 0 /* CTRL + SPACE */
#define GUEST_CONSOLE_ESCAPE_KEY 0x0 /* the "break", put twice to send "break" to guest */
#define GUEST_CONSOLE_TO_HV_SWITCH_KEY 'e' /* escape + e to switch back to hv console */
uint16_t console_vmid = CONFIG_CONSOLE_DEFAULT_VM;
/* if use INIT to kick pcpu only, if not notification IPI still is used for sharing CPU */
@@ -112,16 +113,35 @@ static void vuart_console_rx_chars(struct acrn_vuart *vu)
if (ch == -1)
break;
if (ch == GUEST_CONSOLE_TO_HV_SWITCH_KEY) {
/* Switch the console */
console_vmid = ACRN_INVALID_VMID;
printf("\r\n\r\n ---Entering ACRN SHELL---\r\n");
break;
if (vu->escaping) {
vu->escaping = false;
switch (ch) {
case GUEST_CONSOLE_ESCAPE_KEY:
vuart_putchar(vu, ch);
vu->lsr |= LSR_BI;
recv = true;
break;
case GUEST_CONSOLE_TO_HV_SWITCH_KEY:
/* Switch the console */
console_vmid = ACRN_INVALID_VMID;
printf("\r\n\r\n ---Entering ACRN SHELL---\r\n");
/* following inputs are for hv, don't handle in this loop */
goto exit;
default:
printf("Unknown escaping key: '%c'\r\n", ch);
break;
}
} else {
if (ch == GUEST_CONSOLE_ESCAPE_KEY) {
vu->escaping = true;
} else {
vuart_putchar(vu, ch);
recv = true;
}
}
vuart_putchar(vu, ch);
recv = true;
}
exit:
if (recv) {
vuart_toggle_intr(vu);
}