Skip to contentSkip to conversation

Add riscv tests to cover the base extension specs

PATCH Superseded [email protected] 2 participants 14 messages Mar 13, 2024

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add riscv tests to cover the base extension specs

From: Carlos Maiolino <[email protected]>

Hi,

This is a new version of this series to create tests to cover functions of the riscv's SBI base implementation spec. The series also includes a a few helpers to reduce code duplication.

This new version includes updates related to Drew reviews, and extra massage on the patches due to moving the __base_sbi_ecall() wrapper to the beginninng of the series.
Detailed updates are specified on a patch-basis

Carlos Maiolino (6):
riscv: Add a wrapper to call sbi_ecall for base extension
riscv: Add test to probe SBI Extension
riscv: Factor out environment variable check and report generation
riscv: Implement test for architecture ID register
riscv: Enable gen_report() to print the wrong value in case of failure
riscv: Test for specific SBI implementation ID

 riscv/sbi.c | 82 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 70 insertions(+), 12 deletions(-)
Signature · 1 line
2.44.0
#1 lore raw

PATCH v3 1/6 riscv: Add a wrapper to call sbi_ecall for base extension

From: Carlos Maiolino <[email protected]>

All SBI extension functions accepts at most one argument, so create a wrapper around sbi_ecall() to avoid needing to pass in arguments 1 to 5 all the time, also, the wrapper can specify SBI_EXT_BASE directly.

---
V3:
- Move to the beginning of the series
- Don't mark __base_sbi_ecall() as inline
V2:
- This patch was introduced in V2

 riscv/sbi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
riscv/sbi.c +7 -1
index ffb07a25..48d0b06e 100644
@@ -14,7 +14,13 @@ static void help(void)
 	puts("An environ must be provided where expected values are given.\n");
 }
 
+static struct sbiret __base_sbi_ecall(int fid, unsigned long arg0)
+{
+	return sbi_ecall(SBI_EXT_BASE, fid, arg0, 0, 0, 0, 0, 0);
+}
+
 int main(int argc, char **argv)
+
 {
 	struct sbiret ret;
 	long expected;
@@ -32,7 +38,7 @@ int main(int argc, char **argv)
 	}
 	expected = strtol(getenv("MVENDORID"), NULL, 0);
 
-	ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_MVENDORID, 0, 0, 0, 0, 0, 0);
+	ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MVENDORID, 0);
 	report(!ret.error, "mvendorid: no error");
 	report(ret.value == expected, "mvendorid");
 
Signature · 1 line
2.44.0
#3 lore raw

PATCH v3 2/6 riscv: Add test to probe SBI Extension

In reply to [email protected]

From: Carlos Maiolino <[email protected]>

Factor out vendor id test to a new helper, and add a new test for probing the SBI extension.
Compare the retrieved value against an environment variable, as the implementation can return any non-zero value.

---
V3:
- Adapt patch to use __base_sbi_ecall

 riscv/sbi.c | 44 ++++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 12 deletions(-)
riscv/sbi.c +32 -12
index 48d0b06e..55bfcd42 100644
@@ -19,29 +19,49 @@ static struct sbiret __base_sbi_ecall(int fid, unsigned long arg0)
 	return sbi_ecall(SBI_EXT_BASE, fid, arg0, 0, 0, 0, 0, 0);
 }
 
-int main(int argc, char **argv)
-
+static void check_base(void)
 {
 	struct sbiret ret;
 	long expected;
 
-	if (argc > 1 && !strcmp(argv[1], "-h")) {
-		help();
-		exit(0);
-	}
-
-	report_prefix_push("sbi");
+	report_prefix_push("base");
 
 	if (!getenv("MVENDORID")) {
 		report_skip("mvendorid: missing MVENDORID environment variable");
-		goto done;
+		return;
 	}
+
+	report_prefix_push("mvendorid");
 	expected = strtol(getenv("MVENDORID"), NULL, 0);
 
 	ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MVENDORID, 0);
