Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp912368rwr; Wed, 19 Apr 2023 15:19:50 -0700 (PDT) X-Google-Smtp-Source: AKy350ac6WMFfVin+D8c/xTvtQjMbZ0rL3173ly8vkvtLh+DytHJ7nwKCOIXppLAP/Q7WxUV2KWI X-Received: by 2002:a05:6a00:1a53:b0:63d:3d08:4792 with SMTP id h19-20020a056a001a5300b0063d3d084792mr5777943pfv.32.1681942790101; Wed, 19 Apr 2023 15:19:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681942790; cv=none; d=google.com; s=arc-20160816; b=B5YTSW6/Za3vdKvvwTNeBlYc88SvA9R2fVagIY9ZiMvQBmgvIUTESzEHih6ovikq4b AgeIkfCj/GYgKt9s+tmk1H0oas5IAz1iWJsb+YqQXbTEgo5lfo03XCo3mFwOqJuIKN3p zRrZOBtod1EmBTV8WrvwkX92P4LOdID4jAGogxGFpuZctnhNjb2e43IHF5dYiv1PYGlE bSsPJNxzo6Xtxa2R5wKPGj4K0ln8WZ9ZtCT2mDungoGdUdn68wtkH5vfPgtI0EEYQYq1 6nW3olKZ22hbG5T4lkzcOOOxVu8ShgZvP+cC1QK7x0pq7Hvc5oPqEWs4VY+iHMB2EqZ3 sRgw== 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=T59m5JAZKpRDJgvlPNnQtLbeFsduDf6TBzeyZHAxXV0=; b=g8Vbcgo0JfeRhsxbwWQQoPIrZmJ3MqmGeObP75HA9xElg+nvlPnYrJJJPy9Z/DzlqQ WK4oQiZU88tV2Gy7h62U4WLFsfNLihok0WYeR2UPvFmrBq1Bsva5YYC5RWh+CWLPSGC5 gLxCtCepuavsV1d3N4G6gI/su6Pl0TX72cyaulj6C4zMns7e97+3d2kk0a9yAHgF4zYI uuzUFHNTTnvL/adaP07e0TKggwjc+EkjrQz8hvOmDS00N/GwtrtwwdTEfxn7qeTojbaV pMbvT0DyAy6mcklG4BnpMMgox3eT36d6Dh0W7Z691xQqW3vI6ajwYZjun0zl1T2vvi9i 2K6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=qjxNMIrl; 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 y185-20020a638ac2000000b0051ba9b9c3f3si2808946pgd.321.2023.04.19.15.19.15; Wed, 19 Apr 2023 15:19:50 -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=qjxNMIrl; 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 S231994AbjDSWSf (ORCPT + 99 others); Wed, 19 Apr 2023 18:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231910AbjDSWSQ (ORCPT ); Wed, 19 Apr 2023 18:18:16 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F338D6EB7 for ; Wed, 19 Apr 2023 15:17:51 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1a6762fd23cso4482215ad.3 for ; Wed, 19 Apr 2023 15:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681942669; x=1684534669; 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=T59m5JAZKpRDJgvlPNnQtLbeFsduDf6TBzeyZHAxXV0=; b=qjxNMIrl8HnhfIp/ecw72oYKFII9UTAwql/uMAHKk/FXlEBEiMQ66OH7eiwjlGKtCq fOjlVW3CuH2HqfOiNP9XRTFCzDI4+lJmQdsac4GSSp3r+OkcygCfPaztbk/heRGDIhKM pnYeif4EQ7Prrd5kCwoWu5m8+1XOIOkSJ78OzpuHzmCbajgIzTGS3QZn2FEzSLBwhiSb 6w7a2QMSx0oX83P6+RuntF3wYcXCE4rbF3duzd0QwdejxuKey4lt6WjYMDej+sLNVh9T 6z0R8DizcoQpeT/MVd47bfnzAc938aOKta+516VE8cUvwIwwgAey2BJajvvIriSfLlPU 8bjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681942669; x=1684534669; 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=T59m5JAZKpRDJgvlPNnQtLbeFsduDf6TBzeyZHAxXV0=; b=gB0Lra92rSJ6U2jcb8IkSKUYMjJKub5p6SP5GMHCefXT3MlicvuZMSr4MAqaeKfwtz v99VKVdPVkcNqk7AvgtAS5SQgEJN9sjhHkA5zUInIrkhwIWvyEmnlAe/XdE9BeZf4RBV LbRwbLpkBqIFs7zrLhxCUFyZ0TVxdiZ31dsJKp0au6zThC3Ikg4FN9Zx64g38IxEfKkE g656mwqNSuEuWwRyQvUB6+HaDqad5jS96VobCB4wGzv6w4bCQ4fwhXonVeSO4DoM0UvF cXOh3tZQWtlcn42fV1w+fMM6aIk12rN71lFMk/N3XEuV7gds+Dciu3D+vhRBoUfQQNuh YoiQ== X-Gm-Message-State: AAQBX9cKL+kQ90oM4yTbTkTi8E0FlTrphXgN0Q4Jr4M4vzy/CvwonpGV b8GsXlQ0P+yIEg61s0Sshq2rmKcN87xFR4Vnvzk= X-Received: by 2002:a17:902:aa4a:b0:1a1:f0cb:1055 with SMTP id c10-20020a170902aa4a00b001a1f0cb1055mr6242462plr.28.1681942669632; Wed, 19 Apr 2023 15:17:49 -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.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:17:49 -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 09/48] RISC-V: KVM: Add CoVE related nacl helpers Date: Wed, 19 Apr 2023 15:16:37 -0700 Message-Id: <20230419221716.3603068-10-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 The NACL SBI extension allows the scratch area to be customizable per SBI extension. As per the COVH SBI extension, the scratch area stores the guest gpr state. Add some helpers to read/write gprs easily. Signed-off-by: Atish Patra --- arch/riscv/include/asm/kvm_cove_sbi.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/riscv/include/asm/kvm_cove_sbi.h b/arch/riscv/include/asm/kvm_cove_sbi.h index 24562df..df7d88c 100644 --- a/arch/riscv/include/asm/kvm_cove_sbi.h +++ b/arch/riscv/include/asm/kvm_cove_sbi.h @@ -17,6 +17,21 @@ #include #include +#include + +/** + * CoVE SBI extensions defines the NACL scratch memory. + * uint64_t gprs[32] + * uint64_t reserved[224] + */ +#define get_scratch_gpr_offset(goffset) (goffset - KVM_ARCH_GUEST_ZERO) + +#define nacl_shmem_gpr_write_cove(__s, __g, __o) \ + nacl_shmem_scratch_write_long(__s, get_scratch_gpr_offset(__g), __o) + +#define nacl_shmem_gpr_read_cove(__s, __g) \ + nacl_shmem_scratch_read_long(__s, get_scratch_gpr_offset(__g)) + int sbi_covh_tsm_get_info(struct sbi_cove_tsm_info *tinfo_addr); int sbi_covh_tvm_initiate_fence(unsigned long tvmid); int sbi_covh_tsm_initiate_fence(void); -- 2.25.1