hv_exc: Add a Big Hypervisor Lock

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2021-09-15 23:16:28 +09:00
parent d53b40da48
commit 787c46e8c7
2 changed files with 7 additions and 0 deletions

View file

@ -11,6 +11,8 @@
#define HV_TICK_RATE 1000
DECLARE_SPINLOCK(bhl);
void hv_enter_guest(u64 x0, u64 x1, u64 x2, u64 x3, void *entry);
extern char _hv_vectors_start[0];

View file

@ -8,6 +8,8 @@
#include "uart.h"
#include "uartproxy.h"
extern spinlock_t bhl;
#define _SYSREG_ISS(_1, _2, op0, op1, CRn, CRm, op2) \
(((op0) << ESR_ISS_MSR_OP0_SHIFT) | ((op1) << ESR_ISS_MSR_OP1_SHIFT) | \
((CRn) << ESR_ISS_MSR_CRn_SHIFT) | ((CRm) << ESR_ISS_MSR_CRm_SHIFT) | \
@ -65,6 +67,7 @@ void hv_exc_proxy(u64 *regs, uartproxy_boot_reason_t reason, uartproxy_exc_code_
hv_wdt_breadcrumb('p');
return;
case EXC_EXIT_GUEST:
spin_unlock(&bhl);
hv_exit_guest();
default:
printf("Guest exception not handled, rebooting.\n");
@ -201,6 +204,7 @@ static bool hv_handle_msr(u64 *regs, u64 iss)
static void hv_exc_entry(u64 *regs)
{
UNUSED(regs);
spin_lock(&bhl);
hv_wdt_breadcrumb('X');
exc_entry_time = mrs(CNTPCT_EL0);
/* disable PMU counters in the hypervisor */
@ -220,6 +224,7 @@ static void hv_exc_exit(u64 *regs)
if (lost > 8)
stolen_time += lost - 8;
msr(CNTVOFF_EL2, stolen_time);
spin_unlock(&bhl);
}
void hv_exc_sync(u64 *regs)