mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
This patch implements VCPU create, init and destroy functions required by generic KVM module. We don't have much dynamic resources in struct kvm_vcpu_arch so these functions are quite simple for KVM RISC-V. Signed-off-by: Anup Patel <anup.patel@wdc.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Alexander Graf <graf@amazon.com> Acked-by: Palmer Dabbelt <palmerdabbelt@google.com>
153 lines
3.3 KiB
C
153 lines
3.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2019 Western Digital Corporation or its affiliates.
|
|
*
|
|
* Authors:
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
*/
|
|
|
|
#ifndef __RISCV_KVM_HOST_H__
|
|
#define __RISCV_KVM_HOST_H__
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/kvm.h>
|
|
#include <linux/kvm_types.h>
|
|
|
|
#ifdef CONFIG_64BIT
|
|
#define KVM_MAX_VCPUS (1U << 16)
|
|
#else
|
|
#define KVM_MAX_VCPUS (1U << 9)
|
|
#endif
|
|
|
|
#define KVM_HALT_POLL_NS_DEFAULT 500000
|
|
|
|
#define KVM_VCPU_MAX_FEATURES 0
|
|
|
|
#define KVM_REQ_SLEEP \
|
|
KVM_ARCH_REQ_FLAGS(0, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
|
|
#define KVM_REQ_VCPU_RESET KVM_ARCH_REQ(1)
|
|
|
|
struct kvm_vm_stat {
|
|
struct kvm_vm_stat_generic generic;
|
|
};
|
|
|
|
struct kvm_vcpu_stat {
|
|
struct kvm_vcpu_stat_generic generic;
|
|
u64 ecall_exit_stat;
|
|
u64 wfi_exit_stat;
|
|
u64 mmio_exit_user;
|
|
u64 mmio_exit_kernel;
|
|
u64 exits;
|
|
};
|
|
|
|
struct kvm_arch_memory_slot {
|
|
};
|
|
|
|
struct kvm_arch {
|
|
/* stage2 page table */
|
|
pgd_t *pgd;
|
|
phys_addr_t pgd_phys;
|
|
};
|
|
|
|
struct kvm_cpu_trap {
|
|
unsigned long sepc;
|
|
unsigned long scause;
|
|
unsigned long stval;
|
|
unsigned long htval;
|
|
unsigned long htinst;
|
|
};
|
|
|
|
struct kvm_cpu_context {
|
|
unsigned long zero;
|
|
unsigned long ra;
|
|
unsigned long sp;
|
|
unsigned long gp;
|
|
unsigned long tp;
|
|
unsigned long t0;
|
|
unsigned long t1;
|
|
unsigned long t2;
|
|
unsigned long s0;
|
|
unsigned long s1;
|
|
unsigned long a0;
|
|
unsigned long a1;
|
|
unsigned long a2;
|
|
unsigned long a3;
|
|
unsigned long a4;
|
|
unsigned long a5;
|
|
unsigned long a6;
|
|
unsigned long a7;
|
|
unsigned long s2;
|
|
unsigned long s3;
|
|
unsigned long s4;
|
|
unsigned long s5;
|
|
unsigned long s6;
|
|
unsigned long s7;
|
|
unsigned long s8;
|
|
unsigned long s9;
|
|
unsigned long s10;
|
|
unsigned long s11;
|
|
unsigned long t3;
|
|
unsigned long t4;
|
|
unsigned long t5;
|
|
unsigned long t6;
|
|
unsigned long sepc;
|
|
unsigned long sstatus;
|
|
unsigned long hstatus;
|
|
};
|
|
|
|
struct kvm_vcpu_csr {
|
|
unsigned long vsstatus;
|
|
unsigned long vsie;
|
|
unsigned long vstvec;
|
|
unsigned long vsscratch;
|
|
unsigned long vsepc;
|
|
unsigned long vscause;
|
|
unsigned long vstval;
|
|
unsigned long hvip;
|
|
unsigned long vsatp;
|
|
unsigned long scounteren;
|
|
};
|
|
|
|
struct kvm_vcpu_arch {
|
|
/* VCPU ran at least once */
|
|
bool ran_atleast_once;
|
|
|
|
/* ISA feature bits (similar to MISA) */
|
|
unsigned long isa;
|
|
|
|
/* CPU context of Guest VCPU */
|
|
struct kvm_cpu_context guest_context;
|
|
|
|
/* CPU CSR context of Guest VCPU */
|
|
struct kvm_vcpu_csr guest_csr;
|
|
|
|
/* CPU context upon Guest VCPU reset */
|
|
struct kvm_cpu_context guest_reset_context;
|
|
|
|
/* CPU CSR context upon Guest VCPU reset */
|
|
struct kvm_vcpu_csr guest_reset_csr;
|
|
|
|
/* Don't run the VCPU (blocked) */
|
|
bool pause;
|
|
|
|
/* SRCU lock index for in-kernel run loop */
|
|
int srcu_idx;
|
|
};
|
|
|
|
static inline void kvm_arch_hardware_unsetup(void) {}
|
|
static inline void kvm_arch_sync_events(struct kvm *kvm) {}
|
|
static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {}
|
|
static inline void kvm_arch_vcpu_block_finish(struct kvm_vcpu *vcpu) {}
|
|
|
|
void kvm_riscv_stage2_flush_cache(struct kvm_vcpu *vcpu);
|
|
int kvm_riscv_stage2_alloc_pgd(struct kvm *kvm);
|
|
void kvm_riscv_stage2_free_pgd(struct kvm *kvm);
|
|
void kvm_riscv_stage2_update_hgatp(struct kvm_vcpu *vcpu);
|
|
|
|
int kvm_riscv_vcpu_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run);
|
|
int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
|
|
struct kvm_cpu_trap *trap);
|
|
|
|
static inline void __kvm_riscv_switch_to(struct kvm_vcpu_arch *vcpu_arch) {}
|
|
|
|
#endif /* __RISCV_KVM_HOST_H__ */
|