-	report(!ret.error, "mvendorid: no error");
-	report(ret.value == expected, "mvendorid");
 
-done:
+	report(!ret.error, "no sbi.error");
+	report(ret.value == expected, "expected sbi.value");
+	report_prefix_pop();
+
+	report_prefix_push("probe_ext");
+	expected = getenv("PROBE_EXT") ? strtol(getenv("PROBE_EXT"), NULL, 0) : 1;
+
+	ret = __base_sbi_ecall(SBI_EXT_BASE_PROBE_EXT, 0);
+
+	report(!ret.error, "no sbi.error");
+	report(ret.value == expected, "expected sbi.value");
+	report_prefix_pop();
+
+	report_prefix_pop();
+}
+
+int main(int argc, char **argv)
+{
+
+	if (argc > 1 && !strcmp(argv[1], "-h")) {
+		help();
+		exit(0);
+	}
+
+	report_prefix_push("sbi");
+	check_base();
+
 	return report_summary();
 }
Signature · 1 line
2.44.0
#5 lore raw

PATCH v3 3/6 riscv: Factor out environment variable check and report generation

In reply to [email protected]

From: Carlos Maiolino <[email protected]>

We do check Environment variables and generate reports all the time, so use a couple of helpers for that

---
V3:
- Adapt to use __base_sbi_ecall()

 riscv/sbi.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)
riscv/sbi.c +23 -15
index 55bfcd42..ce0be84f 100644
@@ -19,6 +19,23 @@ static struct sbiret __base_sbi_ecall(int fid, unsigned long arg0)
 	return sbi_ecall(SBI_EXT_BASE, fid, arg0, 0, 0, 0, 0, 0);
 }
 
+static bool env_or_skip(const char *env)
+{
+
+	if (!getenv(env)) {
+		report_skip("missing %s environment variable", env);
+		return false;
+	}
+
+	return true;
+}
+
+static void gen_report(struct sbiret *ret, long expected)
+{
+	report(!ret->error, "no sbi.error");
+	report(ret->value == expected, "expected sbi.value");
+}
+
 static void check_base(void)
 {
 	struct sbiret ret;
@@ -26,27 +43,18 @@ static void check_base(void)
 
 	report_prefix_push("base");
 
-	if (!getenv("MVENDORID")) {
-		report_skip("mvendorid: missing MVENDORID environment variable");
-		return;
-	}
-
 	report_prefix_push("mvendorid");
-	expected = strtol(getenv("MVENDORID"), NULL, 0);
-
-	ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MVENDORID, 0);
-
-	report(!ret.error, "no sbi.error");
-	report(ret.value == expected, "expected sbi.value");
+	if (env_or_skip("MVENDORID")) {
+		expected = strtol(getenv("MVENDORID"), NULL, 0);
+		ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MVENDORID, 0);
+		gen_report(&ret, expected);
+	}
 	report_prefix_pop();
 
 	report_prefix_push("probe_ext");
 	expected = getenv("PROBE_EXT") ? strtol(getenv("PROBE_EXT"), NULL, 0) : 1;
-
 	ret = __base_sbi_ecall(SBI_EXT_BASE_PROBE_EXT, 0);
-
-	report(!ret.error, "no sbi.error");
-	report(ret.value == expected, "expected sbi.value");
+	gen_report(&ret, expected);
 	report_prefix_pop();
 
 	report_prefix_pop();
Signature · 1 line
2.44.0
#7 lore raw

PATCH v3 4/6 riscv: Implement test for architecture ID register

In reply to [email protected]

From: Carlos Maiolino <[email protected]>

Probe the MARCHID register and compare it to the specified MARCHID environment variable.

---
V3:
- Adapt to use __base_sbi_ecall (which also fixes the wrong paramenters)
V2:
- Wrap commit message around 70 chars
- Remove unneeded blank lines

 riscv/sbi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
