1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-21 07:15:49 +00:00

riscv: Add support for building vmm as a kernel module

- Update sys/modules/vmm/Makefile.
- Add some required symbol definitions.
- Hook up vmm in sys/modules/Makefile.

Reviewed by:	br
Differential Revision:	https://reviews.freebsd.org/D47477
This commit is contained in:
Mark Johnston 2024-11-13 14:09:58 +00:00
parent d11d407aee
commit 0a897e6754
4 changed files with 23 additions and 7 deletions

View File

@ -46,7 +46,7 @@ riscv/riscv/dump_machdep.c standard
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

View File

@ -856,7 +856,8 @@ _smartpqi= smartpqi
_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

View File

@ -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 @@ SRCS+= vmm.c \
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_blob.bin: vmm_hyp_blob.elf
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 @@ CLEANFILES+= vmx_assym.h vmx_genassym.o svm_assym.h svm_genassym.o
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 @@ vmx_genassym.o: offset.inc
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 <bsd.kmod.mk>

View File

@ -176,6 +176,11 @@ static void vm_free_memmap(struct vm *vm, int ident);
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.