Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp97324lqg; Wed, 10 Apr 2024 17:16:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXfzhc3mQktf9FklN8ubkSB8pTu714IKDtJWMI1dtLFl9gTR1rAFpOmr4A/ukZtX3NMm+K1dknoed7lc/KwnYcwKfnI4MKE9mf9+1lQYA== X-Google-Smtp-Source: AGHT+IFeeCl6+iuyA8R6w1vufUUAIYGEzGjlTtEx+HRPVEt/Dt3Bv2VMEbnFCqfWhKamWzUt3YFN X-Received: by 2002:a17:907:3203:b0:a51:e43b:cb20 with SMTP id xg3-20020a170907320300b00a51e43bcb20mr3195644ejb.41.1712794597314; Wed, 10 Apr 2024 17:16:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712794597; cv=pass; d=google.com; s=arc-20160816; b=hqEMvNVB5DdJfc19gI/wrZGapi18XZC96t+7MgcjP3N8IiRfniAyLL6+LxyJJsqO8q OF8cKjGcMO3NWVTgFEUA11hSoeitki5GPQpOw9wgkaHeI+RXbasPaZXLjfXGHEMAFOAo 6r01yF4dBfX/ear+sYZUkEfqXx+LRR+i+d3NHdF2JN6KWcdM5fjADN1I6ol1OQ+9q5KN sClNczICCk8iIsW9qkj2BBGH70tLd6yUqbSgBCIo+7WMujPSDejuJU9JNEDqoYUh3APc cYdO+ukOwvOqElNaYIbHEgvy73e4xp6r4b+ewQkjrmeQHchaGqtEMKv/3HYt3M87u2K6 PuEA== 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=tLia834y+X9tlrjVFjCEV4aQslhHW6gNjSHeO9Lbrys=; fh=TV5tejk3Dt07dcNlLLEipj9Q2R7EhRc35yPyoZNpTh8=; b=m5WLExEEWT5/xC2dP4galjWNedth4CRG6VNdQlJRioehu1fAMURtdYavJMFIJbvt16 CIWH+kanz3znMS+9t7R9yAQsSRTnaGY8nUhmcb1P6Nxi997kMU/8j5z4BtbT53P6tDJV hcMrWWmLhgMmpzkuW306L5DXBUtcGLZqMpcFZXc6MvL8jMNOvbJbzoJbfKgS9hok/YDV z5mTfKgUg2moFaupXFEHOyQSjttZNMCfNM4YdFQJvlriFyb2TVi8l8ntZg15pTMWYUEQ m6qihg+WLaZKS53qpfHPurlWMbIVJRhLpACuEs8v1JVbGhmkBHy6Q8m+60wDWwgwHMVL 9p5g==; 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=TBjUQA70; 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-139579-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139579-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a12-20020a1709062b0c00b00a51d844d82bsi156462ejg.377.2024.04.10.17.16.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 17:16:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139579-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=TBjUQA70; 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-139579-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139579-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 DE51B1F24C23 for ; Thu, 11 Apr 2024 00:16:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD79E4C602; Thu, 11 Apr 2024 00:09:15 +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="TBjUQA70" Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 5107C481D5 for ; Thu, 11 Apr 2024 00:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712794154; cv=none; b=KB2Ajlff3A9eMPB1sRF0M7wnfwx831IEnz8/BD+Q14X44vUF7IiQWPilGETT6DxbXcTWq/YWpw8uOfd5+HxEX2EO6YVzblFEiJ8yrI/ZxwYcjtnUjgayjHEdv+lIEoBANXwNvm6W+pfIgsmLuAdIDU00L8d8VOTWZTWwdmaCN0I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712794154; c=relaxed/simple; bh=FfM/sSt5pOIT+SFPpfrQ5W4Ri7Uq0XA+YsWN/Asw1ro=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UvWBADwVb0DDRnse9OCgOqQ2Pu6UTP/n9fZjQeYq4G08SH74VBYTtuCrRFg86tArOiBgCn51VDovZRLYs2f9j1M3jyitqRg+h6/wfDrpp+TlBKc+X+H0ZjGe/jshiXXNd7DUazfAu+YFtud0qjQbq7ujc67rndYLfyg3qVFIHNo= 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=TBjUQA70; arc=none smtp.client-ip=209.85.214.182 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-pl1-f182.google.com with SMTP id d9443c01a7336-1e4266673bbso34130565ad.2 for ; Wed, 10 Apr 2024 17:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712794152; x=1713398952; 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=tLia834y+X9tlrjVFjCEV4aQslhHW6gNjSHeO9Lbrys=; b=TBjUQA70mwDw0vXwlIW1zTAH6wGuKf/aTmWR7uOtf49GfERAOPdkrya+yz1GnqVcsC Ou5tFh72f2wSX0+f7Fr07KDiyeizacH0EApUq+5IZJQ5eRCxrvAUpPJ1zVipcb35VCGm VE/n+7rEojiHcBd6/pdIieyTOE4+EoGj8uyo6MsPt6gFqVNfP9FMYiYae5uV/8CdifD9 f/Xn4Ofa/UTqPwWGN0f8ra/6hTAJC1guQ1cUwZJU9FuQ9hhb8WhwBUGQ6O0dXTeEq2sk 4X0WKHZ2dlOuSO4rR4uwyB1/45biDzDybLwLbompsmXjOeatAee1Fx0B7RtSA6NQ61Jg Hlaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712794152; x=1713398952; 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=tLia834y+X9tlrjVFjCEV4aQslhHW6gNjSHeO9Lbrys=; b=LK6b0OLV4V4EEbWx12oxYDBEHF0LsgkOlX0dzKoAheMUHNXHi1VCFxkbJELYL0Mue0 3XCHb1oygSiQpNEeDm++79ei9KzaX+HA1hvRPBHcxI2C4o5bE0dfPmJkEjeWExQ/u8Lw XIMbmKb5/9oDn+LitR8NelAxd+GNzF5sdVUwgZkqd5tb6vfuN/Y2VvElvqBLLVHglEB5 lx9EAuzKHRoiV/wgj7vfMfGAkzd54tNiI64whUmOEAo2Y8l5atIdihwf8iJuvPPjka0r vkQDmAgwc8VOPSYQFR86DmYh21YgU2pF6PCUTRaBoNAFv54UqR6P/S5YGzIj2vUJfgFw CxYA== X-Gm-Message-State: AOJu0Yzo0aqriEmdOr8o3HU9hB5iO+HZM64wyiwPfTQb+G8/XVmfYr0f Z+LVXsK7d1X1Naqb3MrjOoNqTHdeawg2G7s+jjvRLQfy18ekiV1cm1qHy8l7IDnecJjzJPR5tBK v X-Received: by 2002:a17:902:eb88:b0:1e5:5559:c4a7 with SMTP id q8-20020a170902eb8800b001e55559c4a7mr85239plg.51.1712794152327; Wed, 10 Apr 2024 17:09:12 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id f7-20020a170902684700b001e3d8a70780sm130351pln.171.2024.04.10.17.09.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 17:09:11 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , Alexey Makhalov , Anup Patel , Atish Patra , Broadcom internal kernel review list , 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 v6 24/24] KVM: riscv: selftests: Add commandline option for SBI PMU test Date: Wed, 10 Apr 2024 17:07:52 -0700 Message-Id: <20240411000752.955910-25-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411000752.955910-1-atishp@rivosinc.com> References: <20240411000752.955910-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 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 particular test if they want to. Suggested-by: Andrew Jones Signed-off-by: Atish Patra --- .../selftests/kvm/riscv/sbi_pmu_test.c | 77 ++++++++++++++++--- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c b/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c index 0fd9b76ae838..57025b07a403 100644 --- a/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c +++ b/tools/testing/selftests/kvm/riscv/sbi_pmu_test.c @@ -33,6 +33,16 @@ static unsigned long counter_mask_available; static bool illegal_handler_invoked; +enum sbi_pmu_test_id { + SBI_PMU_TEST_BASIC = 0, + SBI_PMU_TEST_EVENTS, + SBI_PMU_TEST_SNAPSHOT, + SBI_PMU_TEST_OVERFLOW, + SBI_PMU_TEST_MAX, +}; + +static int disabled_test_id = SBI_PMU_TEST_MAX; + unsigned long pmu_csr_read_num(int csr_num) { #define switchcase_csr_read(__csr_num, __val) {\ @@ -608,19 +618,68 @@ static void test_vm_events_overflow(void *guest_code) test_vm_destroy(vm); } -int main(void) +static void test_print_help(char *name) { - test_vm_basic_test(test_pmu_basic_sanity); - pr_info("SBI PMU basic test : PASS\n"); + pr_info("Usage: %s [-h] [-d ]\n", name); + pr_info("\t-d: Test to disable. Available tests are 'basic', 'events', 'snapshot', 'overflow'\n"); + pr_info("\t-h: print this help screen\n"); +} - test_vm_events_test(test_pmu_events); - pr_info("SBI PMU event verification test : PASS\n"); +static bool parse_args(int argc, char *argv[]) +{ + int opt; + + while ((opt = getopt(argc, argv, "hd:")) != -1) { + switch (opt) { + case 'd': + if (!strncmp("basic", optarg, 5)) + disabled_test_id = SBI_PMU_TEST_BASIC; + else if (!strncmp("events", optarg, 6)) + disabled_test_id = SBI_PMU_TEST_EVENTS; + else if (!strncmp("snapshot", optarg, 8)) + disabled_test_id = SBI_PMU_TEST_SNAPSHOT; + else if (!strncmp("overflow", optarg, 8)) + disabled_test_id = SBI_PMU_TEST_OVERFLOW; + else + goto done; + break; + break; + case 'h': + default: + goto done; + } + } - test_vm_events_snapshot_test(test_pmu_events_snaphost); - pr_info("SBI PMU event verification with snapshot test : PASS\n"); + return true; +done: + test_print_help(argv[0]); + return false; +} - test_vm_events_overflow(test_pmu_events_overflow); - pr_info("SBI PMU event verification with overflow test : PASS\n"); +int main(int argc, char *argv[]) +{ + if (!parse_args(argc, argv)) + exit(KSFT_SKIP); + + if (disabled_test_id != SBI_PMU_TEST_BASIC) { + test_vm_basic_test(test_pmu_basic_sanity); + pr_info("SBI PMU basic test : PASS\n"); + } + + if (disabled_test_id != SBI_PMU_TEST_EVENTS) { + test_vm_events_test(test_pmu_events); + pr_info("SBI PMU event verification test : PASS\n"); + } + + if (disabled_test_id != SBI_PMU_TEST_SNAPSHOT) { + test_vm_events_snapshot_test(test_pmu_events_snaphost); + pr_info("SBI PMU event verification with snapshot test : PASS\n"); + } + + if (disabled_test_id != 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