Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp166334lqb; Tue, 16 Apr 2024 11:48:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWGJdvNyCN0FOgkfvr65iOINbMjvi/CfKw7N4HfjnBTeao4iT/sqNmr1ZjjBInliQA+jrDgbw2wIhCJkwvL4pCITJZm/XWnTmhN7qiwnw== X-Google-Smtp-Source: AGHT+IHvDWSZLUAyC0SQ07mwDJ7SzgjDqc/mF7IyqDitTJJuUWiLY0DeNoSZH8hVtVARIhQVSwPt X-Received: by 2002:ad4:5847:0:b0:69b:2523:fcd3 with SMTP id de7-20020ad45847000000b0069b2523fcd3mr14617696qvb.60.1713293321825; Tue, 16 Apr 2024 11:48:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713293321; cv=pass; d=google.com; s=arc-20160816; b=AUxzb1Q3xd01wTwqyWkwveAAbamFZoHX4K99RPX0bohEH7eNeXJHTFtqkHzmF0Ote9 OKI4zmVl+KlWBTEzx1MCWRuPutAwbXeTkqttvqg0EqnzZdFFHLH6dk/yElCWWx9UieSY t9SQJ2476GVrt5hMXiIJhctEIE2KwBICaULF7sdwWrDYWbkSQAoE+YD70hNqzFPD27Xx ucDHH4aibAr7ari9g+qPXchlNtAGfGxfuEHDbk3vStfZhZnumM7tvxNBlVagcyve+4NN 3HUcRY0MZQqAGCY1wPNrFjzwcLagsGfIvKpXpB5QXWOcFATJt5krHvioG5M42xfR69fO mh5Q== 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=oLadZMY/1E+aj61iqE390ie32fUnJXqsMN5cFXtebck=; fh=7SJ88jyRfCa/QyubzHJGr8k28EF3cKZ+/egkoD91Ols=; b=NxvQEkYRhNH2lt5C7xfeq56HUgCERdiH9zzf7by7mbzQXrpllP6/7tmUR6AiN0souS i3YFUk3El06w4XMchBuvNCS2GfTlp3nSqE194dxn3iLk5EwCiK0fhcIdDCdLWSzOTK3c S6D2RMK2v6pEZ81p2oD48GjUTBeZxc5nw2hJXq2CzUS/Y5LzH1mdgKux+A/fbbymkesI IR2MG8zvgVn5u6Y8ODc9hQ+sMipfKI6lmHnt3NE4vydBNlUAbJkNTM4YXGp6+b38vU6i d5wLfFoNxuqKtSBcRVfeK4me4dcbA5DACeFR8lyr8RcCmXbkPt7hXz6oWK5NQucE766N ttYQ==; 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=S5b5U4zv; 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-147410-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147410-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id fv2-20020a056214240200b006a042a4f87fsi490368qvb.374.2024.04.16.11.48.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:48:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147410-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=S5b5U4zv; 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-147410-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147410-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 75D231C21535 for ; Tue, 16 Apr 2024 18:48:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 636AF13C668; Tue, 16 Apr 2024 18:45:00 +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="S5b5U4zv" Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (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 2911213BC1A for ; Tue, 16 Apr 2024 18:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713293099; cv=none; b=KzRzJPZNof8LDLaUSUOol2my2yKk2JyJzA50Kstj7Piw3F/J0zTUkVKPvC9GkDXZMlCEOtcb7KcTOqleqVBHSuHOl4BtUZVh+AmuIUr6h8ge1sG1PBIWnOAcBRUIPprxtMOI4caGrPRTM//2XnkLRQRHitL2OLIN5wkV2DRR3NM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713293099; c=relaxed/simple; bh=+BS7mctHpN9iWLFPEwC2/74zIoWzY97OXSTjHAOIU1s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z8RMW4gQy8NAdr/swbgHW3OyF/zC3ZbuoHJUjTWVPRcKK4ralWUITQGVN0iSQLMNH7YeZjCh0tC7ReoxszSOheiqWOhY/t4MDmtdywA8TrFUmh+W/vzOE9rP5niLAU/fnE8oY7YZEVFQxUBvEfQFYn/AYWBDiMXuAMdxEfcQHTA= 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=S5b5U4zv; arc=none smtp.client-ip=209.85.216.50 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-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2a53e810f10so2946340a91.0 for ; Tue, 16 Apr 2024 11:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713293097; x=1713897897; 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=oLadZMY/1E+aj61iqE390ie32fUnJXqsMN5cFXtebck=; b=S5b5U4zvMHVQd6WP/hv3XBA4A7JnXSNAicRi0OPpfkC1OuSlA9LKaZ5mFWowO0fMqt 4JsHZWhwF1IqMOYettWtnoFyEnQIxS46EmoKrLb3YyjBoSytqKjHvBP/2leTi7uFBTt1 mQG0xUst6pNBvHFBsFX+pUsl86gtkyF1ZPel+55fGjW4lzHNJA+8GPy7OF28Gld44PL7 vBcD5uDI5LAyVBtC6XK0gxd5d6/w2IL+H1OXce5LLgKhvQKD/3d/XIID+SU0bLskF+4t VZfUOlnGG1WLgB+szrfgv+tmJt7338jK3OnLX4eDfUeh79csCNfNfQVcsZ/pK42SquDN qRoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713293097; x=1713897897; 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=oLadZMY/1E+aj61iqE390ie32fUnJXqsMN5cFXtebck=; b=VOaVgOJI4hX2LEQOMi7otwA7IoiN0W6VRxrrjbrejC6MlBwsdkzCWlbQ0lnnLkgb9q mQQZu2d4jXDZbxK5jEQTOFj9S6SMj4hyGcT9gFSwBSv4cH8AjpNTnnr+FsRAfFgpzmwE P9+YDg+wceNkJpZhJrFqdhVLUWsH/en9weTwAlWi7GS4iMeBeRLZnSPvx7EOxc05w1Ny 52XIT4IiALLkrfWv+tH/vXK9KMTehioCi8LaKBe2IGzJqsaBejBjukUun22jVqSSU9Oc EY8/h4VACtERISpotfA3mVjZNrStuhyviPHqCczICr88Kmc10c95aBiXtKtqafFRd58p gZ9w== X-Gm-Message-State: AOJu0YwaVaqtqsgail/wMRhDt8XxXl7BfRW2AD6UqXmZ2IW/bSelt4t/ 1/DDARyGl3D/NZFBzQ10CVNe7qxMtHujG0SOWYPeT7t834dcNkuRi1uwkUqv6KFnpNVIVVN2PxP X X-Received: by 2002:a17:90a:130c:b0:2a6:f414:4e0b with SMTP id h12-20020a17090a130c00b002a6f4144e0bmr9113440pja.41.1713293097058; Tue, 16 Apr 2024 11:44:57 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:44:56 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Anup Patel , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , 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 11/24] RISC-V: KVM: No need to update the counter value during reset Date: Tue, 16 Apr 2024 11:44:08 -0700 Message-Id: <20240416184421.3693802-12-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> 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 virtual counter value is updated during pmu_ctr_read. There is no need to update it in reset case. Otherwise, it will be counted twice which is incorrect. Fixes: 0cb74b65d2e5 ("RISC-V: KVM: Implement perf support without sampling") Reviewed-by: Anup Patel Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- arch/riscv/kvm/vcpu_pmu.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/riscv/kvm/vcpu_pmu.c b/arch/riscv/kvm/vcpu_pmu.c index cee1b9ca4ec4..b5159ce4592d 100644 --- a/arch/riscv/kvm/vcpu_pmu.c +++ b/arch/riscv/kvm/vcpu_pmu.c @@ -397,7 +397,6 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vcpu, unsigned long ctr_base, { struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu); int i, pmc_index, sbiret = 0; - u64 enabled, running; struct kvm_pmc *pmc; int fevent_code; @@ -432,12 +431,9 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vcpu, unsigned long ctr_base, sbiret = SBI_ERR_ALREADY_STOPPED; } - if (flags & SBI_PMU_STOP_FLAG_RESET) { - /* Relase the counter if this is a reset request */ - pmc->counter_val += perf_event_read_value(pmc->perf_event, - &enabled, &running); + if (flags & SBI_PMU_STOP_FLAG_RESET) + /* Release the counter if this is a reset request */ kvm_pmu_release_perf_event(pmc); - } } else { sbiret = SBI_ERR_INVALID_PARAM; } -- 2.34.1