projects/linux·commit 01227a88

Merge tag 'kvm-3.10-1' of git://git.kernel.org/pub/scm/virt/kvm/kvm

01227a88 · Linus Torvalds <[email protected]> · 2013-05-05 14:47:31 -07:00

Pull kvm updates from Gleb Natapov:
 "Highlights of the updates are:

  general:
   - new emulated device API
   - legacy device assignment is now optional
   - irqfd interface is more generic and can be shared between arches

  x86:
   - VMCS shadow support and other nested VMX improvements
   - APIC virtualization and Posted Interrupt hardware support
   - Optimize mmio spte zapping

  ppc:
    - BookE: in-kernel MPIC emulation with irqfd support
    - Book3S: in-kernel XICS emulation (incomplete)
    - Book3S: HV: migration fixes
    - BookE: more debug support preparation
    - BookE: e6500 support

  ARM:
   - reworking of Hyp idmaps

  s390:
   - ioeventfd for virtio-ccw

  And many other bug fixes, cleanups and improvements"

* tag 'kvm-3.10-1' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (204 commits)
  kvm: Add compat_ioctl for device control API
  KVM: x86: Account for failing enable_irq_window for NMI window request
  KVM: PPC: Book3S: Add API for in-kernel XICS emulation
  kvm/ppc/mpic: fix missing unlock in set_base_addr()
  kvm/ppc: Hold srcu lock when calling kvm_io_bus_read/write
  kvm/ppc/mpic: remove users
  kvm/ppc/mpic: fix mmio region lists when multiple guests used
  kvm/ppc/mpic: remove default routes from documentation
  kvm: KVM_CAP_IOMMU only available with device assignment
  ARM: KVM: iterate over all CPUs for CPU compatibility check
  KVM: ARM: Fix spelling in error message
  ARM: KVM: define KVM_ARM_MAX_VCPUS unconditionally
  KVM: ARM: Fix API documentation for ONE_REG encoding
  ARM: KVM: promote vfp_host pointer to generic host cpu context
  ARM: KVM: add architecture specific hook for capabilities
  ARM: KVM: perform HYP initilization for hotplugged CPUs
  ARM: KVM: switch to a dual-step HYP init code
  ARM: KVM: rework HYP page table freeing
  ARM: KVM: enforce maximum size for identity mapped code
  ARM: KVM: move to a KVM provided HYP idmap
  ...
Commit
01227a889ed56ae53aeebb9f93be9d54dd8b2de8
Parents
9e687946 · db6ae615

Merge commit. Changes below are compared with the first parent: 9e687946.

Changes

110 files changed · +8522 −2270

