From patchwork Fri Mar 13 03:49:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifei Jiang X-Patchwork-Id: 11435965 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54EE014E5 for ; Fri, 13 Mar 2020 03:56:28 +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 34BBB206E2 for ; Fri, 13 Mar 2020 03:56:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34BBB206E2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCbQw-0006az-DQ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 12 Mar 2020 23:56:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47911) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCbMK-0006tp-Ak for qemu-devel@nongnu.org; Thu, 12 Mar 2020 23:51:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCbMI-0000dW-LL for qemu-devel@nongnu.org; Thu, 12 Mar 2020 23:51:40 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3284 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jCbMI-0000M6-93; Thu, 12 Mar 2020 23:51:38 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 72366771CD93184FE310; Fri, 13 Mar 2020 11:51:26 +0800 (CST) Received: from huawei.com (10.133.201.158) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 13 Mar 2020 11:51:19 +0800 From: Yifei Jiang To: , Subject: [PATCH RFC 0/9] Add riscv64 kvm accel support Date: Fri, 13 Mar 2020 11:49:40 +0800 Message-ID: <20200313034949.3028-1-jiangyifei@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.133.201.158] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.191 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: anup.patel@wdc.com, zhang.zhanghailiang@huawei.com, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, victor.zhangxiaofeng@huawei.com, Alistair.Francis@wdc.com, yinyipeng1@huawei.com, palmer@dabbelt.com, Yifei Jiang , dengkai1@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Hi, This series adds riscv64 kvm support, It is based on riscv_kvm_master branch at https://github.com/kvm-riscv/linux. This series depends on above pending changes which haven't yet been accepted, so this QEMU patch series is blocked until that dependency has been dealt with, but is worth reviewing anyway. Several steps to use this: 1. Build riscv64 emulation $ ./configure --target-list=riscv64-softmmu $ make -j$(nproc) 2. Build kernel riscv_kvm_master branch at https://github.com/kvm-riscv/linux 3. Build QEMU VM I cross build in riscv toolchain $ PKG_CONFIG_LIBDIR= $ export PKG_CONFIG_SYSROOT_DIR= $ ./configure --target-list=riscv64-softmmu --enable-kvm \ --cross-prefix=riscv64-linux-gnu- --disable-libiscsi --disable-glusterfs \ --disable-libusb --disable-usb-redir --audio-drv-list= --disable-opengl \ --disable-libxml2 4. Start riscv64 emulation $ ./qemu-system-riscv64 -M virt -m 4096M -cpu rv64,x-h=true -nographic \ -name guest=riscv-hyp,debug-threads=on \ -smp 4 \ -kernel ./fw_jump.elf \ -device loader,file=./Image,addr=0x80200000 \ -drive file=./hyp.img,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -append "root=/dev/vda rw console=ttyS0 earlycon=sbi" 5. Start kvm-acceled QEMU VM in riscv64 emulation $ ./qemu-system-riscv64 -M virt,accel=kvm -m 1024M -cpu host -nographic \ -name guest=riscv-guset \ -smp 2 \ -kernel ./Image \ -drive file=./guest.img,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -append "root=/dev/vda rw console=ttyS0 earlycon=sbi" Yifei Jiang (9): linux-header: Update linux/kvm.h target/riscv: Add target/riscv/kvm.c to place the public kvm interface target/riscv: Implement function kvm_arch_init_vcpu target/riscv: Implement kvm_arch_get_registers target/riscv: Implement kvm_arch_put_registers target/riscv: Support start kernel directly by KVM hw/riscv: PLIC update external interrupt by KVM when kvm enabled target/riscv: Handler KVM_EXIT_RISCV_SBI exit target/riscv: add host riscv64 cpu type configure | 1 + hw/riscv/sifive_plic.c | 31 ++- hw/riscv/virt.c | 15 +- linux-headers/linux/kvm.h | 8 + target/riscv/Makefile.objs | 1 + target/riscv/cpu.c | 9 + target/riscv/cpu.h | 4 + target/riscv/kvm.c | 513 +++++++++++++++++++++++++++++++++++++ target/riscv/kvm_riscv.h | 25 ++ 9 files changed, 596 insertions(+), 11 deletions(-) create mode 100644 target/riscv/kvm.c create mode 100644 target/riscv/kvm_riscv.h