Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp350312rdb; Thu, 5 Oct 2023 07:47:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEchce/oe3L3HCSU1k2qsnVaNGWiDrPh5quDUPyEtwErtlD2vhfciAnnHCglyTFvsQTmO/R X-Received: by 2002:a05:6a20:ce89:b0:15d:5f9a:3921 with SMTP id if9-20020a056a20ce8900b0015d5f9a3921mr5151610pzb.27.1696517222360; Thu, 05 Oct 2023 07:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696517222; cv=none; d=google.com; s=arc-20160816; b=xhkVa38h8MzCpFW9SwpsZIYmqo/p5qlzRtBODn9LDQZC2F1ptb7KhCaXXeg4Pt3gGu ufsK8BW8PiH/ycq4tzLhtP8zvlKUXtTyxxID1VeZQJJK2oEsJle6eZ23SZt1YL2b65WV 8HRBO1qFSX2HKQVKP5HCFE/a17KE1yDebIU1ov0ddEX3z0NesJLStFKrAmTBSqKycbmn QKZM8wCP7luJ/dRRTdcBENtgHuagqVdPk7NLftJj8DV4DJEKIpwT9kX23X9VL3dxCKXp gS6EfsQE9H9O3kZlSlCA3yO+8QjO98MZsU6LTY3l7T2774kVjrlKEj4eZZteKgSKgmnI eH5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ewxUVg2/8iTx472jPF0TbBX8sioQfj/0x9UzA3H5PDc=; fh=8cdGqUti9T8etzeUgyIR4Md8xmEx2Bc/hvmPjc6B4+4=; b=LvUVAUf32857N2rN0WYK8H0ZSbC49ybCmtF9JgmZw0vCfL/vkOGkiw6eYihn8BqyRD UCyeerrtDNCOqgB/EKlwMIjF4bZRbMTk5EIQsJrSL6M/vK3MU+3GhqrlBOUadYcRAfD3 a9No5LrC7al8cLqAvoRM/0YS8RqxsTrr7/3aR0fxWpkB0iym1iZZOZlkJ8MO6aylunxL izcXTze6EZVnWQpTJ4bZR9+P99KyNkm2ojVSryWLpF0c1zkvoQvnluzkzH8nCVVvF6QF S8MHSykzcUoZXwvz7wBQkcJpWUTca1x99iteVBZZpjpr1SMo8AmSTXfQu6NKEe2XiZ2e Navw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id 189-20020a6301c6000000b00573f8a5337esi1563149pgb.461.2023.10.05.07.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:47:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9ACD18374683; Thu, 5 Oct 2023 07:46:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239624AbjJEOoa (ORCPT + 99 others); Thu, 5 Oct 2023 10:44:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237447AbjJEOjR (ORCPT ); Thu, 5 Oct 2023 10:39:17 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2B4A76AD; Thu, 5 Oct 2023 07:07:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC1B4C116B9; Thu, 5 Oct 2023 09:18:52 +0000 (UTC) From: Huacai Chen To: Paolo Bonzini , Huacai Chen Cc: kvm@vger.kernel.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, Xuerui Wang , Jiaxun Yang , Huacai Chen Subject: [GIT PULL] LoongArch KVM changes for v6.7 Date: Thu, 5 Oct 2023 17:18:25 +0800 Message-Id: <20231005091825.3207300-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:46:34 -0700 (PDT) The following changes since commit 8a749fd1a8720d4619c91c8b6e7528c0a355c0aa: Linux 6.6-rc4 (2023-10-01 14:15:13 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git tags/loongarch-kvm-6.7 for you to fetch changes up to 2c10cda4b777be4be9d9e69e4f70c818dbb15e21: LoongArch: KVM: Add maintainers for LoongArch KVM (2023-10-02 10:01:29 +0800) ---------------------------------------------------------------- LoongArch KVM changes for v6.7 Add LoongArch's KVM support. Loongson 3A5000/3A6000 supports hardware assisted virtualization. With cpu virtualization, there are separate hw-supported user mode and kernel mode in guest mode. With memory virtualization, there are two-level hw mmu table for guest mode and host mode. Also there is separate hw cpu timer with consant frequency in guest mode, so that vm can migrate between hosts with different freq. Currently, we are able to boot LoongArch Linux guests. Few key aspects of KVM LoongArch added by this series are: 1. Enable kvm hardware features when kvm module is loaded. 2. Implement VM and vcpu related ioctl interface such as vcpu create, vcpu run etc. GET_ONE_REG/SET_ONE_REG ioctl commands are use to get general registers one by one. 3. Hardware access about MMU, timer and csr are emulated in kernel. 4. Hardwares such as mmio and iocsr device are emulated in user space such as IPI, irqchips, pci devices etc. ---------------------------------------------------------------- Tianrui Zhao (25): LoongArch: KVM: Add kvm related header files LoongArch: KVM: Implement kvm module related interface LoongArch: KVM: Implement kvm hardware enable, disable interface LoongArch: KVM: Implement VM related functions LoongArch: KVM: Add vcpu related header files LoongArch: KVM: Implement basic vcpu interfaces LoongArch: KVM: Implement basic vcpu ioctl interfaces LoongArch: KVM: Implement fpu operations for vcpu LoongArch: KVM: Implement vcpu interrupt operations LoongArch: KVM: Implement vcpu load and vcpu put operations LoongArch: KVM: Implement misc vcpu related interfaces LoongArch: KVM: Implement vcpu timer operations LoongArch: KVM: Implement virtual machine tlb operations LoongArch: KVM: Implement kvm mmu operations LoongArch: KVM: Implement handle csr exception LoongArch: KVM: Implement handle iocsr exception LoongArch: KVM: Implement handle idle exception LoongArch: KVM: Implement handle gspr exception LoongArch: KVM: Implement handle mmio exception LoongArch: KVM: Implement handle fpu exception LoongArch: KVM: Implement kvm exception vectors LoongArch: KVM: Implement vcpu world switch LoongArch: KVM: Enable kvm config and add the makefile LoongArch: KVM: Supplement kvm document about LoongArch-specific part LoongArch: KVM: Add maintainers for LoongArch KVM Documentation/virt/kvm/api.rst | 70 ++- MAINTAINERS | 12 + arch/loongarch/Kbuild | 2 + arch/loongarch/Kconfig | 6 + arch/loongarch/configs/loongson3_defconfig | 2 + arch/loongarch/include/asm/inst.h | 16 + arch/loongarch/include/asm/kvm_csr.h | 211 +++++++ arch/loongarch/include/asm/kvm_host.h | 237 ++++++++ arch/loongarch/include/asm/kvm_mmu.h | 139 +++++ arch/loongarch/include/asm/kvm_types.h | 11 + arch/loongarch/include/asm/kvm_vcpu.h | 93 +++ arch/loongarch/include/asm/loongarch.h | 19 +- arch/loongarch/include/uapi/asm/kvm.h | 108 ++++ arch/loongarch/kernel/asm-offsets.c | 32 + arch/loongarch/kvm/Kconfig | 40 ++ arch/loongarch/kvm/Makefile | 22 + arch/loongarch/kvm/exit.c | 696 +++++++++++++++++++++ arch/loongarch/kvm/interrupt.c | 183 ++++++ arch/loongarch/kvm/main.c | 420 +++++++++++++ arch/loongarch/kvm/mmu.c | 914 ++++++++++++++++++++++++++++ arch/loongarch/kvm/switch.S | 250 ++++++++ arch/loongarch/kvm/timer.c | 197 ++++++ arch/loongarch/kvm/tlb.c | 32 + arch/loongarch/kvm/trace.h | 162 +++++ arch/loongarch/kvm/vcpu.c | 939 +++++++++++++++++++++++++++++ arch/loongarch/kvm/vm.c | 94 +++ include/uapi/linux/kvm.h | 9 + 27 files changed, 4902 insertions(+), 14 deletions(-) create mode 100644 arch/loongarch/include/asm/kvm_csr.h create mode 100644 arch/loongarch/include/asm/kvm_host.h create mode 100644 arch/loongarch/include/asm/kvm_mmu.h create mode 100644 arch/loongarch/include/asm/kvm_types.h create mode 100644 arch/loongarch/include/asm/kvm_vcpu.h create mode 100644 arch/loongarch/include/uapi/asm/kvm.h create mode 100644 arch/loongarch/kvm/Kconfig create mode 100644 arch/loongarch/kvm/Makefile create mode 100644 arch/loongarch/kvm/exit.c create mode 100644 arch/loongarch/kvm/interrupt.c create mode 100644 arch/loongarch/kvm/main.c create mode 100644 arch/loongarch/kvm/mmu.c create mode 100644 arch/loongarch/kvm/switch.S create mode 100644 arch/loongarch/kvm/timer.c create mode 100644 arch/loongarch/kvm/tlb.c create mode 100644 arch/loongarch/kvm/trace.h create mode 100644 arch/loongarch/kvm/vcpu.c create mode 100644 arch/loongarch/kvm/vm.c