From patchwork Wed Jun 19 15:39:11 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: 13704192 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 E837FC27C79 for ; Wed, 19 Jun 2024 15:41:35 +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=fTVkaHOimV6BlGE9pDLeePZvvrW6ZhXcr3N17VdzIGw=; b=nboqBJRxYZaK9o DX0imXWSfkihPvC2HRASUgMaq2Dzfr+grnU4va3nxdzUf0b6oFVSKA+423QtShmYNUHj5TgyXlJKd SlCiq5f6z6u/VGF7gQy7c3Xqo2FPTEkfKT7X4bC5EzZGCaEgrLGU453SQNxDe0RjDJiY52ncnUFP/ Wc/mjmjaWpaq2PP2RdGGgmPpiKKwBG6m3jaERBWxf+OWS65wlLMubFaWjP6RUjU6N1rkaNI+BfOae 4FNCVvzeaGBB7x12xIma4M87Tw/C+ZZuwezl+ZXtbzgw33L0gZ3NQy7TdVt7CHuPvS1ZKgFjJLqXx UX3e+SU/GLd5U17UFrzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJxRB-00000001qfV-0GHa; Wed, 19 Jun 2024 15:41:29 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJxQy-00000001qVk-15V0 for linux-riscv@lists.infradead.org; Wed, 19 Jun 2024 15:41:18 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-363d0f1ceaeso70952f8f.2 for ; Wed, 19 Jun 2024 08:41:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1718811675; x=1719416475; 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=6obIhMCgJtCMV7DNAB1Eq7WrI+7/yuJDuJixMHQfyjs=; b=hB3HlfdKP5AGq4YqeEuX4ar/NT+NwmQ3XNmeogKzvCs8jBl5nPrbWYePk8PLmRbJS3 0VzF/0NGVB+QhXF66gxcznoeLxUMuq/r5a0NMIXHtj8cMS11cir8M4pdD59nqOcqbptW kyMSz7+JG9S2oIAkclXvD4yMv2U6FR4fN3gFHW0+BB43Qa+dvq7L0ZjRLZ74VOnB3fAC GBsEwMWTrDW3OZV6w457nWinlxsfFZKbBLfy07XUpX/swhdjK09genoudqJ3SaOnbXeI TLOJKxzBGRJu+K1N/zG3Dh+sHhVFLDB85pkQiF1zTSn52KZp6syzQTneCTPeZ00irkDr cPlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718811675; x=1719416475; 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=6obIhMCgJtCMV7DNAB1Eq7WrI+7/yuJDuJixMHQfyjs=; b=lC3ybIJP2dXZvxptuJpcEcP/e82YjrHYIQX/hDi50jHJsHUd7mQ/5bSZucO7mPKQdv r4W1tWSB+oir9ZGymM+7NjZdjrtGB1az2+jg7whoRsknf0xMjXTeryWs/i+IrIpdEYzP cNyFBrDY08Rpjfg3msGVp9c/1ky3YTkHqnbHSuOwNp6jjs378EJQGW9wyFLtxpM/V17U 3Ng3JDhMedpT4mwzzm43GaOAs6IfOO72j38yCF/yj//wmHpFzXtdjpswvHBtBZR+SrUj I9djQU5VS0XPXDRZcsFhj2ji0ZuX3g7t46U1iLuBEBN7FzFhL5nhgndyIh0k0A58DoEQ XZ2A== X-Forwarded-Encrypted: i=1; AJvYcCWZVbA+AzoTz7va3WJCWqWhZ5BHF3D5d9rvw+tRC0UiNo8zUM24Roy93wGv+Cv4GYCzqaoo5ndZLcjrVrX7BETJN2o5xCzokxqV2NbAyaRW X-Gm-Message-State: AOJu0YzltFDslZL3esfZl2Wfcvgu6r5H7x4oKEGnOb/suXpidnlDvM5W aEdkRPSU8bYMQrb8hbs5L90ouMk4vuUll79OClNg6lixPv0xsrwfP3RJyh/NRzw= X-Google-Smtp-Source: AGHT+IEsiGCR06DYSznwuNGZ/RtWasKc+Sn+mfD0wbhYFJwAh2e2fAjrUA7ukaEqVJFeFkb/5sRZzQ== X-Received: by 2002:a05:6000:18a2:b0:360:872b:7e03 with SMTP id ffacd0b85a97d-36313fd733dmr2801721f8f.0.1718811674851; Wed, 19 Jun 2024 08:41:14 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:819d:b9d2:9c2:3b7a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3607509c785sm17392292f8f.34.2024.06.19.08.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 08:41:14 -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 , Atish Patra Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , 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 4/5] RISC-V: KVM: Allow Zaamo/Zalrsc extensions for Guest/VM Date: Wed, 19 Jun 2024 17:39:11 +0200 Message-ID: <20240619153913.867263-5-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240619153913.867263-1-cleger@rivosinc.com> References: <20240619153913.867263-1-cleger@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_084116_439094_57DC47E4 X-CRM114-Status: UNSURE ( 9.76 ) 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 Zaamo/Zalrsc extensions for Guest/VM. Signed-off-by: Clément Léger --- arch/riscv/include/uapi/asm/kvm.h | 2 ++ arch/riscv/kvm/vcpu_onereg.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index a6215634df7c..f10c6e133d4d 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -174,6 +174,8 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_ZCD, KVM_RISCV_ISA_EXT_ZCF, KVM_RISCV_ISA_EXT_ZCMOP, + KVM_RISCV_ISA_EXT_ZAAMO, + KVM_RISCV_ISA_EXT_ZALRSC, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c index fa5ee544bc69..0972a997beca 100644 --- a/arch/riscv/kvm/vcpu_onereg.c +++ b/arch/riscv/kvm/vcpu_onereg.c @@ -41,7 +41,9 @@ static const unsigned long kvm_isa_ext_arr[] = { KVM_ISA_EXT_ARR(SVINVAL), KVM_ISA_EXT_ARR(SVNAPOT), KVM_ISA_EXT_ARR(SVPBMT), + KVM_ISA_EXT_ARR(ZAAMO), KVM_ISA_EXT_ARR(ZACAS), + KVM_ISA_EXT_ARR(ZALRSC), KVM_ISA_EXT_ARR(ZBA), KVM_ISA_EXT_ARR(ZBB), KVM_ISA_EXT_ARR(ZBC), @@ -131,7 +133,9 @@ 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_ZAAMO: case KVM_RISCV_ISA_EXT_ZACAS: + case KVM_RISCV_ISA_EXT_ZALRSC: case KVM_RISCV_ISA_EXT_ZBA: case KVM_RISCV_ISA_EXT_ZBB: case KVM_RISCV_ISA_EXT_ZBC: