Skip to content

[Backport]: RISC-V: KVM: Add SBI system suspend support#276

Open
yechao-w wants to merge 4 commits into
RVCK-Project:rvck-6.6from
yechao-w:sbi-susp
Open

[Backport]: RISC-V: KVM: Add SBI system suspend support#276
yechao-w wants to merge 4 commits into
RVCK-Project:rvck-6.6from
yechao-w:sbi-susp

Conversation

@yechao-w
Copy link
Copy Markdown
Contributor

issues: #262 SBI SUSP支持部分

合入L0如下补丁,使得kvm虚拟机支持SBI SUSPEND,能够支持系统挂起操作。

编号 Commit 信息 补丁一致性
1 df1fc66 RISCV: KVM: Introduce vcpu->reset_cntx_lock 一致
2 a19a1db RISC-V: KVM: Add SBI system suspend support 一致
3 1ad9933 KVM: riscv: selftests: Add SBI SUSP to get-reg-list test 一致
4 351e02b riscv: KVM: Fix SBI sleep_type use 一致

测试:
get-reg-list测试用例执行成功

[root@tcg kvm]# ./get-reg-list --config=sbi-susp
sbi-susp: Number blessed registers:    56
sbi-susp: Number registers:           118 (includes 47 filtered registers)

sbi-susp: There are 16 new registers.
Consider adding them to the blessed reg list with the following lines:

        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_CSR | KVM_REG_RISCV_CSR_GENERAL | 10 /* UNKNOWN */,
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_ISA_EXT | (null),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_SBI_EXT | KVM_REG_RISCV_SBI_SINGLE | 12 /* UNKNOWN */,
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_SBI_STATE | KVM_REG_RISCV_SBI_STA | KVM_REG_RISCV_SBI_STA_REG(shmem_lo),
        KVM_REG_RISCV | KVM_REG_SIZE_U64 | KVM_REG_RISCV_SBI_STATE | KVM_REG_RISCV_SBI_STA | KVM_REG_RISCV_SBI_STA_REG(shmem_hi),

sbi-susp: PASS

yong-xuan and others added 4 commits May 18, 2026 15:37
mainline inclusion
from mainline-6.10-rc1
commit 9752fed
category: feature
bugzilla: RVCK-Project#262

--------------------------------

Originally, the use of kvm->lock in SBI_EXT_HSM_HART_START also avoids
the simultaneous updates to the reset context of target VCPU. Since this
lock has been replace with vcpu->mp_state_lock, and this new lock also
protects the vcpu->mp_state. We have to add a separate lock for
vcpu->reset_cntx.

Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20240417074528.16506-3-yongxuan.wang@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
mainline inclusion
from mainline-6.14-rc1
commit 023c151
category: feature
bugzilla: RVCK-Project#262

--------------------------------

Implement a KVM SBI SUSP extension handler. The handler only
validates the system suspend entry criteria and prepares for resuming
in the appropriate state at the resume_addr (as specified by the SBI
spec), but then it forwards the call to the VMM where any system
suspend behavior may be implemented. Since VMM support is needed, KVM
disables the extension by default.

Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20241017074538.18867-5-ajones@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
mainline inclusion
from mainline-6.14-rc1
commit cc57f6c
category: feature
bugzilla: RVCK-Project#262

--------------------------------

KVM supports SBI SUSP, so add it to the get-reg-list test.

Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20241017074538.18867-6-ajones@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
mainline inclusion
from mainline-6.14-rc5
commit 351e02b
category: feature
bugzilla: RVCK-Project#262

--------------------------------

The spec says sleep_type is 32 bits wide and "In case the data is
defined as 32bit wide, higher privilege software must ensure that it
only uses 32 bit data." Mask off upper bits of sleep_type before
using it.

Fixes: 023c151 ("RISC-V: KVM: Add SBI system suspend support")
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20250217084506.18763-12-ajones@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026


开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/26020840802

参数解析结果
args value
repository RVCK-Project/rvck
head ref pull/276/head
base ref rvck-6.6
LAVA repo RVCK-Project/lavaci
LAVA hardware
LAVA Testcase path
need run job kunit-test,kernel-build,check-patch,lava-trigger

测试完成

详细结果:
check result
kunit-test success
kernel-build success
check-patch success
lava-trigger-qemu skipped
lava-trigger-sg2042 skipped
lava-trigger-k1 skipped
lava-trigger-lpi4a skipped

Kunit Test Result

[08:00:49] Testing complete. Ran 457 tests: passed: 445, skipped: 12

Kernel Build Result

Check Patch Result

Total Errors 0
Total Warnings 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants