From patchwork Sat Apr 20 15:17:26 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: 13636830 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 A2C3314532A for ; Fri, 19 Apr 2024 23:48:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713570484; cv=none; b=WPetfK08+2ld4iz9kSKG2bacgmmS/lWqz8AHCOKGEaYpd364eL6rvLQ/nJ/o/0ki1WE1Ty5yHwVTo/Mf/ySVbeP3W2uIQFTvrphKyykgvKcMbfk/OOoYnKyrK76+3KYCIq5OdmjGqoQ+wiFUnFFSlPfX8QWnj+VJJg6/Pl/xJNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713570484; c=relaxed/simple; bh=i4/+SnhxIOkVH6jnqRPVGKLSvQvEdBjQqHeh5YP3SQk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N/oZmCFBG/VI+Vsur0r/WsJhMIT1f5xwp4x79b+yR4Cj+XUqyeWX2bkAZ/nUC65KRkwU2EQD0ERPzRKhtKHwmmsZQTQgMfVZbuRTXP+/EU7v2kMCfSbc+5cZEwagjX8i/XID3befbqJsWiVhCAn0BP7r215ddAkRC+6D1VNgYB0= 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.174 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 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: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1e3c9300c65so24854905ad.0 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=EHgndfY9+BinIYD8ZtlhUsLTg4mS0Ts1tGKMF5IfwztUUZgCWD1Ba4evEEzGd4xQ8+ 7Si6va26qKHrajf3nUWDfOZh9wT7KnKPrA4zy9jhn0v1qNQzV79zYX3oWrXx/4op3faR Fe8t5rLUrwLWKc6wsovJC0nIFeiun12o7UJdhmLaHi2ktn6d4TCtRCuBTU3tIWBtce/I hLMh23cqPrWHpdvl7n7B6uYyljJIDRMTV79gLzuYZNG7O7tvlttBE1GX9vTBzroLKbHT AOrqzpjb2YxyUPNUHYdwCzanGJsaj3QKo7f4FhdcmUkAws/DGHnFAXyyiMRzMonCDPZY euOg== X-Forwarded-Encrypted: i=1; AJvYcCWr40RqVCsK0PijUz5GnfodH/u6PSt5VqUjUvWFuSGpK31QLNM1Yi1SuV8lW5eYbOLEKGrlW/4BmqVRioxjhb83mXQi X-Gm-Message-State: AOJu0YxTKasoREjRf4q5ZMWtBmcC7M+fRfg6YKXIsodUAxU4H793/313 umNps4rZyqwVH5r379OrWb5d4xyPHf3VlnZD9ZsnX9vTx5EMaRC3zIIHx8dBYWU= X-Google-Smtp-Source: AGHT+IFuxivVAucFqLYqwANgIIbEmyPV0tNMGWLxqaH8776sBq/Go9KZec7LTwKbbmPafjRvAwUZ5w== 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: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Anup Patel --- 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;