[kvm-unit-tests PATCH] riscv: Add fwft landing_pad tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Added invalid value, invalid flags, locking and other checks for fwft landing_pad feature.

Signed-off-by: Akshay Behl <akshaybehl231@xxxxxxxxx>
---
 riscv/sbi-fwft.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/riscv/sbi-fwft.c b/riscv/sbi-fwft.c
index ac2e3486..5d88d683 100644
--- a/riscv/sbi-fwft.c
+++ b/riscv/sbi-fwft.c
@@ -329,6 +329,87 @@ adue_done:
 	report_prefix_pop();
 }
 
+static struct sbiret fwft_landing_pad_set(unsigned long value, unsigned long flags)
+{
+	return fwft_set(SBI_FWFT_LANDING_PAD, value, flags);
+}
+
+static struct sbiret fwft_landing_pad_get(void)
+{
+	return fwft_get(SBI_FWFT_LANDING_PAD);
+}
+
+static void fwft_check_landing_pad(void)
+{
+	struct sbiret ret;
+	report_prefix_push("landing_pad");
+
+	ret = fwft_landing_pad_get();
+	if (ret.error == SBI_ERR_NOT_SUPPORTED) {
+		report_skip("SBI_FWFT_LANDING_PAD is not supported");
+		return;
+	} else if (!sbiret_report_error(&ret, SBI_SUCCESS, "get landing pad feature"))
+		return;
+
+	report(ret.value == 0, "initial landing pad feature value is 0");
+
+	/* Invalid value test */
+	ret = fwft_landing_pad_set(2, 0);
+	sbiret_report_error(&ret, SBI_ERR_INVALID_PARAM,
+			    "set landing pad feature invalid value 2");
+	ret = fwft_landing_pad_set(0xFFFFFFFF, 0);
+	sbiret_report_error(&ret, SBI_ERR_INVALID_PARAM,
+				"set landing pad feature invalid value 0xFFFFFFFF");
+
+	/* Set to 1 and check with get */
+	ret = fwft_landing_pad_set(1, 0);
+	sbiret_report_error(&ret, SBI_SUCCESS,
+			    "set landing pad feature to 1");
+	ret = fwft_landing_pad_get();
+	sbiret_report(&ret, SBI_SUCCESS, 1,
+		      "get landing pad feature expected value 1");
+
+	/* Set to 0 and check with get */
+	ret = fwft_landing_pad_set(0, 0);
+	sbiret_report_error(&ret, SBI_SUCCESS,
+			    "set landing pad feature to 0");
+	ret = fwft_landing_pad_get();
+	sbiret_report(&ret, SBI_SUCCESS, 0,
+		      "get landing pad feature expected value 0");
+
+#if __riscv_xlen > 32
+	/* Test using invalid flag bits */
+	ret = fwft_landing_pad_set(BIT(32), 0);
+	sbiret_report_error(&ret, SBI_ERR_INVALID_PARAM,
+			    "Set misaligned deleg with invalid value > 32bits");
+	ret = fwft_landing_pad_set(1, BIT(32));
+	sbiret_report_error(&ret, SBI_ERR_INVALID_PARAM,
+			    "set landing pad feature with invalid flag > 32 bits");
+#endif
+
+	/* Locking test */
+	ret = fwft_landing_pad_set(1, SBI_FWFT_SET_FLAG_LOCK);
+	sbiret_report_error(&ret, SBI_SUCCESS,
+			    "set landing pad feature to 1 and lock");
+
+	/* Attempt without the lock flag */
+	ret = fwft_landing_pad_set(0, 0);
+	sbiret_report_error(&ret, SBI_ERR_DENIED_LOCKED,
+			    "attempt to set locked landing pad feature to 0 without lock flag");
+
+	/* Attempt with the lock flag still should fail */
+	ret = fwft_landing_pad_set(0, SBI_FWFT_SET_FLAG_LOCK);
+	sbiret_report_error(&ret, SBI_ERR_DENIED_LOCKED,
+			    "attempt to set locked landing pad feature to 0 with lock flag");
+
+	/* Verify that the value remains locked at 1 */
+	ret = fwft_landing_pad_get();
+	sbiret_report(&ret, SBI_SUCCESS, 1,
+		      "get locked landing pad feature expected value 1");
+
+	report_prefix_pop();
+}
+
 void check_fwft(void)
 {
 	report_prefix_push("fwft");
@@ -344,6 +425,7 @@ void check_fwft(void)
 	fwft_check_base();
 	fwft_check_misaligned_exc_deleg();
 	fwft_check_pte_ad_hw_updating();
+	fwft_check_landing_pad();
 
 	report_prefix_pop();
 }
-- 
2.34.1





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux