Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp95560lqg; Wed, 10 Apr 2024 17:11:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0Z8ZvUW233URFN5me9UkA/XXzHBO7xu5IIrBRED996rVmcykBByBbp7Xjlr/On7hXm3Al2vht/2C9J6u7fyKiJ3HzWa4TWnIl1L21Kw== X-Google-Smtp-Source: AGHT+IHmGXHYrT4ZnOlYWsz3v79TH/kvtpvzLWNYUgSqXrZ9SnqbrAzhnz2EI0LBLSAz0TxtyOak X-Received: by 2002:a05:6214:21ec:b0:69b:16bb:d66a with SMTP id p12-20020a05621421ec00b0069b16bbd66amr4105072qvj.47.1712794308480; Wed, 10 Apr 2024 17:11:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712794308; cv=pass; d=google.com; s=arc-20160816; b=bY0nUxVu6FmxrztX+eAKBnxJZUvb+jv/3NWL6hCran4UnwBkdbf8DXGp1QvqmqWnaI 5Nok3iBVggCtU9K9I2dNgU+X7xpO2oCU9/AahaKR3iqUiJPoR2bEQx4t4RRMB8Nciw5p //ItWXKJGMY3VEJm1r/0d1aer4YA4VfB+z/7Vh5XVbOIJAVZeMmn1lH0v2SllnJtTxku fBh/JSnQ7YSYr34fhmr8FiorZcCTJhDM/md6v04kCJiQ7EvNsUbnH/uE6G+NZzR5Oqi3 v0PT6yg6fNGk7RPLzdeqfV/TDzAmTrcb01s+0QdfZ8xR1rbutKeWNTgpWzPP10QccwnK TFqA== 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=TV5tejk3Dt07dcNlLLEipj9Q2R7EhRc35yPyoZNpTh8=; b=xayTIA2dAwQBkCwOCLNYLHfE/L5D/X/Cq73bKv4wRK2kQmmXKU1cvqaUP3jkqJm18D +k72+AzIK/gASFhriME3ASZETJU8qL/+gzkvkBVWWbg1nz382C7YKt4X8YQ5NcHg/JGq 0mM7MKM2vd7oH936oJm8CDt6TBq0i3hrGpyy1RU4WUVbD8s+6ebdbkgq1BgxXR+5+OBB NvCTblr3TGUDrF6kFZ2woTKq3BewmHA7Rofz4rPOTEUU0zyw/o4SPK5FNyBmIsRW3T6V YwpAIsEN3uC8Brub1E0xv00K46cSmSpx+2rZYsLhUL3I94XkXQ/qU9kERHvUqIeFVHVl W5Xw==; 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=l6q4d0pp; 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-139565-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139565-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p9-20020ad452c9000000b0069b4144f0absi345334qvs.119.2024.04.10.17.11.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 17:11:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139565-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=l6q4d0pp; 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-139565-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139565-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 387D31C22F50 for ; Thu, 11 Apr 2024 00:11:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AC3B225D7; Thu, 11 Apr 2024 00:08:37 +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="l6q4d0pp" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 07C7E1DFF9 for ; Thu, 11 Apr 2024 00:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712794116; cv=none; b=fyKGqpH31678FgrpLaGQLV7WNakoW0xpzm0JTCSuWUXi/Aax1XiTPB0zjVSgjxT5nf18+rkZIJiWDRkG+R04nRlnknTmStkB2pAJEmIh7cB7Q8/Eu9ZvzA54Gu0tDwAAqeYkd2EnYWfJAch8I+uSMeBi7oFOzU9npPANwOWMgfY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712794116; c=relaxed/simple; bh=i4/+SnhxIOkVH6jnqRPVGKLSvQvEdBjQqHeh5YP3SQk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MNtHG9Ll/kYsfLFD3ZkV3CTcdqwvtoWGBbGanlptmQNVZdDcbhgVxKFtgr4phLDRYrUbJfzhlcmUvk17UO/rZfOizA1Sx93bBoVR9WtsM2+FVPjFrcghtJ+upnBnTIQ7Oa53TMadXFw78NpRtGpF7QTcLDTat5qnlZYqqkPUO14= 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=l6q4d0pp; arc=none smtp.client-ip=209.85.214.175 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-f175.google.com with SMTP id d9443c01a7336-1e24c889618so59414535ad.2 for ; Wed, 10 Apr 2024 17:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712794114; x=1713398914; 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=l6q4d0ppNxosr61PxpO+nUwCvp8BuauMe8AT/gF+ws53u+i1hRcpLbAxgLL/RR9FNM I2ehD7DsI9uFFtzN6CmfRs0UQs23vpNYKPCV57cGjhERXd1jCXhEJT2XFyXnERDqU9qr hDX27UVa/IAVTggAs3avcEOHN+5kbilri8uxj9GTd4MxtBzOYq5BfIxhtGBbRNNxF0aC wxUA2/IWKnkYOblTYQWHV9V0yVhMugliuiLDTPpoiAiGaf7gwPk1BOQlymixilBoEsco ZIa3OcH8XGoBnSDo99fhtXchf3E5jKN4U/1Tgx5MpbrQaf8hHA/losih3lakGF2Xx5UE TcZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712794114; x=1713398914; 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=MioMByPyyxiuREJyOX+kkqVoy5fVEqtbwWJWB3HC0TrpivRHZDzoQdQjon92SYImIe 5ArLPUggEuJYGWAMCQsUNVvyJBc0Njl96VD2WBov+Iyv06FlZ8Q1CXDNnBgUdc01sk1H t0ZrqUhNFMgs0fBqt2HiC+wF7oNP+swLwEdDdO1t3pQAt3TsDuZl31HJoCPxXXSHjeZC 95b6Bde0du/lLXxMfUvQlJcLW7skLLqt5KYEbl21ju6ZN1aaj2AM6i+IRab/W2xZSI+4 7a7d1HRxiGuim/bmkw2vMhPZMQxkb5dO9h0w5LgiMiQBR61dO6nyKT5FOjCGBvik4Da5 slOA== X-Gm-Message-State: AOJu0Yxap/oCShNxQEZ2kpVm6TBMAqRUSGA6eBghq07mDkzpjnYqgdgy /hkdHKUoOCHpzFd2LMteS15FL/NuEW0cQoYL76qROn7L9hiZr4j7zZNa+mETrPlbdUI2ed0ETg0 5 X-Received: by 2002:a17:902:8490:b0:1e0:119e:f935 with SMTP id c16-20020a170902849000b001e0119ef935mr3564608plo.15.1712794114043; Wed, 10 Apr 2024 17:08:34 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id f7-20020a170902684700b001e3d8a70780sm130351pln.171.2024.04.10.17.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 17:08:33 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , Alexey Makhalov , Anup Patel , Atish Patra , Broadcom internal kernel review list , 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 v6 10/24] RISC-V: KVM: Fix the initial sample period value Date: Wed, 10 Apr 2024 17:07:38 -0700 Message-Id: <20240411000752.955910-11-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411000752.955910-1-atishp@rivosinc.com> References: <20240411000752.955910-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