FileStatusAddDelContent
Documentation/virtual/kvm/api.txtmodified+140−6View file
Documentation/virtual/kvm/devices/READMEadded+1−0View file
Documentation/virtual/kvm/devices/mpic.txtadded+53−0View file
Documentation/virtual/kvm/devices/xics.txtadded+66−0View file
arch/arm/include/asm/idmap.hmodified+0−1View file
arch/arm/include/asm/kvm_host.hmodified+32−15View file
arch/arm/include/asm/kvm_mmu.hmodified+23−5View file
arch/arm/kernel/asm-offsets.cmodified+1−1View file
arch/arm/kernel/vmlinux.lds.Smodified+6−1View file
arch/arm/kvm/Kconfigmodified+3−3View file
arch/arm/kvm/Makefilemodified+1−1View file
arch/arm/kvm/arch_timer.cmodified+4−3View file
arch/arm/kvm/arm.cmodified+75−54View file
arch/arm/kvm/init.Smodified+59−19View file
arch/arm/kvm/mmu.cmodified+257−198View file
arch/arm/kvm/perf.cadded+68−0View file
arch/arm/mm/idmap.cmodified+1−31View file
arch/ia64/include/asm/kvm_host.hmodified+1−0View file
arch/ia64/include/uapi/asm/kvm.hmodified+0−1View file
arch/ia64/kvm/Kconfigmodified+12−2View file
arch/ia64/kvm/Makefilemodified+3−3View file
arch/ia64/kvm/kvm-ia64.cmodified+9−26View file
arch/ia64/kvm/lapic.hmodified+0−6View file
arch/powerpc/include/asm/hvcall.hmodified+3−0View file
arch/powerpc/include/asm/kvm_book3s.hmodified+6−1View file
arch/powerpc/include/asm/kvm_book3s_64.hmodified+13−0View file
arch/powerpc/include/asm/kvm_book3s_asm.hmodified+7−1View file
arch/powerpc/include/asm/kvm_booke.hmodified+2−0View file
arch/powerpc/include/asm/kvm_host.hmodified+40−1View file
arch/powerpc/include/asm/kvm_ppc.hmodified+109−5View file
arch/powerpc/include/asm/reg.hmodified+1−0View file
arch/powerpc/include/uapi/asm/kvm.hmodified+94−0View file
arch/powerpc/kernel/asm-offsets.cmodified+4−0View file
arch/powerpc/kvm/44x.cmodified+12−0View file
arch/powerpc/kvm/Kconfigmodified+23−3View file
arch/powerpc/kvm/Makefilemodified+11−1View file
arch/powerpc/kvm/book3s.cmodified+33−3View file
arch/powerpc/kvm/book3s_64_mmu_hv.cmodified+102−18View file
arch/powerpc/kvm/book3s_emulate.cmodified+3−1View file
arch/powerpc/kvm/book3s_hv.cmodified+76−16View file
arch/powerpc/kvm/book3s_hv_rm_mmu.cmodified+0−11View file
arch/powerpc/kvm/book3s_hv_rm_xics.cadded+406−0View file
arch/powerpc/kvm/book3s_hv_rmhandlers.Smodified+161−67View file
arch/powerpc/kvm/book3s_pr.cmodified+3−4View file
arch/powerpc/kvm/book3s_pr_papr.cmodified+21−0View file
arch/powerpc/kvm/book3s_rtas.cadded+274−0View file
arch/powerpc/kvm/book3s_xics.cadded+1270−0View file
arch/powerpc/kvm/book3s_xics.hadded+130−0View file
arch/powerpc/kvm/booke.cmodified+110−48View file
arch/powerpc/kvm/booke_interrupts.Smodified+39−3View file
arch/powerpc/kvm/e500.cmodified+14−0View file
arch/powerpc/kvm/e500.hmodified+22−0View file
arch/powerpc/kvm/e500_emulate.cmodified+19−0View file
arch/powerpc/kvm/e500_mmu.cmodified+170−22View file
arch/powerpc/kvm/e500mc.cmodified+16−0View file
arch/powerpc/kvm/emulate.cmodified+2−0View file
arch/powerpc/kvm/irq.hadded+20−0View file
arch/powerpc/kvm/mpic.cadded+1853−0View file
arch/powerpc/kvm/powerpc.cmodified+108−25View file
arch/powerpc/sysdev/xics/icp-native.cmodified+8−0View file
arch/s390/include/uapi/asm/Kbuildmodified+1−0View file
arch/s390/include/uapi/asm/virtio-ccw.hadded+21−0View file
arch/s390/kvm/Kconfigmodified+1−0View file
arch/s390/kvm/Makefilemodified+1−1View file
arch/s390/kvm/diag.cmodified+26−0View file
arch/s390/kvm/gaccess.hmodified+73−356View file
arch/s390/kvm/intercept.cmodified+7−11View file
arch/s390/kvm/interrupt.cmodified+73−172View file
arch/s390/kvm/kvm-s390.cmodified+22−21View file
arch/s390/kvm/kvm-s390.hmodified+6−6View file
arch/s390/kvm/priv.cmodified+109−161View file
arch/x86/include/asm/entry_arch.hmodified+4−0View file
arch/x86/include/asm/hardirq.hmodified+3−0View file
arch/x86/include/asm/hw_irq.hmodified+1−0View file
arch/x86/include/asm/irq_vectors.hmodified+5−0View file
arch/x86/include/asm/kvm_host.hmodified+16−10View file
arch/x86/include/asm/vmx.hmodified+18−0View file
arch/x86/include/uapi/asm/kvm.hmodified+0−1View file
arch/x86/include/uapi/asm/msr-index.hmodified+2−0View file
arch/x86/include/uapi/asm/vmx.hmodified+3−2View file
arch/x86/kernel/entry_64.Smodified+5−0View file
arch/x86/kernel/irq.cmodified+22−0View file
arch/x86/kernel/irqinit.cmodified+4−0View file
arch/x86/kernel/kvmclock.cmodified+8−1View file
arch/x86/kvm/Kconfigmodified+12−2View file
arch/x86/kvm/Makefilemodified+3−2View file
arch/x86/kvm/emulate.cmodified+23−8View file
arch/x86/kvm/i8254.cmodified+2−2View file
arch/x86/kvm/lapic.cmodified+107−82View file
arch/x86/kvm/lapic.hmodified+17−5View file
arch/x86/kvm/mmu.cmodified+61−47View file
arch/x86/kvm/mmu.hmodified+4−7View file
arch/x86/kvm/paging_tmpl.hmodified+1−1View file
arch/x86/kvm/pmu.cmodified+11−3View file
arch/x86/kvm/svm.cmodified+20−20View file
arch/x86/kvm/vmx.cmodified+834−243View file
arch/x86/kvm/x86.cmodified+158−85View file
drivers/s390/kvm/kvm_virtio.cmodified+6−5View file
drivers/s390/kvm/virtio_ccw.cmodified+12−8View file
include/linux/kvm_host.hmodified+112−54View file
include/trace/events/kvm.hmodified+10−2View file
include/uapi/linux/kvm.hmodified+39−6View file
virt/kvm/Kconfigmodified+3−0View file
virt/kvm/assigned-dev.cmodified+7−36View file
virt/kvm/eventfd.cmodified+33−20View file
virt/kvm/ioapic.cmodified+132−31View file
virt/kvm/ioapic.hmodified+20−7View file
virt/kvm/irq_comm.cmodified+16−199View file
virt/kvm/irqchip.cadded+237−0View file
virt/kvm/kvm_main.cmodified+211−47View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/virtual/kvm/api.txt