riscv/sbi.c +8 -0
index ce0be84f..56b27765 100644
@@ -57,6 +57,14 @@ static void check_base(void)
 	gen_report(&ret, expected);
 	report_prefix_pop();
 
+	report_prefix_push("marchid");
+	if (env_or_skip("MARCHID")) {
+		expected = strtol(getenv("MARCHID"), NULL, 0);
+		ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MARCHID, 0);
+		gen_report(&ret, expected);
+	}
+	report_prefix_pop();
+
 	report_prefix_pop();
 }
 
Signature · 1 line
2.44.0
#9 lore raw

PATCH v3 5/6 riscv: Enable gen_report() to print the wrong value in case of failure

In reply to [email protected]

From: Carlos Maiolino <[email protected]>

If the test fails because the expected value doesn't match, it's useful to know what value was actually printed.

---
V3:
- Include expected error check in gen_report()
- Implement Drew's suggestion on cleaning up the function a bit
- Update patch to use __base_sbi_ecall()
V2:
- Reduce subject to fit 70 chars
- Use report_info() to output expected vs received values, leaving only necessary information for parsers on report()

 riscv/sbi.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
riscv/sbi.c +14 -6
index 56b27765..a4a16325 100644
@@ -30,10 +30,18 @@ static bool env_or_skip(const char *env)
 	return true;
 }
 
-static void gen_report(struct sbiret *ret, long expected)
+static void gen_report(struct sbiret *ret,
+		       long expected_error, long expected_value)
 {
-	report(!ret->error, "no sbi.error");
-	report(ret->value == expected, "expected sbi.value");
+	bool check_error = ret->error == expected_error;
+	bool check_value = ret->value == expected_value;
+
+	if (!check_error || !check_value)
+		report_info("expected (error: %ld, value: %ld), received: (error: %ld, value %ld)\n",
+			    expected_error, expected_value, ret->error, ret->value);
+
+	report(check_error, "expected sbi.error");
+	report(check_value, "expected sbi.value");
 }
 
 static void check_base(void)
@@ -47,21 +55,21 @@ static void check_base(void)
 	if (env_or_skip("MVENDORID")) {
 		expected = strtol(getenv("MVENDORID"), NULL, 0);
 		ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MVENDORID, 0);
-		gen_report(&ret, expected);
+		gen_report(&ret, 0, expected);
 	}
 	report_prefix_pop();
 
 	report_prefix_push("probe_ext");
 	expected = getenv("PROBE_EXT") ? strtol(getenv("PROBE_EXT"), NULL, 0) : 1;
 	ret = __base_sbi_ecall(SBI_EXT_BASE_PROBE_EXT, 0);
-	gen_report(&ret, expected);
+	gen_report(&ret, 0, expected);
 	report_prefix_pop();
 
 	report_prefix_push("marchid");
 	if (env_or_skip("MARCHID")) {
 		expected = strtol(getenv("MARCHID"), NULL, 0);
 		ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MARCHID, 0);
-		gen_report(&ret, expected);
+		gen_report(&ret, 0, expected);
 	}
 	report_prefix_pop();
 
Signature · 1 line
2.44.0
#11 lore raw

PATCH v3 6/6 riscv: Test for specific SBI implementation ID

In reply to [email protected]

From: Carlos Maiolino <[email protected]>

Retrieve the ID from the SBI, and test it against IMPL_ID enviroment variable.

---
V3:
- Update to use __base_sbi_ecall (also fixes the correct paramenters)
- Rename env var to IMPL_ID to match the other tests
V2:
- Update commit description to fit 70 chars
- Move sbi_ecall() after expected assignment to make consistent with other tests

 riscv/sbi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
riscv/sbi.c +8 -0
index a4a16325..8a624655 100644
@@ -59,6 +59,14 @@ static void check_base(void)
 	}
 	report_prefix_pop();
 
