mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-17 07:14:25 +00:00
Currently, the SBI extension handle is expected to return Linux error code. The top SBI layer converts the Linux error code to SBI specific error code that can be returned to guest invoking the SBI calls. This model works as long as SBI error codes have 1-to-1 mappings between them. However, that may not be true always. This patch attempts to disassociate both these error codes by allowing the SBI extension implementation to return SBI specific error codes as well. The extension will continue to return the Linux error specific code which will indicate any problem *with* the extension emulation while the SBI specific error will indicate the problem *of* the emulation. Reviewed-by: Anup Patel <anup@brainfault.org> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Suggested-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Anup Patel <anup@brainfault.org>
64 lines
2.0 KiB
C
64 lines
2.0 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/**
|
|
* Copyright (c) 2021 Western Digital Corporation or its affiliates.
|
|
*
|
|
* Authors:
|
|
* Atish Patra <atish.patra@wdc.com>
|
|
*/
|
|
|
|
#ifndef __RISCV_KVM_VCPU_SBI_H__
|
|
#define __RISCV_KVM_VCPU_SBI_H__
|
|
|
|
#define KVM_SBI_IMPID 3
|
|
|
|
#define KVM_SBI_VERSION_MAJOR 1
|
|
#define KVM_SBI_VERSION_MINOR 0
|
|
|
|
struct kvm_vcpu_sbi_context {
|
|
int return_handled;
|
|
};
|
|
|
|
struct kvm_vcpu_sbi_return {
|
|
unsigned long out_val;
|
|
unsigned long err_val;
|
|
struct kvm_cpu_trap *utrap;
|
|
bool uexit;
|
|
};
|
|
|
|
struct kvm_vcpu_sbi_extension {
|
|
unsigned long extid_start;
|
|
unsigned long extid_end;
|
|
/**
|
|
* SBI extension handler. It can be defined for a given extension or group of
|
|
* extension. But it should always return linux error codes rather than SBI
|
|
* specific error codes.
|
|
*/
|
|
int (*handler)(struct kvm_vcpu *vcpu, struct kvm_run *run,
|
|
struct kvm_vcpu_sbi_return *retdata);
|
|
|
|
/* Extension specific probe function */
|
|
unsigned long (*probe)(struct kvm_vcpu *vcpu);
|
|
};
|
|
|
|
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);
|
|
int kvm_riscv_vcpu_sbi_return(struct kvm_vcpu *vcpu, struct kvm_run *run);
|
|
const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext(unsigned long extid);
|
|
int kvm_riscv_vcpu_sbi_ecall(struct kvm_vcpu *vcpu, struct kvm_run *run);
|
|
|
|
#ifdef CONFIG_RISCV_SBI_V01
|
|
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_v01;
|
|
#endif
|
|
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_base;
|
|
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_time;
|
|
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_ipi;
|
|
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_rfence;
|
|
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_srst;
|
|
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_hsm;
|
|
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_experimental;
|
|
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_vendor;
|
|
|
|
#endif /* __RISCV_KVM_VCPU_SBI_H__ */
|