View file
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 119358d..5f91eda 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1486,15 +1486,23 @@ struct kvm_ioeventfd {
__u8 pad[36];
};
+For the special case of virtio-ccw devices on s390, the ioevent is matched
+to a subchannel/virtqueue tuple instead.
+
The following flags are defined:
#define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
#define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
#define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
+#define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \
+ (1 << kvm_ioeventfd_flag_nr_virtio_ccw_notify)
If datamatch flag is set, the event will be signaled only if the written value
to the registered address is equal to datamatch in struct kvm_ioeventfd.
+For virtio-ccw devices, addr contains the subchannel id and datamatch the
+virtqueue index.
+
4.60 KVM_DIRTY_TLB
@@ -1780,27 +1788,48 @@ registers, find a list below:
PPC | KVM_REG_PPC_VPA_DTL | 128
PPC | KVM_REG_PPC_EPCR | 32
PPC | KVM_REG_PPC_EPR | 32
+ PPC | KVM_REG_PPC_TCR | 32
+ PPC | KVM_REG_PPC_TSR | 32
+ PPC | KVM_REG_PPC_OR_TSR | 32
+ PPC | KVM_REG_PPC_CLEAR_TSR | 32
+ PPC | KVM_REG_PPC_MAS0 | 32
+ PPC | KVM_REG_PPC_MAS1 | 32
+ PPC | KVM_REG_PPC_MAS2 | 64
+ PPC | KVM_REG_PPC_MAS7_3 | 64
+ PPC | KVM_REG_PPC_MAS4 | 32
+ PPC | KVM_REG_PPC_MAS6 | 32
+ PPC | KVM_REG_PPC_MMUCFG | 32
+ PPC | KVM_REG_PPC_TLB0CFG | 32
+ PPC | KVM_REG_PPC_TLB1CFG | 32
+ PPC | KVM_REG_PPC_TLB2CFG | 32
+ PPC | KVM_REG_PPC_TLB3CFG | 32
+ PPC | KVM_REG_PPC_TLB0PS | 32
+ PPC | KVM_REG_PPC_TLB1PS | 32
+ PPC | KVM_REG_PPC_TLB2PS | 32
+ PPC | KVM_REG_PPC_TLB3PS | 32
+ PPC | KVM_REG_PPC_EPTCFG | 32
+ PPC | KVM_REG_PPC_ICP_STATE | 64
ARM registers are mapped using the lower 32 bits. The upper 16 of that
is the register group type, or coprocessor number:
ARM core registers have the following id bit patterns:
- 0x4002 0000 0010 <index into the kvm_regs struct:16>
+ 0x4020 0000 0010 <index into the kvm_regs struct:16>
ARM 32-bit CP15 registers have the following id bit patterns:
- 0x4002 0000 000F <zero:1> <crn:4> <crm:4> <opc1:4> <opc2:3>
+ 0x4020 0000 000F <zero:1> <crn:4> <crm:4> <opc1:4> <opc2:3>
ARM 64-bit CP15 registers have the following id bit patterns:
- 0x4003 0000 000F <zero:1> <zero:4> <crm:4> <opc1:4> <zero:3>
+ 0x4030 0000 000F <zero:1> <zero:4> <crm:4> <opc1:4> <zero:3>
ARM CCSIDR registers are demultiplexed by CSSELR value:
- 0x4002 0000 0011 00 <csselr:8>
+ 0x4020 0000 0011 00 <csselr:8>
ARM 32-bit VFP control registers have the following id bit patterns:
- 0x4002 0000 0012 1 <regno:12>
+ 0x4020 0000 0012 1 <regno:12>
ARM 64-bit FP registers have the following id bit patterns:
- 0x4002 0000 0012 0 <regno:12>
+ 0x4030 0000 0012 0 <regno:12>
4.69 KVM_GET_ONE_REG
@@ -2161,6 +2190,76 @@ header; first `n_valid' valid entries with contents from the data
written, then `n_invalid' invalid entries, invalidating any previously
valid entries found.
+4.79 KVM_CREATE_DEVICE
+
+Capability: KVM_CAP_DEVICE_CTRL
+Type: vm ioctl
+Parameters: struct kvm_create_device (in/out)
+Returns: 0 on success, -1 on error
+Errors:
+ ENODEV: The device type is unknown or unsupported
+ EEXIST: Device already created, and this type of device may not
+ be instantiated multiple times
+
+ Other error conditions may be defined by individual device types or
+ have their standard meanings.
+
+Creates an emulated device in the kernel. The file descriptor returned
+in fd can be used with KVM_SET/GET/HAS_DEVICE_ATTR.
+
+If the KVM_CREATE_DEVICE_TEST flag is set, only test whether the
+device type is supported (not necessarily whether it can be created
+in the current vm).
+
+Individual devices should not define flags. Attributes should be used
+for specifying any behavior that is not implied by the device type
+number.
+
+struct kvm_create_device {
+ __u32 type; /* in: KVM_DEV_TYPE_xxx */
+ __u32 fd; /* out: device handle */
+ __u32 flags; /* in: KVM_CREATE_DEVICE_xxx */
+};
+
+4.80 KVM_SET_DEVICE_ATTR/KVM_GET_DEVICE_ATTR
+
+Capability: KVM_CAP_DEVICE_CTRL
+Type: device ioctl
+Parameters: struct kvm_device_attr
+Returns: 0 on success, -1 on error
+Errors:
+ ENXIO: The group or attribute is unknown/unsupported for this device
+ EPERM: The attribute cannot (currently) be accessed this way
+ (e.g. read-only attribute, or attribute that only makes
+ sense when the device is in a different state)
+
+ Other error conditions may be defined by individual device types.
+
+Gets/sets a specified piece of device configuration and/or state. The
+semantics are device-specific. See individual device documentation in
+the "devices" directory. As with ONE_REG, the size of the data
+transferred is defined by the particular attribute.
+
+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 */
+};
+
+4.81 KVM_HAS_DEVICE_ATTR
+
+Capability: KVM_CAP_DEVICE_CTRL
+Type: device ioctl
+Parameters: struct kvm_device_attr
+Returns: 0 on success, -1 on error
+Errors:
+ ENXIO: The group or attribute is unknown/unsupported for this device
+
+Tests whether a device supports a particular attribute. A successful
+return indicates the attribute is implemented. It does not necessarily
+indicate that the attribute can be read or written in the device's
+current state. "addr" is ignored.
4.77 KVM_ARM_VCPU_INIT
@@ -2243,6 +2342,25 @@ and distributor interface, the ioctl must be called after calling
KVM_CREATE_IRQCHIP, but before calling KVM_RUN on any of the VCPUs. Calling
this ioctl twice for any of the base addresses will return -EEXIST.
+4.82 KVM_PPC_RTAS_DEFINE_TOKEN
+
+Capability: KVM_CAP_PPC_RTAS
+Architectures: ppc
+Type: vm ioctl
+Parameters: struct kvm_rtas_token_args
+Returns: 0 on success, -1 on error
+
+Defines a token value for a RTAS (Run Time Abstraction Services)
+service in order to allow it to be handled in the kernel. The
+argument struct gives the name of the service, which must be the name
+of a service that has a kernel-side implementation. If the token
+value is non-zero, it will be associated with that service, and
+subsequent RTAS calls by the guest specifying that token will be
+handled by the kernel. If the token value is 0, then any token
+associated with the service will be forgotten, and subsequent RTAS
+calls by the guest for that service will be passed to userspace to be
+handled.
+
5. The kvm_run structure
------------------------
@@ -2646,3 +2764,19 @@ to receive the topmost interrupt vector.
When disabled (args[0] == 0), behavior is as if this facility is unsupported.
When this capability is enabled, KVM_EXIT_EPR can occur.
+
+6.6 KVM_CAP_IRQ_MPIC
+
+Architectures: ppc
+Parameters: args[0] is the MPIC device fd
+ args[1] is the MPIC CPU number for this vcpu
+
+This capability connects the vcpu to an in-kernel MPIC device.
+
+6.7 KVM_CAP_IRQ_XICS
+
+Architectures: ppc
+Parameters: args[0] is the XICS device fd
+ args[1] is the XICS CPU number (server ID) for this vcpu
+
+This capability connects the vcpu to an in-kernel XICS device.