+	report_prefix_push("impl_id");
+	if (env_or_skip("IMPL_ID")) {
+		expected = strtol(getenv("IMPL_ID"), NULL, 0);
+		ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, 0, 0, 0, 0, 0, 0);
+		gen_report(&ret, 0, expected);
+	}
+	report_prefix_pop();
+
 	report_prefix_push("probe_ext");
 	expected = getenv("PROBE_EXT") ? strtol(getenv("PROBE_EXT"), NULL, 0) : 1;
 	ret = __base_sbi_ecall(SBI_EXT_BASE_PROBE_EXT, 0);
Signature · 1 line
2.44.0
#2 lore raw

PATCH 1/6 riscv: Add a wrapper to call sbi_ecall for base extension

In reply to [email protected]
Quoted 22 lines · cem at kernel.org

From: Carlos Maiolino <[email protected]>

All SBI extension functions accepts at most one argument, so create a wrapper around sbi_ecall() to avoid needing to pass in arguments 1 to 5 all the time, also, the wrapper can specify SBI_EXT_BASE directly.

---
V3:
- Move to the beginning of the series
- Don't mark __base_sbi_ecall() as inline
V2:
- This patch was introduced in V2

 riscv/sbi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
riscv/sbi.c +0 -0
index ffb07a25..48d0b06e 100644

riscv/sbi.c static void help(void) · line 23

Quoted 10 lines
riscv/sbi.c +6 -0
@@ -14,7 +14,13 @@ static void help(void)
 	puts("An environ must be provided where expected values are given.\n");
 }
 
+static struct sbiret __base_sbi_ecall(int fid, unsigned long arg0)
+{
+	return sbi_ecall(SBI_EXT_BASE, fid, arg0, 0, 0, 0, 0, 0);
+}
+
 int main(int argc, char **argv)
+

stray blank line

Quoted 15 lines
riscv/sbi.c +1 -1
 {
 	struct sbiret ret;
 	long expected;
@@ -32,7 +38,7 @@ int main(int argc, char **argv)
 	}
 	expected = strtol(getenv("MVENDORID"), NULL, 0);
 
-	ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_MVENDORID, 0, 0, 0, 0, 0, 0);
+	ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MVENDORID, 0);
 	report(!ret.error, "mvendorid: no error");
 	report(ret.value == expected, "mvendorid");
 
Signature · 1 line
2.44.0
#4 lore raw

PATCH 2/6 riscv: Add test to probe SBI Extension

In reply to [email protected]
Quoted 20 lines · cem at kernel.org

From: Carlos Maiolino <[email protected]>

Factor out vendor id test to a new helper, and add a new test for probing the SBI extension.
Compare the retrieved value against an environment variable, as the implementation can return any non-zero value.

---
V3:
- Adapt patch to use __base_sbi_ecall

 riscv/sbi.c | 44 ++++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 12 deletions(-)
riscv/sbi.c +0 -0
index 48d0b06e..55bfcd42 100644

riscv/sbi.c static struct sbiret __base_sbi_ecall(int fid, unsigned long arg0) · line 23

Quoted 5 lines
riscv/sbi.c +0 -2
@@ -19,29 +19,49 @@ static struct sbiret __base_sbi_ecall(int fid, unsigned long arg0)
 	return sbi_ecall(SBI_EXT_BASE, fid, arg0, 0, 0, 0, 0, 0);
 }
 
-int main(int argc, char **argv)
-

The last patch's stray blank line is removed here, so OK, but better to not add it in the first place.

Quoted 25 lines
riscv/sbi.c +5 -9
+static void check_base(void)
 {
 	struct sbiret ret;
 	long expected;
 
-	if (argc > 1 && !strcmp(argv[1], "-h")) {
-		help();
-		exit(0);
-	}
-
-	report_prefix_push("sbi");
+	report_prefix_push("base");
 
 	if (!getenv("MVENDORID")) {
 		report_skip("mvendorid: missing MVENDORID environment variable");
-		goto done;
+		return;
 	}
+
+	report_prefix_push("mvendorid");
 	expected = strtol(getenv("MVENDORID"), NULL, 0);
 
 	ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MVENDORID, 0);
