#define pr_fmt(fmt) …
#include <linux/kvm_types.h>
#include <linux/hashtable.h>
#include <linux/amd-iommu.h>
#include <linux/kvm_host.h>
#include <asm/irq_remapping.h>
#include "trace.h"
#include "lapic.h"
#include "x86.h"
#include "irq.h"
#include "svm.h"
#define AVIC_VCPU_ID_MASK …
#define AVIC_VM_ID_SHIFT …
#define AVIC_VM_ID_MASK …
#define AVIC_GATAG_TO_VMID(x) …
#define AVIC_GATAG_TO_VCPUID(x) …
#define __AVIC_GATAG(vm_id, vcpu_id) …
#define AVIC_GATAG(vm_id, vcpu_id) …
static_assert(…);
static bool force_avic;
module_param_unsafe(force_avic, bool, 0444);
#define SVM_VM_DATA_HASH_BITS …
static DEFINE_HASHTABLE(svm_vm_data_hash, SVM_VM_DATA_HASH_BITS);
static u32 next_vm_id = …;
static bool next_vm_id_wrapped = …;
static DEFINE_SPINLOCK(svm_vm_data_hash_lock);
bool x2avic_enabled;
struct amd_svm_iommu_ir { … };
static void avic_activate_vmcb(struct vcpu_svm *svm)
{ … }
static void avic_deactivate_vmcb(struct vcpu_svm *svm)
{ … }
int avic_ga_log_notifier(u32 ga_tag)
{ … }
void avic_vm_destroy(struct kvm *kvm)
{ … }
int avic_vm_init(struct kvm *kvm)
{ … }
void avic_init_vmcb(struct vcpu_svm *svm, struct vmcb *vmcb)
{ … }
static u64 *avic_get_physical_id_entry(struct kvm_vcpu *vcpu,
unsigned int index)
{ … }
static int avic_init_backing_page(struct kvm_vcpu *vcpu)
{ … }
void avic_ring_doorbell(struct kvm_vcpu *vcpu)
{ … }
static void avic_kick_vcpu(struct kvm_vcpu *vcpu, u32 icrl)
{ … }
static void avic_kick_vcpu_by_physical_id(struct kvm *kvm, u32 physical_id,
u32 icrl)
{ … }
static void avic_kick_vcpu_by_logical_id(struct kvm *kvm, u32 *avic_logical_id_table,
u32 logid_index, u32 icrl)
{ … }
static int avic_kick_target_vcpus_fast(struct kvm *kvm, struct kvm_lapic *source,
u32 icrl, u32 icrh, u32 index)
{ … }
static void avic_kick_target_vcpus(struct kvm *kvm, struct kvm_lapic *source,
u32 icrl, u32 icrh, u32 index)
{ … }
int avic_incomplete_ipi_interception(struct kvm_vcpu *vcpu)
{ … }
unsigned long avic_vcpu_get_apicv_inhibit_reasons(struct kvm_vcpu *vcpu)
{ … }
static u32 *avic_get_logical_id_entry(struct kvm_vcpu *vcpu, u32 ldr, bool flat)
{ … }
static void avic_ldr_write(struct kvm_vcpu *vcpu, u8 g_physical_id, u32 ldr)
{ … }
static void avic_invalidate_logical_id_entry(struct kvm_vcpu *vcpu)
{ … }
static void avic_handle_ldr_update(struct kvm_vcpu *vcpu)
{ … }
static void avic_handle_dfr_update(struct kvm_vcpu *vcpu)
{ … }
static int avic_unaccel_trap_write(struct kvm_vcpu *vcpu)
{ … }
static bool is_avic_unaccelerated_access_trap(u32 offset)
{ … }
int avic_unaccelerated_access_interception(struct kvm_vcpu *vcpu)
{ … }
int avic_init_vcpu(struct vcpu_svm *svm)
{ … }
void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu)
{ … }
static int avic_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate)
{ … }
static void svm_ir_list_del(struct vcpu_svm *svm, struct amd_iommu_pi_data *pi)
{ … }
static int svm_ir_list_add(struct vcpu_svm *svm, struct amd_iommu_pi_data *pi)
{ … }
static int
get_pi_vcpu_info(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e,
struct vcpu_data *vcpu_info, struct vcpu_svm **svm)
{ … }
int avic_pi_update_irte(struct kvm *kvm, unsigned int host_irq,
uint32_t guest_irq, bool set)
{ … }
static inline int
avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int cpu, bool r)
{ … }
void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
{ … }
void avic_vcpu_put(struct kvm_vcpu *vcpu)
{ … }
void avic_refresh_virtual_apic_mode(struct kvm_vcpu *vcpu)
{ … }
void avic_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu)
{ … }
void avic_vcpu_blocking(struct kvm_vcpu *vcpu)
{ … }
void avic_vcpu_unblocking(struct kvm_vcpu *vcpu)
{ … }
bool avic_hardware_setup(void)
{ … }