From patchwork Tue Jun 4 12:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 13685249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59848C25B78 for ; Tue, 4 Jun 2024 12:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HuCwWAG96qb/fgvSCjwG0o7YAgDAW2R5mjzRE7dnexU=; b=m4kH5kuImz2osD Gsb9mSy9Fam3+nKJAvhWZ6zDTP7mvTVD2Ed++tI2d1HymqzQII5tXVlno+o6xYPyEf31OzvuVuNTB D9Xq/wmJT6kBm5V1SX24VanfRCgI81lOo9ulx8MlYxTVDPZ6WriyKQ2cqHox2jCqienI59USMHBMP rtQixWLhPiUbjBnE96K/5cWndbZeK4FZW9PFuSXtEGfkDwciMLkuagvR/aiWtHttYJZstoxG8OBPP pO8bgG3qFxR7mJe8OF5MROkhGcWNmkYwClza3B0V8W8RSvcCt0mKrSgxyxpt02YY1CzA+CN+Wx3Qq I81l2N5pncNiglM1yyxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sETaJ-00000002MXF-1Jys; Tue, 04 Jun 2024 12:48:16 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sETaC-00000002MOt-3dmD for linux-riscv@lists.infradead.org; Tue, 04 Jun 2024 12:48:12 +0000 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-6c8b6e40ea6so337686a12.3 for ; Tue, 04 Jun 2024 05:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1717505284; x=1718110084; darn=lists.infradead.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=Gs55v193sdHVl0rBHs/P2Y++ez1UXnaq9pE10ZEsFSw=; b=2nDvWW00yp99ZBmS1PfA6/9wxpttVU/LDTExQ2XX66ZUU+J6jM9w8ac7fi6LcL3xg2 7DQlRQSJyNxuYF9ZwFtKvkEE7+S9OYAfRZ+dlKP38CVBBla3y5cuAk68t80l1leqqKI6 OBZ/9sOEt9VsXo9GhEVkXmEX8o4tgMg3eOuiSeSx7GvSx49PIC02+BrmKnj0riHCfmqo pKkGCTS7D85reP0uHuol7VUaTRu6DHPsCgNCyyetq74s+8OfG9rontUzKwFTU9AfSYCU jHYcirvTzC3ghwgdbnMto95SvEUKmlhL+FKq3bVBBniDKQ0kr0e6M+KDF2PGifzftYyK Vyqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717505284; x=1718110084; 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=Gs55v193sdHVl0rBHs/P2Y++ez1UXnaq9pE10ZEsFSw=; b=Ubj0t5ByMKM/EvSoIEk9Lmmr5tQ0946oOB7LmeF5bl9tM5seT5MyZHLdiC+gEmYd5H tZPyA8yjl1AVOnAANSDKSrVEtrCfJe+GQ9r9uVqjpH45kyQOT2/mRUIapI6+SAOvwBKJ Yf3lqTtS///SeXVOLHAyGA2F1ysHoWfVd+X2gX3BbVVyZ/5zRCpvkmyrSWZV673Wlk2I CnKP6GEhA0hOwNQkmKJkPNz/Q8Cp0PF9a1yjAhJEBuV/838wPuoJxY6FQEDgNjAIzS9J expRojPP9hXI1WaiwGcndpc/R2Zqn8t3x2aXrJ/mKaICWMlK6naf9J5qZ1i+odXaPK/X TGKw== X-Forwarded-Encrypted: i=1; AJvYcCVNnDdJW9E8l5F1oMQyCEphkrn+VdqAhvBGJb/CKkVp6rXLSl2sVEKpS8ixYrC3LoRZXERfYlFVCMwY7oRsBF0SmaETqF7HyOT6pYxW3nD1 X-Gm-Message-State: AOJu0Yxhsqs3iEsvYlOQSNcCohBxHGegsfAhY1wauacMCdD2dqWgAxFf G49MoXQEbfIvcZsDsFlI5Q7H9KlVsY6AWrZJRs7gBoCm6Y6+E09doccqscix6UM= X-Google-Smtp-Source: AGHT+IEsMZJmc0GRfwnGJXawzgQpJTLYGNhY37MgDtgsSTzGDBp6EPH/FvyBY3q5m6FyKXNVAkhfqw== X-Received: by 2002:a05:6a21:99a6:b0:1af:a4a5:a26a with SMTP id adf61e73a8af0-1b26f0f25c3mr13691235637.1.1717505284134; Tue, 04 Jun 2024 05:48:04 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:327b:5ba3:8154:37ed]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6323ebc69sm83042885ad.211.2024.06.04.05.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 05:48:03 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Anup Patel , Shuah Khan Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Atish Patra , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org Subject: [PATCH v6 10/16] RISC-V: KVM: Allow Zca, Zcf, Zcd and Zcb extensions for Guest/VM Date: Tue, 4 Jun 2024 14:45:42 +0200 Message-ID: <20240604124550.3214710-11-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240604124550.3214710-1-cleger@rivosinc.com> References: <20240604124550.3214710-1-cleger@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240604_054808_962164_B6908DAF X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Extend the KVM ISA extension ONE_REG interface to allow KVM user space to detect and enable Zca, Zcf, Zcd and Zcb extensions for Guest/VM. Signed-off-by: Clément Léger Reviewed-by: Anup Patel Acked-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 db482ef0ae1e..71b17a6799e6 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -169,6 +169,10 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_ZACAS, KVM_RISCV_ISA_EXT_SSCOFPMF, KVM_RISCV_ISA_EXT_ZIMOP, + KVM_RISCV_ISA_EXT_ZCA, + KVM_RISCV_ISA_EXT_ZCB, + KVM_RISCV_ISA_EXT_ZCD, + KVM_RISCV_ISA_EXT_ZCF, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c index 09f0aa92a4da..f68b15b15f0e 100644 --- a/arch/riscv/kvm/vcpu_onereg.c +++ b/arch/riscv/kvm/vcpu_onereg.c @@ -49,6 +49,10 @@ static const unsigned long kvm_isa_ext_arr[] = { KVM_ISA_EXT_ARR(ZBKC), KVM_ISA_EXT_ARR(ZBKX), KVM_ISA_EXT_ARR(ZBS), + KVM_ISA_EXT_ARR(ZCA), + KVM_ISA_EXT_ARR(ZCB), + KVM_ISA_EXT_ARR(ZCD), + KVM_ISA_EXT_ARR(ZCF), KVM_ISA_EXT_ARR(ZFA), KVM_ISA_EXT_ARR(ZFH), KVM_ISA_EXT_ARR(ZFHMIN), @@ -134,6 +138,10 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext) case KVM_RISCV_ISA_EXT_ZBKC: case KVM_RISCV_ISA_EXT_ZBKX: case KVM_RISCV_ISA_EXT_ZBS: + case KVM_RISCV_ISA_EXT_ZCA: + case KVM_RISCV_ISA_EXT_ZCB: + case KVM_RISCV_ISA_EXT_ZCD: + case KVM_RISCV_ISA_EXT_ZCF: case KVM_RISCV_ISA_EXT_ZFA: case KVM_RISCV_ISA_EXT_ZFH: case KVM_RISCV_ISA_EXT_ZFHMIN: