diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/kvm_host.h | 54 | ||||
| -rw-r--r-- | include/trace/events/kvm.h | 12 | ||||
| -rw-r--r-- | include/uapi/linux/kvm.h | 36 | 
3 files changed, 89 insertions, 13 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 7bde42470e3..30977471589 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -303,10 +303,10 @@ struct kvm_kernel_irq_routing_entry {  	struct hlist_node link;  }; -#ifdef __KVM_HAVE_IOAPIC +#ifdef CONFIG_HAVE_KVM_IRQ_ROUTING  struct kvm_irq_routing_table { -	int chip[KVM_NR_IRQCHIPS][KVM_IOAPIC_NUM_PINS]; +	int chip[KVM_NR_IRQCHIPS][KVM_IRQCHIP_NUM_PINS];  	struct kvm_kernel_irq_routing_entry *rt_entries;  	u32 nr_rt_entries;  	/* @@ -392,6 +392,7 @@ struct kvm {  	long mmu_notifier_count;  #endif  	long tlbs_dirty; +	struct list_head devices;  };  #define kvm_err(fmt, ...) \ @@ -431,7 +432,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);  int __must_check vcpu_load(struct kvm_vcpu *vcpu);  void vcpu_put(struct kvm_vcpu *vcpu); -#ifdef __KVM_HAVE_IOAPIC +#ifdef CONFIG_HAVE_KVM_IRQ_ROUTING  int kvm_irqfd_init(void);  void kvm_irqfd_exit(void);  #else @@ -718,11 +719,6 @@ void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq,  void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,  			     bool mask); -#ifdef __KVM_HAVE_IOAPIC -void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic, -				   union kvm_ioapic_redirect_entry *entry, -				   unsigned long *deliver_bitmask); -#endif  int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level,  		bool line_status);  int kvm_set_irq_inatomic(struct kvm *kvm, int irq_source_id, u32 irq, int level); @@ -956,7 +952,7 @@ static inline int mmu_notifier_retry(struct kvm *kvm, unsigned long mmu_seq)  }  #endif -#ifdef KVM_CAP_IRQ_ROUTING +#ifdef CONFIG_HAVE_KVM_IRQ_ROUTING  #define KVM_MAX_IRQ_ROUTES 1024 @@ -965,6 +961,9 @@ int kvm_set_irq_routing(struct kvm *kvm,  			const struct kvm_irq_routing_entry *entries,  			unsigned nr,  			unsigned flags); +int kvm_set_routing_entry(struct kvm_irq_routing_table *rt, +			  struct kvm_kernel_irq_routing_entry *e, +			  const struct kvm_irq_routing_entry *ue);  void kvm_free_irq_routing(struct kvm *kvm);  int kvm_send_userspace_msi(struct kvm *kvm, struct kvm_msi *msi); @@ -1065,6 +1064,43 @@ static inline bool kvm_check_request(int req, struct kvm_vcpu *vcpu)  extern bool kvm_rebooting; +struct kvm_device_ops; + +struct kvm_device { +	struct kvm_device_ops *ops; +	struct kvm *kvm; +	void *private; +	struct list_head vm_node; +}; + +/* create, destroy, and name are mandatory */ +struct kvm_device_ops { +	const char *name; +	int (*create)(struct kvm_device *dev, u32 type); + +	/* +	 * Destroy is responsible for freeing dev. +	 * +	 * Destroy may be called before or after destructors are called +	 * on emulated I/O regions, depending on whether a reference is +	 * held by a vcpu or other kvm component that gets destroyed +	 * after the emulated I/O. +	 */ +	void (*destroy)(struct kvm_device *dev); + +	int (*set_attr)(struct kvm_device *dev, struct kvm_device_attr *attr); +	int (*get_attr)(struct kvm_device *dev, struct kvm_device_attr *attr); +	int (*has_attr)(struct kvm_device *dev, struct kvm_device_attr *attr); +	long (*ioctl)(struct kvm_device *dev, unsigned int ioctl, +		      unsigned long arg); +}; + +void kvm_device_get(struct kvm_device *dev); +void kvm_device_put(struct kvm_device *dev); +struct kvm_device *kvm_device_from_filp(struct file *filp); + +extern struct kvm_device_ops kvm_mpic_ops; +  #ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT  static inline void kvm_vcpu_set_in_spin_loop(struct kvm_vcpu *vcpu, bool val) diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h index 19911dddaeb..7005d1109ec 100644 --- a/include/trace/events/kvm.h +++ b/include/trace/events/kvm.h @@ -37,7 +37,7 @@ TRACE_EVENT(kvm_userspace_exit,  		  __entry->errno < 0 ? -__entry->errno : __entry->reason)  ); -#if defined(__KVM_HAVE_IRQ_LINE) +#if defined(CONFIG_HAVE_KVM_IRQCHIP)  TRACE_EVENT(kvm_set_irq,  	TP_PROTO(unsigned int gsi, int level, int irq_source_id),  	TP_ARGS(gsi, level, irq_source_id), @@ -122,6 +122,10 @@ TRACE_EVENT(kvm_msi_set_irq,  	{KVM_IRQCHIP_PIC_SLAVE,		"PIC slave"},		\  	{KVM_IRQCHIP_IOAPIC,		"IOAPIC"} +#endif /* defined(__KVM_HAVE_IOAPIC) */ + +#if defined(CONFIG_HAVE_KVM_IRQCHIP) +  TRACE_EVENT(kvm_ack_irq,  	TP_PROTO(unsigned int irqchip, unsigned int pin),  	TP_ARGS(irqchip, pin), @@ -136,14 +140,18 @@ TRACE_EVENT(kvm_ack_irq,  		__entry->pin		= pin;  	), +#ifdef kvm_irqchips  	TP_printk("irqchip %s pin %u",  		  __print_symbolic(__entry->irqchip, kvm_irqchips),  		 __entry->pin) +#else +	TP_printk("irqchip %d pin %u", __entry->irqchip, __entry->pin) +#endif  ); +#endif /* defined(CONFIG_HAVE_KVM_IRQCHIP) */ -#endif /* defined(__KVM_HAVE_IOAPIC) */  #define KVM_TRACE_MMIO_READ_UNSATISFIED 0  #define KVM_TRACE_MMIO_READ 1 diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 74d0ff3dfd6..d4005192ad6 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -579,9 +579,7 @@ struct kvm_ppc_smmu_info {  #ifdef __KVM_HAVE_PIT  #define KVM_CAP_REINJECT_CONTROL 24  #endif -#ifdef __KVM_HAVE_IOAPIC  #define KVM_CAP_IRQ_ROUTING 25 -#endif  #define KVM_CAP_IRQ_INJECT_STATUS 26  #ifdef __KVM_HAVE_DEVICE_ASSIGNMENT  #define KVM_CAP_DEVICE_DEASSIGNMENT 27 @@ -668,6 +666,9 @@ struct kvm_ppc_smmu_info {  #define KVM_CAP_PPC_EPR 86  #define KVM_CAP_ARM_PSCI 87  #define KVM_CAP_ARM_SET_DEVICE_ADDR 88 +#define KVM_CAP_DEVICE_CTRL 89 +#define KVM_CAP_IRQ_MPIC 90 +#define KVM_CAP_PPC_RTAS 91  #ifdef KVM_CAP_IRQ_ROUTING @@ -821,6 +822,27 @@ struct kvm_arm_device_addr {  };  /* + * Device control API, available with KVM_CAP_DEVICE_CTRL + */ +#define KVM_CREATE_DEVICE_TEST		1 + +struct kvm_create_device { +	__u32	type;	/* in: KVM_DEV_TYPE_xxx */ +	__u32	fd;	/* out: device handle */ +	__u32	flags;	/* in: KVM_CREATE_DEVICE_xxx */ +}; + +struct kvm_device_attr { +	__u32	flags;		/* no flags currently defined */ +	__u32	group;		/* device-defined */ +	__u64	attr;		/* group-defined */ +	__u64	addr;		/* userspace address of attr data */ +}; + +#define KVM_DEV_TYPE_FSL_MPIC_20	1 +#define KVM_DEV_TYPE_FSL_MPIC_42	2 + +/*   * ioctls for VM fds   */  #define KVM_SET_MEMORY_REGION     _IOW(KVMIO,  0x40, struct kvm_memory_region) @@ -907,6 +929,16 @@ struct kvm_s390_ucas_mapping {  #define KVM_PPC_GET_HTAB_FD	  _IOW(KVMIO,  0xaa, struct kvm_get_htab_fd)  /* Available with KVM_CAP_ARM_SET_DEVICE_ADDR */  #define KVM_ARM_SET_DEVICE_ADDR	  _IOW(KVMIO,  0xab, struct kvm_arm_device_addr) +/* Available with KVM_CAP_PPC_RTAS */ +#define KVM_PPC_RTAS_DEFINE_TOKEN _IOW(KVMIO,  0xac, struct kvm_rtas_token_args) + +/* ioctl for vm fd */ +#define KVM_CREATE_DEVICE	  _IOWR(KVMIO,  0xe0, struct kvm_create_device) + +/* ioctls for fds returned by KVM_CREATE_DEVICE */ +#define KVM_SET_DEVICE_ATTR	  _IOW(KVMIO,  0xe1, struct kvm_device_attr) +#define KVM_GET_DEVICE_ATTR	  _IOW(KVMIO,  0xe2, struct kvm_device_attr) +#define KVM_HAS_DEVICE_ATTR	  _IOW(KVMIO,  0xe3, struct kvm_device_attr)  /*   * ioctls for vcpu fds  |