From nobody Wed Nov 13 14:15:18 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XpQKf6Pc5z5dfNq; Wed, 13 Nov 2024 14:15:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XpQKf40d0z4mvh; Wed, 13 Nov 2024 14:15:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731507318; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ytcSI2b6UiCs1DoaC6NvIOapXb9zPSLq1zCLlYmgWN0=; b=VamppcKhyCy0h85kM1OmyKbZEz3pYneApP29FmE0C4ALL9PMvKwsPWHGmhyf0fHLdM0OTD 0UMRoMaimcyBBkZdh9WN2H9T2N06/TLgBlzqdOffeW7qbA6WjcxTRb7xvkt6gyPmKe3HFK YEXIqnVCB/dK0q/KIH8Y81RS08PrOIyKsEStktlwOIVkWTx68Kg47dE5pjIySHGEuhDF16 SoSrrg1KYjcnk4N9EQ92P/4O42Wp7Dy+zIgciqREOv5tYT7OBILmInDUDOAkPiUX+P/VFq 5Q0jGzVVcDmmCDnDuiCyYFWmrJ3A6ocxfgIqtcTILojX6mHVCtUITMuNrnC75A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731507318; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ytcSI2b6UiCs1DoaC6NvIOapXb9zPSLq1zCLlYmgWN0=; b=GbQl1KJ/D9Qbq2WB0OFTk4QkAF0Em8cCLrMoxJzpHi8LVLlitrmTILx8ZHEtVydafngefy CxvPmiqOhLvRTST4DXB5GexFC6GPzALs2vzLPyFh3PduZJDB5NTgRn0uLYM6qLQjijnDnP qxQ1sUTiMfDFLwejFahRpHwgFMa0PcwhMrXvpwpS5IwZJApUlR2VGZbkbN53dJlHrTZtAP ZsTQ8yWBEDsCJKOfxY9/oWTRVfFCOf+lNX14s6jvK953ECqyQjioOAHxjTd8Rr9hJQEA38 NRJrfygS7sDRKMm9hykpHDFf1iiRLkDbPafiCzikUrMjybJ1l5fAuUZC/DuEvQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731507318; a=rsa-sha256; cv=none; b=mIREKVdNQLbmVZb8zcIXidpHsF5jSkgyhm0LKWn1PNETEEX+uo6Ucv2U6g9ZVa1FeQkbbW ldaFBwLY6rztJD1iVVytIfJwRGTLggLj2/sy84i6TTAgWkYDPAo13ZGXULPahmzXUOqLsG QC1YzbPE5mbS3S8eAneD1MOl0Nbv9RdN6ec1b8xQzTGEQ/zvoPlTGfX5GH5LyZ3X5Yucsh uAWVUcJUTgmrEEsGDlbmGFUGowFzGwFUfXb4dwiVSAJsuV9zBlSas4YZQu+8dXOXkpnj/W PRvG7u85865VYhUPNlNBwfW4FvVocbkEednyEtsEV9Fd8RkdFO1JD5VhvOO40w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XpQKf3c23zxWR; Wed, 13 Nov 2024 14:15:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4ADEFIrH054873; Wed, 13 Nov 2024 14:15:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ADEFI69054870; Wed, 13 Nov 2024 14:15:18 GMT (envelope-from git) Date: Wed, 13 Nov 2024 14:15:18 GMT Message-Id: <202411131415.4ADEFI69054870@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 0a897e675481 - main - riscv: Add support for building vmm as a kernel module List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0a897e67548156ed731dae68eafd21728894ef91 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0a897e67548156ed731dae68eafd21728894ef91 commit 0a897e67548156ed731dae68eafd21728894ef91 Author: Mark Johnston AuthorDate: 2024-11-13 14:09:58 +0000 Commit: Mark Johnston CommitDate: 2024-11-13 14:15:07 +0000 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 --- sys/conf/files.riscv | 2 +- sys/modules/Makefile | 3 ++- sys/modules/vmm/Makefile | 20 +++++++++++++++----- sys/riscv/vmm/vmm.c | 5 +++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv index f75fee72fde2..d325502e03ee 100644 --- a/sys/conf/files.riscv +++ b/sys/conf/files.riscv @@ -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 diff --git a/sys/modules/Makefile b/sys/modules/Makefile index d76e16b1da1b..be485b9d393c 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -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 diff --git a/sys/modules/vmm/Makefile b/sys/modules/vmm/Makefile index 15454b345934..0ec1147d0d4b 100644 --- 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 @@ 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 diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c index f8be363b6170..33a0cb5fe420 100644 --- a/sys/riscv/vmm/vmm.c +++ b/sys/riscv/vmm/vmm.c @@ -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.