Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp49316rwp; Wed, 12 Jul 2023 09:30:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlGXZKHkRK5TUTnSrFtvEfjB+mMqqD2exUybMVJ/4lMA5CvRkejryFevPzkzkMCXILIcdHrv X-Received: by 2002:a17:902:b213:b0:1b3:d432:3026 with SMTP id t19-20020a170902b21300b001b3d4323026mr14695074plr.15.1689179410639; Wed, 12 Jul 2023 09:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689179410; cv=none; d=google.com; s=arc-20160816; b=vfcLx/pwzt5b9YrBlwkh0qPukke87iEeKwzgBk+ijGKhRX+vitKniK0PkIrvmNQWE8 sUSMsC6v38+ZaLPVYBcl60ame58AOo5t/QTziup5DkfXkdv4mGx9XqIb2ilFd5NbMMdi eaOJz4D2Nnf5PjUWCKs/b/QBtFJGPPQ0/IFMRwvo6CTEJnCbJYdXibDS5mW3fIOxM+Gl 9rfESkbXvsJEqOseuq9P71vJ1eVqoNVHvzBli4KQk4TvdpKkWFPsyRt6Ot2K7g2sG0oB KGXAh0v1R1g2tBFfjq4ujejdqfav0gJ3nyqx15nKOCm/ogmIF200InPbgLIAmqY7e0v4 dgdg== 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=yIhoBJIji5REw+c97wvX8gH5yx7OMiGOjWHtFLvuXY8=; fh=7vtz7jDuhUIG1VC6d7lmHII/nER6vGRryESMvDC33bc=; b=XRp9cRnlhWDn3wj/BgiCtYpOfzTez39pFkyDwIhBS/xMideB4QURRDkzvQUKNeBarf tdwb50XlFyxxigIGdUKNfbodnepgBb8eM+xJ1CtE88N1WkSaljjL5VaGntwwaBe0oe51 oR04JEbk/KrtGW2fn5fgSUaetcSFwRwhOP3IFVLpMfV1ABnTUy/LEzhzsBYNkQLcjFwl OMEyNM6pB1bFCjBQG5LertG07zELjGzgEpzc/YL4mjXsuxw/44GZ1XuEb1t+xaaK08Lc fQWGtU6LTrZpTwxdQIFDptws3L3+JIuPfc7jQiwxWmm55XhWwD6Msgku6AWlRoN+4tnG Bxhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=DZZl6Tyw; 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 w1-20020a170902e88100b001b6c462acbdsi3683301plg.15.2023.07.12.09.29.58; Wed, 12 Jul 2023 09:30:10 -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=DZZl6Tyw; 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 S232856AbjGLQLc (ORCPT + 99 others); Wed, 12 Jul 2023 12:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232720AbjGLQLY (ORCPT ); Wed, 12 Jul 2023 12:11:24 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32A102101 for ; Wed, 12 Jul 2023 09:11:18 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1b8a462e0b0so37208595ad.3 for ; Wed, 12 Jul 2023 09:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1689178277; x=1691770277; 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=yIhoBJIji5REw+c97wvX8gH5yx7OMiGOjWHtFLvuXY8=; b=DZZl6Tyw8rygxq6v1Ip8WcrsD1yMw3IJx70AOvwyWIZXUv6g7wymi7DWduMTgyI/t9 uvO8LdmbUqraLqRMq8xwFd6S9oAciovNB9nTsIblGR+XwQ9Xe/FL5Qf1lsXCblO0QXM3 X8jEL+v85UEWQggyFYzoT0GNUi+xZunYwUP07iidokwKQYaorj8lmWEV1b1jrIBPCrQR qO8iH1vLuooQC01OSehv8g3+36qDMzDLYB5Ccghk1GLgLihiA6Orq5rk7GKR17rBy4SO rPpkN1ZEChVnqODAcYV2KjMouU3bds6fmw4j/qEkE6SBWX7QfhNkYV/nW7wRcyRbh1cY dipw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689178277; x=1691770277; 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=yIhoBJIji5REw+c97wvX8gH5yx7OMiGOjWHtFLvuXY8=; b=Ti40sBpjKfGRDFQky2YRV9EHB8WiryPB9BWspnfhdSXtsbHtkSu0id7Uzy71QEZmWf 9vrD0/m6cIfAHOj1hw2Z6NSzdEc5eK7f8add/clbgfxvzHuRJeNFgGg390/Hspf3hUBP PnvG+BiYjQkTXYFnb8R75BbLn3ux9wEPx4rHfo6/iQRLmZ+jVN+Y+XnCVb1HEKbgx3N/ D1ARHvI+l8emgvz2/hN61pY083hqvDn3bOWcQsRW1WgekPFlB3UmmSDbCCA+dW3CnHH/ txbK6KnfQfoNOOhRr4zK0uPzqmsfpfSqeFt9mjkL3Sq9pwTrxd3XIOOD6HIplU1PdMGO t4Zg== X-Gm-Message-State: ABy/qLZXZQq0+3OkpPNPEotwfHvyMYm6WSbB4kHAk4BOUFLJHLjmIUZC C3Hbh2KHiNZDAUqZWSv8/bd7PA== X-Received: by 2002:a17:903:2305:b0:1b8:9b17:f63d with SMTP id d5-20020a170903230500b001b89b17f63dmr18745465plh.23.1689178277316; Wed, 12 Jul 2023 09:11:17 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 09:11:16 -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 4/7] RISC-V: KVM: Allow Zicntr, Zicsr, Zifencei, and Zihpm for Guest/VM Date: Wed, 12 Jul 2023 21:40:44 +0530 Message-Id: <20230712161047.1764756-5-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,URIBL_BLOCKED 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 We extend the KVM ISA extension ONE_REG interface to allow KVM user space to detect and enable Zicntr, Zicsr, Zifencei, and Zihpm extensions for Guest/VM. Signed-off-by: Anup Patel --- arch/riscv/include/uapi/asm/kvm.h | 4 ++++ arch/riscv/kvm/vcpu_onereg.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index 68f929d88f43..9c35e1427f73 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -126,6 +126,10 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_SVNAPOT, KVM_RISCV_ISA_EXT_ZBA, KVM_RISCV_ISA_EXT_ZBS, + KVM_RISCV_ISA_EXT_ZICNTR, + KVM_RISCV_ISA_EXT_ZICSR, + KVM_RISCV_ISA_EXT_ZIFENCEI, + KVM_RISCV_ISA_EXT_ZIHPM, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c index 555acebcbe02..e73f9b105a02 100644 --- a/arch/riscv/kvm/vcpu_onereg.c +++ b/arch/riscv/kvm/vcpu_onereg.c @@ -40,7 +40,11 @@ static const unsigned long kvm_isa_ext_arr[] = { KVM_ISA_EXT_ARR(ZBA), KVM_ISA_EXT_ARR(ZBB), KVM_ISA_EXT_ARR(ZBS), + KVM_ISA_EXT_ARR(ZICNTR), + KVM_ISA_EXT_ARR(ZICSR), + KVM_ISA_EXT_ARR(ZIFENCEI), KVM_ISA_EXT_ARR(ZIHINTPAUSE), + KVM_ISA_EXT_ARR(ZIHPM), KVM_ISA_EXT_ARR(ZICBOM), KVM_ISA_EXT_ARR(ZICBOZ), }; @@ -82,7 +86,11 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext) case KVM_RISCV_ISA_EXT_SSTC: case KVM_RISCV_ISA_EXT_SVINVAL: case KVM_RISCV_ISA_EXT_SVNAPOT: + 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_ZBA: case KVM_RISCV_ISA_EXT_ZBB: case KVM_RISCV_ISA_EXT_ZBS: -- 2.34.1