blob: 8733901130cf02b1dccbfdd09cc7fe6a09d0e462 [file] [log] [blame]
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2020 Google LLC
* Author: Will Deacon <will@kernel.org>
*/
#ifndef __KVM_ARM_SPCI_H
#define __KVM_ARM_SPCI_H
#include <linux/of_reserved_mem.h>
#include <linux/kobject.h>
enum kvm_spci_mem_prot {
KVM_SPCI_MEM_PROT_X = 1 << 0,
KVM_SPCI_MEM_PROT_W = 1 << 1,
KVM_SPCI_MEM_PROT_R = 1 << 2,
};
struct kvm_spci_memory {
struct reserved_mem *rmem; /* Physical carveout */
phys_addr_t ipa_base;
phys_addr_t ipa_size; /* Size of guest region */
enum kvm_spci_mem_prot prot;
};
struct kvm_spci_partition {
struct kobject kobj;
struct list_head list;
int id;
uuid_t uuid;
u64 entry_point;
int nr_vcpus;
int nr_mems;
bool is_32bit;
struct kvm *kvm;
struct kvm_spci_memory *mems[];
};
#ifdef CONFIG_KVM_ARM_SPCI
int kvm_spci_init(void);
bool kvm_spci_supported(void);
int kvm_spci_init_vm(struct kvm *kvm, unsigned long type);
void kvm_spci_destroy_vm(struct kvm *kvm);
int kvm_spci_check_vcpu_init_features(const struct kvm_vcpu *vcpu,
const struct kvm_vcpu_init *init);
int kvm_spci_vcpu_first_run_init(struct kvm_vcpu *vcpu);
int kvm_spci_vcpu_reg_list_num(struct kvm_vcpu *vcpu, unsigned long *num);
int kvm_spci_vcpu_reg_list(struct kvm_vcpu *vcpu, u64 __user *uindices);
int kvm_spci_check_vcpu_access_reg(struct kvm_vcpu *vcpu,
struct kvm_one_reg *reg);
#else
static inline int kvm_spci_init(void) { return 0; }
static inline bool kvm_spci_supported(void) { return false; }
static inline int kvm_spci_init_vm(struct kvm *kvm, unsigned long type)
{
return 0;
}
static inline void kvm_spci_destroy_vm(struct kvm *kvm) {}
static inline int kvm_spci_check_vcpu_init_features(const struct kvm_vcpu *vcpu,
const struct kvm_vcpu_init *init)
{
return 0;
}
static inline int kvm_spci_vcpu_first_run_init(struct kvm_vcpu *vcpu)
{
return 0;
}
int kvm_spci_check_vcpu_access_reg(struct kvm_vcpu *vcpu,
struct kvm_one_reg *reg)
{
return 0;
}
#endif /* CONFIG_KVM_ARM_SPCI */
#endif /* __KVM_ARM_SPCI_H */