From patchwork Mon Jun 12 05:39:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 10612 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2377935vqr; Sun, 11 Jun 2023 22:59:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5nmXCCprMbuEZgA3peUamGBCXIncuUoInB9kDcrevGvyCMt2bftjTgr/C1F1ly/57sB3ot X-Received: by 2002:aa7:dad4:0:b0:514:a376:9e12 with SMTP id x20-20020aa7dad4000000b00514a3769e12mr3675737eds.26.1686549566688; Sun, 11 Jun 2023 22:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686549566; cv=none; d=google.com; s=arc-20160816; b=hQbpfSyapvMBC29K0CuH/g24sSawPA5GxdRjjtU5zUAKt2oagARK3LzgcTy2ox9Jef LNpf9uRzVgDV63u+ZUwTStHDGm7ZvamiUaUt9WifhtUXQWCpd+ciH9BGUTsdW23LQpV4 9IjogPndWogvztc/JdEs7R3S/TeBgKbTVgNrl1DbLE4Q02G6qUgGNRXI8tTJO5DRpBcw DtTB4bKHDNPuBerZmIDksuIDzZtV4oWZEdSb4bra7I7Abjm+ElkghzVN/lM0aRXjNAbA MAbQhF9yh4xwzevAm4aZldGKxxePRlgyh1Md7mB98bZ0Dt/inHbN8DegZ8SE+BL4oAcE qUNw== 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:dkim-signature; bh=sWYCGAosK0SUS0+dkv9itjjrp/dSQPeY98ZsDkT2lhs=; b=VwG9VJU3SmD11H5QmDKXdUu5kmh2V5mODF0hWGxfqnJA7eElB19/RzB26pUOSLQl+u 4tfdv+5R5m6SjxMwCHfEJPAGqu0dkmbqOstkKeMGJqmdnz56As54MDe2wDlsiPeucIoQ wrE5yro8lbpnA1k8r590KKpKnT2w3V/jfeaxrSlN3JLexaCq86g4oPLhGpHNoXSFEc98 08dPLHYBumQLnVpdvp/ORrs1rcZ3A3rBr22IO726J4Vhl3ALEHUaoOeVDrfdunJItycq DUU0c2omLVn4CrECaRvqUPq7FmnIkIkMqreo92m+2o3AYZK+JnySoPdrC5Wl0x6OyXns 0HUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=RGIjU88M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e24-20020aa7d7d8000000b00514bc83782asi5854968eds.631.2023.06.11.22.59.02; Sun, 11 Jun 2023 22:59:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=RGIjU88M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236122AbjFLFka (ORCPT + 99 others); Mon, 12 Jun 2023 01:40:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236088AbjFLFj6 (ORCPT ); Mon, 12 Jun 2023 01:39:58 -0400 Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9482E57 for ; Sun, 11 Jun 2023 22:39:50 -0700 (PDT) Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-1a6960956d5so288020fac.3 for ; Sun, 11 Jun 2023 22:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1686548383; x=1689140383; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=sWYCGAosK0SUS0+dkv9itjjrp/dSQPeY98ZsDkT2lhs=; b=RGIjU88MGvlPicR5dhW//WR7XWLFopn2hQUTjPMK2Lo7t0uqFoMXVJaTy/7khu+J5X EueKw+1U72mIxX52AhIrOEiVi70grwPry1iRrUsgrCSidPaTqbCtHj1Ne0gxuAtYnTrZ 0eh1efmuB7TDJLFlP1a5ByM3wDNYk/VV3/RjBJZcVQsaHbrP3M+YGeemDTFbSx8uAtis ifnRUc1qLFCFWSmPP2t07rPV38bE4zqF9by9X4nJSSyqW5I1+Ek6T7tYFBpHXXCV0PiG zY1gDb6eNPMxoTyV/Enj0Xds+QOwJm5Puym2867C8LzuJStEKkfkONpj6Mo7k7pIvCY+ FnIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686548383; x=1689140383; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sWYCGAosK0SUS0+dkv9itjjrp/dSQPeY98ZsDkT2lhs=; b=SiR6XVoB+gefEJHdErye/vTvCqGjrE+xhqinUM3GhfMp5K6gT4gESqMylBfrQCKKsP 3hXWo27npuBIJrjixMIPPECgt0QIdeWVwc3sfnhfnPXf8yKpLPnBrrrDCMMajp4gg+LM 9qCCiAzepB8aHZ9zhBAp3rmiWaRyGmIxjPEA82P8sPdlIcV8POh16TRM6pcPx0++QWie q+hXd9q4IZNZLz9SLK4VDKEyC11DbB57PRXRxvCAdVqtz9L4g9j4amtSH6JUe+gjJQIU 0ozyZvwgT4Hrd0EQTBZlFEiSJUEMwX2QphQrVPEKgW9urOsGyQ+HEOzeQryExRqeG9ui o2Tg== X-Gm-Message-State: AC+VfDz3Nf6e4kOkGsey/hvR+KywM/m1LTzYst/NbmY68BsLCTmUVrfC 9PjU7ct88gNuVZIg77zHZV+O+A== X-Received: by 2002:a05:6870:772d:b0:184:39e3:9c85 with SMTP id dw45-20020a056870772d00b0018439e39c85mr5356831oab.29.1686548382777; Sun, 11 Jun 2023 22:39:42 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id lv19-20020a056871439300b001a30d846520sm5534869oab.7.2023.06.11.22.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jun 2023 22:39:42 -0700 (PDT) From: Anup Patel To: Paolo Bonzini , Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Andrew Jones , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v2 00/10] RISC-V KVM in-kernel AIA irqchip Date: Mon, 12 Jun 2023 11:09:22 +0530 Message-Id: <20230612053932.58604-1-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768475398226545153?= X-GMAIL-MSGID: =?utf-8?q?1768475398226545153?= This series adds in-kernel AIA irqchip to KVM RISC-V which trap-n-emulate IMSIC and APLIC MSI-mode for Guest. The APLIC MSI-mode trap-n-emulate is optional so KVM user space can emulate APLIC entirely in user space. The use of IMSIC HW guest files to accelerate IMSIC virtualization will be done as separate series since this depends on AIA irqchip drivers to be upstreamed. This series has no dependency on the AIA irqchip drivers. There is also a KVM AIA irq-bypass (or device MSI virtualization) series under development which depends on this series and upcoming IOMMU driver series. These patches (or this series) can also be found in the riscv_kvm_aia_irqchip_v2 branch at: https://github.com/avpatel/linux.git Changes since v1: - Rebased on Linux-6.4-rc6 - Addressed Atish's comment in PATCH6 - Added comments in arch/riscv/include/uapi/asm/kvm.h about APLIC and IMSIC device attribute type Anup Patel (10): RISC-V: KVM: Implement guest external interrupt line management RISC-V: KVM: Add IMSIC related defines RISC-V: KVM: Add APLIC related defines RISC-V: KVM: Set kvm_riscv_aia_nr_hgei to zero RISC-V: KVM: Skeletal in-kernel AIA irqchip support RISC-V: KVM: Implement device interface for AIA irqchip RISC-V: KVM: Add in-kernel emulation of AIA APLIC RISC-V: KVM: Expose APLIC registers as attributes of AIA irqchip RISC-V: KVM: Add in-kernel virtualization of AIA IMSIC RISC-V: KVM: Expose IMSIC registers as attributes of AIA irqchip arch/riscv/include/asm/kvm_aia.h | 107 ++- arch/riscv/include/asm/kvm_aia_aplic.h | 58 ++ arch/riscv/include/asm/kvm_aia_imsic.h | 38 + arch/riscv/include/asm/kvm_host.h | 4 + arch/riscv/include/uapi/asm/kvm.h | 72 ++ arch/riscv/kvm/Kconfig | 4 + arch/riscv/kvm/Makefile | 3 + arch/riscv/kvm/aia.c | 274 +++++- arch/riscv/kvm/aia_aplic.c | 617 ++++++++++++++ arch/riscv/kvm/aia_device.c | 672 +++++++++++++++ arch/riscv/kvm/aia_imsic.c | 1083 ++++++++++++++++++++++++ arch/riscv/kvm/main.c | 3 +- arch/riscv/kvm/vcpu.c | 2 + arch/riscv/kvm/vm.c | 115 +++ include/uapi/linux/kvm.h | 2 + 15 files changed, 3021 insertions(+), 33 deletions(-) create mode 100644 arch/riscv/include/asm/kvm_aia_aplic.h create mode 100644 arch/riscv/include/asm/kvm_aia_imsic.h create mode 100644 arch/riscv/kvm/aia_aplic.c create mode 100644 arch/riscv/kvm/aia_device.c create mode 100644 arch/riscv/kvm/aia_imsic.c