From nobody Tue Feb 10 20:28:01 2026 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 427EE257AD7 for ; Wed, 26 Feb 2025 20:25:15 +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=1740601516; cv=none; b=biShXxhJsFLQ2/gKCDo/+WY4uPbkVodd3llkc9yonHf7UkQyDo6T3xmV/P8qGCC1jCY4roYzgIKqIyYDFiZdfQO2YJdyVSKhY6fWycgvjTmrwmIkZiOEAumhDCsOpKV+6A0JDqRDZ5Ym/4/PT5DW46EKRd1HsRUiN8JP580Y9Os= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740601516; c=relaxed/simple; bh=60wxU0lkF9ES7Q2Y1xRG0c1Mze/bj/KB7bV531P/zP8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XFKKwWCyDCt1/GJRrlzdc+SKpfjn5x81Ox/8m4PzOszICC4VhdM0Q4Qe7wQcXWohIUL8pQc6IB8dOpIaAEnEIgfDIQwh+bXX5djzceAn0Kg4kmElUy1hwbNUJsflEhgwjok9LUOdRwTITR5Brbw4XbgFmjrqYIs0YvKMDkRAamI= 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=jQh2RCUk; 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 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="jQh2RCUk" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2211cd4463cso2660355ad.2 for ; Wed, 26 Feb 2025 12:25:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1740601514; x=1741206314; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=K+xf5rb3O3ZrwcS1pmKysmwXefhXbLuGjQJfAu9gHOI=; b=jQh2RCUkMktFEZfucqbsRKlUqXy3ySCsKrij1MvceFCF9AKTip/2M8+Z/TrZhGc5xV OI8V/eSdPtEgZP1jaz8FI1+4mGffnWv0yJesWBHnNQl3y7M2z7BwrqiUtXoG0Zz/+y7D Eb2U2yIjPFmt/Y9df93LdHK/ixYNHQjjT2tddfvqP9vgRLFehQ+yFfjBGwcODwZuF/nB urD5L0jjR8JVJ3GeP1KStQxy+8iP6zsU4uDw9vRXmQCFnDUPxZ59ba73PUKmD4bwcfLf YLjGUMssmv/JChM1rnL2v3LxXqiOhXH0SEF9RNL0OBfN4qLqfT+UCShgDylR7+fWc2ui vtvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740601514; x=1741206314; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K+xf5rb3O3ZrwcS1pmKysmwXefhXbLuGjQJfAu9gHOI=; b=GI/onFZ9ZvHE9qaCARNoSblPHJqPwdqNQutzkFyXv0noc1lMyjdKL7l7rc+pHUET7C VUF9qF7z0ZDYqaPpjQBfTFoBGS8xU50ED40XDBUQdmN2etFMbX1k9CT1QpIzgtbHikSg oWBLLbf4nkKx0gQIiwUPon7B33qcS98XCDwpoe/B5B1tovh/c5aUNuj5ItB55bSWKqzq PwQeYvUDwXPHJp1Fv+hxDrImc+gPZjkS6cD0XnOZUXqrhwc8ux+7hV2cYFgC6ZE5uf7k hXpyz3j6MbUx0UwEU7Yj25UQLWnPIRAhyV8Rzbmxv/UlQwROjEpbCMnQDnWYtc2bdOzN 00eQ== X-Forwarded-Encrypted: i=1; AJvYcCWl/hyA/UHpxA7TQjqbIKeYdDFo+OCAYcjaVl0BiVmZBxsu2ywLq0Ce6m1QGHnE8zNRdZ9BL+Pwe2T9PjA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw01CvEn+cTjI4nzCRc8UixGBHR+Oq6v+FJFjbLpRHolQtpfU7j CzcTYwf9ur8aTvpbnsdsehTE2zFjhH57XfbrtT8i1exCQZdsjEg8g6ZucWLCljk= X-Gm-Gg: ASbGncsmxoMBK5pe8xXriXJ6oMiKJbYrAdMRPJ8kaBiw2CNhNdJZuClNQsTmPN5n1qm pkPmvvuuFHgMTZe03Ci30Vv87psKrjobyqbxMFr11ZiquRb1iAARICATt85WNWUmZshh3Dvx18m I0t2mGn3wNgTOlT94oZB+9cnpY9LTXHREN4f7xzGRl9YVAt0gzf8LRdxXaR71cijO8d9S6gl+dZ 6fX8AazwRUlJuuhyEMubAJliEhYyvnSV73ezFy4dwtGNXPdcbW2+vO2OnfAG7SkTlyB3Ly6Oys5 eYkViWIG9I1Ua0iAYUx3mI3GoOKIsN4O/4tjTy0= X-Google-Smtp-Source: AGHT+IHw0vBB+PSny2qMliUf6DTVa+ZvGcPh/rPnK0tt+c9UR1fNAKJeSn8VDRagyarmbZCnK8Ejgg== X-Received: by 2002:a05:6a00:a26:b0:72d:3b2e:fef9 with SMTP id d2e1a72fcca58-734791aa184mr14536500b3a.20.1740601514558; Wed, 26 Feb 2025 12:25:14 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7347a7f7de2sm4100963b3a.106.2025.02.26.12.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2025 12:25:14 -0800 (PST) From: Atish Patra Date: Wed, 26 Feb 2025 12:25:06 -0800 Subject: [PATCH 4/4] KVM: riscv: selftests: Allow number of interrupts to be configurable 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: quoted-printable Message-Id: <20250226-kvm_pmu_improve-v1-4-74c058c2bf6d@rivosinc.com> References: <20250226-kvm_pmu_improve-v1-0-74c058c2bf6d@rivosinc.com> In-Reply-To: <20250226-kvm_pmu_improve-v1-0-74c058c2bf6d@rivosinc.com> To: Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Andrew Jones , Paolo Bonzini , Shuah Khan Cc: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Atish Patra X-Mailer: b4 0.15-dev-13183 It is helpful to vary the number of the LCOFI interrupts generated by the overflow test. Allow additional argument for overflow test to accommodate that. It can be easily cross-validated with /proc/interrupts output in the host. Signed-off-by: Atish Patra --- tools/testing/selftests/kvm/riscv/sbi_pmu_test.c | 36 ++++++++++++++++++++= ---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c b/tools/testi= ng/selftests/kvm/riscv/sbi_pmu_test.c index 533b76d0de82..7c273a1adb17 100644 --- a/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c +++ b/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c @@ -39,8 +39,10 @@ static bool illegal_handler_invoked; #define SBI_PMU_TEST_SNAPSHOT BIT(2) #define SBI_PMU_TEST_OVERFLOW BIT(3) =20 +#define SBI_PMU_OVERFLOW_IRQNUM_DEFAULT 5 struct test_args { int disabled_tests; + int overflow_irqnum; }; =20 static struct test_args targs; @@ -478,7 +480,7 @@ static void test_pmu_events_snaphost(void) =20 static void test_pmu_events_overflow(void) { - int num_counters =3D 0; + int num_counters =3D 0, i =3D 0; =20 /* Verify presence of SBI PMU and minimum requrired SBI version */ verify_sbi_requirement_assert(); @@ -495,11 +497,15 @@ static void test_pmu_events_overflow(void) * Qemu supports overflow for cycle/instruction. * This test may fail on any platform that do not support overflow for th= ese two events. */ - test_pmu_event_overflow(SBI_PMU_HW_CPU_CYCLES); - GUEST_ASSERT_EQ(vcpu_shared_irq_count, 1); + for (i =3D 0; i < targs.overflow_irqnum; i++) + test_pmu_event_overflow(SBI_PMU_HW_CPU_CYCLES); + GUEST_ASSERT_EQ(vcpu_shared_irq_count, targs.overflow_irqnum); + + vcpu_shared_irq_count =3D 0; =20 - test_pmu_event_overflow(SBI_PMU_HW_INSTRUCTIONS); - GUEST_ASSERT_EQ(vcpu_shared_irq_count, 2); + for (i =3D 0; i < targs.overflow_irqnum; i++) + test_pmu_event_overflow(SBI_PMU_HW_INSTRUCTIONS); + GUEST_ASSERT_EQ(vcpu_shared_irq_count, targs.overflow_irqnum); =20 GUEST_DONE(); } @@ -621,8 +627,11 @@ static void test_vm_events_overflow(void *guest_code) =20 static void test_print_help(char *name) { - pr_info("Usage: %s [-h] [-t ]\n", name); + pr_info("Usage: %s [-h] [-t ] [-n ]\n", + name); pr_info("\t-t: Test to run (default all). Available tests are 'basic', 'e= vents', 'snapshot', 'overflow'\n"); + pr_info("\t-n: Number of LCOFI interrupt to trigger for each event in ove= rflow test (default: %d)\n", + SBI_PMU_OVERFLOW_IRQNUM_DEFAULT); pr_info("\t-h: print this help screen\n"); } =20 @@ -631,6 +640,8 @@ static bool parse_args(int argc, char *argv[]) int opt; int temp_disabled_tests =3D SBI_PMU_TEST_BASIC | SBI_PMU_TEST_EVENTS | SB= I_PMU_TEST_SNAPSHOT | SBI_PMU_TEST_OVERFLOW; + int overflow_interrupts =3D -1; + while ((opt =3D getopt(argc, argv, "h:t:n:")) !=3D -1) { switch (opt) { case 't': @@ -646,12 +657,24 @@ static bool parse_args(int argc, char *argv[]) goto done; targs.disabled_tests =3D temp_disabled_tests; break; + case 'n': + overflow_interrupts =3D atoi_positive("Number of LCOFI", optarg); + break; case 'h': default: goto done; } } =20 + if (overflow_interrupts > 0) { + if (targs.disabled_tests & SBI_PMU_TEST_OVERFLOW) { + pr_info("-n option is only available for overflow test\n"); + goto done; + } else { + targs.overflow_irqnum =3D overflow_interrupts; + } + } + return true; done: test_print_help(argv[0]); @@ -661,6 +684,7 @@ static bool parse_args(int argc, char *argv[]) int main(int argc, char *argv[]) { targs.disabled_tests =3D 0; + targs.overflow_irqnum =3D SBI_PMU_OVERFLOW_IRQNUM_DEFAULT; =20 if (!parse_args(argc, argv)) exit(KSFT_SKIP); --=20 2.43.0