Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp727226rwd; Thu, 15 Jun 2023 00:53:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41UG5RmpaAu4JS8iteEZQnvJzVwqaDyRg0Omf77eW+23dqtQIjIGr3JuTq5ap6oL+hH5fa X-Received: by 2002:a17:906:6a02:b0:97e:38ab:b287 with SMTP id qw2-20020a1709066a0200b0097e38abb287mr14833922ejc.68.1686815609557; Thu, 15 Jun 2023 00:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686815609; cv=none; d=google.com; s=arc-20160816; b=zUrEHVKL7E3/eTkawV4p9FVlDPPrw0W49Vq5B9e3pX78IPIsyxZzNW4xLMJmnxFtjG asD69BrxlNr3UOXA2C2jevSWyWI8IdTLWtB5TFnfF4ZJBCAxndYp1Hzfn3aXGY2RSdrl hS38QVyUq0PlWuAWsdP8TVzOhrrY/r781mLkP2RrJ+TrkW88KSQUt5NCS5wudvDYuMKD 3lBqw0yNtUoJeLP3Su9XdnkLzOkj13tsZKyGslO4NNwXUZV2TuPiPf2qpoOTFCUy8hUZ rmZ6hLi7pLpLniU3XgEUSE9hJ3S4xR0MNNnF7bVLDJxgS96EZXlk+sGFMxD+clxHmeHP 2SDA== 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=uSVZgRG5YqM/eFQOFzsv+7qQx2kR6U7K/exhbfh3iHo=; b=Q2c+ZdKA7sDkGiWgmTE7qJ/WoAk+7+n0MSJyhOxImB3aNFQufyuBzMiKm+DJM3qODn 15MV11krj2lE/ZZUoYpPACrXAfiZqYTaYd2Yc9xBHrw2OdjRnB3DstiXOBmSSSc5udka wevHNJLmPzR6D+A1aDJXVT5iO9953Pmfv+HbHEzWw1hkLZUxblENxMuEsxLm58iwAztU P3+ut77zznqwx6D4b/JLRfUCRgY5DEJrD9NWl0MxUEtpn+h/31ybSIyGEor+bXBZLI/g U839oVqgpVhNmrubQlmVacasMCAzG8tktpCtiFFh75v6SlVcT/lOKH0w1jNCWxrPWvdC uqtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ZU5NKMa7; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a17090634c700b00974f4afea43si9550876ejb.935.2023.06.15.00.53.04; Thu, 15 Jun 2023 00:53:29 -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=ZU5NKMa7; 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 S244939AbjFOHf2 (ORCPT + 99 others); Thu, 15 Jun 2023 03:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244993AbjFOHem (ORCPT ); Thu, 15 Jun 2023 03:34:42 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C0072949 for ; Thu, 15 Jun 2023 00:34:03 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-66615629689so1886386b3a.2 for ; Thu, 15 Jun 2023 00:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1686814443; x=1689406443; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uSVZgRG5YqM/eFQOFzsv+7qQx2kR6U7K/exhbfh3iHo=; b=ZU5NKMa7G4ct8b3MBmjVWKrm9NhEKEL5tmHTacR2un8854Mv7M7pqhvPirLhVQlLKD yQJrWHCAeRXcVIuM2TcU0o7A0ieXOuLIj9mPpX0XJAvWzt397TT8XVjBsBEjPQmCjUHi G6wwzmRmXhg8W1M7ODggv7uVUuVaMsRhPBVt+shONlAZyFq4rVmMix++00q5mtjr/wK2 rrsXFvjGIQZE5quFdViRsx8SRkNIb+eSdgUXVFzVNdJCEMBKlmIk39JaFHbnNrob+DWs TFLKaYjlcY2JbZxX3Ipx9OGlOT9J2DwPNPx4qP3MiX8qUURz0qzLsH3ZwbpHr1OFD3Gx 2eVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686814443; x=1689406443; 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=uSVZgRG5YqM/eFQOFzsv+7qQx2kR6U7K/exhbfh3iHo=; b=du+lR/MRK4BvnX2q018T2xbYkU8yhNchWNDolknOcmgWuojxpz3zMSY6iDj0ECdfdK M6aN6mFliatLs3wHTNH33OTajRYnTX8LIp4gZGErHdfaXFkz9rNtHrFuWUvDvYg7Trv+ IvNmRfPMDmYDOYP/t8zqqLF5AIbN/7DQYsKU/BYl7T0Vj9+QY+VmgUCui7D2ni+r6SVX MJGxBOgacqS6JY33d3TYH5nsBuAUMILhF8DLIuCnRqEeJgxEB1IcUWemWfwQFI1cBh28 qr7sAy2DHvwftH3FE+6ZZZVGSKdAl2GrFD3eefjkPM4puqALgSSkQN/MldGdz6iNYYVS XeQQ== X-Gm-Message-State: AC+VfDxulsMUncjwjH47l1z4720q2NGwib4tP5N9cBz3Hvotf9DVH3Ws 3Nh7OZqumzWUZVfK/U2m8DwO1Q== X-Received: by 2002:a05:6a21:329a:b0:10b:cdb1:3563 with SMTP id yt26-20020a056a21329a00b0010bcdb13563mr4810645pzb.46.1686814442720; Thu, 15 Jun 2023 00:34:02 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id ji1-20020a170903324100b001b016313b1dsm8049855plb.86.2023.06.15.00.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 00:34:02 -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 v3 00/10] RISC-V KVM in-kernel AIA irqchip Date: Thu, 15 Jun 2023 13:03:43 +0530 Message-Id: <20230615073353.85435-1-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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_v3 branch at: https://github.com/avpatel/linux.git Changes since v2: - Added KVM_CAP_IRQCHIP in PATCH5 - Fix check for KVM_DEV_RISCV_AIA_CONFIG_IDS write in PATCH6 - Fix APLIC_IRQ_STATE_ENPEND usage in PATCH7 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 | 619 ++++++++++++++ arch/riscv/kvm/aia_device.c | 673 +++++++++++++++ arch/riscv/kvm/aia_imsic.c | 1083 ++++++++++++++++++++++++ arch/riscv/kvm/main.c | 3 +- arch/riscv/kvm/vcpu.c | 2 + arch/riscv/kvm/vm.c | 118 +++ include/uapi/linux/kvm.h | 2 + 15 files changed, 3027 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 -- 2.34.1