Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp54043rwp; Wed, 12 Jul 2023 09:33:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlFr9/gYsomo+CjCpuVk6HAfrnygRlPWbQ+5s3TVodSBbz12EB5HSKsgmnbb4igKe3a3vs0L X-Received: by 2002:a17:907:8a24:b0:993:e85c:4ad6 with SMTP id sc36-20020a1709078a2400b00993e85c4ad6mr3642030ejc.7.1689179620005; Wed, 12 Jul 2023 09:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689179619; cv=none; d=google.com; s=arc-20160816; b=rPBWjcBrwJbgpxvxpJ4j29jVCdhg5xgnYPPyCCOgPMkBLLyktPi1FYTZRkSD1QzDyT e3SghRjEKLfl7aH0+qXulSZgfDO01jd/xbogu3X1cbxc5YkjTzO+gIeJnRoyA+baP1Ap seKoLga4o48JOa6tTs4/Uo1xK1p5OIHMi3Ob/ty9oC6rLq72lkUI7v2HpyQDn7T/0OY+ 8vuPLk3OG+WL1YD6t4NJJMhvUm3xMrk/T1G4jMf/V3FgbNiO9qN4+0mnE2Q/QFJ7pI+N l+0TO8OItLWN+9X731qrZM9BolME+T/gxdP8uaO59F/zTixEvsivlQ1nhLN43AL0Iu+m gNmw== 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=gtCtF2Lqb1YygYwlUUaBy2ctB42EouI70e6s/Uz9+Cc=; fh=7vtz7jDuhUIG1VC6d7lmHII/nER6vGRryESMvDC33bc=; b=J5BcAfGUvc1ljHsHEoUKSwKQa/yoyjcGvEHxVJTgkutWfq6/EFl1rRk/FFTnKVf4Iv s7rzxqyF4Ygc9HJs5A/yvGjxH69J6QBlhfnfSy6PinSrYt0NwSq9XBz4f7u6O7/e3Hkq ynQwk2Wcc6RR2f17cci7EYoSpRnieJseIrhNDS0pCJ+aHqUr607TClqViflI12zhbDpO XvRxhQya7uSflgGZbP4Pyhj1UwSXyDI2ClFuS6HVLzMNOiX0VtBYbPNzodFZLXcA4p5u iB6yKd86fcfonqLpiykDaVAdcy8/NdrE133/AbIQr4Tixvf+a6+s7p4Go6YUylMVQ6i1 Wgkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=EZkO2jms; 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 ss15-20020a170907038f00b0099317a3240esi5185726ejb.396.2023.07.12.09.33.14; Wed, 12 Jul 2023 09:33:39 -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=@ventanamicro.com header.s=google header.b=EZkO2jms; 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 S233305AbjGLQLq (ORCPT + 99 others); Wed, 12 Jul 2023 12:11:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233133AbjGLQLm (ORCPT ); Wed, 12 Jul 2023 12:11:42 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 065F41FE0 for ; Wed, 12 Jul 2023 09:11:24 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1b8b2b60731so33359975ad.2 for ; Wed, 12 Jul 2023 09:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1689178284; x=1691770284; 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=gtCtF2Lqb1YygYwlUUaBy2ctB42EouI70e6s/Uz9+Cc=; b=EZkO2jmsowUwtRgDtIpbAptf0MaO6v+JJ4rLp6Fydhm3WGP1O6M9N26UzmspPwksWt A33s76ThRvy/igg9Y403/YV9StsFgmrOTRt+SSzsRHBZkSliHPdcIl1oxFONKI35UKkr 8ySFxiJPbhgW0gFTA13HOZijL25Q8jHVyK7BopBPMovq/ajmTOUK3oxeJiecPUbe7rzi ZCxUmFrqpUCZUZWTQIZQ/lrrjrNB/5reJLh3GZnHICm7vO5PDsyIRD0rpwR8kmM/XrLm I3Ptl+6pK1xx7CgcLkx0lfK0Z8XkI/S2RlVFQWmP/jQN3eB7UF4daBbEuSvNeUDC6G/v lErw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689178284; x=1691770284; 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=gtCtF2Lqb1YygYwlUUaBy2ctB42EouI70e6s/Uz9+Cc=; b=XWo7DroixJHgUoasyKUn1ciEv164AZ6HJMd39BLxi/S3du9vt/s65aiUYTlpapta7m MA3zX0GnXqyjc/7DNfl9VvaRUZYnE9rM10sLD5C8S47wxSTwnc1E+uxzA4f7hZ0oS25C qUbROJ7lKkT4KPkCRFBCitz+xVwkvpOxSyNl+FcU4S8UVYHSM3jLW1Ti+HoiNPpaqMZr Zqsw5vE5y8dfI5S9zKfzON1n7EX1Cm3jukU49MtlkvG9BwdFSMigXdwV2bxiHKgSgvGy PgbHK8gbA/Hd9pYF5II5zqheOkNHwYkQXpFLfeunEoSiWc2AiVfttptMuU3SXCwtJu70 PJHg== X-Gm-Message-State: ABy/qLbxI8WKaxBsVF4eK3595EzOXpodf2/lZ3jSvx/U0nFzXgjAXPRg zFoDgE3b6FG0aOJKi0/UmGu7lw== X-Received: by 2002:a17:902:9a4b:b0:1ac:7245:ba5a with SMTP id x11-20020a1709029a4b00b001ac7245ba5amr13407006plv.61.1689178284234; Wed, 12 Jul 2023 09:11:24 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([171.76.82.173]) by smtp.gmail.com with ESMTPSA id bc2-20020a170902930200b001b9f032bb3dsm3811650plb.3.2023.07.12.09.11.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 09:11:23 -0700 (PDT) From: Anup Patel To: Paolo Bonzini , Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Andrew Jones , Heiko Stuebner , Samuel Ortiz , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH 6/7] RISC-V: KVM: Allow Zbc, Zbk* and Zk* extensions for Guest/VM Date: Wed, 12 Jul 2023 21:40:46 +0530 Message-Id: <20230712161047.1764756-7-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712161047.1764756-1-apatel@ventanamicro.com> References: <20230712161047.1764756-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UPPERCASE_50_75, URIBL_BLOCKED autolearn=no 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 We extend the KVM ISA extension ONE_REG interface to allow KVM user space to detect and enable Zbc, Zbk* and Zk* extensions for Guest/VM. Signed-off-by: Anup Patel --- arch/riscv/include/uapi/asm/kvm.h | 11 +++++++++++ arch/riscv/kvm/vcpu_onereg.c | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index 9c35e1427f73..182e7bdfc842 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -130,6 +130,17 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_ZICSR, KVM_RISCV_ISA_EXT_ZIFENCEI, KVM_RISCV_ISA_EXT_ZIHPM, + KVM_RISCV_ISA_EXT_ZBC, + KVM_RISCV_ISA_EXT_ZBKB, + KVM_RISCV_ISA_EXT_ZBKC, + KVM_RISCV_ISA_EXT_ZBKX, + KVM_RISCV_ISA_EXT_ZKND, + KVM_RISCV_ISA_EXT_ZKNE, + KVM_RISCV_ISA_EXT_ZKNH, + KVM_RISCV_ISA_EXT_ZKR, + KVM_RISCV_ISA_EXT_ZKSED, + KVM_RISCV_ISA_EXT_ZKSH, + KVM_RISCV_ISA_EXT_ZKT, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c index 36871a417e69..08e077260214 100644 --- a/arch/riscv/kvm/vcpu_onereg.c +++ b/arch/riscv/kvm/vcpu_onereg.c @@ -40,6 +40,10 @@ static const unsigned long kvm_isa_ext_arr[] = { KVM_ISA_EXT_ARR(SVPBMT), KVM_ISA_EXT_ARR(ZBA), KVM_ISA_EXT_ARR(ZBB), + KVM_ISA_EXT_ARR(ZBC), + KVM_ISA_EXT_ARR(ZBKB), + KVM_ISA_EXT_ARR(ZBKC), + KVM_ISA_EXT_ARR(ZBKX), KVM_ISA_EXT_ARR(ZBS), KVM_ISA_EXT_ARR(ZICBOM), KVM_ISA_EXT_ARR(ZICBOZ), @@ -48,6 +52,13 @@ static const unsigned long kvm_isa_ext_arr[] = { KVM_ISA_EXT_ARR(ZIFENCEI), KVM_ISA_EXT_ARR(ZIHINTPAUSE), KVM_ISA_EXT_ARR(ZIHPM), + KVM_ISA_EXT_ARR(ZKND), + KVM_ISA_EXT_ARR(ZKNE), + KVM_ISA_EXT_ARR(ZKNH), + KVM_ISA_EXT_ARR(ZKR), + KVM_ISA_EXT_ARR(ZKSED), + KVM_ISA_EXT_ARR(ZKSH), + KVM_ISA_EXT_ARR(ZKT), }; static unsigned long kvm_riscv_vcpu_base2isa_ext(unsigned long base_ext) @@ -89,12 +100,23 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext) case KVM_RISCV_ISA_EXT_SVNAPOT: case KVM_RISCV_ISA_EXT_ZBA: case KVM_RISCV_ISA_EXT_ZBB: + case KVM_RISCV_ISA_EXT_ZBC: + case KVM_RISCV_ISA_EXT_ZBKB: + case KVM_RISCV_ISA_EXT_ZBKC: + case KVM_RISCV_ISA_EXT_ZBKX: case KVM_RISCV_ISA_EXT_ZBS: case KVM_RISCV_ISA_EXT_ZICNTR: case KVM_RISCV_ISA_EXT_ZICSR: case KVM_RISCV_ISA_EXT_ZIFENCEI: case KVM_RISCV_ISA_EXT_ZIHINTPAUSE: case KVM_RISCV_ISA_EXT_ZIHPM: + case KVM_RISCV_ISA_EXT_ZKND: + case KVM_RISCV_ISA_EXT_ZKNE: + case KVM_RISCV_ISA_EXT_ZKNH: + case KVM_RISCV_ISA_EXT_ZKR: + case KVM_RISCV_ISA_EXT_ZKSED: + case KVM_RISCV_ISA_EXT_ZKSH: + case KVM_RISCV_ISA_EXT_ZKT: return false; default: break; -- 2.34.1