Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2236026lqt; Mon, 22 Apr 2024 05:41:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWT2KL8bEQdIoXSRhiM0U02ObNtCKUFFwcFGt/ymwhGKX54K+Rq1f2CwK5+vzXM52MAYYZ0S7YwZ9FI3cqDn9u2voHuQtpQdsy62iU/Cg== X-Google-Smtp-Source: AGHT+IHqaGkO24yMbvRBx4cZXWpKb/yx8fI9fgfeuByx9QI3x8KpPDIQ3/mYz9Tn6sjKSPrlW+bc X-Received: by 2002:a50:9f84:0:b0:570:7e4:8e9e with SMTP id c4-20020a509f84000000b0057007e48e9emr6174647edf.15.1713789704640; Mon, 22 Apr 2024 05:41:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713789704; cv=pass; d=google.com; s=arc-20160816; b=m89LFENFJ0gZFoLQbC8N078qBiUFgJCfYzEF3VwEt2fMwnSAR2VbydbqWbPkbgw7Kf 0oGLA0XIUME5riPu7txCAy/hL2NWaLPYwGHU3LS0TzvvQ/+j1xbHXjicxB2gGllHcld0 vJkv3gTmSLed+xOVYFzo52HdFPinqYT3igz8z5gXpNthSg5IVE6eTA61xr8TQMNq4sMn A9K50n+V1b9It/Ua6SAlERkCBCC1AQEb5S8FL6hO6aX7CVG2Cc6M2QeuEbmG5/vEMRZP Ry7mYwsTg5+s16HN9a5DlneUEmgZkYi2z0JO8RscECDgpBSVRwf90U3g96d4A0nKAyxH ma4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=+mSLO7qsMu9ScrRVYm3QHz5Wa7uqrp1Jo4sRqwEm41k=; fh=A4o1dfTWrAjNg1kbsgLVw4fFrmHsgZRIuWsPcb89/Ww=; b=SmsFeG+WUuz7PQNOfSQe8kdTkcj7XobcynANjd08+1MEDt64LJXiYjG8ysh/HSWQZr KDdpgFMBXJarOFYAjg8jyPi6RaN0/AnatidVDZCthk9We5R/XdisiH5KbQalvM165haj LGxmfLnoxibGA+EZMGCXeGjW8xpn5+xhINUFd9HCDmM6xs3YeX4xHl3D0HbvKg6dw/Sf tjXI8N8O4efhdwc6490LbVDXASWhH9Jel3ril6hWsP2fBtrQho14LrmaFoOh/yAlyTei R7Tmah9HtC4/0oG4xUdzGWnIvtK3GUuRmS5JbZlAaMmUC6WipQiGgYeE24vI9ikAp8Lx CX8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=o6tQD90I; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-152745-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152745-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b10-20020aa7c6ca000000b005700cd608c0si6027650eds.313.2024.04.22.05.41.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:41:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152745-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=o6tQD90I; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-152745-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152745-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 529951F22689 for ; Mon, 22 Apr 2024 05:33:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7387E18AED; Mon, 22 Apr 2024 05:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b="o6tQD90I" Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (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 39CD511CAB for ; Mon, 22 Apr 2024 05:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713763972; cv=none; b=IdCLKkmPMma1kE7Rwe4vxZ/oOmPWPw/aQv1X804GAzUevXUIqk8bG/gtRqEsANm2rVWxxAWmVO0DQmne8zKdEeskmi1Nat6eMtEJowp0Xl5Efb8qftgqX8ik/tEWoN6qerhauvnUte+Lz0ojwGcK/B56kaynNwk+/yyXoaF6h4g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713763972; c=relaxed/simple; bh=BwCdWcMLmgKeTy/zl1TsPBXPPuxkE/Xsmo260vkgIDo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=DgnW6ZXKPbu7aAUJBxhL5PAdiEtwrkjeKGLv5naHvcOMwRAgBYoiNOQpirhNPYY2HqXgJ1xMcjT3GdqkUuAGbQx5Pf5snMaOjtpaKbP8Yz7U5ZWTXvTTu7SMEmGjrKE4VyubxDNOEag8U0e0dJCKKj/3jtFb/hAaT5kfqgVysdA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org; spf=none smtp.mailfrom=brainfault.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b=o6tQD90I; arc=none smtp.client-ip=209.85.166.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=brainfault.org Received: by mail-io1-f54.google.com with SMTP id ca18e2360f4ac-7da3ec3e044so147604639f.2 for ; Sun, 21 Apr 2024 22:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1713763970; x=1714368770; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+mSLO7qsMu9ScrRVYm3QHz5Wa7uqrp1Jo4sRqwEm41k=; b=o6tQD90ICgKGUhcbrhk1jF3W+tlwQyTzOMCPEuDBKXwb7XAeo2TRjRwTAGKDHdsGBX 4t/GLY8tVkSf5IQ7cDbqBdQRiKlYUV2yWxdhi7+MrHdhuMP0d7kULVF61AWI+kl/ALtH VmtSmgQQ/LxURYZZjf7JZxM4vSOYG2XuVWcTnzVVmvfd2OQ9T9d/M43yOF2piP9ncmBZ i0/Y/WGQAV9wZON4/r+Egvl03Ma0PgSKEuvw57rs6UwMznjUI2yTi4AD9w7HrMowtZTm OuVRzWteq23FoVe+983P33VvHrVz+rzc4axkuGn/HJC+MfliELkHuOxMlm8mgLps3dxL z2ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713763970; x=1714368770; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+mSLO7qsMu9ScrRVYm3QHz5Wa7uqrp1Jo4sRqwEm41k=; b=hH9UJrdylhz6hUj6MBO6JuZihaGccdAZGgIp4uffrIkFv+vW3GAVri82Yz21L2gYVa D9p+/Cq9jGfC4ZjYIlnNyHM/Pz5XSF/nahapEM6BrRnVKdW0dTn64PBywtFcQMWiyoQS 77M4sZ+NUbj/+N/DTGVquhzQUAMgBlHg9+9A5xDaztPEwoohQ3qa/HdJXXt4w1iA+UTQ CRhWxhinQUHk1j32otcU7Sea8HIQNpcquxioDhcVplKgYXTKusMeqlIU/L3/n6GLBP4u UJU66f2YK1N6blFfE/VqpYv9ZMckFr2q7oHPVYGkt+0LxnF5xdvz8BboFjJqE/XWlgRX A8FA== X-Gm-Message-State: AOJu0YyngzjoXx9TSyTTcsKquONeaLTYxuGEfW/dABw1xVwziQP10HZ9 TDykn1nFS/gDe5nQ4d7hts/piSo8pKKNoew9O5dgv86qwoNj23PtpFmqnNj/sBGez3WeuS0P4jk ZK2DOXcsCo86GksWDqlqSqHZ35eVtFTAwbeUZhA== X-Received: by 2002:a05:6e02:144d:b0:36a:686:b3bf with SMTP id p13-20020a056e02144d00b0036a0686b3bfmr13479495ilo.17.1713763970407; Sun, 21 Apr 2024 22:32:50 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240420151741.962500-1-atishp@rivosinc.com> <20240420151741.962500-25-atishp@rivosinc.com> In-Reply-To: <20240420151741.962500-25-atishp@rivosinc.com> From: Anup Patel Date: Mon, 22 Apr 2024 11:02:39 +0530 Message-ID: Subject: Re: [PATCH v8 24/24] KVM: riscv: selftests: Add commandline option for SBI PMU test To: Atish Patra Cc: linux-kernel@vger.kernel.org, Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Apr 20, 2024 at 5:18=E2=80=AFAM Atish Patra w= rote: > > SBI PMU test comprises of multiple tests and user may want to run > only a subset depending on the platform. The most common case would > be to run all to validate all the tests. However, some platform may > not support all events or all ISA extensions. > > The commandline option allows user to disable any set of tests if > they want to. > > Suggested-by: Andrew Jones > Signed-off-by: Atish Patra LGTM. Reviewed-by: Anup Patel Regards, Anup > --- > .../selftests/kvm/riscv/sbi_pmu_test.c | 73 ++++++++++++++++--- > 1 file changed, 64 insertions(+), 9 deletions(-) > > diff --git a/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c b/tools/tes= ting/selftests/kvm/riscv/sbi_pmu_test.c > index 0fd9b76ae838..69bb94e6b227 100644 > --- a/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c > +++ b/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c > @@ -33,6 +33,13 @@ static unsigned long counter_mask_available; > > static bool illegal_handler_invoked; > > +#define SBI_PMU_TEST_BASIC BIT(0) > +#define SBI_PMU_TEST_EVENTS BIT(1) > +#define SBI_PMU_TEST_SNAPSHOT BIT(2) > +#define SBI_PMU_TEST_OVERFLOW BIT(3) > + > +static int disabled_tests; > + > unsigned long pmu_csr_read_num(int csr_num) > { > #define switchcase_csr_read(__csr_num, __val) {\ > @@ -608,19 +615,67 @@ static void test_vm_events_overflow(void *guest_cod= e) > test_vm_destroy(vm); > } > > -int main(void) > +static void test_print_help(char *name) > +{ > + pr_info("Usage: %s [-h] [-d ]\n", name); > + pr_info("\t-d: Test to disable. Available tests are 'basic', 'eve= nts', 'snapshot', 'overflow'\n"); > + pr_info("\t-h: print this help screen\n"); > +} > + > +static bool parse_args(int argc, char *argv[]) > +{ > + int opt; > + > + while ((opt =3D getopt(argc, argv, "hd:")) !=3D -1) { > + switch (opt) { > + case 'd': > + if (!strncmp("basic", optarg, 5)) > + disabled_tests |=3D SBI_PMU_TEST_BASIC; > + else if (!strncmp("events", optarg, 6)) > + disabled_tests |=3D SBI_PMU_TEST_EVENTS; > + else if (!strncmp("snapshot", optarg, 8)) > + disabled_tests |=3D SBI_PMU_TEST_SNAPSHOT= ; > + else if (!strncmp("overflow", optarg, 8)) > + disabled_tests |=3D SBI_PMU_TEST_OVERFLOW= ; > + else > + goto done; > + break; > + case 'h': > + default: > + goto done; > + } > + } > + > + return true; > +done: > + test_print_help(argv[0]); > + return false; > +} > + > +int main(int argc, char *argv[]) > { > - test_vm_basic_test(test_pmu_basic_sanity); > - pr_info("SBI PMU basic test : PASS\n"); > + if (!parse_args(argc, argv)) > + exit(KSFT_SKIP); > + > + if (!(disabled_tests & SBI_PMU_TEST_BASIC)) { > + test_vm_basic_test(test_pmu_basic_sanity); > + pr_info("SBI PMU basic test : PASS\n"); > + } > > - test_vm_events_test(test_pmu_events); > - pr_info("SBI PMU event verification test : PASS\n"); > + if (!(disabled_tests & SBI_PMU_TEST_EVENTS)) { > + test_vm_events_test(test_pmu_events); > + pr_info("SBI PMU event verification test : PASS\n"); > + } > > - test_vm_events_snapshot_test(test_pmu_events_snaphost); > - pr_info("SBI PMU event verification with snapshot test : PASS\n")= ; > + if (!(disabled_tests & SBI_PMU_TEST_SNAPSHOT)) { > + test_vm_events_snapshot_test(test_pmu_events_snaphost); > + pr_info("SBI PMU event verification with snapshot test : = PASS\n"); > + } > > - test_vm_events_overflow(test_pmu_events_overflow); > - pr_info("SBI PMU event verification with overflow test : PASS\n")= ; > + if (!(disabled_tests & SBI_PMU_TEST_OVERFLOW)) { > + test_vm_events_overflow(test_pmu_events_overflow); > + pr_info("SBI PMU event verification with overflow test : = PASS\n"); > + } > > return 0; > } > -- > 2.34.1 >