From patchwork Wed Mar 31 20:07:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinoud Zandijk X-Patchwork-Id: 12176177 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E140C433ED for ; Wed, 31 Mar 2021 20:16:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DF69610A2 for ; Wed, 31 Mar 2021 20:16:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DF69610A2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=NetBSD.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRhGc-0000kT-Us for qemu-devel@archiver.kernel.org; Wed, 31 Mar 2021 16:16:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRh8m-0006qD-4H for qemu-devel@nongnu.org; Wed, 31 Mar 2021 16:08:36 -0400 Received: from 13thmonkey.org ([80.100.255.32]:60958 helo=diablo.13thmonkey.org) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRh8k-0002xU-7H for qemu-devel@nongnu.org; Wed, 31 Mar 2021 16:08:35 -0400 Received: by diablo.13thmonkey.org (Postfix, from userid 103) id 12BB2C13ADE; Wed, 31 Mar 2021 22:08:30 +0200 (CEST) From: Reinoud Zandijk To: qemu-devel@nongnu.org Subject: [PATCH v6 0/4] Implements the NetBSD Virtual Machine Monitor accelerator Date: Wed, 31 Mar 2021 22:07:56 +0200 Message-Id: <20210331200800.24168-1-reinoud@NetBSD.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Received-SPF: none client-ip=80.100.255.32; envelope-from=reinoud@diablo.13thmonkey.org; helo=diablo.13thmonkey.org X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Richard Henderson , Kamil Rytarowski , Reinoud Zandijk , Paolo Bonzini , Ryo ONODERA Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The NetBSD team has been working hard on a new user-mode API for our hypervisor that will be released as part of the upcoming NetBSD 9.0. The NetBSD team has implemented its new hypervisor called NVMM. It has been included since NetBSD 9.0 and has been in use now for quite some time. NVMM adds user-mode capabilities to create and manage virtual machines, configure memory mappings for guest machines, and create and control execution of virtual processors. With this new API we are now able to bring our hypervisor to the QEMU community! The following patches implement the NetBSD Virtual Machine Monitor accelerator (NVMM) for QEMU on NetBSD 9.0 and newer hosts. When compiling QEMU for x86_64 it will autodetect nvmm and will compile the accelerator for use if found. At runtime using the '-accel nvmm' should see a significant performance improvement over emulation, much like when using 'hax' on NetBSD. The documentation for this new API is visible at https://man.netbsd.org under the libnvmm(3) and nvmm(4) pages. NVMM was designed and implemented by Maxime Villard Thank you for your feedback. Refrences: https://m00nbsd.net/4e0798b7f2620c965d0dd9d6a7a2f296.html Test plan: 1. Download a NetBSD 9.1 release: http://cdn.netbsd.org/pub/NetBSD/NetBSD-9.1/amd64/installation/cdrom/boot.iso 2. Install it natively on a not too old x86_64 hardware (Intel or AMD). There is no support for nested virtualization in NVMM. 3. Setup the system. export PKG_PATH=http://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/9.0/All/ pkg_add git gmake python37 glib2 bison pkgconf pixman Install mozilla-rootcerts and follow post-install instructions. pkg_add mozilla-rootcerts More information: https://wiki.qemu.org/Hosts/BSD#NetBSD 4. Build qemu mkdir build cd build ../configure --python=python3.7 gmake gmake check 5. Test qemu -accel nvmm ... History: v5 -> v6: - Ported to updated Qemu 6.0 build system and reshuffeling and refactoring - Improved auto detection - Added support for improved NVMM interface fixing feedback on the use of signals v4 -> v5: - Mainly cosmetic - Automatic detection v3 -> v4: - Correct build warning by adding a missing include - Do not set R8-R16 registers unless TARGET_X86_64 v2 -> v3: - Register nvmm in targetos NetBSD check - Stop including hw/boards.h - Rephrase old code comments (remove XXX) v1 -> v2: - Included the testing plan as requested by Philippe Mathieu-Daude - Formatting nit fix in qemu-options.hx - Document NVMM in the accel section of qemu-options.hx Signed-off-by: Reinoud Zandijk Signed-off-by: Kamil Rytarowski Reinoud Zandijk (4): Add NVMM accelerator: configure and build logic Add NVMM accelerator: x86 CPU support Add NVMM accelerator: acceleration enlightenments Add NVMM Accelerator: add maintainers for NetBSD/NVMM MAINTAINERS | 11 + accel/Kconfig | 3 + configure | 12 +- include/sysemu/hw_accel.h | 1 + include/sysemu/nvmm.h | 26 + meson.build | 23 +- meson_options.txt | 2 + qemu-options.hx | 8 +- target/i386/helper.c | 2 +- target/i386/meson.build | 1 + target/i386/nvmm/meson.build | 4 + target/i386/nvmm/nvmm-accel-ops.c | 111 +++ target/i386/nvmm/nvmm-accel-ops.h | 25 + target/i386/nvmm/nvmm-all.c | 1231 +++++++++++++++++++++++++++++ 14 files changed, 1449 insertions(+), 11 deletions(-) create mode 100644 include/sysemu/nvmm.h create mode 100644 target/i386/nvmm/meson.build create mode 100644 target/i386/nvmm/nvmm-accel-ops.c create mode 100644 target/i386/nvmm/nvmm-accel-ops.h create mode 100644 target/i386/nvmm/nvmm-all.c