Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6159927rwl; Tue, 4 Apr 2023 08:36:47 -0700 (PDT) X-Google-Smtp-Source: AKy350Z+gkZ559CiffD2Qtc+iy5mShaEQFCtYZeXHWFvE2wxBiFdwn9jDZ9Q0nDPiFwIJH8Cwbaz X-Received: by 2002:aa7:97ac:0:b0:626:14fb:3c87 with SMTP id d12-20020aa797ac000000b0062614fb3c87mr2527867pfq.4.1680622607554; Tue, 04 Apr 2023 08:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680622607; cv=none; d=google.com; s=arc-20160816; b=a0snaLsvuBocYytKGBtOJNPJaXG8K4ISczmxNrEaL8vL6iKJJKTTWOpLj01j2LcG5X SZI/BGJ3JO0gLcwUKpP8sJfpk0MDTjrQLCXU+Uxg2wMLKhfFSUD1N+vPMhY9My0fy7sR MElrPS8920hssjGYJFRLcVCh+/t+NKIOdvYwT2llUdqDxx2jUIvFxPlZ7lLYOGhzmhE4 Ag+BmM5C4C2LeCS4A0x7xR2m+f0zsyEBcWF5sJ/UG+xNEoHaCIsG9khYgP3ATX7mhyqu uMUEvjpuEDUSvvWEv5+9fqWpG7NTB62aTDsTZqGJO4mDWy5FhUb5Z1RuVj09o6KBDS7f 2ssg== 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=C6R4aOyJyDkIgHIVotRNcx/chT2oC7UuU6Y6qIEoUAE=; b=hbUqQGjLpCii8J7Rv9A8bIyBy6gmAk4pu9vdsBAjenA2F4MseYtBDgeKV3c/8nZmH0 yTlk6PmD/XtQtolpvHV5geMc/uVYzpXL9D//RZ/3xINNIwpXo5J4SNhAA0U92T8ftVso kP57qHjk9n8TeUD9c5p82XcuO3wlMMhDVThQOm2UEKZkr24FNpt2udIw/M9BBv207Jrk 0Cai6EGlQEGIpWF8J5+sz/aeOOqvtcNmoTkWPJlCPhB9PwSkH16SQZCi8nBuMuZSbhrO rFzmIUWxzbFd9dZPR2+HCBwwI9O9xCu9k4cmk6UaFa0IWjfwIP5P6PbgQjHRo/r2Fpue xrdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=j4Q5gDOH; 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 f82-20020a623855000000b0062ae46c1c06si10425436pfa.78.2023.04.04.08.36.12; Tue, 04 Apr 2023 08:36:47 -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=j4Q5gDOH; 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 S235386AbjDDPfN (ORCPT + 99 others); Tue, 4 Apr 2023 11:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235024AbjDDPfM (ORCPT ); Tue, 4 Apr 2023 11:35:12 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1422719AF for ; Tue, 4 Apr 2023 08:35:11 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id r14so18820693oiw.12 for ; Tue, 04 Apr 2023 08:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1680622510; x=1683214510; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=C6R4aOyJyDkIgHIVotRNcx/chT2oC7UuU6Y6qIEoUAE=; b=j4Q5gDOHHnM+qB7ifoJy+oxC06Zdjb9mpbd7zIX7SMvhGKkBoDsWify1l6fwb3SssM N02pq7k5H0o9Hmlxm2NiGEwFdUER2roPwv10kwFFy8YE0Cd1C9H9eKvfB9OdFpJGozYm FLMkRMNBQgL5JkXiSaR9238raAY8paxS8rmwYLS0pnfW/uIN0NBYqUNKOCd7kVKcKPZ6 h82T3FzgWs/iIAjpTKhFEh4nrllSp/gPvdowFqLjmartx45XFKmLMN5j2Y8yOzH0ZsPm s+sy5jMukDwXigjWAVzcmaRwq7jf3mWiySiJcR0XOvU1ROc3iKWZ+dVPDzUVm+60yFZg KeNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680622510; x=1683214510; 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=C6R4aOyJyDkIgHIVotRNcx/chT2oC7UuU6Y6qIEoUAE=; b=5HgiYLhmbdSs1enlqI9ZE8HIIoki/EDK0aPpcUt4WGCmLGceSNJMniS6ECeSALiBJu xwXA868q4wCrOa5hXqYlgKGg639WTEzPuRAMd3F1cfXvxp1BQstio5jL1IDUMb7OpMhB oTJ37Q0F+89mKazi1EU+vPQKJ5bRJpLsyYS2k9hnFJRpdiBB95gjOqyOII98Dtu4oMaM dbHItRBQpT+c7CHpc5EGFaJfyHVKGcX6Cpzan+brIhhVO9RuE9Q7bNEv5LBdaaIeasTu Qhr3fvawkDhqHp/C624K0Uxkio1/tAtFfzqqMZW1LTRbr2MhMxgkY8RmAFYCYw8Qmcoc pu7g== X-Gm-Message-State: AAQBX9cfspEHhjQ8FKah7UC/N1rPosDraxfFJsxrhrYadWD7WEJ63XJt 3e3qWbIFFUxRgKeG3C9fKTIzK9TW8AMF+qO6zYQ= X-Received: by 2002:a05:6808:2d5:b0:386:d629:81a1 with SMTP id a21-20020a05680802d500b00386d62981a1mr1300978oid.35.1680622510321; Tue, 04 Apr 2023 08:35:10 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id w124-20020acadf82000000b00387384dc768sm5325803oig.9.2023.04.04.08.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 08:35:09 -0700 (PDT) From: Anup Patel To: Paolo Bonzini , Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Andrew Jones , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v4 0/9] RISC-V KVM virtualize AIA CSRs Date: Tue, 4 Apr 2023 21:04:43 +0530 Message-Id: <20230404153452.2405681-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=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The RISC-V AIA specification is now frozen as-per the RISC-V international process. The latest frozen specifcation can be found at: https://github.com/riscv/riscv-aia/releases/download/1.0-RC3/riscv-interrupts-1.0-RC3.pdf This series implements first phase of AIA virtualization which targets virtualizing AIA CSRs. This also provides a foundation for the second phase of AIA virtualization which will target in-kernel AIA irqchip (including both IMSIC and APLIC). The first two patches are shared with the "Linux RISC-V AIA Support" series which adds AIA driver support. To test this series, use AIA drivers from the "Linux RISC-V AIA Support" series and use KVMTOOL from the riscv_aia_v1 branch at: https://github.com/avpatel/kvmtool.git These patches can also be found in the riscv_kvm_aia_csr_v4 branch at: https://github.com/avpatel/linux.git Based-on: 20230401112730.2105240-1-apatel@ventanamicro.com (https://lore.kernel.org/lkml/20230401112730.2105240-1-apatel@ventanamicro.com/) Based-on: 20230403121527.2286489-1-apatel@ventanamicro.com (https://lore.kernel.org/lkml/20230403121527.2286489-1-apatel@ventanamicro.com/) Changes since v3: - Split PATCH7 into two patches - Addressed comments in PATCH7, PATCH8 and PATCH9 Changes since v2: - Rebased on Linux-6.3-rc5 - Split PATCH5 into two separate patches as suggested by Atish. Changes since v1: - Addressed from Drew and Conor in PATCH1 - Use alphabetical ordering for SMAIA and SSAIA enum in PATCH2 - Use GENMASK() in PATCH3 Anup Patel (9): RISC-V: Add AIA related CSR defines RISC-V: Detect AIA CSRs from ISA string RISC-V: KVM: Drop the _MASK suffix from hgatp.VMID mask defines RISC-V: KVM: Initial skeletal support for AIA RISC-V: KVM: Implement subtype for CSR ONE_REG interface RISC-V: KVM: Add ONE_REG interface for AIA CSRs RISC-V: KVM: Use bitmap for irqs_pending and irqs_pending_mask RISC-V: KVM: Virtualize per-HART AIA CSRs RISC-V: KVM: Implement guest external interrupt line management arch/riscv/include/asm/csr.h | 107 ++++- arch/riscv/include/asm/hwcap.h | 8 + arch/riscv/include/asm/kvm_aia.h | 137 +++++++ arch/riscv/include/asm/kvm_host.h | 14 +- arch/riscv/include/uapi/asm/kvm.h | 18 +- arch/riscv/kernel/cpu.c | 2 + arch/riscv/kernel/cpufeature.c | 2 + arch/riscv/kvm/Makefile | 1 + arch/riscv/kvm/aia.c | 627 ++++++++++++++++++++++++++++++ arch/riscv/kvm/main.c | 23 +- arch/riscv/kvm/mmu.c | 3 +- arch/riscv/kvm/vcpu.c | 190 +++++++-- arch/riscv/kvm/vcpu_insn.c | 1 + arch/riscv/kvm/vm.c | 4 + arch/riscv/kvm/vmid.c | 4 +- 15 files changed, 1083 insertions(+), 58 deletions(-) create mode 100644 arch/riscv/include/asm/kvm_aia.h create mode 100644 arch/riscv/kvm/aia.c -- 2.34.1