From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 45D1D2D661B for ; Fri, 29 Aug 2025 14:41:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756478471; cv=none; b=BbTRFJjMFXQqJTdjJMbP4n5pzHjxFtLt2EbdsUQqvMCyksiAH2S4HNfMr4OZLvqFJtrk+KqQQkVNJaPmYgz3egOokbMYouOIYoU7Bc5omW8EySrNOgsoCaeHzKuLKGiAcXnxbu+635ZLHY2NdpXR605pO6EXTLCPq7JVf/iJ7DQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756478471; c=relaxed/simple; bh=7IkrvrDV7cSoQssT0NirSi0XvDjmOWIRETuOhZnQfEA=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=IxgK+c4uOUbV0sgPKmd/oYVaUSwvPo2aAiCjuNRHhBS76Kvlk7+n4aX564i2q6abZKhukNg39LvEIwGuGLyHr1Hcz6YSGmwSw67KdoCObsD9d0h9L5g9f/jUwnINurtsNZURwGThYVHs1tZSFvLcpKYq7BYoTvdxbbPqXBM4fhA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc.com header.i=@rivosinc.com header.b=atKwZJaR; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (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 header.i=@rivosinc.com header.b="atKwZJaR" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-76e4f2e4c40so1936302b3a.2 for ; Fri, 29 Aug 2025 07:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc.com; s=google; t=1756478468; x=1757083268; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=oF5TQ5tmAgJotT6TBzfmeh55EB+gENZQcbLkBFQiOtM=; b=atKwZJaRz57g9S7/aqHOQWhaCO3efFhJo/snYdnShTXeLTf/v3EKH/v4ikZthyEvAR tjtbfMk73BghAvYwTK1M1TXe20oo0lbEc8SKIh6pW0KtXfB8cdBBom8rQ6lc68yzWTiQ p0dQKKQX6rTqCJbXVJTxaHVkhtdW8DNnZ3TSIcwD+nxr1NHBuONOJC5j083Coaik/TFK GivDlUqTqJNiiHCuwWmwk8el6Wpq4qXqu/Hh3q1gSOTagZmqeP/xv2DgvTz2caMIroOS lWIjnqm+0nTUR4F/YgH+JKzUxPurpOorZp5mQ5a94xBsGkE7iAhqX3XHjoVYbDZs7zfA 0z5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756478468; x=1757083268; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oF5TQ5tmAgJotT6TBzfmeh55EB+gENZQcbLkBFQiOtM=; b=whSo+uWgE9uxUkKFpDpxRzrZOCG7ifF+pfOz8vamKNtL+awhqDjpp9JHGBJs3fiZOo RKO00F/ClJxnvn86ffkkyVVOuRF/84g6pxe9ah11FJ0YhU9pC0L8JKQzJxxyW7sjPWwu gnrRMB5Hg2ft5drsaXBtfRVP86UWsJUiYITUDx5YYqUfV85sie9wMDWOqdVrP7QxSKD2 fE1sAtVGFT72tZtIyzHslXZQLVns4v/OzV+CDm3j73nCXwRQF0j3hy8U4R4g558lKJ+y tmCOoYQkQOQ7rxUZCWALohLpLr/WJ3mc8lbsFsUCUFesZepb77bBS2EHF8jgPO8/YPvG RXFg== X-Forwarded-Encrypted: i=1; AJvYcCUILo8FoW7F7SxwYuzDLYdSG4T5tqqSttN4aLvYYuKGWqEYPw22Dqh4JdJhPfPqYQEAWy6ucGyPsHt8b4E=@vger.kernel.org X-Gm-Message-State: AOJu0YxQgD0+bVQK6TO2SZn0o3NlNpRQ/HAWAM1eg1s3PWeWM8Yqo/t5 qFJ3QZrBEVBC9xYgBik8tYZMaHVEwhvILkJBjgioltb7wPY5ol7GA2tQVC04bqBs+dY= X-Gm-Gg: ASbGncvLcxKQy4Q11kVZNOhA9Ukeb5FzmpzInG1vYpkE7pfpd0ome+cWaB4xKm3EAHB sdHPe77GNQza32zXzKvtf+1qlA20ECcx+c7MfNlSTWN4IblaVFyYtmKel+mv/1g3CWl1LAiYVt+ wBuFELxZLC4jgRPM/v9Tu30f+sMCDNMWEWr/PWN/URwA3Hduf7YqC7yAN2Ru/JnZdaWYcNJ4Pzk iEHRjlxNK8bGKB6/NI4qnV84SAsVSbPePAdsOjKtPnR31iq1xvO/PlaMjCWJ/ID1ucZDgoQau5f H8vDhd2Eu/jPUjUk0AkgZOf7YyeXgGDBEBPl+hO8/M5tP/Ox4b1rqQbpvAEz13J4fc1GZAa05XQ 7wc97ZIMhX/wGrd2L1vw0v0lEGtLMdW4lXdg= X-Google-Smtp-Source: AGHT+IGfKLBhrAwQIfIo51JxqP/Uh80E+uh15u67yO328vBecr+7D5ezoUnfonrgJ2TgVx7Oab+e/A== X-Received: by 2002:a05:6a20:12d1:b0:243:98b1:395c with SMTP id adf61e73a8af0-24398b13d1cmr16044556637.31.1756478468352; Fri, 29 Aug 2025 07:41:08 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7722a4e1f86sm2560999b3a.72.2025.08.29.07.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 07:41:07 -0700 (PDT) From: Atish Patra Subject: [PATCH v5 0/9] Add SBI v3.0 PMU enhancements Date: Fri, 29 Aug 2025 07:41:01 -0700 Message-Id: <20250829-pmu_event_info-v5-0-9dca26139a33@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAP27sWgC/23RTW7DIBAF4KtYrEvkGX4MUVX1HlUV2WRoWNhOw UGtoty92FaVNsnyIfHBvDmzRDFQYtvqzCLlkMI4lKCeKuYO7fBBPOxLZlijhBoMP/anHWUapl0 Y/Mit0YTgSHd7wcqlYyQfvhbw7b3kQ0jTGL8XP8N8ulIA9pbKwGveSm+1BYngzWsMeUxhcBs39 mzWMv4KqgZQdwIWwUgDqmtqYUT3QBBXQSHeCaIIvum6tvF76zw9EORVaBDuBDlP4RrdKNNK1PZ GuKwlRfo8lbKntSnWU0rtUva2el4KQvj7uaXTXZlvHREEFdwrq/Ef/zKvoGsT8RL6MG2rrDcge HRYXr78APgRHZ3uAQAA X-Change-ID: 20241018-pmu_event_info-986e21ce6bd3 To: Anup Patel , Will Deacon , Mark Rutland , Paul Walmsley , Palmer Dabbelt , Mayuresh Chitale Cc: linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Atish Patra , Sean Christopherson X-Mailer: b4 0.15-dev-50721 SBI v3.0 specification[1] added two new improvements to the PMU chaper. The SBI v3.0 specification is frozen and under public review phase as per the RISC-V International guidelines. 1. Added an additional get_event_info function to query event availablity in bulk instead of individual SBI calls for each event. This helps in improving the boot time. 2. Raw event width allowed by the platform is widened to have 56 bits with RAW event v2 as per new clarification in the priv ISA[2]. Apart from implementing these new features, this series improves the gpa range check in KVM and updates the kvm SBI implementation to SBI v3.0. The opensbi patches have been merged. This series can be found at [3]. [1] https://github.com/riscv-non-isa/riscv-sbi-doc/releases/download/v3.0-rc7/riscv-sbi.pdf [2] https://github.com/riscv/riscv-isa-manual/issues/1578 [3] https://github.com/atishp04/linux/tree/b4/pmu_event_info_v4 Signed-off-by: Atish Patra --- Changes in v5: - Rebased on top of v6.17-rc3 - Updated PATCH 6 as per feedback to improve the generic helper function - Adapted PATCH 7 & 8 as per PATCH 6. - Link to v4: https://lore.kernel.org/r/20250721-pmu_event_info-v4-0-ac76758a4269@rivosinc.com Changes in v4: - Rebased on top of v6.16-rc7 - Fixed a potential compilation issue in PATCH5. - Minor typos fixed PATCH2 and PATCH3. - Fixed variable ordering in PATCH6 - Link to v3: https://lore.kernel.org/r/20250522-pmu_event_info-v3-0-f7bba7fd9cfe@rivosinc.com Changes in v3: - Rebased on top of v6.15-rc7 - Link to v2: https://lore.kernel.org/r/20250115-pmu_event_info-v2-0-84815b70383b@rivosinc.com Changes in v2: - Dropped PATCH 2 to be taken during rcX. - Improved gpa range check validation by introducing a helper function and checking the entire range. - Link to v1: https://lore.kernel.org/r/20241119-pmu_event_info-v1-0-a4f9691421f8@rivosinc.com --- Atish Patra (9): drivers/perf: riscv: Add SBI v3.0 flag drivers/perf: riscv: Add raw event v2 support RISC-V: KVM: Add support for Raw event v2 drivers/perf: riscv: Implement PMU event info function drivers/perf: riscv: Export PMU event info function KVM: Add a helper function to check if a gpa is in writable memselot RISC-V: KVM: Use the new gpa validate helper function RISC-V: KVM: Implement get event info function RISC-V: KVM: Upgrade the supported SBI version to 3.0 arch/riscv/include/asm/kvm_vcpu_pmu.h | 3 + arch/riscv/include/asm/kvm_vcpu_sbi.h | 2 +- arch/riscv/include/asm/sbi.h | 13 +++ arch/riscv/kvm/vcpu_pmu.c | 77 +++++++++++++- arch/riscv/kvm/vcpu_sbi_pmu.c | 3 + arch/riscv/kvm/vcpu_sbi_sta.c | 6 +- drivers/perf/riscv_pmu_sbi.c | 191 +++++++++++++++++++++++++--------- include/linux/kvm_host.h | 8 ++ include/linux/perf/riscv_pmu.h | 1 + 9 files changed, 245 insertions(+), 59 deletions(-) --- base-commit: e32a80927434907f973f38a88cd19d7e51991d24 change-id: 20241018-pmu_event_info-986e21ce6bd3 -- Regards, Atish patra