Documentation/virtual/kvm/devices/README

View file
diff --git a/Documentation/virtual/kvm/devices/README b/Documentation/virtual/kvm/devices/README
new file mode 100644
index 0000000..34a6983
--- /dev/null
+++ b/Documentation/virtual/kvm/devices/README
@@ -0,0 +1 @@
+This directory contains specific device bindings for KVM_CAP_DEVICE_CTRL.

Documentation/virtual/kvm/devices/mpic.txt

View file
diff --git a/Documentation/virtual/kvm/devices/mpic.txt b/Documentation/virtual/kvm/devices/mpic.txt
new file mode 100644
index 0000000..8257397
--- /dev/null
+++ b/Documentation/virtual/kvm/devices/mpic.txt
@@ -0,0 +1,53 @@
+MPIC interrupt controller
+=========================
+
+Device types supported:
+ KVM_DEV_TYPE_FSL_MPIC_20 Freescale MPIC v2.0
+ KVM_DEV_TYPE_FSL_MPIC_42 Freescale MPIC v4.2
+
+Only one MPIC instance, of any type, may be instantiated. The created
+MPIC will act as the system interrupt controller, connecting to each
+vcpu's interrupt inputs.
+
+Groups:
+ KVM_DEV_MPIC_GRP_MISC
+ Attributes:
+ KVM_DEV_MPIC_BASE_ADDR (rw, 64-bit)
+ Base address of the 256 KiB MPIC register space. Must be
+ naturally aligned. A value of zero disables the mapping.
+ Reset value is zero.
+
+ KVM_DEV_MPIC_GRP_REGISTER (rw, 32-bit)
+ Access an MPIC register, as if the access were made from the guest.
+ "attr" is the byte offset into the MPIC register space. Accesses
+ must be 4-byte aligned.
+
+ MSIs may be signaled by using this attribute group to write
+ to the relevant MSIIR.
+
+ KVM_DEV_MPIC_GRP_IRQ_ACTIVE (rw, 32-bit)
+ IRQ input line for each standard openpic source. 0 is inactive and 1
+ is active, regardless of interrupt sense.
+
+ For edge-triggered interrupts: Writing 1 is considered an activating
+ edge, and writing 0 is ignored. Reading returns 1 if a previously
+ signaled edge has not been acknowledged, and 0 otherwise.
+
+ "attr" is the IRQ number. IRQ numbers for standard sources are the
+ byte offset of the relevant IVPR from EIVPR0, divided by 32.
+
+IRQ Routing:
+
+ The MPIC emulation supports IRQ routing. Only a single MPIC device can
+ be instantiated. Once that device has been created, it's available as
+ irqchip id 0.
+
+ This irqchip 0 has 256 interrupt pins, which expose the interrupts in
+ the main array of interrupt sources (a.k.a. "SRC" interrupts).
+
+ The numbering is the same as the MPIC device tree binding -- based on
+ the register offset from the beginning of the sources array, without
+ regard to any subdivisions in chip documentation such as "internal"
+ or "external" interrupts.
+
+ Access to non-SRC interrupts is not implemented through IRQ routing mechanisms.

