diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv --- a/sys/conf/files.riscv +++ b/sys/conf/files.riscv @@ -46,7 +46,7 @@ riscv/riscv/elf_machdep.c standard riscv/riscv/exception.S standard riscv/riscv/exec_machdep.c standard -riscv/riscv/fpe.c optional vmm +riscv/riscv/fpe.c standard riscv/riscv/gdb_machdep.c optional gdb riscv/riscv/intc.c standard riscv/riscv/identcpu.c standard diff --git a/sys/modules/Makefile b/sys/modules/Makefile --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -856,7 +856,8 @@ _p2sb= p2sb .endif -.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" +.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ + ${MACHINE_CPUARCH} == "riscv" .if ${MK_BHYVE} != "no" || defined(ALL_MODULES) .if ${KERN_OPTS:MSMP} _vmm= vmm diff --git a/sys/modules/vmm/Makefile b/sys/modules/vmm/Makefile --- a/sys/modules/vmm/Makefile +++ b/sys/modules/vmm/Makefile @@ -3,16 +3,12 @@ KMOD= vmm .if ${MACHINE_CPUARCH} == "amd64" -SRCS+= opt_acpi.h \ - opt_bhyve_snapshot.h \ - opt_ddb.h .endif SRCS+= acpi_if.h bus_if.h device_if.h pci_if.h pcib_if.h vnode_if.h CFLAGS+= -DVMM_KEEP_STATS CFLAGS+= -I${SRCTOP}/sys/${MACHINE}/vmm -CFLAGS+= -I${SRCTOP}/sys/${MACHINE}/vmm/io # generic vmm support .PATH: ${SRCTOP}/sys/dev/vmm ${SRCTOP}/sys/${MACHINE}/vmm @@ -24,6 +20,7 @@ vmm_stat.c .if ${MACHINE_CPUARCH} == "aarch64" +CFLAGS+= -I${SRCTOP}/sys/${MACHINE}/vmm/io DPSRCS+= assym.inc # TODO: Add the new EL2 code @@ -71,12 +68,17 @@ vmm_hyp_el2.o: vmm_hyp_blob.bin .elif ${MACHINE_CPUARCH} == "amd64" +CFLAGS+= -I${SRCTOP}/sys/${MACHINE}/vmm/io DPSRCS+= vmx_assym.h svm_assym.h DPSRCS+= vmx_genassym.c svm_genassym.c offset.inc CFLAGS+= -I${SRCTOP}/sys/amd64/vmm/intel CFLAGS+= -I${SRCTOP}/sys/amd64/vmm/amd +SRCS+= opt_acpi.h \ + opt_bhyve_snapshot.h \ + opt_ddb.h + SRCS+= vmm_host.c \ vmm_ioport.c \ vmm_lapic.c \ @@ -123,7 +125,6 @@ OBJS_DEPEND_GUESS.vmx_support.o+= vmx_assym.h OBJS_DEPEND_GUESS.svm_support.o+= svm_assym.h -.endif vmx_assym.h: vmx_genassym.o sh ${SYSDIR}/kern/genassym.sh vmx_genassym.o > ${.TARGET} @@ -148,4 +149,13 @@ svm_genassym.o: offset.inc ${CC} -c ${NOSAN_CFLAGS:N-flto*:N-fno-common} -fcommon ${.IMPSRC} +.elif ${MACHINE_CPUARCH} == "riscv" + +SRCS+= vmm_aplic.c \ + vmm_riscv.c \ + vmm_sbi.c \ + vmm_switch.S + +.endif + .include diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c --- a/sys/riscv/vmm/vmm.c +++ b/sys/riscv/vmm/vmm.c @@ -176,6 +176,11 @@ static bool sysmem_mapping(struct vm *vm, struct mem_map *mm); static void vcpu_notify_event_locked(struct vcpu *vcpu); +/* global statistics */ +VMM_STAT(VMEXIT_COUNT, "total number of vm exits"); +VMM_STAT(VMEXIT_IRQ, "number of vmexits for an irq"); +VMM_STAT(VMEXIT_UNHANDLED, "number of vmexits for an unhandled exception"); + /* * Upper limit on vm_maxcpu. We could increase this to 28 bits, but this * is a safe value for now.