kvm-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <andrew.jones@linux.dev>
To: kvm-riscv@lists.infradead.org
Cc: atishp@rivosinc.com, cleger@rivosinc.com, jamestiotio@gmail.com
Subject: [kvm-unit-tests PATCH v2 11/11] riscv: sbi: Add bad fid tests
Date: Thu, 27 Feb 2025 15:22:39 +0100	[thread overview]
Message-ID: <20250227142238.102412-2-andrew.jones@linux.dev> (raw)
In-Reply-To: <20250227141946.91604-13-andrew.jones@linux.dev>

Ensure we get the correct error code when attempting to use an
invalid FID.

Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
 riscv/sbi-fwft.c  |  2 ++
 riscv/sbi-tests.h |  2 ++
 riscv/sbi.c       | 18 ++++++++++++++++++
 3 files changed, 22 insertions(+)

diff --git a/riscv/sbi-fwft.c b/riscv/sbi-fwft.c
index ca4d49b5db85..ac2e34869dfa 100644
--- a/riscv/sbi-fwft.c
+++ b/riscv/sbi-fwft.c
@@ -339,6 +339,8 @@ void check_fwft(void)
 		return;
 	}
 
+	sbi_bad_fid(SBI_EXT_FWFT);
+
 	fwft_check_base();
 	fwft_check_misaligned_exc_deleg();
 	fwft_check_pte_ad_hw_updating();
diff --git a/riscv/sbi-tests.h b/riscv/sbi-tests.h
index 7c7fe30541e4..f8ce3c269d48 100644
--- a/riscv/sbi-tests.h
+++ b/riscv/sbi-tests.h
@@ -70,5 +70,7 @@
 #define sbiret_check(ret, expected_error, expected_value) \
 	sbiret_report(ret, expected_error, expected_value, "check sbi.error and sbi.value")
 
+void sbi_bad_fid(int ext);
+
 #endif /* __ASSEMBLY__ */
 #endif /* _RISCV_SBI_TESTS_H_ */
diff --git a/riscv/sbi.c b/riscv/sbi.c
index 1d9d1871a28b..0404bb81317d 100644
--- a/riscv/sbi.c
+++ b/riscv/sbi.c
@@ -72,6 +72,12 @@ static struct sbiret sbi_system_suspend_raw(unsigned long sleep_type, unsigned l
 	return sbi_ecall(SBI_EXT_SUSP, 0, sleep_type, resume_addr, opaque, 0, 0, 0);
 }
 
+void sbi_bad_fid(int ext)
+{
+	struct sbiret ret = sbi_ecall(ext, 0xbad, 0, 0, 0, 0, 0, 0);
+	sbiret_report_error(&ret, SBI_ERR_NOT_SUPPORTED, "Bad FID");
+}
+
 static void start_cpu(void *data)
 {
 	/* nothing to do */
@@ -178,6 +184,8 @@ static void check_base(void)
 
 	report_prefix_push("base");
 
+	sbi_bad_fid(SBI_EXT_BASE);
+
 	ret = sbi_base(SBI_EXT_BASE_GET_SPEC_VERSION, 0);
 
 	report_prefix_push("spec_version");
@@ -331,6 +339,8 @@ static void check_time(void)
 		return;
 	}
 
+	sbi_bad_fid(SBI_EXT_TIME);
+
 	report_prefix_push("set_timer");
 
 	install_irq_handler(IRQ_S_TIMER, timer_irq_handler);
@@ -438,6 +448,8 @@ static void check_ipi(void)
 		return;
 	}
 
+	sbi_bad_fid(SBI_EXT_IPI);
+
 	if (nr_cpus_present < 2) {
 		report_skip("At least 2 cpus required");
 		report_prefix_pop();
@@ -731,6 +743,8 @@ static void check_hsm(void)
 		return;
 	}
 
+	sbi_bad_fid(SBI_EXT_HSM);
+
 	report_prefix_push("hart_get_status");
 
 	hartid = current_thread_info()->hartid;
@@ -1210,6 +1224,8 @@ static void check_dbcn(void)
 		return;
 	}
 
+	sbi_bad_fid(SBI_EXT_DBCN);
+
 	report_prefix_push("write");
 
 	dbcn_write_test(DBCN_WRITE_TEST_STRING, num_bytes, false);
@@ -1475,6 +1491,8 @@ static void check_susp(void)
 		return;
 	}
 
+	sbi_bad_fid(SBI_EXT_SUSP);
+
 	timer_setup(susp_timer);
 	local_irq_enable();
 	timer_start(SBI_SUSP_TIMER_DURATION_US);
-- 
2.48.1


-- 
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv

  parent reply	other threads:[~2025-02-27 14:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27 14:19 [kvm-unit-tests PATCH v2 00/11] riscv: sbi: Test improvements and a couple new Andrew Jones
2025-02-27 14:19 ` [kvm-unit-tests PATCH v2 01/11] riscv: sbi: Drop fwft upper bits test Andrew Jones
2025-02-27 14:21   ` Clément Léger
2025-02-27 14:19 ` [kvm-unit-tests PATCH v2 02/11] riscv: sbi: Add fwft pte_hw_ad_updating test Andrew Jones
2025-02-27 14:30   ` Clément Léger
2025-02-27 14:19 ` [kvm-unit-tests PATCH v2 03/11] riscv: sbi: Ensure we have IPIs enabled for HSM suspend tests Andrew Jones
2025-02-27 14:19 ` [kvm-unit-tests PATCH v2 04/11] riscv: sbi: Ensure SUSP test gets an interrupt Andrew Jones
2025-02-27 14:19 ` [kvm-unit-tests PATCH v2 05/11] riscv: sbi: Improve susp expected error output Andrew Jones
2025-02-27 14:38   ` Clément Léger
2025-02-27 14:19 ` [kvm-unit-tests PATCH v2 06/11] riscv: sbi: Improve interrupt handling cleanup Andrew Jones
2025-02-27 14:19 ` [kvm-unit-tests PATCH v2 07/11] lib/cpumask: Add some operators Andrew Jones
2025-02-27 14:22 ` [kvm-unit-tests PATCH v2 08/11] riscv: sbi: HSM suspend may not be supported Andrew Jones
2025-02-27 14:22 ` [kvm-unit-tests PATCH v2 09/11] riscv: sbi: Probe/skip SUSP Andrew Jones
2025-02-27 14:22 ` [kvm-unit-tests PATCH v2 10/11] riscv: sbi: susp: Check upper bits of sleep_type are ignored Andrew Jones
2025-02-27 14:22 ` Andrew Jones [this message]
2025-02-27 14:33   ` [kvm-unit-tests PATCH v2 11/11] riscv: sbi: Add bad fid tests Clément Léger
2025-03-04  9:31 ` [kvm-unit-tests PATCH v2 00/11] riscv: sbi: Test improvements and a couple new Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250227142238.102412-2-andrew.jones@linux.dev \
    --to=andrew.jones@linux.dev \
    --cc=atishp@rivosinc.com \
    --cc=cleger@rivosinc.com \
    --cc=jamestiotio@gmail.com \
    --cc=kvm-riscv@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).