RISC-V: KVM: Add common kvm_riscv_vcpu_sbi_system_reset() function
We rename kvm_sbi_system_shutdown() to kvm_riscv_vcpu_sbi_system_reset() and move it to vcpu_sbi.c so that it can be shared by SBI v0.1 shutdown and SBI v0.3 SRST extension. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
parent
a03faf01a5
commit
4b11d86571
@ -28,6 +28,9 @@ struct kvm_vcpu_sbi_extension {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void kvm_riscv_vcpu_sbi_forward(struct kvm_vcpu *vcpu, struct kvm_run *run);
|
void kvm_riscv_vcpu_sbi_forward(struct kvm_vcpu *vcpu, struct kvm_run *run);
|
||||||
|
void kvm_riscv_vcpu_sbi_system_reset(struct kvm_vcpu *vcpu,
|
||||||
|
struct kvm_run *run,
|
||||||
|
u32 type, u64 flags);
|
||||||
const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext(unsigned long extid);
|
const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext(unsigned long extid);
|
||||||
|
|
||||||
#endif /* __RISCV_KVM_VCPU_SBI_H__ */
|
#endif /* __RISCV_KVM_VCPU_SBI_H__ */
|
||||||
|
@ -79,6 +79,23 @@ void kvm_riscv_vcpu_sbi_forward(struct kvm_vcpu *vcpu, struct kvm_run *run)
|
|||||||
run->riscv_sbi.ret[1] = cp->a1;
|
run->riscv_sbi.ret[1] = cp->a1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void kvm_riscv_vcpu_sbi_system_reset(struct kvm_vcpu *vcpu,
|
||||||
|
struct kvm_run *run,
|
||||||
|
u32 type, u64 flags)
|
||||||
|
{
|
||||||
|
unsigned long i;
|
||||||
|
struct kvm_vcpu *tmp;
|
||||||
|
|
||||||
|
kvm_for_each_vcpu(i, tmp, vcpu->kvm)
|
||||||
|
tmp->arch.power_off = true;
|
||||||
|
kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_SLEEP);
|
||||||
|
|
||||||
|
memset(&run->system_event, 0, sizeof(run->system_event));
|
||||||
|
run->system_event.type = type;
|
||||||
|
run->system_event.flags = flags;
|
||||||
|
run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
int kvm_riscv_vcpu_sbi_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
|
int kvm_riscv_vcpu_sbi_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
|
||||||
{
|
{
|
||||||
struct kvm_cpu_context *cp = &vcpu->arch.guest_context;
|
struct kvm_cpu_context *cp = &vcpu->arch.guest_context;
|
||||||
|
@ -14,21 +14,6 @@
|
|||||||
#include <asm/kvm_vcpu_timer.h>
|
#include <asm/kvm_vcpu_timer.h>
|
||||||
#include <asm/kvm_vcpu_sbi.h>
|
#include <asm/kvm_vcpu_sbi.h>
|
||||||
|
|
||||||
static void kvm_sbi_system_shutdown(struct kvm_vcpu *vcpu,
|
|
||||||
struct kvm_run *run, u32 type)
|
|
||||||
{
|
|
||||||
unsigned long i;
|
|
||||||
struct kvm_vcpu *tmp;
|
|
||||||
|
|
||||||
kvm_for_each_vcpu(i, tmp, vcpu->kvm)
|
|
||||||
tmp->arch.power_off = true;
|
|
||||||
kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_SLEEP);
|
|
||||||
|
|
||||||
memset(&run->system_event, 0, sizeof(run->system_event));
|
|
||||||
run->system_event.type = type;
|
|
||||||
run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int kvm_sbi_ext_v01_handler(struct kvm_vcpu *vcpu, struct kvm_run *run,
|
static int kvm_sbi_ext_v01_handler(struct kvm_vcpu *vcpu, struct kvm_run *run,
|
||||||
unsigned long *out_val,
|
unsigned long *out_val,
|
||||||
struct kvm_cpu_trap *utrap,
|
struct kvm_cpu_trap *utrap,
|
||||||
@ -80,7 +65,8 @@ static int kvm_sbi_ext_v01_handler(struct kvm_vcpu *vcpu, struct kvm_run *run,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SBI_EXT_0_1_SHUTDOWN:
|
case SBI_EXT_0_1_SHUTDOWN:
|
||||||
kvm_sbi_system_shutdown(vcpu, run, KVM_SYSTEM_EVENT_SHUTDOWN);
|
kvm_riscv_vcpu_sbi_system_reset(vcpu, run,
|
||||||
|
KVM_SYSTEM_EVENT_SHUTDOWN, 0);
|
||||||
*exit = true;
|
*exit = true;
|
||||||
break;
|
break;
|
||||||
case SBI_EXT_0_1_REMOTE_FENCE_I:
|
case SBI_EXT_0_1_REMOTE_FENCE_I:
|
||||||
|
Loading…
Reference in New Issue
Block a user