riscv: sbi: Check spec version and test rest
Subsystems (2)
cover riscv: sbi: Check spec version and test rest
The base extension tests require spec version 0.2 or later, so check for that, and also add the remaining function tests.
This is based on Carlos' series [1]
[1] http://lists.infradead.org/pipermail/kvm-riscv/2024-March/006047.html
Andrew Jones (2):
riscv: sbi: Check and test spec version
riscv: sbi: Test remaining base functions
riscv/sbi.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
Signature · 1 line
2.44.0
PATCH 1/2 riscv: sbi: Check and test spec version
The base extension tests are only valid for spec versions 0.2 and later, so ensure we have that before proceeding. Also check the spec version matches an expected value, as we do the other functions.
--- riscv/sbi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
riscv/sbi.c +13 -0
@@ -50,6 +50,19 @@ static void check_base(void)report_prefix_push ("base" ); + ret =__base_sbi_ecall (SBI_EXT_BASE_GET_SPEC_VERSION ,0 ); +if (ret.error || ret.value <2 ) { +report_skip ("SBI spec version 0.2 or higher required" ); +return ; + } + +report_prefix_push ("spec_version" ); +if (env_or_skip ("SPEC_VERSION" )) { + expected =strtol (getenv ("SPEC_VERSION" ),NULL ,0 ); +gen_report (&ret,0 , expected); + } +report_prefix_pop (); +report_prefix_push ("impl_id" );if (env_or_skip ("IMPL_ID" )) { expected =strtol (getenv ("IMPL_ID" ),NULL ,0 );
Signature · 1 line
2.44.0
PATCH 1/2 riscv: sbi: Check and test spec version
Quoted 8 lines · Andrew Jones
The base extension tests are only valid for spec versions 0.2 and later, so ensure we have that before proceeding. Also check the spec version matches an expected value, as we do the other functions.
Signed-off-by Andrew Jones <[email protected]>--- riscv/sbi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Looks good.
Quoted 28 lines
riscv/sbi.c +13
-0@@ -50,6 +50,19 @@ static void check_base(void)report_prefix_push ("base" ); + ret =__base_sbi_ecall (SBI_EXT_BASE_GET_SPEC_VERSION ,0 ); +if (ret.error || ret.value <2 ) { +report_skip ("SBI spec version 0.2 or higher required" ); +return ; + } + +report_prefix_push ("spec_version" ); +if (env_or_skip ("SPEC_VERSION" )) { + expected =strtol (getenv ("SPEC_VERSION" ),NULL ,0 ); +gen_report (&ret,0 , expected); + } +report_prefix_pop (); +report_prefix_push ("impl_id" );if (env_or_skip ("IMPL_ID" )) { expected =strtol (getenv ("IMPL_ID" ),NULL ,0 );Signature · 1 line
2.44.0
PATCH 2/2 riscv: sbi: Test remaining base functions
In reply to Andrew JonesAdd the two remaining base extension functions to the base test.
--- riscv/sbi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
riscv/sbi.c +16 -0
@@ -71,6 +71,14 @@ static void check_base(void) }report_prefix_pop (); +report_prefix_push ("impl_version" ); +if (env_or_skip ("IMPL_VERSION" )) { + expected =strtol (getenv ("IMPL_VERSION" ),NULL ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_GET_IMP_VERSION ,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 ,SBI_EXT_BASE );
@@ -93,6 +101,14 @@ static void check_base(void) }report_prefix_pop (); +report_prefix_push ("mimpid" ); +if (env_or_skip ("MIMPID" )) { + expected =strtol (getenv ("MIMPID" ),NULL ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_GET_MIMPID ,0 ); +gen_report (&ret,0 , expected); + } +report_prefix_pop (); +report_prefix_pop (); }
Signature · 1 line
2.44.0
PATCH 2/2 riscv: sbi: Test remaining base functions
Quoted 12 lines · Andrew Jones
Add the two remaining base extension functions to the base test.
Signed-off-by Andrew Jones <[email protected]>--- riscv/sbi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)riscv/sbi.c +0
-0
riscv/sbi.c static void check_base(void) · line 72
Quoted 2 lines
riscv/sbi.c +0
-0@@ -71,6 +71,14 @@ static void check_base(void) }report_prefix_pop ();
Quoted 30 lines
riscv/sbi.c +16
-0+report_prefix_push ("impl_version" ); +if (env_or_skip ("IMPL_VERSION" )) { + expected =strtol (getenv ("IMPL_VERSION" ),NULL ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_GET_IMP_VERSION ,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 ,SBI_EXT_BASE );@@ -93,6 +101,14 @@ static void check_base(void) }report_prefix_pop (); +report_prefix_push ("mimpid" ); +if (env_or_skip ("MIMPID" )) { + expected =strtol (getenv ("MIMPID" ),NULL ,0 ); + ret =__base_sbi_ecall (SBI_EXT_BASE_GET_MIMPID ,0 ); +gen_report (&ret,0 , expected); + } +report_prefix_pop (); +report_prefix_pop (); }Signature · 1 line
2.44.0
cover riscv: sbi: Check spec version and test rest
In reply to Andrew JonesQuoted 5 lines · Andrew Jones
The base extension tests require spec version 0.2 or later, so check for that, and also add the remaining function tests.
This is based on Carlos' series [1]
Quoted 12 lines
[1] http://lists.infradead.org/pipermail/kvm-riscv/2024-March/006047.html
Andrew Jones (2):
riscv: sbi: Check and test spec version
riscv: sbi: Test remaining base functionsriscv/sbi.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)Signature · 1 line
2.44.0
Merged to https://gitlab.com/kvm-unit-tests/kvm-unit-tests
Thanks,
drew