From patchwork Tue Apr 16 18:44:07 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: 1924330 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=rXdTbT+1; 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=DkfAIYRR; 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 4VJtJk21B8z1yZC for ; Wed, 17 Apr 2024 04:45:26 +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: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=wpjzRn/TGRh2uiAy+TlEAqqaXY6+OBbqmeU8WVh1JcU=; b=rXdTbT+1eStfV4 nR/LaZMzmY7xGsv+UkY+92vQbdcR+n2HpiUwcEfUMCBIy6/ElEJBXneHGEX//0W/tCOhP1o6XgAmK h+l4IfrX5jtrquxMT9joCTKDFMl4jsHf6Bxo6sxeNUIj3L5AGnfmq+ZoPnA+nvzmCSEYXfZyHSXP3 2tuwIsEBGaRbj1y1ymJKXfIItbuq2+GtT36pvY3TPHzZK+DOKrzQmJH7ihztj2vTEFnXNMtkBAx/H pxseFp4sT3B8M5XKfQ11HC0TVZX5eoVEq97JRrbpaDFn0GMue0fRDMg3w/7kglxb9xtpRmjHrrPVb yVK5fxgFAR4ckFhhl3Ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwno4-0000000DMjn-1CGd; Tue, 16 Apr 2024 18:45:24 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwnnc-0000000DMJd-3Hqi for kvm-riscv@lists.infradead.org; Tue, 16 Apr 2024 18:45:06 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2a502547460so3248898a91.2 for ; Tue, 16 Apr 2024 11:44:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713293095; x=1713897895; 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=N3Hu7DESDZEmcgrq2jc0sr2sorL47aa7h3H8SzaxXXM=; b=DkfAIYRRrV6aicq5JvksZJqvcI47+dqRFExYgzKFbPloYpSqtatkugVIHn6Bne8yqR 4XW/BFiXqKNQITb2oXkT80Z8ZlicAKr7KDfQqm2kztDxGL0Ow1GG/SHRHhT+tZHc4nyx KCThFlXrI94mzkL4xgoL108ULUtq8dWmZpW3/0CP3ouA418i/VArKHnMJlAyGYtqkRxs c0Ohae8A8ecAuC999MG8X3WZLILy+1E2VvD1MRuskUoiq3XYV+kvBpXqYPhizqu/0Jb1 mmw+jjM9yoc6lk8zn/AioAMgd4gd2rt5vIvBxOwWV7aejzW/q/4m0IFmj6COM1HRkwGx rAaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713293095; x=1713897895; 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=N3Hu7DESDZEmcgrq2jc0sr2sorL47aa7h3H8SzaxXXM=; b=GyrBNqVMixiUWfisBmJFSbvm4mFv/VF8+sYus7OHyEvhN37/ojnBKiEionDPxEzifI w5p8TWSUPxavoZABTBmuCbq9ZtAdqDNGZf4zCqsvI4nwark9xW8pzDGkFFqJGvk/RQVg pejO3Ydje4sd8PmHR7y1ENQ2K/H176JgR80RanEEiM01KOHsvvTT4U2I/z2jSTA2zDJW rmCDLWnakyBr+WOc1jqU6ZQqactH0TLEP3huVIr0RKHlgYVgYQNEKSO1PkBCt6jXydcH Hk92eXbEDRB0+6EU+0zmtCD2gQQBNJDhXTV5iJWWrNnKPgm5PYUqo0Xpj3F2Wvducoz8 jZiw== X-Forwarded-Encrypted: i=1; AJvYcCVQ1lwYJMeg10cfNpBSTzLSniiyhMcyNJR12WX97E4U3KBvDEFZtApBzxUWmoTEY+qLCIkQIshdasDWLfwFQH6O2Rc080Qu3MnlkEtPfg== X-Gm-Message-State: AOJu0Yw1VSH76bSXGqQW2OrWNzJcQVCLGenKaMpa+osYEaFCNdWOo95q r3iDe0eBVCT7caolGCwTGPaYZu90+3/igfrD2gw5bJFeNH3iYibQ8mahXGhh++M= X-Google-Smtp-Source: AGHT+IHMrJmnJNbaJLJrDUHsyvS17+PaYjcpk56OE5mezOqfopuoWKSQzyxBPEpMmbqXUeSJxlz5IA== X-Received: by 2002:a17:90a:d511:b0:2a4:8706:ed44 with SMTP id t17-20020a17090ad51100b002a48706ed44mr10231042pju.19.1713293095691; Tue, 16 Apr 2024 11:44:55 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id o19-20020a17090aac1300b002a269828bb8sm8883645pjq.40.2024.04.16.11.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:44:55 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , Anup Patel , Conor Dooley , Juergen Gross , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Shuah Khan , virtualization@lists.linux.dev, Will Deacon , x86@kernel.org Subject: [PATCH v7 10/24] RISC-V: KVM: Fix the initial sample period value Date: Tue, 16 Apr 2024 11:44:07 -0700 Message-Id: <20240416184421.3693802-11-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416184421.3693802-1-atishp@rivosinc.com> References: <20240416184421.3693802-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240416_114456_884075_88720B00 X-CRM114-Status: GOOD ( 11.31 ) X-Spam-Score: 0.0 (/) 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 initial sample period value when counter value is not assigned should be set to maximum value supported by the counter width. Otherwise, it may result in spurious interrupts. Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- arch/riscv/kvm/vcpu_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Content analysis details: (0.0 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:1031 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_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 initial sample period value when counter value is not assigned should be set to maximum value supported by the counter width. Otherwise, it may result in spurious interrupts. Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- arch/riscv/kvm/vcpu_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/kvm/vcpu_pmu.c b/arch/riscv/kvm/vcpu_pmu.c index 86391a5061dd..cee1b9ca4ec4 100644 --- a/arch/riscv/kvm/vcpu_pmu.c +++ b/arch/riscv/kvm/vcpu_pmu.c @@ -39,7 +39,7 @@ static u64 kvm_pmu_get_sample_period(struct kvm_pmc *pmc) u64 sample_period; if (!pmc->counter_val) - sample_period = counter_val_mask + 1; + sample_period = counter_val_mask; else sample_period = (-pmc->counter_val) & counter_val_mask;