Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp914832rwr; Wed, 19 Apr 2023 15:22:41 -0700 (PDT) X-Google-Smtp-Source: AKy350aa9Ey552/gF8DUPMK6M1RxbWHq4aexUekED/5bCmo+b5vMNl3/3Ua4JX+Yx24sG+/d6IG6 X-Received: by 2002:a05:6a21:586:b0:ef:957f:5a2b with SMTP id lw6-20020a056a21058600b000ef957f5a2bmr6616pzb.48.1681942961160; Wed, 19 Apr 2023 15:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681942961; cv=none; d=google.com; s=arc-20160816; b=BQ5scTwU57lWkV94QyHIqYa8n16mF33xmgA8d8Yepjnmq1+u+6tBdJcv47U2AecDzE abnw48lKkKAZaGK72V0SpF7AA9ruz663pbl3U3NaUDFntDUuXoCDhbyAEffyHxIVPLtP eiqX0t9kJpwleHH4effL0CGnzLTST0tuKAS6xMAyojmeoZ0OCKY9YhJTNbuFzqBYPd0W igF3UuxgO/fgZxTNlnPNDviYQakMaB8gbizSRat10z6FZeQ5qB/tV7yD+EyGAIETQCsQ 3GTIhR+RXqwaTcj7s80eg+Me/p+qb2Gv5xsAzbwDotsprSLqfVCG2PBBK75xxm49lZUq kyPg== 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=V944izAfHfvPXt2SodYy8axfAv3FUhh/YjA49qCII3Y=; b=lUps09F7mO9z3Wq6qOwKdLbkgC0egXJ/ZzVnXS+wcSXpuHPXmGYcAsW1Ys6rXnRXG3 XK1lF+Hn8Kjy230L5GgTR2rpbwTAv14OcShWGpIJ5oA4YSv2JT8EbMGCUrFNLKByZdrz vLPS94jOwUqCKdjYCBUno9ui5b4YTvVfD1nJpOmSSvSIFpxslsYrR+Jv6v8KEQxnGFS6 daIWMgEkQQiFp7PySlwUd/dOyIuN/7ZyvWuX8ruG1ibrVhcWW3ANS8u7ORjOr97ekrrZ dbSZ7rbsUXWv3XIaE49ea3DFRqAwizJ/2C/czDYKPJPoAb2xfS72N/WW5e0ILUyqjLne iuSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=WToiBYM9; 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 i187-20020a6254c4000000b006354c293903si16721246pfb.283.2023.04.19.15.22.29; Wed, 19 Apr 2023 15:22:41 -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=WToiBYM9; 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 S233224AbjDSWVu (ORCPT + 99 others); Wed, 19 Apr 2023 18:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233227AbjDSWVM (ORCPT ); Wed, 19 Apr 2023 18:21:12 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8F9F8689 for ; Wed, 19 Apr 2023 15:19:52 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1a682eee3baso4404995ad.0 for ; Wed, 19 Apr 2023 15:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681942725; x=1684534725; 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=V944izAfHfvPXt2SodYy8axfAv3FUhh/YjA49qCII3Y=; b=WToiBYM90+kXSHR4f4lcMC2do7CnNE609AkBJ9ILRsQSAqLQhvGE4fka9RZc7XkmOV nVSgbPgR0g26+R9aOz7prZ0ZYw39dV9KxvmHBGDvRgR8MR74QfL1ZHIt8XSWqAKcLN8r 0f6Tq006zXgK2g4OuuillctnBCZLY1xVWuRZMqYQdfd3ybKvutxZLqu19QqqHmXC8ODS KoYa4jRQnyk9O92MghnQdSKIAU/AWL4fTpgXKATBvPLDFP59BwJ0oeGTqTbRTShwnDj2 1+Ojob0S1CfD+/Tznk4BIbXVZIp9qmP+FcBhkm6vxxe63VSq5U1n2NJ31boDb5/Auf9y qI8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681942725; x=1684534725; 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=V944izAfHfvPXt2SodYy8axfAv3FUhh/YjA49qCII3Y=; b=jp22FV3CYZZWjxpvmWzotzlDsJ4cbvq7rcHqVIl6xdtdi+s6uuQvkj/Os7kyGfU0bO 8kNY2UoKqMuzopeWBlbsruzKneLbeLjz9Vp5q1tFay1rum54L8kMgPLHHs24jp7xENfE aFCmA3TNg1etFPfmN2xbrZ0XAcmPp0CbIEg4y81e3csA0euVjpG/UXRRTuzc+aUEJ5cD iMYYhu91rgODY5juPTXFqsMaZmreGHkdVAaQH2pmzpfIJE8dLGhCURBqL+UDn+RRIG8j WHWB/zk1AsVXWF6dexmTCDZ+QJa+JQLT/kgc0chshfTE2FWfvfIAyZqmLrihbufUBVze 6h3A== X-Gm-Message-State: AAQBX9eXQuKdBmO7QE80qSDVh2m90syr0f1bxwRoq6YDTLpsIb7KXhA5 boEZAqI1SPwESBfX/RUfyj4oIIVa246Xlp4Z6LE= X-Received: by 2002:a17:903:2409:b0:19e:839e:49d8 with SMTP id e9-20020a170903240900b0019e839e49d8mr6224177plo.59.1681942725072; Wed, 19 Apr 2023 15:18:45 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:18:44 -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 34/48] RISC-V: KVM: Initialize CoVE Date: Wed, 19 Apr 2023 15:17:02 -0700 Message-Id: <20230419221716.3603068-35-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 CoVE initialization depends on few underlying conditions that differs from normal VMs. 1. RFENCE extension is no longer mandatory as TEEH APIs has its own set of fence APIs. 2. SBI NACL is mandatory for TEE VMs to share memory between the host and the TSM. Signed-off-by: Atish Patra --- arch/riscv/kvm/main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c index 842b78d..a059414 100644 --- a/arch/riscv/kvm/main.c +++ b/arch/riscv/kvm/main.c @@ -102,15 +102,12 @@ static int __init riscv_kvm_init(void) return -ENODEV; } - if (sbi_probe_extension(SBI_EXT_RFENCE) <= 0) { - kvm_info("require SBI RFENCE extension\n"); - return -ENODEV; - } - rc = kvm_riscv_nacl_init(); if (rc && rc != -ENODEV) return rc; + kvm_riscv_cove_init(); + kvm_riscv_gstage_mode_detect(); kvm_riscv_gstage_vmid_detect(); @@ -121,6 +118,15 @@ static int __init riscv_kvm_init(void) return rc; } + /* TVM don't need RFENCE extension as hardware imsic support is mandatory for TVMs + * TODO: This check should happen later if HW_ACCEL mode is not set as RFENCE + * should only be mandatory in that case. + */ + if (!kvm_riscv_cove_enabled() && sbi_probe_extension(SBI_EXT_RFENCE) <= 0) { + kvm_info("require SBI RFENCE extension\n"); + return -ENODEV; + } + kvm_info("hypervisor extension available\n"); if (kvm_riscv_nacl_available()) { -- 2.25.1