-	report(!ret.error, "mvendorid: no error");
-	report(ret.value == expected, "mvendorid");

riscv/sbi.c static struct sbiret __base_sbi_ecall(int fid, unsigned long arg0) · line 46

Quoted 10 lines
riscv/sbi.c +8 -1
 
-done:
+	report(!ret.error, "no sbi.error");
+	report(ret.value == expected, "expected sbi.value");
+	report_prefix_pop();
+
+	report_prefix_push("probe_ext");
+	expected = getenv("PROBE_EXT") ? strtol(getenv("PROBE_EXT"), NULL, 0) : 1;
+
+	ret = __base_sbi_ecall(SBI_EXT_BASE_PROBE_EXT, 0);

The arg shouldn't be zero for this test. Before, you probed for the base extension itself.

Quoted 24 lines
riscv/sbi.c +19 -0
+
+	report(!ret.error, "no sbi.error");
+	report(ret.value == expected, "expected sbi.value");
+	report_prefix_pop();
+
+	report_prefix_pop();
+}
+
+int main(int argc, char **argv)
+{
+
+	if (argc > 1 && !strcmp(argv[1], "-h")) {
+		help();
+		exit(0);
+	}
+
+	report_prefix_push("sbi");
+	check_base();
+
 	return report_summary();
 }
Signature · 1 line
2.44.0

Thanks,
drew

#6 lore raw

PATCH 3/6 riscv: Factor out environment variable check and report generation

In reply to [email protected]
Quoted 18 lines · cem at kernel.org

From: Carlos Maiolino <[email protected]>

We do check Environment variables and generate reports all the time, so use a couple of helpers for that

---
V3:
- Adapt to use __base_sbi_ecall()

 riscv/sbi.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)
riscv/sbi.c +0 -0
index 55bfcd42..ce0be84f 100644

riscv/sbi.c static struct sbiret __base_sbi_ecall(int fid, unsigned long arg0) · line 24

Quoted 6 lines
riscv/sbi.c +3 -0
@@ -19,6 +19,23 @@ static struct sbiret __base_sbi_ecall(int fid, unsigned long arg0)
 	return sbi_ecall(SBI_EXT_BASE, fid, arg0, 0, 0, 0, 0, 0);
 }
 
+static bool env_or_skip(const char *env)
+{
+

stray blank line here (might want to check your editor settings...)

Quoted 54 lines
riscv/sbi.c +20 -15
+	if (!getenv(env)) {
+		report_skip("missing %s environment variable", env);
+		return false;
+	}
+
+	return true;
+}
+
+static void gen_report(struct sbiret *ret, long expected)
+{
+	report(!ret->error, "no sbi.error");
+	report(ret->value == expected, "expected sbi.value");
+}
+
 static void check_base(void)
 {
 	struct sbiret ret;
@@ -26,27 +43,18 @@ static void check_base(void)
 
 	report_prefix_push("base");
 
-	if (!getenv("MVENDORID")) {
-		report_skip("mvendorid: missing MVENDORID environment variable");
-		return;
-	}
-
 	report_prefix_push("mvendorid");
-	expected = strtol(getenv("MVENDORID"), NULL, 0);
-
-	ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MVENDORID, 0);
-
-	report(!ret.error, "no sbi.error");
-	report(ret.value == expected, "expected sbi.value");
+	if (env_or_skip("MVENDORID")) {
+		expected = strtol(getenv("MVENDORID"), NULL, 0);
+		ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MVENDORID, 0);
+		gen_report(&ret, expected);
+	}
 	report_prefix_pop();
 
 	report_prefix_push("probe_ext");
 	expected = getenv("PROBE_EXT") ? strtol(getenv("PROBE_EXT"), NULL, 0) : 1;
