Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp918812rwr; Wed, 19 Apr 2023 15:27:39 -0700 (PDT) X-Google-Smtp-Source: AKy350Znj0EX4cWl5EWrCu5sINYi7nNXvt+qq4DXv9QlGxgYnKyPpQBfb6TkLn72/l3jURzz0SFT X-Received: by 2002:a17:902:db09:b0:1a6:67e1:4d2c with SMTP id m9-20020a170902db0900b001a667e14d2cmr8620288plx.6.1681943258815; Wed, 19 Apr 2023 15:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681943258; cv=none; d=google.com; s=arc-20160816; b=vhCFP7MhwiGxE2C1bHObN3T2oAZ8jrGQZdiuhbj9Q3cIEqcRe8rOCe7FMBn233ycTH XdoEvSdYjnVjMMeHo6fHulV1wfiTsBpXMrd7788VDFzp+siFLFWt8hJ98QCmcZZ806R1 pHk8q5vrjCeFxuqq4xg7+OxZyJNsDQCvbpxanTos7grNVBkYSev4WufXfyqwT+qNW5Ta lP5M6DtrUAk0op8pYjv4nB0uSq/79sb3qxia9OY+n8MpuqXn4uMz+tsCvMCx5pbtOHQR VCPIZaahjY/oAEVCfNI5/8V9lKF3Rre0EpQIF8UpKvT1e/seCZ2FjxIntZI8Rs6SakEJ 9Zvw== 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=9TyRM4nmtqohXFcwttydo/M979fjFpXSQwmt1QhEq7M=; b=ZfkAOAPkfor7SLimZRALidfxqUix/22KCRSfvthGAsYT7SeeSycKbVoB8f49uUp1XM 8kOFhpTc9crZZjxXrk4qbT2W8uV2nq3vGGdFWjubxAUo7g+2EmhTWIun+S49BZzNQrPG hRDIVeYF+/+jEs8NO3lkAexqFUqMMeMpgsmvo0dc4RQp7pWdrIhQjd8bca7nZOSvDTro QlAZvneJqUQRqlw6gQSysElXyqe9oYQaG2UAg17KsJqWRHxauOXUpCKCPDk3hie5FMOx gdHQPWQAC7boSfBpIrZIcbkyW7i6B7UDYUoWpO348lfJhJ+sxds/qsem+ygTN9VFzIRX ZLGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=o6BPf3mJ; 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 u18-20020a170902e5d200b0019926d9c734si18463897plf.602.2023.04.19.15.27.24; Wed, 19 Apr 2023 15:27:38 -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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=o6BPf3mJ; 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 S233712AbjDSW1I (ORCPT + 99 others); Wed, 19 Apr 2023 18:27:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233606AbjDSW0t (ORCPT ); Wed, 19 Apr 2023 18:26:49 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D21497EF3 for ; Wed, 19 Apr 2023 15:25:23 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-63b4dfead1bso379563b3a.3 for ; Wed, 19 Apr 2023 15:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943042; x=1684535042; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9TyRM4nmtqohXFcwttydo/M979fjFpXSQwmt1QhEq7M=; b=o6BPf3mJiKmzHDTQduMjlUPZ224ynCQVPjqAxFiYl/xtjQhTUbKlM14FTeWvmNMg/L l0DrouIryk3u/EqI3byzcjbrgz+G8kwOXpTd0QZK3d3sEG9AOlbIPNTOq+DH6PD+Epo3 zKe9QwsowdLs42oiVJKkIvYtT/MItZZgmSKR5C8Ea2x67PbxuR6leIH+i/b17jseR8bM VBwwA8Z195NKwe50pkO3mLwwTJ4OtkL6UCepduj0leLb4C5T7elpUTzmBMMBASJjF094 bjxf9OSnAjUqLeAmsOa6EGQ0N3vUcmm6xctjwRZKzfkPZSzkZvKP3toboLwrlJYiGk9k 5odA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943042; x=1684535042; 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=9TyRM4nmtqohXFcwttydo/M979fjFpXSQwmt1QhEq7M=; b=H53PX1aDfcL8EfvuTp9l+S0m0i56fY/THg85rU0F4Tn1f4mjxkd++RIDKi0fVcnanD VCZHyCiIF4WnVp19IevFAIMWYOpdWnGMChG95H8JC2fzQYQv7ag9pHBgX1zxOtobrl1Y cwk+aKWO+W6TEnTe/UAP6yC4u2oa3P2PyvyE6LmsL1LFvfv17iOWlr9hFLT1nJ+f7+K4 9XlBggR0uny/6c3L1E8DW7RJ90a311/z8vpl52Kuvx3po2GRCL8i//0hIfJzxsbwQ2QR bhgaRcV1an5ICM2dI0tNZo5+CLYg+Q3at9bPAWPaC59KvPz88dyEk17icAxNmMnU9Z3y Kw/g== X-Gm-Message-State: AAQBX9fOzOmWEfVQVcFevjTl6GhLS88Vf9p2NYWou/OdmOeUZs8/r2cQ 23vyxJLPL6mUI869c4mzoLGe6OYO7WuRJ3frh2Y= X-Received: by 2002:a17:902:7244:b0:1a2:37fc:b5e2 with SMTP id c4-20020a170902724400b001a237fcb5e2mr5966265pll.7.1681943042538; Wed, 19 Apr 2023 15:24:02 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:02 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC kvmtool 00/10] RISC-V CoVE support Date: Wed, 19 Apr 2023 15:23:40 -0700 Message-Id: <20230419222350.3604274-1-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 This series is an initial version of the support for running confidential VMs on riscv architecture. This is to get feedback on the proposed COVH, COVI and COVG extensions for running Confidential VMs on riscv. The specification is available here [0]. Make sure to build it to get the latest changes as it gets updated from time to time. We have added a new option, `--cove-vm` to the `run` command to mark the VM as a confidential VM. The host including the kernel and kvmtool, must not access any memory allocated to the confidential VM. The TSM is responsible for providing all the required information to handle faults and emulate devices. The series adds support to manage CoVE VMs, which includes: * Configuration * Creation of CoVE VM and VCPUs. * Load initial memory images using measurement ioctls. * Virtio support for CoVE VMs. We don't yet support APLIC and thus no line based interrupts. So we use pci transport for all the virtio devices. As serial and rtc devices are only mmio based so we don't yet support those as well. virtio for the CoVE enforces VIRTIO_F_ACCESS_PLATFORM flag to force SWIOTLB bounce buffers in confidential linux guest. The SWIOTLB buffers are shared with the host using share/unshare calls in COVG extension. Thus host can directly write to those buffers without TSM involvement. This series depends on few RISC-V series which are not yet upstream. * AIA support[1] * SBI DBCN extension[2] It also reuses the arch specific virtio host flag hook from CCA series[4]. The patches are also available here: https://github.com/rivosinc/kvmtool/commits/cove-integration-03072023 The corresponding linux patches are also available here: https://github.com/rivosinc/linux/tree/cove-integration Running a CoVE VM ------------------ Extra options needed: --cove-vm: Launches a confidential VM. --virtio-transport: We don't yet support MMIO devices so we need to force virtio device to use pci transport. $ lkvm run \ --cove-vm \ --virtio-transport=pci \ The details instructions can be found at [5] Links ============ [0] CoVE architecture Specification. https://github.com/riscv-non-isa/riscv-ap-tee/blob/main/specification/riscv-aptee-spec.pdf [1] https://github.com/avpatel/kvmtool/tree/riscv_aia_v1 [2] https://github.com/avpatel/kvmtool/tree/riscv_sbi_dbcn_v1 [4] https://lore.kernel.org/lkml/20230127113932.166089-28-suzuki.poulose@arm.com/ [5] https://github.com/rivosinc/cove/wiki/CoVE-KVM-RISCV64-on-QEMU Atish Patra (7): riscv: Add a CoVE VM type. riscv: Define a command line option for CoVE VM riscv: Define a measure region IOCTL riscv: Invoke measure region for VM images riscv: Do not create APLIC for TVMs riscv: Change initrd alignment to a page size riscv: Define riscv specific vm_type function Rajnesh Kanwal (3): riscv: virtio: Enforce VIRTIO_F_ACCESS_PLATFORM feature flag. riscv: Don't emit MMIO devices for CoVE VM. riscv: cove: Don't emit interrupt_map for pci devices in fdt. include/linux/kvm.h | 4 ++ riscv/aia.c | 31 +++++++---- riscv/fdt.c | 38 +++++++------ riscv/include/asm/kvm.h | 6 +++ riscv/include/kvm/kvm-arch.h | 4 +- riscv/include/kvm/kvm-config-arch.h | 4 +- riscv/kvm.c | 51 +++++++++++++++++- riscv/pci.c | 83 +++++++++++++++-------------- 8 files changed, 152 insertions(+), 69 deletions(-) -- 2.25.1