Documentation/virtual/kvm/devices/xics.txt

View file
diff --git a/Documentation/virtual/kvm/devices/xics.txt b/Documentation/virtual/kvm/devices/xics.txt
new file mode 100644
index 0000000..4286493
--- /dev/null
+++ b/Documentation/virtual/kvm/devices/xics.txt
@@ -0,0 +1,66 @@
+XICS interrupt controller
+
+Device type supported: KVM_DEV_TYPE_XICS
+
+Groups:
+ KVM_DEV_XICS_SOURCES
+ Attributes: One per interrupt source, indexed by the source number.
+
+This device emulates the XICS (eXternal Interrupt Controller
+Specification) defined in PAPR. The XICS has a set of interrupt
+sources, each identified by a 20-bit source number, and a set of
+Interrupt Control Presentation (ICP) entities, also called "servers",
+each associated with a virtual CPU.
+
+The ICP entities are created by enabling the KVM_CAP_IRQ_ARCH
+capability for each vcpu, specifying KVM_CAP_IRQ_XICS in args[0] and
+the interrupt server number (i.e. the vcpu number from the XICS's
+point of view) in args[1] of the kvm_enable_cap struct. Each ICP has
+64 bits of state which can be read and written using the
+KVM_GET_ONE_REG and KVM_SET_ONE_REG ioctls on the vcpu. The 64 bit
+state word has the following bitfields, starting at the
+least-significant end of the word:
+
+* Unused, 16 bits
+
+* Pending interrupt priority, 8 bits
+ Zero is the highest priority, 255 means no interrupt is pending.
+
+* Pending IPI (inter-processor interrupt) priority, 8 bits
+ Zero is the highest priority, 255 means no IPI is pending.
+
+* Pending interrupt source number, 24 bits
+ Zero means no interrupt pending, 2 means an IPI is pending
+
+* Current processor priority, 8 bits
+ Zero is the highest priority, meaning no interrupts can be
+ delivered, and 255 is the lowest priority.
+
+Each source has 64 bits of state that can be read and written using
+the KVM_GET_DEVICE_ATTR and KVM_SET_DEVICE_ATTR ioctls, specifying the
+KVM_DEV_XICS_SOURCES attribute group, with the attribute number being
+the interrupt source number. The 64 bit state word has the following
+bitfields, starting from the least-significant end of the word:
+
+* Destination (server number), 32 bits
+ This specifies where the interrupt should be sent, and is the
+ interrupt server number specified for the destination vcpu.
+
+* Priority, 8 bits
+ This is the priority specified for this interrupt source, where 0 is
+ the highest priority and 255 is the lowest. An interrupt with a
+ priority of 255 will never be delivered.
+
+* Level sensitive flag, 1 bit
+ This bit is 1 for a level-sensitive interrupt source, or 0 for
+ edge-sensitive (or MSI).
+
+* Masked flag, 1 bit
+ This bit is set to 1 if the interrupt is masked (cannot be delivered
+ regardless of its priority), for example by the ibm,int-off RTAS
+ call, or 0 if it is not masked.
+
+* Pending flag, 1 bit
+ This bit is 1 if the source has a pending interrupt, otherwise 0.
+
+Only one XICS instance may be created per VM.

