Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp963222lqt; Fri, 19 Apr 2024 16:50:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXW6izicwM/EhochyajFEpEA0QFFvT4hhGfs/UR7DtAVsxxpBVQNj/YrXjUAxv2CqXGHGGv/PADQ227GZahH9aXaOD3euLfx9Wzko9Z4w== X-Google-Smtp-Source: AGHT+IHCzMkR/kp2AzcFZc3SboI9IGfcMobDBCxdCblNV/FCT76x5xBppcmKH3iEsli62Oi2guMX X-Received: by 2002:ac2:5189:0:b0:51a:9f4b:1fd7 with SMTP id u9-20020ac25189000000b0051a9f4b1fd7mr2147285lfi.58.1713570659478; Fri, 19 Apr 2024 16:50:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713570659; cv=pass; d=google.com; s=arc-20160816; b=gwMpQXwmqZqMn2kRt0+JiJ6Gqm+zFO/RJ5uMc/mKwkZS2X8P317Fe9wJ3MsBo1u5Ub IlMZZxpi60j4GfpM+jg2alF3P36dMiQMHAby/2GovEIwaLAEqXNM1nWdL+lRMXLFNfD3 2ua/SjbSittmodzqmAXR9svMAk3GwNKUc83jb+g6qVTCjh34NyoKuFqDj0KurXz+3n5E rLEkv+CMjeR1DowYRsPnUaiFEtx3hGMWGPUGyRFtsv/HcdBpu9QpoiZdttR2lesRIxoo ZdE210NZRn1j1KtJ6AsqbDX2Nqv1mJRdIc4jbzc9rjGbfWq8oZ/4B5+iodcIEcM6b08o zYBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=N3Hu7DESDZEmcgrq2jc0sr2sorL47aa7h3H8SzaxXXM=; fh=z7fJWkZ4T7GjqwnZHLiFaBRNsKIE6v81MvuCrwEofW0=; b=Gk+I/xxnz9AOGgVLV1vFZjUyoRAan+POqMHU0ELJ46KWmGL7pBLGf8B5qN1IsYQJek K34aL0JwU8Tu1Wh/Kobz3Iky2cXCl8/F+Muy0k6GVwVWWPr14GlwVnvla3npjJZTDIEw ShJlWCvBHhcob7BNvLRbocFFYXLQqp7WjS9tZQTUZUu/k6UEy6CPfVJmtNVcEoo6mvqj FJjPW2CtDc53umHDOTJwO94egFJU0GS+/CAw7R6+OefiXq+AMvOGp9V7MSwKjwM/zsub hvqxgzS/hp3ecCJHN7u55Zz/ZrTURiV4IxXjQsij5/S+71C6wh0uwbQDqKua6LKqGXWZ gIcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=ovqiwdIm; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-152033-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152033-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p10-20020a170906b20a00b00a523af47254si2608173ejz.446.2024.04.19.16.50.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 16:50:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152033-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=ovqiwdIm; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-152033-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152033-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 325191F21D50 for ; Fri, 19 Apr 2024 23:50:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE994142658; Fri, 19 Apr 2024 23:48:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="ovqiwdIm" Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3B3D145345 for ; Fri, 19 Apr 2024 23:48:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713570485; cv=none; b=WpmpmGNqI03+vp8GthWpyJYTdyHadAtnUzp0QU0fPvPtmCT6PwxvOyNQfnh9/PFPV7OUfAyFkHc0GmX2BHDPW/kOqE5X+uPYcA7JO1lsqOYwBbwUwIZ2wV331xm1jXDeMCWZlwkCxlAYJ5ZZxdkfOXtZxZZP+3nWCpf2lMaEVo8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713570485; c=relaxed/simple; bh=i4/+SnhxIOkVH6jnqRPVGKLSvQvEdBjQqHeh5YP3SQk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Se9DZd0ZgvXLPR5DY/WYMUBvSJe+wqwCIV6Vo6+zSrSdMImeMHiC9qF5KLqfePNGoomZCGpgi3f0hwr815Cppj2LLrzKRa+xK4c6zm9ejQkHyMJCkZE5E4m+PK7MLLwrDmj0urpf4JfQ9nrCHdnxKFHx777HH/fiT7HkKU4ECdk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=ovqiwdIm; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1e40042c13eso21256645ad.2 for ; Fri, 19 Apr 2024 16:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713570483; x=1714175283; darn=vger.kernel.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=ovqiwdIm+tdsGciS90weKXkMlO8DwB/UxneEkFaoo1mgU3NtFEq9GEIpJ3XVa/Mm6S 3ZOYsl2x5iVjNX97pFAyN4vhzf7q7c1t5XoXq2nKgxpzwfhBApvWe1coJSx5AbgFe2AI ShfAxvxpBDe9pe3CsftZqHSL+WRdSI7oN+RYk5YxOMUEKqS6jSih5ex7GljPZ7LdUlvm i+XrwrppMxr126gsSHB0zAj9YKIR99SBZupyqErK6Lxzs1b1ERFLY4gzpKk8hooNDtrj RWe+8IJ/OdGtO49ugND1qQJUuoZhxo87/3NO1Afc1/UAi1J+5Pdz4TfXKkpRU+gO9nux +voQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713570483; x=1714175283; 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=C9w3Sqhy5PP5lFW9GcSJQRkTlKF1G7Z7U7sCFFhx1K21TFiUb0dd26PhB0H7cFOyu8 rMepT4wzVclY0m20XnN/NGShr4F0KuGsbxmo+HzDadE3nW5QaYb3Lnm7+4zTRsHtpckV FexYaWz7SjGFHfvJtStaUwDz9BNTge8z5/WOshBOl8v8J6o0Tj4IiX3ebPO9Ou7kvXw5 4QqNxIwk36c9Nk1c7MFyc1i2t+w/6EfxTdOAjDguEqZ3t53jCA/uVc/ERmrh+TQJPKo6 FqNjoYjS5o5dozTBKK7c58dm4AADliORwoAzWjX68DHL3D+QTGDA95K5gS7sajXxVUd2 lmVw== X-Gm-Message-State: AOJu0YxvzNkOaeViZu3BU17wF1gwt2OEi9W45n2JCQORo1yev9JVs7TJ 51qav2C9vmUxDnky1zhgyyyre+tcqkkodrlEBxjVjRgcr1P1/nwvAstBFoZe5de1fplA8kmt4R/ A X-Received: by 2002:a17:903:22ca:b0:1e5:2ba9:a667 with SMTP id y10-20020a17090322ca00b001e52ba9a667mr4212130plg.3.1713570483020; Fri, 19 Apr 2024 16:48:03 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id w17-20020a170902d11100b001e42f215f33sm3924017plw.85.2024.04.19.16.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 16:48:02 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , Anup Patel , samuel.holland@sifive.com, 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 v8 10/24] RISC-V: KVM: Fix the initial sample period value Date: Sat, 20 Apr 2024 08:17:26 -0700 Message-Id: <20240420151741.962500-11-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240420151741.962500-1-atishp@rivosinc.com> References: <20240420151741.962500-1-atishp@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.34.1