-
 	ret = __base_sbi_ecall(SBI_EXT_BASE_PROBE_EXT, 0);
-
-	report(!ret.error, "no sbi.error");
-	report(ret.value == expected, "expected sbi.value");
+	gen_report(&ret, expected);
 	report_prefix_pop();
 
 	report_prefix_pop();
Signature · 1 line
2.44.0

With the fixups it'll need after fixing the last patch and the removal of the blank line,

#8 lore raw

PATCH 4/6 riscv: Implement test for architecture ID register

In reply to [email protected]
Quoted 38 lines · cem at kernel.org

From: Carlos Maiolino <[email protected]>

Probe the MARCHID register and compare it to the specified MARCHID environment variable.

---
V3:
- Adapt to use __base_sbi_ecall (which also fixes the wrong paramenters)
V2:
- Wrap commit message around 70 chars
- Remove unneeded blank lines

 riscv/sbi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
riscv/sbi.c +8 -0
index ce0be84f..56b27765 100644
@@ -57,6 +57,14 @@ static void check_base(void)
 	gen_report(&ret, expected);
 	report_prefix_pop();
 
+	report_prefix_push("marchid");
+	if (env_or_skip("MARCHID")) {
+		expected = strtol(getenv("MARCHID"), NULL, 0);
+		ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MARCHID, 0);
+		gen_report(&ret, expected);
+	}
+	report_prefix_pop();
+
 	report_prefix_pop();
 }
 
Signature · 1 line
2.44.0
#10 lore raw

PATCH 5/6 riscv: Enable gen_report() to print the wrong value in case of failure

In reply to [email protected]
Quoted 73 lines · cem at kernel.org

From: Carlos Maiolino <[email protected]>

If the test fails because the expected value doesn't match, it's useful to know what value was actually printed.

---
V3:
- Include expected error check in gen_report()
- Implement Drew's suggestion on cleaning up the function a bit
- Update patch to use __base_sbi_ecall()
V2:
- Reduce subject to fit 70 chars
- Use report_info() to output expected vs received values, leaving only necessary information for parsers on report()

 riscv/sbi.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
riscv/sbi.c +14 -6
index 56b27765..a4a16325 100644
@@ -30,10 +30,18 @@ static bool env_or_skip(const char *env)
 	return true;
 }
 
-static void gen_report(struct sbiret *ret, long expected)
+static void gen_report(struct sbiret *ret,
+		       long expected_error, long expected_value)
 {
-	report(!ret->error, "no sbi.error");
-	report(ret->value == expected, "expected sbi.value");
+	bool check_error = ret->error == expected_error;
+	bool check_value = ret->value == expected_value;
+
+	if (!check_error || !check_value)
+		report_info("expected (error: %ld, value: %ld), received: (error: %ld, value %ld)\n",
+			    expected_error, expected_value, ret->error, ret->value);
+
+	report(check_error, "expected sbi.error");
+	report(check_value, "expected sbi.value");
 }
 
 static void check_base(void)
@@ -47,21 +55,21 @@ static void check_base(void)
 	if (env_or_skip("MVENDORID")) {
 		expected = strtol(getenv("MVENDORID"), NULL, 0);
 		ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MVENDORID, 0);
-		gen_report(&ret, expected);
+		gen_report(&ret, 0, expected);
 	}
 	report_prefix_pop();
 
 	report_prefix_push("probe_ext");
 	expected = getenv("PROBE_EXT") ? strtol(getenv("PROBE_EXT"), NULL, 0) : 1;
 	ret = __base_sbi_ecall(SBI_EXT_BASE_PROBE_EXT, 0);
