Commit ea2108c9 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

Merge branch 'kvms390-irqfd' of...

Merge branch 'kvms390-irqfd' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into kvm-next
parents 673f7b42 f3f710bc
Loading
Loading
Loading
Loading
+21 −6
Original line number Original line Diff line number Diff line
@@ -586,8 +586,8 @@ struct kvm_fpu {


4.24 KVM_CREATE_IRQCHIP
4.24 KVM_CREATE_IRQCHIP


Capability: KVM_CAP_IRQCHIP
Capability: KVM_CAP_IRQCHIP, KVM_CAP_S390_IRQCHIP (s390)
Architectures: x86, ia64, ARM, arm64
Architectures: x86, ia64, ARM, arm64, s390
Type: vm ioctl
Type: vm ioctl
Parameters: none
Parameters: none
Returns: 0 on success, -1 on error
Returns: 0 on success, -1 on error
@@ -596,7 +596,10 @@ Creates an interrupt controller model in the kernel. On x86, creates a virtual
ioapic, a virtual PIC (two PICs, nested), and sets up future vcpus to have a
ioapic, a virtual PIC (two PICs, nested), and sets up future vcpus to have a
local APIC.  IRQ routing for GSIs 0-15 is set to both PIC and IOAPIC; GSI 16-23
local APIC.  IRQ routing for GSIs 0-15 is set to both PIC and IOAPIC; GSI 16-23
only go to the IOAPIC.  On ia64, a IOSAPIC is created. On ARM/arm64, a GIC is
only go to the IOAPIC.  On ia64, a IOSAPIC is created. On ARM/arm64, a GIC is
created.
created. On s390, a dummy irq routing table is created.

Note that on s390 the KVM_CAP_S390_IRQCHIP vm capability needs to be enabled
before KVM_CREATE_IRQCHIP can be used.




4.25 KVM_IRQ_LINE
4.25 KVM_IRQ_LINE
@@ -932,9 +935,9 @@ documentation when it pops into existence).


4.37 KVM_ENABLE_CAP
4.37 KVM_ENABLE_CAP


Capability: KVM_CAP_ENABLE_CAP
Capability: KVM_CAP_ENABLE_CAP, KVM_CAP_ENABLE_CAP_VM
Architectures: ppc, s390
Architectures: ppc, s390
Type: vcpu ioctl
Type: vcpu ioctl, vm ioctl (with KVM_CAP_ENABLE_CAP_VM)
Parameters: struct kvm_enable_cap (in)
Parameters: struct kvm_enable_cap (in)
Returns: 0 on success; -1 on error
Returns: 0 on success; -1 on error


@@ -965,6 +968,8 @@ function properly, this is the place to put them.
       __u8  pad[64];
       __u8  pad[64];
};
};


The vcpu ioctl should be used for vcpu-specific capabilities, the vm ioctl
for vm-wide capabilities.


4.38 KVM_GET_MP_STATE
4.38 KVM_GET_MP_STATE


@@ -1334,7 +1339,7 @@ KVM_ASSIGN_DEV_IRQ. Partial deassignment of host or guest IRQ is allowed.
4.52 KVM_SET_GSI_ROUTING
4.52 KVM_SET_GSI_ROUTING


Capability: KVM_CAP_IRQ_ROUTING
Capability: KVM_CAP_IRQ_ROUTING
Architectures: x86 ia64
Architectures: x86 ia64 s390
Type: vm ioctl
Type: vm ioctl
Parameters: struct kvm_irq_routing (in)
Parameters: struct kvm_irq_routing (in)
Returns: 0 on success, -1 on error
Returns: 0 on success, -1 on error
@@ -1357,6 +1362,7 @@ struct kvm_irq_routing_entry {
	union {
	union {
		struct kvm_irq_routing_irqchip irqchip;
		struct kvm_irq_routing_irqchip irqchip;
		struct kvm_irq_routing_msi msi;
		struct kvm_irq_routing_msi msi;
		struct kvm_irq_routing_s390_adapter adapter;
		__u32 pad[8];
		__u32 pad[8];
	} u;
	} u;
};
};
@@ -1364,6 +1370,7 @@ struct kvm_irq_routing_entry {
/* gsi routing entry types */
/* gsi routing entry types */
#define KVM_IRQ_ROUTING_IRQCHIP 1
#define KVM_IRQ_ROUTING_IRQCHIP 1
#define KVM_IRQ_ROUTING_MSI 2
#define KVM_IRQ_ROUTING_MSI 2
#define KVM_IRQ_ROUTING_S390_ADAPTER 3


No flags are specified so far, the corresponding field must be set to zero.
No flags are specified so far, the corresponding field must be set to zero.


@@ -1379,6 +1386,14 @@ struct kvm_irq_routing_msi {
	__u32 pad;
	__u32 pad;
};
};