arch/arm/include/asm/idmap.h

View file
diff --git a/arch/arm/include/asm/idmap.h b/arch/arm/include/asm/idmap.h
index 1a66f90..bf863ed 100644
--- a/arch/arm/include/asm/idmap.h
+++ b/arch/arm/include/asm/idmap.h
@@ -8,7 +8,6 @@
#define __idmap __section(.idmap.text) noinline notrace
extern pgd_t *idmap_pgd;
-extern pgd_t *hyp_pgd;
void setup_mm_for_reboot(void);

arch/arm/include/asm/kvm_host.h

View file
diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
index 0c4e643..57cb786 100644
--- a/arch/arm/include/asm/kvm_host.h
+++ b/arch/arm/include/asm/kvm_host.h
@@ -87,7 +87,7 @@ struct kvm_vcpu_fault_info {
u32 hyp_pc; /* PC when exception was taken from Hyp mode */
};
-typedef struct vfp_hard_struct kvm_kernel_vfp_t;
+typedef struct vfp_hard_struct kvm_cpu_context_t;
struct kvm_vcpu_arch {
struct kvm_regs regs;
@@ -105,8 +105,10 @@ struct kvm_vcpu_arch {
struct kvm_vcpu_fault_info fault;
/* Floating point registers (VFP and Advanced SIMD/NEON) */
- kvm_kernel_vfp_t vfp_guest;
- kvm_kernel_vfp_t *vfp_host;
+ struct vfp_hard_struct vfp_guest;
+
+ /* Host FP context */
+ kvm_cpu_context_t *host_cpu_context;
/* VGIC state */
struct vgic_cpu vgic_cpu;
@@ -188,23 +190,38 @@ int kvm_arm_coproc_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *);
int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
int exception_index);
-static inline void __cpu_init_hyp_mode(unsigned long long pgd_ptr,
+static inline void __cpu_init_hyp_mode(unsigned long long boot_pgd_ptr,
+ unsigned long long pgd_ptr,
unsigned long hyp_stack_ptr,
unsigned long vector_ptr)
{
- unsigned long pgd_low, pgd_high;
-
- pgd_low = (pgd_ptr & ((1ULL << 32) - 1));
- pgd_high = (pgd_ptr >> 32ULL);
-
/*
- * Call initialization code, and switch to the full blown
- * HYP code. The init code doesn't need to preserve these registers as
- * r1-r3 and r12 are already callee save according to the AAPCS.
- * Note that we slightly misuse the prototype by casing the pgd_low to
- * a void *.
+ * Call initialization code, and switch to the full blown HYP
+ * code. The init code doesn't need to preserve these
+ * registers as r0-r3 are already callee saved according to
+ * the AAPCS.
+ * Note that we slightly misuse the prototype by casing the
+ * stack pointer to a void *.
+ *
+ * We don't have enough registers to perform the full init in
+ * one go. Install the boot PGD first, and then install the
+ * runtime PGD, stack pointer and vectors. The PGDs are always
+ * passed as the third argument, in order to be passed into
+ * r2-r3 to the init code (yes, this is compliant with the
+ * PCS!).
*/
- kvm_call_hyp((void *)pgd_low, pgd_high, hyp_stack_ptr, vector_ptr);
+
+ kvm_call_hyp(NULL, 0, boot_pgd_ptr);
+
+ kvm_call_hyp((void*)hyp_stack_ptr, vector_ptr, pgd_ptr);
}
+static inline int kvm_arch_dev_ioctl_check_extension(long ext)
+{
+ return 0;
+}
+
+int kvm_perf_init(void);
+int kvm_perf_teardown(void);
+
#endif /* __ARM_KVM_HOST_H__ */

arch/arm/include/asm/kvm_mmu.h

View file
diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h
index 970f3b5..472ac70 100644
--- a/arch/arm/include/asm/kvm_mmu.h
+++ b/arch/arm/include/asm/kvm_mmu.h
@@ -19,21 +19,33 @@
#ifndef __ARM_KVM_MMU_H__
#define __ARM_KVM_MMU_H__
-#include <asm/cacheflush.h>
-#include <asm/pgalloc.h>
-#include <asm/idmap.h>
+#include <asm/memory.h>
+#include <asm/page.h>
/*
* We directly use the kernel VA for the HYP, as we can directly share
* the mapping (HTTBR "covers" TTBR1).
*/
-#define HYP_PAGE_OFFSET_MASK (~0UL)
+#define HYP_PAGE_OFFSET_MASK UL(~0)
#define HYP_PAGE_OFFSET PAGE_OFFSET
#define KERN_TO_HYP(kva) (kva)
+/*
+ * Our virtual mapping for the boot-time MMU-enable code. Must be
+ * shared across all the page-tables. Conveniently, we use the vectors
+ * page, where no kernel data will ever be shared with HYP.
+ */
+#define TRAMPOLINE_VA UL(CONFIG_VECTORS_BASE)
+
+#ifndef __ASSEMBLY__
+
+#include <asm/cacheflush.h>
+#include <asm/pgalloc.h>
+
int create_hyp_mappings(void *from, void *to);
int create_hyp_io_mappings(void *from, void *to, phys_addr_t);
-void free_hyp_pmds(void);
+void free_boot_hyp_pgd(void);
+void free_hyp_pgds(void);
int kvm_alloc_stage2_pgd(struct kvm *kvm);
void kvm_free_stage2_pgd(struct kvm *kvm);
@@ -45,6 +57,8 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run);
void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu);
phys_addr_t kvm_mmu_get_httbr(void);
+phys_addr_t kvm_mmu_get_boot_httbr(void);
+phys_addr_t kvm_get_idmap_vector(void);
int kvm_mmu_init(void);
void kvm_clear_hyp_idmap(void);
@@ -114,4 +128,8 @@ static inline void coherent_icache_guest_page(struct kvm *kvm, gfn_t gfn)
}
}
+#define kvm_flush_dcache_to_poc(a,l) __cpuc_flush_dcache_area((a), (l))
+
+#endif /* !__ASSEMBLY__ */
+
#endif /* __ARM_KVM_MMU_H__ */