-	gen_report(&ret, expected);
+	gen_report(&ret, 0, expected);
 	report_prefix_pop();
 
 	report_prefix_push("marchid");
 	if (env_or_skip("MARCHID")) {
 		expected = strtol(getenv("MARCHID"), NULL, 0);
 		ret = __base_sbi_ecall(SBI_EXT_BASE_GET_MARCHID, 0);
-		gen_report(&ret, expected);
+		gen_report(&ret, 0, expected);
 	}
 	report_prefix_pop();
 
Signature · 1 line
2.44.0
#12 lore raw

PATCH 6/6 riscv: Test for specific SBI implementation ID

In reply to [email protected]
Quoted 23 lines · cem at kernel.org

From: Carlos Maiolino <[email protected]>

Retrieve the ID from the SBI, and test it against IMPL_ID enviroment variable.

---
V3:
- Update to use __base_sbi_ecall (also fixes the correct paramenters)
- Rename env var to IMPL_ID to match the other tests
V2:
- Update commit description to fit 70 chars
- Move sbi_ecall() after expected assignment to make consistent with other tests

 riscv/sbi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
riscv/sbi.c +0 -0
index a4a16325..8a624655 100644

riscv/sbi.c static void check_base(void) · line 65

Quoted 7 lines
riscv/sbi.c +4 -0
@@ -59,6 +59,14 @@ static void check_base(void)
 	}
 	report_prefix_pop();
 
+	report_prefix_push("impl_id");
+	if (env_or_skip("IMPL_ID")) {
+		expected = strtol(getenv("IMPL_ID"), NULL, 0);
+		ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, 0, 0, 0, 0, 0, 0);

commit message says you switched to __base_sbi_ecall(), but you didn't :-)

Quoted 10 lines
riscv/sbi.c +4 -0
+		gen_report(&ret, 0, expected);
+	}
+	report_prefix_pop();
+
 	report_prefix_push("probe_ext");
 	expected = getenv("PROBE_EXT") ? strtol(getenv("PROBE_EXT"), NULL, 0) : 1;
 	ret = __base_sbi_ecall(SBI_EXT_BASE_PROBE_EXT, 0);
Signature · 1 line
2.44.0

Thanks,
drew

#13 lore raw

PATCH v3 6/6 riscv: Test for specific SBI implementation ID

Quoted 27 lines · Andrew Jones
Quoted 26 lines · cem at kernel.org

From: Carlos Maiolino <[email protected]>

Retrieve the ID from the SBI, and test it against IMPL_ID enviroment variable.

---
V3:
- Update to use __base_sbi_ecall (also fixes the correct paramenters)
- Rename env var to IMPL_ID to match the other tests
V2:
- Update commit description to fit 70 chars
- Move sbi_ecall() after expected assignment to make consistent with other tests

 riscv/sbi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
riscv/sbi.c +0 -0
index a4a16325..8a624655 100644
@@ -59,6 +59,14 @@ static void check_base(void)
 	}
 	report_prefix_pop();
 
Quoted 6 lines

riscv/sbi.c static void check_base(void) · line 65

Quoted 4 lines
riscv/sbi.c +4 -0
+	report_prefix_push("impl_id");
+	if (env_or_skip("IMPL_ID")) {
+		expected = strtol(getenv("IMPL_ID"), NULL, 0);
+		ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, 0, 0, 0, 0, 0, 0);

commit message says you switched to __base_sbi_ecall(), but you didn't :-)

Sigh... my apologies, had a short time to update these patches and overlooked it, I'll fix it and send a decent version tonight.

Thanks for the reviews

Carlos

Quoted 14 lines
Quoted 11 lines
riscv/sbi.c +4 -1
+		gen_report(&ret, 0, expected);
+	}
+	report_prefix_pop();
+
 	report_prefix_push("probe_ext");
 	expected = getenv("PROBE_EXT") ? strtol(getenv("PROBE_EXT"), NULL, 0) : 1;
 	ret = __base_sbi_ecall(SBI_EXT_BASE_PROBE_EXT, 0);
--

2.44.0

Thanks,
drew