struct kvm_irq_routing_s390_adapter {
	__u64 ind_addr;
	__u64 summary_addr;
	__u64 ind_offset;
	__u32 summary_offset;
	__u32 adapter_id;
};



4.53 KVM_ASSIGN_SET_MSIX_NR
4.53 KVM_ASSIGN_SET_MSIX_NR


+45 −0
Original line number Original line Diff line number Diff line
@@ -12,6 +12,7 @@ FLIC provides support to
- inspect currently pending interrupts (KVM_FLIC_GET_ALL_IRQS)
- inspect currently pending interrupts (KVM_FLIC_GET_ALL_IRQS)
- purge all pending floating interrupts (KVM_DEV_FLIC_CLEAR_IRQS)
- purge all pending floating interrupts (KVM_DEV_FLIC_CLEAR_IRQS)
- enable/disable for the guest transparent async page faults
- enable/disable for the guest transparent async page faults
- register and modify adapter interrupt sources (KVM_DEV_FLIC_ADAPTER_*)


Groups:
Groups:
  KVM_DEV_FLIC_ENQUEUE
  KVM_DEV_FLIC_ENQUEUE
@@ -44,3 +45,47 @@ Groups:
    Disables async page faults for the guest and waits until already pending
    Disables async page faults for the guest and waits until already pending
    async page faults are done. This is necessary to trigger a completion interrupt
    async page faults are done. This is necessary to trigger a completion interrupt
    for every init interrupt before migrating the interrupt list.
    for every init interrupt before migrating the interrupt list.

  KVM_DEV_FLIC_ADAPTER_REGISTER
    Register an I/O adapter interrupt source. Takes a kvm_s390_io_adapter
    describing the adapter to register:

struct kvm_s390_io_adapter {
	__u32 id;
	__u8 isc;
	__u8 maskable;
	__u8 swap;
	__u8 pad;
};

   id contains the unique id for the adapter, isc the I/O interruption subclass
   to use, maskable whether this adapter may be masked (interrupts turned off)
   and swap whether the indicators need to be byte swapped.


  KVM_DEV_FLIC_ADAPTER_MODIFY
    Modifies attributes of an existing I/O adapter interrupt source. Takes
    a kvm_s390_io_adapter_req specifiying the adapter and the operation:

struct kvm_s390_io_adapter_req {
	__u32 id;
	__u8 type;
	__u8 mask;
	__u16 pad0;
	__u64 addr;
};

    id specifies the adapter and type the operation. The supported operations
    are:

    KVM_S390_IO_ADAPTER_MASK
      mask or unmask the adapter, as specified in mask

    KVM_S390_IO_ADAPTER_MAP
      perform a gmap translation for the guest address provided in addr,
      pin a userspace page for the translated address and add it to the
      list of mappings

    KVM_S390_IO_ADAPTER_UNMAP
      release a userspace page for the translated address specified in addr
      from the list of mappings
+32 −0
Original line number Original line Diff line number Diff line
@@ -19,10 +19,19 @@
#include <linux/kvm.h>
#include <linux/kvm.h>
#include <asm/debug.h>
#include <asm/debug.h>
#include <asm/cpu.h>
#include <asm/cpu.h>
#include <asm/isc.h>


#define KVM_MAX_VCPUS 64
#define KVM_MAX_VCPUS 64
#define KVM_USER_MEM_SLOTS 32
#define KVM_USER_MEM_SLOTS 32


/*
 * These seem to be used for allocating ->chip in the routing table,
 * which we don't use. 4096 is an out-of-thin-air value. If we need
 * to look at ->chip later on, we'll need to revisit this.
 */
#define KVM_NR_IRQCHIPS 1
#define KVM_IRQCHIP_NUM_PINS 4096

