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 09/10] riscv: sbi: susp: Check upper bits of sleep_type are ignored
Date: Fri, 21 Feb 2025 16:55:43 +0100 [thread overview]
Message-ID: <20250221155533.123418-21-andrew.jones@linux.dev> (raw)
In-Reply-To: <20250221155533.123418-12-andrew.jones@linux.dev>
When an SBI function parameter has a specific bit width which is
less than that of a long, then the upper bits should be ignored
by the SBI implementation. I.e. since sleep_type is a uint32_t,
then on rv64 both 0 and 0x1_0000_0000 are valid and mean suspend
to ram.
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
riscv/sbi.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/riscv/sbi.c b/riscv/sbi.c
index e5f6e1c72ae6..1d9d1871a28b 100644
--- a/riscv/sbi.c
+++ b/riscv/sbi.c
@@ -67,7 +67,7 @@ static struct sbiret sbi_hart_suspend_raw(unsigned long suspend_type, unsigned l
return sbi_ecall(SBI_EXT_HSM, SBI_EXT_HSM_HART_SUSPEND, suspend_type, resume_addr, opaque, 0, 0, 0);
}
-static struct sbiret sbi_system_suspend(uint32_t sleep_type, unsigned long resume_addr, unsigned long opaque)
+static struct sbiret sbi_system_suspend_raw(unsigned long sleep_type, unsigned long resume_addr, unsigned long opaque)
{
return sbi_ecall(SBI_EXT_SUSP, 0, sleep_type, resume_addr, opaque, 0, 0, 0);
}
@@ -1367,6 +1367,19 @@ static bool susp_type_prep(unsigned long ctx[], struct susp_params *params)
return true;
}
+#if __riscv_xlen != 32
+static bool susp_type_prep2(unsigned long ctx[], struct susp_params *params)
+{
+ bool r;
+
+ r = susp_basic_prep(ctx, params);
+ assert(r);
+ params->sleep_type = BIT(32);
+
+ return true;
+}
+#endif
+
static bool susp_badaddr_prep(unsigned long ctx[], struct susp_params *params)
{
phys_addr_t badaddr;
@@ -1432,6 +1445,7 @@ static void check_susp(void)
#define SUSP_FIRST_TESTNUM 1
SUSP_BASIC = SUSP_FIRST_TESTNUM,
SUSP_TYPE,
+ SUSP_TYPE2,
SUSP_BAD_ADDR,
SUSP_ONE_ONLINE,
NR_SUSP_TESTS,
@@ -1441,10 +1455,13 @@ static void check_susp(void)
bool (*prep)(unsigned long ctx[], struct susp_params *params);
void (*check)(unsigned long ctx[], struct susp_params *params);
} susp_tests[] = {
- [SUSP_BASIC] = { "basic", susp_basic_prep, susp_basic_check, },
- [SUSP_TYPE] = { "sleep_type", susp_type_prep, },
- [SUSP_BAD_ADDR] = { "bad addr", susp_badaddr_prep, },
- [SUSP_ONE_ONLINE] = { "one cpu online", susp_one_prep, },
+ [SUSP_BASIC] = { "basic", susp_basic_prep, susp_basic_check, },
+ [SUSP_TYPE] = { "sleep_type", susp_type_prep, },
+#if __riscv_xlen != 32
+ [SUSP_TYPE2] = { "sleep_type upper bits", susp_type_prep2, susp_basic_check },
+#endif
+ [SUSP_BAD_ADDR] = { "bad addr", susp_badaddr_prep, },
+ [SUSP_ONE_ONLINE] = { "one cpu online", susp_one_prep, },
};
struct susp_params params;
struct sbiret ret;
@@ -1466,6 +1483,9 @@ static void check_susp(void)
report(ret.error == SBI_ERR_NOT_SUPPORTED, "funcid != 0 not supported");
for (i = SUSP_FIRST_TESTNUM; i < NR_SUSP_TESTS; i++) {
+ if (!susp_tests[i].name)
+ continue;
+
report_prefix_push(susp_tests[i].name);
ctx[SBI_SUSP_TESTNUM_IDX] = i;
@@ -1480,7 +1500,7 @@ static void check_susp(void)
}
if ((testnum = setjmp(sbi_susp_jmp)) == 0) {
- ret = sbi_system_suspend(params.sleep_type, params.resume_addr, params.opaque);
+ ret = sbi_system_suspend_raw(params.sleep_type, params.resume_addr, params.opaque);
local_irq_enable();
--
2.48.1
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
next prev parent reply other threads:[~2025-02-21 15:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 15:55 [kvm-unit-tests PATCH 00/10] riscv: sbi: Test improvements and a couple new Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 01/10] riscv: sbi: Mark known fwft failures as kfails Andrew Jones
2025-02-24 16:53 ` Clément Léger
2025-02-25 10:14 ` Clément Léger
2025-02-25 10:25 ` Andrew Jones
2025-02-25 15:32 ` Andrew Jones
2025-02-25 15:48 ` Clément Léger
2025-02-26 18:01 ` Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 02/10] riscv: sbi: Ensure we have IPIs enabled for HSM suspend tests Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 03/10] riscv: sbi: Ensure SUSP test gets an interrupt Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 04/10] riscv: sbi: Improve susp expected error output Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 05/10] riscv: sbi: Improve interrupt handling cleanup Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 06/10] lib/cpumask: Add some operators Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 07/10] riscv: sbi: HSM suspend may not be supported Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 08/10] riscv: sbi: Probe/skip SUSP Andrew Jones
2025-02-25 15:16 ` Clément Léger
2025-02-21 15:55 ` Andrew Jones [this message]
2025-02-25 15:20 ` [kvm-unit-tests PATCH 09/10] riscv: sbi: susp: Check upper bits of sleep_type are ignored Clément Léger
2025-02-21 15:55 ` [kvm-unit-tests PATCH 10/10] riscv: sbi: Add bad fid tests Andrew Jones
2025-02-26 17:59 ` [kvm-unit-tests PATCH 11/10] riscv: sbi: Add fwft pte_hw_ad_updating test Andrew Jones
2025-02-27 9:09 ` Clément Léger
2025-02-27 12:07 ` 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=20250221155533.123418-21-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).