arch/arm/kernel/asm-offsets.c

View file
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index a53efa9..ee68cce 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -158,7 +158,7 @@ int main(void)
DEFINE(VCPU_MIDR, offsetof(struct kvm_vcpu, arch.midr));
DEFINE(VCPU_CP15, offsetof(struct kvm_vcpu, arch.cp15));
DEFINE(VCPU_VFP_GUEST, offsetof(struct kvm_vcpu, arch.vfp_guest));
- DEFINE(VCPU_VFP_HOST, offsetof(struct kvm_vcpu, arch.vfp_host));
+ DEFINE(VCPU_VFP_HOST, offsetof(struct kvm_vcpu, arch.host_cpu_context));
DEFINE(VCPU_REGS, offsetof(struct kvm_vcpu, arch.regs));
DEFINE(VCPU_USR_REGS, offsetof(struct kvm_vcpu, arch.regs.usr_regs));
DEFINE(VCPU_SVC_REGS, offsetof(struct kvm_vcpu, arch.regs.svc_regs));

arch/arm/kernel/vmlinux.lds.S

View file
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index b571484..a871b8e 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -20,7 +20,7 @@
VMLINUX_SYMBOL(__idmap_text_start) = .; \
*(.idmap.text) \
VMLINUX_SYMBOL(__idmap_text_end) = .; \
- ALIGN_FUNCTION(); \
+ . = ALIGN(32); \
VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
*(.hyp.idmap.text) \
VMLINUX_SYMBOL(__hyp_idmap_text_end) = .;
@@ -315,3 +315,8 @@ SECTIONS
*/
ASSERT((__proc_info_end - __proc_info_begin), "missing CPU support")
ASSERT((__arch_info_end - __arch_info_begin), "no machine record defined")
+/*
+ * The HYP init code can't be more than a page long.
+ * The above comment applies as well.
+ */
+ASSERT(((__hyp_idmap_text_end - __hyp_idmap_text_start) <= PAGE_SIZE), "HYP init code too big")

arch/arm/kvm/Kconfig

View file
diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index 49dd64e..370e1a8 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -41,9 +41,9 @@ config KVM_ARM_HOST
Provides host support for ARM processors.
config KVM_ARM_MAX_VCPUS
- int "Number maximum supported virtual CPUs per VM"
- depends on KVM_ARM_HOST
- default 4
+ int "Number maximum supported virtual CPUs per VM" if KVM_ARM_HOST
+ default 4 if KVM_ARM_HOST
+ default 0
help
Static number of max supported virtual CPUs per VM.

arch/arm/kvm/Makefile

View file
diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
index 8dc5e76..53c5ed8 100644
--- a/arch/arm/kvm/Makefile
+++ b/arch/arm/kvm/Makefile
@@ -18,6 +18,6 @@ kvm-arm-y = $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o)
obj-y += kvm-arm.o init.o interrupts.o
obj-y += arm.o handle_exit.o guest.o mmu.o emulate.o reset.o
-obj-y += coproc.o coproc_a15.o mmio.o psci.o
+obj-y += coproc.o coproc_a15.o mmio.o psci.o perf.o
obj-$(CONFIG_KVM_ARM_VGIC) += vgic.o
obj-$(CONFIG_KVM_ARM_TIMER) += arch_timer.o

arch/arm/kvm/arch_timer.c

