From patchwork Fri Aug 16 07:08:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 1973062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=kD0rTAdy; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=FDgWqhRf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WlY5G6t3gz20GC for ; Fri, 16 Aug 2024 17:09:20 +1000 (AEST) 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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fTN3tsyNJHZyJa5wifDVo3mJaIIOFfo3/yBq+mRCjfY=; b=kD0rTAdyIrKCbJ b44bwz1riSGtLnpd1z2iYgGnz2d1yggbNXq+OUp1x6EXvxwFYVfB0M5MGY/h7fPRECEhcAWzEixC4 EVgLp6DOgS1G06Z4ZL846MC9hIaUnokiK3yr/tTNAloJ0f25jtgMsPHYDw/8HUq2n9REE3pxnF87q iEJX41tZyIrqOSf+48o6XXEU2Bv8So8FkZ/aNf/6yj7F0rOVDPmf6eCdftvM+1OxHaYTffQPcnDnD hrK96x/ccvgEvgyKez/pfvXN4rE7I0bEr3PtzxsRBG1JCywmUgTju9zVKExS+5jdIiYmnV8DwC7Qh AkDC4JInRG+TbQ7f6vdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ser5K-0000000C2Q3-3XFF; Fri, 16 Aug 2024 07:09:18 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ser4o-0000000C2Es-3d0s for kvm-riscv@lists.infradead.org; Fri, 16 Aug 2024 07:08:55 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-70d1d6369acso1813640b3a.0 for ; Fri, 16 Aug 2024 00:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1723792125; x=1724396925; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=pw60AMQmDUGOq7sBB5Z5rKu5bDKRw5A77nRIXJhY5Ak=; b=FDgWqhRfHfHSxJgBLz74BGGkOHhQM4/QscXV30Ym2F6ZEsntDv9TViMQvctqTzM/IB at9cbcxFUD/N8Uh71DlEOpoduP5fTByFSHX4DPSc1U5BPjyZ6Lwz1W6hBJh6momfqpJF Hi0QZB/ERNB7rRFSDPKOCRNNi0PDuntBEqZsjuIIYE4ZlQ58LnF+PA6LVVcG1+reZ+o+ PVn9rVC1NUP/L97FbQiVYTsnrR6cmCIZqS+CZTFLc6ak1ve1EFOJHeCtNXtwgpIefJPf oFOeW8QhpGGVJqu72HAlxvuNhSCHC1VCpBmH172WBd02sysZSzU54bYxgXN+TcAjLcMG IkRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723792125; x=1724396925; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pw60AMQmDUGOq7sBB5Z5rKu5bDKRw5A77nRIXJhY5Ak=; b=JeeNknbEzVGQaGW45o9bW0qa8fcYs4FuOwnRst1vkS8p5+wChPrZ8nxy3h34tjCocJ pMs1DlYNbizTZxrjXYX/h2qcHrkUJsL8AyyKxCEnM1E4GXdALobUBj2db0eFaWKOJ3cr mD/8GGCwZ49bLpITFyTODiUkOhcjSSO4W8T6Zy9au5kLDtfhpBK8MLe/iikZ3XDA3W97 PjYYjvMNNuy4hfzzPxLRGGMMNwgvCZlVFFo/0nMwphca+fiRJcRmKRNUCfojO2j8awAO p84GfTQZtclyNOB7UUYKh4Q7t8BM6W1k45x5zwVqvoGMaAelgJrEQVdI7kD/hjWW12Ch XFKA== X-Forwarded-Encrypted: i=1; AJvYcCUEw0G5EE/bNOZwgVzlhCcfgIJ573pqUpHKwwSM4OBJ80fn9Zp5or18uWjAQyinfwSs+vqY+fLB98Q=@lists.infradead.org X-Gm-Message-State: AOJu0YyiyDIeH+wyWS6QZXOQIJbbWTKgJMaTr3k6mMGH7spByi/eURHT TlcCzOfs+2ouGosUQSXDHofPO6WFMkn00UB2b5IvXyLY/eyXEjQOJDBhvcfSOmLzlxjGz4LJHJQ p X-Google-Smtp-Source: AGHT+IGfPiFtzcHt7xqywSUtWik5isvNee8OUxNOoMhtzMTbtl8SwHVtQ2tadLTbV6ViRAikB2BvDQ== X-Received: by 2002:a05:6a20:244b:b0:1c8:aa88:f10a with SMTP id adf61e73a8af0-1c8f85f45e0mr7807946637.10.1723792125575; Fri, 16 Aug 2024 00:08:45 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7c6b636bcabsm2293792a12.90.2024.08.16.00.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 00:08:45 -0700 (PDT) From: Atish Patra Date: Fri, 16 Aug 2024 00:08:09 -0700 Subject: [PATCH 2/2] RISC-V: KVM: Fix to allow hpmcounter31 from the guest MIME-Version: 1.0 Message-Id: <20240816-kvm_pmu_fixes-v1-2-cdfce386dd93@rivosinc.com> References: <20240816-kvm_pmu_fixes-v1-0-cdfce386dd93@rivosinc.com> In-Reply-To: <20240816-kvm_pmu_fixes-v1-0-cdfce386dd93@rivosinc.com> To: Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones Cc: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Atish Patra X-Mailer: b4 0.15-dev-13183 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_000846_911991_9DA510EE X-CRM114-Status: UNSURE ( 8.90 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The csr_fun defines a count parameter which defines the total number CSRs emulated in KVM starting from the base. This value should be equal to total number of counters possible for trap/emulation (32 [...] Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42e listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-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: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The csr_fun defines a count parameter which defines the total number CSRs emulated in KVM starting from the base. This value should be equal to total number of counters possible for trap/emulation (32). Fixes: a9ac6c37521f ("RISC-V: KVM: Implement trap & emulate for hpmcounters") Signed-off-by: Atish Patra --- arch/riscv/include/asm/kvm_vcpu_pmu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/riscv/include/asm/kvm_vcpu_pmu.h b/arch/riscv/include/asm/kvm_vcpu_pmu.h index c309daa2d75a..1d85b6617508 100644 --- a/arch/riscv/include/asm/kvm_vcpu_pmu.h +++ b/arch/riscv/include/asm/kvm_vcpu_pmu.h @@ -65,11 +65,11 @@ struct kvm_pmu { #if defined(CONFIG_32BIT) #define KVM_RISCV_VCPU_HPMCOUNTER_CSR_FUNCS \ -{.base = CSR_CYCLEH, .count = 31, .func = kvm_riscv_vcpu_pmu_read_hpm }, \ -{.base = CSR_CYCLE, .count = 31, .func = kvm_riscv_vcpu_pmu_read_hpm }, +{.base = CSR_CYCLEH, .count = 32, .func = kvm_riscv_vcpu_pmu_read_hpm }, \ +{.base = CSR_CYCLE, .count = 32, .func = kvm_riscv_vcpu_pmu_read_hpm }, #else #define KVM_RISCV_VCPU_HPMCOUNTER_CSR_FUNCS \ -{.base = CSR_CYCLE, .count = 31, .func = kvm_riscv_vcpu_pmu_read_hpm }, +{.base = CSR_CYCLE, .count = 32, .func = kvm_riscv_vcpu_pmu_read_hpm }, #endif int kvm_riscv_vcpu_pmu_incr_fw(struct kvm_vcpu *vcpu, unsigned long fid);