Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp914871rwr; Wed, 19 Apr 2023 15:22:45 -0700 (PDT) X-Google-Smtp-Source: AKy350alYZ1wtvaVGY9vzh9Rpya9mdg/ynCySlg1ZBVgDeC4VZvVpXtXmGl2Y5jh3saAv5/SBkcV X-Received: by 2002:a17:903:22c7:b0:1a6:3737:750c with SMTP id y7-20020a17090322c700b001a63737750cmr4104229plg.21.1681942964862; Wed, 19 Apr 2023 15:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681942964; cv=none; d=google.com; s=arc-20160816; b=M4MiCMCzkut/1Aa2uzeQFHBuDTfFpOioYzdKgR4+JXZ2OHZy47SP1CamGCYu61PcP+ DTAni+L77H1PRCxh/ImH3W5nCtUvYj1nbCv1N+GtYqz68I5Aq2TndKOKuXwVC3ueORKf oeW2FuxYIuoGdwXPyGku01QtSS9xQo/0Vll8+Lwl3fKdOEOopK6kEZyKu1u900l7BP8d IROraXGlpgKXc9CcAuCdDFNlIHLmvA+GhVMzvbCV5vpAuG5LWcw5g/TtvULD8eA1q3ui LQn7Kmh2ooQeuupP6vqulJYOymYLd8dKPviVyNwR9nAgphHtsFhfsHt3cP0UkDYD1k2z rkZg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PF8Qn0Z7zg/7RPDtBuNuOPN3zeJXhr/Jx4YP7Fj6yI4=; b=tJFtu1TDD9Iv5jzBP+qGiw2lxytX1zbQpDCdVnmecKMu3g5HeDNiWPo7aU/ME2/Owe KG2cIgtCnyfF/28R0dEscXxeKBLsb0OchLXkfS0GoqU2OJYE4goRnszxamJ3TlIPaEV7 o/f/TyIVUJm06KaaS4e8ypDWDvuFOGbz34K3B1El1rVF6i4RhSSc4oLufkcxFtCPpiUl 8kki5cIk0BaPww7JyGwwiaCOVAO9B06zREapMX6+jR/Gaqh9AavtPw4yQO9hP1x0L7aD 4WTTqOCRdlcZDHe7PEZI19icc1OsR8wdNNYpPdnBMjq2K0EfaOhtsNAMgRQQ7t6BmZ/r vYyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b="G/Fug0YD"; 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 4-20020a630f44000000b0050bf5a814a8si16478960pgp.403.2023.04.19.15.22.33; Wed, 19 Apr 2023 15:22:44 -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="G/Fug0YD"; 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 S233325AbjDSWWE (ORCPT + 99 others); Wed, 19 Apr 2023 18:22:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232395AbjDSWV2 (ORCPT ); Wed, 19 Apr 2023 18:21:28 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF588B440 for ; Wed, 19 Apr 2023 15:19:59 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-63b73203e0aso2786785b3a.1 for ; Wed, 19 Apr 2023 15:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681942727; x=1684534727; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PF8Qn0Z7zg/7RPDtBuNuOPN3zeJXhr/Jx4YP7Fj6yI4=; b=G/Fug0YDh/vT2gLC0JnMu9cK8/lm7JaHRK8wavACXkcusYj2LIYmBRBKMqHOqlZK+w 4X0VmEj6BTotc/ZSwQ/hqCf5XFjDLPfMNoRWYQ9eoQMvSpOlejZpx2S6qdCGkDr0mV1j tz/t8nrgfTSM3p2DcPJ6IP/ULX8p9u8n4bLZ8UppcJfyijITcktTN9QxUA/PYL/GUGR2 g1Dwy3qOR6S1EA5f1HDfH1/Z8AcgmbMd6OoD3Rpin7C3Tw7AepN0itfwNNwkxK4BS08T wI5vk6637oOkFsektud4GizoiS09rEJkFLg8xFSYn4+9QqroF/v5cNomyMNwCRJWPRAY /ruQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681942727; x=1684534727; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PF8Qn0Z7zg/7RPDtBuNuOPN3zeJXhr/Jx4YP7Fj6yI4=; b=l8bLfvxtrAJQV1AyAX2eALO58Hi8gC9kUwu7MQadQ0zOfvGauzWRqrr5mzMC2FT6HC EHY5/VG1EKzKNNoMXpzsR+20GARQ0MBQBxl3uuKlPPAuE8t+FWs/cpC6zLo57J68BMn1 pvGvNALp2sfSCK2iUz2WT0Ood9Y8z1AUXd9JsySwUEzaAiIo1U+d5nj2ir6tn9FfER9p C7LJCocijQ4/c8KRBCBmEsXSbsLBG4Cmb2keG7BAwn5w5lMUQfe7qC+SCGh7uAZvNXfW StyRsp2pB+R0x1YqOkfJhoRQ9mGwGtqK5fiXuTBGFNm5adZjffmZ2DuzpCXbmRez5Cht 1cSg== X-Gm-Message-State: AAQBX9cZFHAp0umZiJeN12L4qDRGgZSF9thQy7w5Qx0b0fYxeaZI6sEJ lek/8sEHDQZWs05HJsVyheRx5u1gcJT7D7/TyyI= X-Received: by 2002:a17:902:ea03:b0:19b:64bb:d546 with SMTP id s3-20020a170902ea0300b0019b64bbd546mr4360345plg.18.1681942727339; Wed, 19 Apr 2023 15:18:47 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id jn11-20020a170903050b00b00196807b5189sm11619190plb.292.2023.04.19.15.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:18:47 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Christoph Hellwig , Conor Dooley , Greg Kroah-Hartman , Guo Ren , Heiko Stuebner , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Mayuresh Chitale , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC 35/48] RISC-V: KVM: Add TVM init/destroy calls Date: Wed, 19 Apr 2023 15:17:03 -0700 Message-Id: <20230419221716.3603068-36-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419221716.3603068-1-atishp@rivosinc.com> References: <20230419221716.3603068-1-atishp@rivosinc.com> 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 A TVM can only be created upon explicit request from the VMM via the vm type if CoVE SBI extensions must supported by the TSM. Signed-off-by: Atish Patra --- arch/riscv/kvm/vm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/riscv/kvm/vm.c b/arch/riscv/kvm/vm.c index 1b59a8f..8a1460d 100644 --- a/arch/riscv/kvm/vm.c +++ b/arch/riscv/kvm/vm.c @@ -42,6 +42,19 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) return r; } + if (unlikely(type == KVM_VM_TYPE_RISCV_COVE)) { + if (!kvm_riscv_cove_enabled()) { + kvm_err("Unable to init CoVE VM because cove is not enabled\n"); + return -EPERM; + } + + r = kvm_riscv_cove_vm_init(kvm); + if (r) + return r; + kvm->arch.vm_type = type; + kvm_info("Trusted VM instance init successful\n"); + } + kvm_riscv_aia_init_vm(kvm); kvm_riscv_guest_timer_init(kvm); @@ -54,6 +67,9 @@ void kvm_arch_destroy_vm(struct kvm *kvm) kvm_destroy_vcpus(kvm); kvm_riscv_aia_destroy_vm(kvm); + + if (unlikely(is_cove_vm(kvm))) + kvm_riscv_cove_vm_destroy(kvm); } int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irql, -- 2.25.1