Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3902322rdh; Tue, 28 Nov 2023 06:55:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbBX9Sk2YN7+7/J1l9KHP9nUKgOLHxzOOI3p4dSi6PTLowkKC83gxGatLzcDVLvEdCNiBX X-Received: by 2002:a17:902:ecc2:b0:1cf:e9b3:e217 with SMTP id a2-20020a170902ecc200b001cfe9b3e217mr5013281plh.55.1701183351139; Tue, 28 Nov 2023 06:55:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701183351; cv=none; d=google.com; s=arc-20160816; b=MeoTnGyfGjUbp/Diw+mxheh5hG3KWZrOA5AFRgpUkrr/ABunyx4dqZaHxhGMa+Sr+9 oyugZPKiKtYlWslqK+E3pjGKQm9LjftgPa37SdJ8S9m2+l8LIAMroVvNnL6tadeZYrTh LX1D1yrcn9+q1LRgAnnVAw13UTXuI+wtofBjZfM4z8Y8urDDqYMhrzwqmcEPEQPQ37uq 8igAy4WHOjgudG7bDqoAt9oWYftIRyqdL7RqnJ5H1sG3R1Ksmz97u20Sk3aksWmYbGWC F76/DCQSQ/RwkFLBxn/+5NuaDWcvMCSeoRbh54qwyv/kjlJLtHWd4gwuQg2+tfhDGLUn ZQ+Q== 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=YC/uOewY1L4dDGRSRiyNDutyC8uaZPgPc5G7fpX+EZI=; fh=+jOfndtgkMGLet8rfMfGblttrnHjUS2P+rQOE/pONQo=; b=hfv10/UERg8ZIRT8e21sOcPbQPl89jqYlRdAQWUOkW9bRGIheQH/pIZskdxu+OqdCu 831Ff9gVkLm3AdPMJezxunJExJbc5UU4MiKi7zxOkm43qcbtbk6+XKxp7au5YEVXML+F AjVExMZnoh/XHLejspsVlRihNE3Cww1JurMF6qkh65zGpRw7hjWTxcVy0frcY3Fzg49Z +IFF2on1CJ4NPpWEXF5WOWEx2ShQYa7zRFRxfCVFnkDu2Af30d6fmm3waSgqeVEYrdVx 9PUt5p/56Oz3BIPXuZIWSqe38Kf1qOp5DQubU14fjNdCEOsaGh4w43rJKmaCVPbBqOaJ ErSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=dyUD96rJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id n18-20020a170902f61200b001bbf293f45esi12912579plg.625.2023.11.28.06.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 06:55:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=dyUD96rJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E84778080E08; Tue, 28 Nov 2023 06:55:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346422AbjK1OzB (ORCPT + 99 others); Tue, 28 Nov 2023 09:55:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346450AbjK1Oyo (ORCPT ); Tue, 28 Nov 2023 09:54:44 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 317091FD9 for ; Tue, 28 Nov 2023 06:54:40 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1cfafe3d46bso31745305ad.0 for ; Tue, 28 Nov 2023 06:54:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1701183279; x=1701788079; darn=vger.kernel.org; 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=YC/uOewY1L4dDGRSRiyNDutyC8uaZPgPc5G7fpX+EZI=; b=dyUD96rJ+cVkzEiE+MSTiACDwT7zKEKlbzmTUqDl/QNS77QUG2z0fINqU6vBqF4/QP cvRSodRT0y+5NXZ7mqCCPrkg00GMvk81oUgjM3HfaiDBVGk2/+9Zkkx88Ppa4pd9MOZH /M0W6CKv/OiztI3l/HQNuOCfM8HlpCERTBu0RTuHHMLyqRVQ5H9i5LzK4UN7uBB+MYkL LbWbtc8iGxCjqoW+D6vkPH5ioMDEwD78cCBwdX/PRv9Rw94htaFTbpcqpoEW9o0QpOuq S8YvpoXoM7K7IkVSn8+TaTaYzlT6irBro6p06h3J91wmL20wio30zAQOtaZvcB1nuzkg /uuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701183279; x=1701788079; 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=YC/uOewY1L4dDGRSRiyNDutyC8uaZPgPc5G7fpX+EZI=; b=fqMRWoI4pX7VgW+0VO/yhF3BGA36Ni21KP4ffKGmLjyRmgjfLwnKTcjnDsm35vhS2e NqP4Jc41r/6by6/AiJ3UKgA3uXSL+tEqAUwYrs0GDPWmFDQq/5lW/bXA88RMaTvhA5hl IDU2tpgsECfRWhuwd5x0zN8ukzSUj8pnHiR0hbyTNftEoZGGiMNnGfBFKYbh/d6kSG7J 9R24XR//H2QNMhFvlhLS0rqY1hEPfbPefsha/vPRJ8Yom8TBSI4KiX4Tpk+nVZTakVd3 cvDIoX5KRtKSkvuu5gLdKEmMx+REXyugnlasS7qccrFAp4ZWeUSakwbmb7QmUL4XklG9 APIQ== X-Gm-Message-State: AOJu0YxQHxfrR8yk3qNDl1GFPJz5vMbOdro+qXgMgC0HidOC1lydRUDv mQhDodkbI+B+ViqYasDzyIXZfw== X-Received: by 2002:a17:902:7483:b0:1cc:6ec2:d24e with SMTP id h3-20020a170902748300b001cc6ec2d24emr17051391pll.53.1701183279334; Tue, 28 Nov 2023 06:54:39 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id u11-20020a170902e80b00b001bf11cf2e21sm10281552plg.210.2023.11.28.06.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 06:54:38 -0800 (PST) From: Anup Patel To: Paolo Bonzini , Atish Patra , Palmer Dabbelt , Paul Walmsley , Shuah Khan Cc: Anup Patel , Andrew Jones , devicetree@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Anup Patel Subject: [PATCH 06/15] RISC-V: KVM: Allow vector crypto extensions for Guest/VM Date: Tue, 28 Nov 2023 20:23:48 +0530 Message-Id: <20231128145357.413321-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128145357.413321-1-apatel@ventanamicro.com> References: <20231128145357.413321-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 28 Nov 2023 06:55:36 -0800 (PST) We extend the KVM ISA extension ONE_REG interface to allow KVM user space to detect and enable vector crypto extensions for Guest/VM. This includes extensions Zvbb, Zvbc, Zvkb, Zvkg, Zvkned, Zvknha, Zvknhb, Zvksed, Zvksh, and Zvkt. Signed-off-by: Anup Patel --- arch/riscv/include/uapi/asm/kvm.h | 10 ++++++++++ arch/riscv/kvm/vcpu_onereg.c | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index 7b54fa215d6d..241632f91f73 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -150,6 +150,16 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_ZKSED, KVM_RISCV_ISA_EXT_ZKSH, KVM_RISCV_ISA_EXT_ZKT, + KVM_RISCV_ISA_EXT_ZVBB, + KVM_RISCV_ISA_EXT_ZVBC, + KVM_RISCV_ISA_EXT_ZVKB, + KVM_RISCV_ISA_EXT_ZVKG, + KVM_RISCV_ISA_EXT_ZVKNED, + KVM_RISCV_ISA_EXT_ZVKNHA, + KVM_RISCV_ISA_EXT_ZVKNHB, + KVM_RISCV_ISA_EXT_ZVKSED, + KVM_RISCV_ISA_EXT_ZVKSH, + KVM_RISCV_ISA_EXT_ZVKT, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c index b0beebd4f86e..4cd075f4cf9f 100644 --- a/arch/riscv/kvm/vcpu_onereg.c +++ b/arch/riscv/kvm/vcpu_onereg.c @@ -62,6 +62,16 @@ static const unsigned long kvm_isa_ext_arr[] = { KVM_ISA_EXT_ARR(ZKSED), KVM_ISA_EXT_ARR(ZKSH), KVM_ISA_EXT_ARR(ZKT), + KVM_ISA_EXT_ARR(ZVBB), + KVM_ISA_EXT_ARR(ZVBC), + KVM_ISA_EXT_ARR(ZVKB), + KVM_ISA_EXT_ARR(ZVKG), + KVM_ISA_EXT_ARR(ZVKNED), + KVM_ISA_EXT_ARR(ZVKNHA), + KVM_ISA_EXT_ARR(ZVKNHB), + KVM_ISA_EXT_ARR(ZVKSED), + KVM_ISA_EXT_ARR(ZVKSH), + KVM_ISA_EXT_ARR(ZVKT), }; static unsigned long kvm_riscv_vcpu_base2isa_ext(unsigned long base_ext) @@ -121,6 +131,16 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext) case KVM_RISCV_ISA_EXT_ZKSED: case KVM_RISCV_ISA_EXT_ZKSH: case KVM_RISCV_ISA_EXT_ZKT: + case KVM_RISCV_ISA_EXT_ZVBB: + case KVM_RISCV_ISA_EXT_ZVBC: + case KVM_RISCV_ISA_EXT_ZVKB: + case KVM_RISCV_ISA_EXT_ZVKG: + case KVM_RISCV_ISA_EXT_ZVKNED: + case KVM_RISCV_ISA_EXT_ZVKNHA: + case KVM_RISCV_ISA_EXT_ZVKNHB: + case KVM_RISCV_ISA_EXT_ZVKSED: + case KVM_RISCV_ISA_EXT_ZVKSH: + case KVM_RISCV_ISA_EXT_ZVKT: return false; /* Extensions which can be disabled using Smstateen */ case KVM_RISCV_ISA_EXT_SSAIA: -- 2.34.1