struct sca_entry {
struct sca_entry {
	atomic_t scn;
	atomic_t scn;
	__u32	reserved;
	__u32	reserved;
@@ -245,6 +254,27 @@ struct kvm_vm_stat {
struct kvm_arch_memory_slot {
struct kvm_arch_memory_slot {
};
};


struct s390_map_info {
	struct list_head list;
	__u64 guest_addr;
	__u64 addr;
	struct page *page;
};

struct s390_io_adapter {
	unsigned int id;
	int isc;
	bool maskable;
	bool masked;
	bool swap;
	struct rw_semaphore maps_lock;
	struct list_head maps;
	atomic_t nr_maps;
};

#define MAX_S390_IO_ADAPTERS ((MAX_ISC + 1) * 8)
#define MAX_S390_ADAPTER_MAPS 256

struct kvm_arch{
struct kvm_arch{
	struct sca_block *sca;
	struct sca_block *sca;
	debug_info_t *dbf;
	debug_info_t *dbf;
@@ -252,6 +282,8 @@ struct kvm_arch{
	struct kvm_device *flic;
	struct kvm_device *flic;
	struct gmap *gmap;
	struct gmap *gmap;
	int css_support;
	int css_support;
	int use_irqchip;
	struct s390_io_adapter *adapters[MAX_S390_IO_ADAPTERS];
};
};


#define KVM_HVA_ERR_BAD		(-1UL)
#define KVM_HVA_ERR_BAD		(-1UL)
+22 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,8 @@
#define KVM_DEV_FLIC_CLEAR_IRQS		3
#define KVM_DEV_FLIC_CLEAR_IRQS		3
#define KVM_DEV_FLIC_APF_ENABLE		4
#define KVM_DEV_FLIC_APF_ENABLE		4
#define KVM_DEV_FLIC_APF_DISABLE_WAIT	5
#define KVM_DEV_FLIC_APF_DISABLE_WAIT	5
#define KVM_DEV_FLIC_ADAPTER_REGISTER	6
#define KVM_DEV_FLIC_ADAPTER_MODIFY	7
/*
/*
 * We can have up to 4*64k pending subchannels + 8 adapter interrupts,
 * We can have up to 4*64k pending subchannels + 8 adapter interrupts,
 * as well as up  to ASYNC_PF_PER_VCPU*KVM_MAX_VCPUS pfault done interrupts.
 * as well as up  to ASYNC_PF_PER_VCPU*KVM_MAX_VCPUS pfault done interrupts.
@@ -32,6 +34,26 @@
#define KVM_S390_MAX_FLOAT_IRQS	266250
#define KVM_S390_MAX_FLOAT_IRQS	266250
#define KVM_S390_FLIC_MAX_BUFFER	0x2000000
#define KVM_S390_FLIC_MAX_BUFFER	0x2000000


struct kvm_s390_io_adapter {
	__u32 id;
	__u8 isc;
	__u8 maskable;
	__u8 swap;
	__u8 pad;
};

#define KVM_S390_IO_ADAPTER_MASK 1
#define KVM_S390_IO_ADAPTER_MAP 2
#define KVM_S390_IO_ADAPTER_UNMAP 3

struct kvm_s390_io_adapter_req {
	__u32 id;
	__u8 type;
	__u8 mask;
	__u16 pad0;
	__u64 addr;
};

/* for KVM_GET_REGS and KVM_SET_REGS */
/* for KVM_GET_REGS and KVM_SET_REGS */
struct kvm_regs {
struct kvm_regs {
	/* general purpose regs for s390 */
	/* general purpose regs for s390 */
+2 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,8 @@ config KVM
	select HAVE_KVM_EVENTFD
	select HAVE_KVM_EVENTFD
	select KVM_ASYNC_PF
	select KVM_ASYNC_PF
	select KVM_ASYNC_PF_SYNC
	select KVM_ASYNC_PF_SYNC
	select HAVE_KVM_IRQCHIP
	select HAVE_KVM_IRQ_ROUTING
	---help---
	---help---
	  Support hosting paravirtualized guest machines using the SIE
	  Support hosting paravirtualized guest machines using the SIE
	  virtualization capability on the mainframe. This should work
	  virtualization capability on the mainframe. This should work
Loading