View file
diff --git a/arch/arm/kvm/arch_timer.c b/arch/arm/kvm/arch_timer.c
index 6ac938d..c55b608 100644
--- a/arch/arm/kvm/arch_timer.c
+++ b/arch/arm/kvm/arch_timer.c
@@ -22,6 +22,7 @@
#include <linux/kvm_host.h>
#include <linux/interrupt.h>
+#include <clocksource/arm_arch_timer.h>
#include <asm/arch_timer.h>
#include <asm/kvm_vgic.h>
@@ -64,7 +65,7 @@ static void kvm_timer_inject_irq(struct kvm_vcpu *vcpu)
{
struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
- timer->cntv_ctl |= 1 << 1; /* Mask the interrupt in the guest */
+ timer->cntv_ctl |= ARCH_TIMER_CTRL_IT_MASK;
kvm_vgic_inject_irq(vcpu->kvm, vcpu->vcpu_id,
vcpu->arch.timer_cpu.irq->irq,
vcpu->arch.timer_cpu.irq->level);
@@ -133,8 +134,8 @@ void kvm_timer_sync_hwstate(struct kvm_vcpu *vcpu)
cycle_t cval, now;
u64 ns;
- /* Check if the timer is enabled and unmasked first */
- if ((timer->cntv_ctl & 3) != 1)
+ if ((timer->cntv_ctl & ARCH_TIMER_CTRL_IT_MASK) ||
+ !(timer->cntv_ctl & ARCH_TIMER_CTRL_ENABLE))
return;
cval = timer->cntv_cval;

arch/arm/kvm/arm.c

View file
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index a0dfc2a..37d216d 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -16,6 +16,7 @@
* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include <linux/cpu.h>
#include <linux/errno.h>

This diff is incomplete. Download the complete patch.

arch/arm/kvm/init.S

View file

This diff is incomplete. Download the complete patch.

arch/arm/kvm/mmu.c

View file

This diff is incomplete. Download the complete patch.

arch/arm/kvm/perf.c

View file

This diff is incomplete. Download the complete patch.

arch/arm/mm/idmap.c

View file

This diff is incomplete. Download the complete patch.

arch/ia64/include/asm/kvm_host.h

View file

This diff is incomplete. Download the complete patch.

arch/ia64/include/uapi/asm/kvm.h

View file

This diff is incomplete. Download the complete patch.

arch/ia64/kvm/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/ia64/kvm/Makefile

View file

This diff is incomplete. Download the complete patch.

arch/ia64/kvm/kvm-ia64.c

View file

This diff is incomplete. Download the complete patch.

arch/ia64/kvm/lapic.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/hvcall.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/kvm_book3s.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/kvm_book3s_64.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/kvm_book3s_asm.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/kvm_booke.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/kvm_host.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/kvm_ppc.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/reg.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/uapi/asm/kvm.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kernel/asm-offsets.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/44x.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/Makefile

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_64_mmu_hv.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_emulate.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_hv.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_hv_rm_mmu.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_hv_rm_xics.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_hv_rmhandlers.S

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_pr.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_pr_papr.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_rtas.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_xics.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_xics.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/booke.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/booke_interrupts.S

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/e500.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/e500.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/e500_emulate.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/e500_mmu.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/e500mc.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/emulate.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/irq.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/mpic.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/powerpc.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/sysdev/xics/icp-native.c

View file

This diff is incomplete. Download the complete patch.

arch/s390/include/uapi/asm/Kbuild

View file

This diff is incomplete. Download the complete patch.

arch/s390/include/uapi/asm/virtio-ccw.h

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/Makefile

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/diag.c

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/gaccess.h

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/intercept.c

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/interrupt.c

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/kvm-s390.c

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/kvm-s390.h

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/priv.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/entry_arch.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/hardirq.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/hw_irq.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/irq_vectors.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/kvm_host.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/vmx.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/uapi/asm/kvm.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/uapi/asm/msr-index.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/uapi/asm/vmx.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/entry_64.S

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/irq.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/irqinit.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/kvmclock.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/Makefile

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/emulate.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/i8254.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/lapic.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/lapic.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/mmu.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/mmu.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/paging_tmpl.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/pmu.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/svm.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/vmx.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/x86.c

View file

This diff is incomplete. Download the complete patch.

drivers/s390/kvm/kvm_virtio.c

View file

This diff is incomplete. Download the complete patch.

drivers/s390/kvm/virtio_ccw.c

View file

This diff is incomplete. Download the complete patch.

include/linux/kvm_host.h

View file

This diff is incomplete. Download the complete patch.

include/trace/events/kvm.h

View file

This diff is incomplete. Download the complete patch.

include/uapi/linux/kvm.h

View file

This diff is incomplete. Download the complete patch.

virt/kvm/Kconfig

View file

This diff is incomplete. Download the complete patch.

virt/kvm/assigned-dev.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/eventfd.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/ioapic.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/ioapic.h

View file

This diff is incomplete. Download the complete patch.

virt/kvm/irq_comm.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/irqchip.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/kvm_main.c

View file

This diff is incomplete. Download the complete patch.