projects/linux·commit 66bb0aa0

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

66bb0aa0 · Linus Torvalds <[email protected]> · 2014-08-07 11:35:30 -07:00

Pull second round of KVM changes from Paolo Bonzini:
 "Here are the PPC and ARM changes for KVM, which I separated because
  they had small conflicts (respectively within KVM documentation, and
  with 3.16-rc changes).  Since they were all within the subsystem, I
  took care of them.

  Stephen Rothwell reported some snags in PPC builds, but they are all
  fixed now; the latest linux-next report was clean.

  New features for ARM include:
   - KVM VGIC v2 emulation on GICv3 hardware
   - Big-Endian support for arm/arm64 (guest and host)
   - Debug Architecture support for arm64 (arm32 is on Christoffer's todo list)

  And for PPC:
   - Book3S: Good number of LE host fixes, enable HV on LE
   - Book3S HV: Add in-guest debug support

  This release drops support for KVM on the PPC440.  As a result, the
  PPC merge removes more lines than it adds.  :)

  I also included an x86 change, since Davidlohr tied it to an
  independent bug report and the reporter quickly provided a Tested-by;
  there was no reason to wait for -rc2"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (122 commits)
  KVM: Move more code under CONFIG_HAVE_KVM_IRQFD
  KVM: nVMX: fix "acknowledge interrupt on exit" when APICv is in use
  KVM: nVMX: Fix nested vmexit ack intr before load vmcs01
  KVM: PPC: Enable IRQFD support for the XICS interrupt controller
  KVM: Give IRQFD its own separate enabling Kconfig option
  KVM: Move irq notifier implementation into eventfd.c
  KVM: Move all accesses to kvm::irq_routing into irqchip.c
  KVM: irqchip: Provide and use accessors for irq routing table
  KVM: Don't keep reference to irq routing table in irqfd struct
  KVM: PPC: drop duplicate tracepoint
  arm64: KVM: fix 64bit CP15 VM access for 32bit guests
  KVM: arm64: GICv3: mandate page-aligned GICV region
  arm64: KVM: GICv3: move system register access to msr_s/mrs_s
  KVM: PPC: PR: Handle FSCR feature deselects
  KVM: PPC: HV: Remove generic instruction emulation
  KVM: PPC: BOOKEHV: rename e500hv_spr to bookehv_spr
  KVM: PPC: Remove DCR handling
  KVM: PPC: Expose helper functions for data/inst faults
  KVM: PPC: Separate loadstore emulation from priv emulation
  KVM: PPC: Handle magic page in kvmppc_ld/st
  ...
Commit
66bb0aa077978dbb76e6283531eb3cc7a878de38
Parents
e306e3be · c77dcacb

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

Changes

116 files changed · +5010 −2825

FileStatusAddDelContent
Documentation/arm64/booting.txtmodified+8−0View file
Documentation/devicetree/bindings/arm/gic-v3.txtadded+79−0View file
Documentation/powerpc/00-INDEXmodified+0−2View file
Documentation/powerpc/kvm_440.txtdeleted+0−41View before deletion
Documentation/virtual/kvm/api.txtmodified+52−8View file
arch/arm/include/asm/kvm_asm.hmodified+18−0View file
arch/arm/include/asm/kvm_emulate.hmodified+18−4View file
arch/arm/include/asm/kvm_host.hmodified+5−3View file
arch/arm/include/asm/kvm_mmu.hmodified+12−0View file
arch/arm/kernel/asm-offsets.cmodified+7−7View file
arch/arm/kernel/hyp-stub.Smodified+1−3View file
arch/arm/kvm/Kconfigmodified+1−1View file
arch/arm/kvm/Makefilemodified+1−0View file
arch/arm/kvm/arm.cmodified+1−38View file
arch/arm/kvm/coproc.cmodified+79−9View file
arch/arm/kvm/guest.cmodified+0−10View file
arch/arm/kvm/init.Smodified+2−2View file
arch/arm/kvm/interrupts.Smodified+7−2View file
arch/arm/kvm/interrupts_head.Smodified+31−17View file
arch/arm/kvm/mmu.cmodified+138−76View file
arch/arm64/include/asm/debug-monitors.hmodified+14−5View file
arch/arm64/include/asm/kvm_arm.hmodified+3−2View file
arch/arm64/include/asm/kvm_asm.hmodified+43−10View file
arch/arm64/include/asm/kvm_coproc.hmodified+2−1View file
arch/arm64/include/asm/kvm_emulate.hmodified+22−0View file
arch/arm64/include/asm/kvm_host.hmodified+46−2View file
arch/arm64/include/asm/kvm_mmu.hmodified+15−0View file
arch/arm64/include/asm/virt.hmodified+4−0View file
arch/arm64/kernel/asm-offsets.cmodified+19−7View file
arch/arm64/kernel/debug-monitors.cmodified+0−9View file
arch/arm64/kvm/Makefilemodified+4−0View file
arch/arm64/kvm/guest.cmodified+67−1View file
arch/arm64/kvm/handle_exit.cmodified+2−2View file
arch/arm64/kvm/hyp.Smodified+494−106View file
arch/arm64/kvm/sys_regs.cmodified+473−73View file
arch/arm64/kvm/vgic-v2-switch.Sadded+133−0View file
arch/arm64/kvm/vgic-v3-switch.Sadded+267−0View file
arch/ia64/kvm/Kconfigmodified+1−0View file
arch/ia64/kvm/kvm-ia64.cmodified+1−1View file
arch/mips/kvm/mips.cmodified+1−1View file
arch/powerpc/Kconfig.debugmodified+1−3View file
arch/powerpc/configs/ppc44x_defconfigmodified+0−1View file
arch/powerpc/include/asm/asm-compat.hmodified+4−0View file
arch/powerpc/include/asm/cache.hmodified+7−0View file
arch/powerpc/include/asm/hvcall.hmodified+6−0View file
arch/powerpc/include/asm/kvm_44x.hdeleted+0−67View before deletion
arch/powerpc/include/asm/kvm_asm.hmodified+1−1View file
arch/powerpc/include/asm/kvm_book3s.hmodified+19−32View file
arch/powerpc/include/asm/kvm_book3s_64.hmodified+18−11View file
arch/powerpc/include/asm/kvm_booke.hmodified+10−5View file
arch/powerpc/include/asm/kvm_host.hmodified+16−12View file
arch/powerpc/include/asm/kvm_ppc.hmodified+106−10View file
arch/powerpc/include/asm/mmu-book3e.hmodified+7−1View file
arch/powerpc/include/asm/ppc-opcode.hmodified+17−0View file
arch/powerpc/include/asm/reg.hmodified+10−3View file
arch/powerpc/include/asm/time.hmodified+9−0View file
arch/powerpc/include/uapi/asm/kvm.hmodified+2−0View file
arch/powerpc/kernel/asm-offsets.cmodified+2−0View file
arch/powerpc/kvm/44x.cdeleted+0−237View before deletion
arch/powerpc/kvm/44x_emulate.cdeleted+0−194View before deletion
arch/powerpc/kvm/44x_tlb.cdeleted+0−528View before deletion
arch/powerpc/kvm/44x_tlb.hdeleted+0−86View before deletion
arch/powerpc/kvm/Kconfigmodified+4−16View file
arch/powerpc/kvm/Makefilemodified+4−14View file
arch/powerpc/kvm/book3s.cmodified+75−81View file
arch/powerpc/kvm/book3s_32_mmu.cmodified+1−1View file
arch/powerpc/kvm/book3s_32_mmu_host.cmodified+3−4View file
arch/powerpc/kvm/book3s_64_mmu_host.cmodified+3−2View file
arch/powerpc/kvm/book3s_64_mmu_hv.cmodified+72−73View file
arch/powerpc/kvm/book3s_emulate.cmodified+17−11View file
arch/powerpc/kvm/book3s_hv.cmodified+228−43View file
arch/powerpc/kvm/book3s_hv_builtin.cmodified+13−0View file
arch/powerpc/kvm/book3s_hv_ras.cmodified+3−3View file
arch/powerpc/kvm/book3s_hv_rm_mmu.cmodified+83−63View file
arch/powerpc/kvm/book3s_hv_rm_xics.cmodified+5−0View file
arch/powerpc/kvm/book3s_hv_rmhandlers.Smodified+46−24View file
arch/powerpc/kvm/book3s_paired_singles.cmodified+24−14View file
arch/powerpc/kvm/book3s_pr.cmodified+161−62View file
arch/powerpc/kvm/book3s_pr_papr.cmodified+80−12View file
arch/powerpc/kvm/book3s_xics.cmodified+46−9View file
arch/powerpc/kvm/book3s_xics.hmodified+2−0View file
arch/powerpc/kvm/booke.cmodified+136−89View file
arch/powerpc/kvm/booke.hmodified+0−7View file
arch/powerpc/kvm/booke_emulate.cmodified+4−4View file
arch/powerpc/kvm/booke_interrupts.Smodified+0−5View file
arch/powerpc/kvm/bookehv_interrupts.Smodified+10−50View file
arch/powerpc/kvm/e500_emulate.cmodified+12−0View file
arch/powerpc/kvm/e500_mmu_host.cmodified+102−0View file
arch/powerpc/kvm/e500mc.cmodified+23−5View file
arch/powerpc/kvm/emulate.cmodified+11−195View file
arch/powerpc/kvm/emulate_loadstore.cadded+272−0View file
arch/powerpc/kvm/mpic.cmodified+1−3View file
arch/powerpc/kvm/powerpc.cmodified+163−18View file
arch/powerpc/kvm/timing.cmodified+0−1View file
arch/powerpc/kvm/timing.hmodified+0−3View file
arch/s390/kvm/Kconfigmodified+1−0View file
arch/s390/kvm/interrupt.cmodified+1−2View file
arch/s390/kvm/kvm-s390.cmodified+1−1View file
arch/x86/kvm/Kconfigmodified+1−0View file
arch/x86/kvm/irq.cmodified+1−1View file
arch/x86/kvm/lapic.cmodified+39−13View file
arch/x86/kvm/vmx.cmodified+2−2View file
arch/x86/kvm/x86.cmodified+1−1View file
include/kvm/arm_arch_timer.hmodified+14−0View file
include/kvm/arm_vgic.hmodified+104−11View file
include/linux/kvm_host.hmodified+16−31View file
include/trace/events/kvm.hmodified+4−4View file
include/uapi/linux/kvm.hmodified+4−2View file
virt/kvm/Kconfigmodified+3−0View file
virt/kvm/arm/vgic-v2.cadded+265−0View file
virt/kvm/arm/vgic-v3.cadded+247−0View file
virt/kvm/arm/vgic.cmodified+213−176View file
virt/kvm/eventfd.cmodified+102−32View file
virt/kvm/irq_comm.cmodified+10−14View file
virt/kvm/irqchip.cmodified+37−61View file
virt/kvm/kvm_main.cmodified+34−28View file

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

Documentation/arm64/booting.txt

View file
diff --git a/Documentation/arm64/booting.txt b/Documentation/arm64/booting.txt
index 85af34d..f3c05b5 100644
--- a/Documentation/arm64/booting.txt
+++ b/Documentation/arm64/booting.txt
@@ -168,6 +168,14 @@ Before jumping into the kernel, the following conditions must be met:
the kernel image will be entered must be initialised by software at a
higher exception level to prevent execution in an UNKNOWN state.
+ For systems with a GICv3 interrupt controller:
+ - If EL3 is present:
+ ICC_SRE_EL3.Enable (bit 3) must be initialiased to 0b1.
+ ICC_SRE_EL3.SRE (bit 0) must be initialised to 0b1.
+ - If the kernel is entered at EL1:
+ ICC.SRE_EL2.Enable (bit 3) must be initialised to 0b1
+ ICC_SRE_EL2.SRE (bit 0) must be initialised to 0b1.
+
The requirements described above for CPU mode, caches, MMUs, architected
timers, coherency and system registers apply to all CPUs. All CPUs must
enter the kernel in the same exception level.

Documentation/devicetree/bindings/arm/gic-v3.txt

View file
diff --git a/Documentation/devicetree/bindings/arm/gic-v3.txt b/Documentation/devicetree/bindings/arm/gic-v3.txt
new file mode 100644
index 0000000..33cd05e
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/gic-v3.txt
@@ -0,0 +1,79 @@
+* ARM Generic Interrupt Controller, version 3
+
+AArch64 SMP cores are often associated with a GICv3, providing Private
+Peripheral Interrupts (PPI), Shared Peripheral Interrupts (SPI),
+Software Generated Interrupts (SGI), and Locality-specific Peripheral
+Interrupts (LPI).
+
+Main node required properties:
+
+- compatible : should at least contain "arm,gic-v3".
+- interrupt-controller : Identifies the node as an interrupt controller
+- #interrupt-cells : Specifies the number of cells needed to encode an
+ interrupt source. Must be a single cell with a value of at least 3.
+
+ The 1st cell is the interrupt type; 0 for SPI interrupts, 1 for PPI
+ interrupts. Other values are reserved for future use.
+
+ The 2nd cell contains the interrupt number for the interrupt type.
+ SPI interrupts are in the range [0-987]. PPI interrupts are in the
+ range [0-15].
+
+ The 3rd cell is the flags, encoded as follows:
+ bits[3:0] trigger type and level flags.
+ 1 = edge triggered
+ 4 = level triggered
+
+ Cells 4 and beyond are reserved for future use. When the 1st cell
+ has a value of 0 or 1, cells 4 and beyond act as padding, and may be
+ ignored. It is recommended that padding cells have a value of 0.
+
+- reg : Specifies base physical address(s) and size of the GIC
+ registers, in the following order:
+ - GIC Distributor interface (GICD)
+ - GIC Redistributors (GICR), one range per redistributor region
+ - GIC CPU interface (GICC)
+ - GIC Hypervisor interface (GICH)
+ - GIC Virtual CPU interface (GICV)
+
+ GICC, GICH and GICV are optional.
+
+- interrupts : Interrupt source of the VGIC maintenance interrupt.
+
+Optional
+
+- redistributor-stride : If using padding pages, specifies the stride
+ of consecutive redistributors. Must be a multiple of 64kB.
+
+- #redistributor-regions: The number of independent contiguous regions
+ occupied by the redistributors. Required if more than one such
+ region is present.
+
+Examples:
+
+ gic: interrupt-controller@2cf00000 {
+ compatible = "arm,gic-v3";
+ #interrupt-cells = <3>;
+ interrupt-controller;
+ reg = <0x0 0x2f000000 0 0x10000>, // GICD
+ <0x0 0x2f100000 0 0x200000>, // GICR
+ <0x0 0x2c000000 0 0x2000>, // GICC
+ <0x0 0x2c010000 0 0x2000>, // GICH
+ <0x0 0x2c020000 0 0x2000>; // GICV
+ interrupts = <1 9 4>;
+ };
+
+ gic: interrupt-controller@2c010000 {
+ compatible = "arm,gic-v3";
+ #interrupt-cells = <3>;
+ interrupt-controller;
+ redistributor-stride = <0x0 0x40000>; // 256kB stride
+ #redistributor-regions = <2>;
+ reg = <0x0 0x2c010000 0 0x10000>, // GICD
+ <0x0 0x2d000000 0 0x800000>, // GICR 1: CPUs 0-31
+ <0x0 0x2e000000 0 0x800000>; // GICR 2: CPUs 32-63
+ <0x0 0x2c040000 0 0x2000>, // GICC
+ <0x0 0x2c060000 0 0x2000>, // GICH
+ <0x0 0x2c080000 0 0x2000>; // GICV
+ interrupts = <1 9 4>;
+ };

Documentation/powerpc/00-INDEX

View file
diff --git a/Documentation/powerpc/00-INDEX b/Documentation/powerpc/00-INDEX
index 6db73df..a68784d 100644
--- a/Documentation/powerpc/00-INDEX
+++ b/Documentation/powerpc/00-INDEX
@@ -17,8 +17,6 @@ firmware-assisted-dump.txt
- Documentation on the firmware assisted dump mechanism "fadump".
hvcs.txt
- IBM "Hypervisor Virtual Console Server" Installation Guide
-kvm_440.txt
- - Various notes on the implementation of KVM for PowerPC 440.
mpc52xx.txt
- Linux 2.6.x on MPC52xx family
pmu-ebb.txt

Documentation/powerpc/kvm_440.txt

View before deletion
diff --git a/Documentation/powerpc/kvm_440.txt b/Documentation/powerpc/kvm_440.txt
deleted file mode 100644
index c02a003..0000000
--- a/Documentation/powerpc/kvm_440.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-Hollis Blanchard <[email protected]>
-15 Apr 2008
-
-Various notes on the implementation of KVM for PowerPC 440:
-
-To enforce isolation, host userspace, guest kernel, and guest userspace all
-run at user privilege level. Only the host kernel runs in supervisor mode.
-Executing privileged instructions in the guest traps into KVM (in the host
-kernel), where we decode and emulate them. Through this technique, unmodified
-440 Linux kernels can be run (slowly) as guests. Future performance work will
-focus on reducing the overhead and frequency of these traps.
-
-The usual code flow is started from userspace invoking an "run" ioctl, which
-causes KVM to switch into guest context. We use IVPR to hijack the host
-interrupt vectors while running the guest, which allows us to direct all
-interrupts to kvmppc_handle_interrupt(). At this point, we could either
-- handle the interrupt completely (e.g. emulate "mtspr SPRG0"), or
-- let the host interrupt handler run (e.g. when the decrementer fires), or
-- return to host userspace (e.g. when the guest performs device MMIO)
-
-Address spaces: We take advantage of the fact that Linux doesn't use the AS=1
-address space (in host or guest), which gives us virtual address space to use
-for guest mappings. While the guest is running, the host kernel remains mapped
-in AS=0, but the guest can only use AS=1 mappings.
-
-TLB entries: The TLB entries covering the host linear mapping remain
-present while running the guest. This reduces the overhead of lightweight
-exits, which are handled by KVM running in the host kernel. We keep three
-copies of the TLB:
- - guest TLB: contents of the TLB as the guest sees it
- - shadow TLB: the TLB that is actually in hardware while guest is running
- - host TLB: to restore TLB state when context switching guest -> host
-When a TLB miss occurs because a mapping was not present in the shadow TLB,
-but was present in the guest TLB, KVM handles the fault without invoking the
-guest. Large guest pages are backed by multiple 4KB shadow pages through this
-mechanism.
-
-IO: MMIO and DCR accesses are emulated by userspace. We use virtio for network
-and block IO, so those drivers must be enabled in the guest. It's possible
-that some qemu device emulation (e.g. e1000 or rtl8139) may also work with
-little effort.

Documentation/virtual/kvm/api.txt

View file
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 68cda1f..beae3fd 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -148,9 +148,9 @@ of banks, as set via the KVM_X86_SETUP_MCE ioctl.
4.4 KVM_CHECK_EXTENSION
-Capability: basic
+Capability: basic, KVM_CAP_CHECK_EXTENSION_VM for vm ioctl
Architectures: all
-Type: system ioctl
+Type: system ioctl, vm ioctl
Parameters: extension identifier (KVM_CAP_*)
Returns: 0 if unsupported; 1 (or some other positive integer) if supported
@@ -160,6 +160,9 @@ receives an integer that describes the extension availability.
Generally 0 means no and 1 means yes, but some extensions may report
additional information in the integer return value.
+Based on their initialization different VMs may have different capabilities.
+It is thus encouraged to use the vm ioctl to query for capabilities (available
+with KVM_CAP_CHECK_EXTENSION_VM on the vm fd)
4.5 KVM_GET_VCPU_MMAP_SIZE
@@ -1892,7 +1895,8 @@ registers, find a list below:
PPC | KVM_REG_PPC_PID | 64
PPC | KVM_REG_PPC_ACOP | 64
PPC | KVM_REG_PPC_VRSAVE | 32
- PPC | KVM_REG_PPC_LPCR | 64
+ PPC | KVM_REG_PPC_LPCR | 32
+ PPC | KVM_REG_PPC_LPCR_64 | 64
PPC | KVM_REG_PPC_PPR | 64
PPC | KVM_REG_PPC_ARCH_COMPAT | 32
PPC | KVM_REG_PPC_DABRX | 32
@@ -2677,8 +2681,8 @@ The 'data' member contains, in its first 'len' bytes, the value as it would
appear if the VCPU performed a load or store of the appropriate width directly
to the byte array.
-NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_DCR,
- KVM_EXIT_PAPR and KVM_EXIT_EPR the corresponding
+NOTE: For KVM_EXIT_IO, KVM_EXIT_MMIO, KVM_EXIT_OSI, KVM_EXIT_PAPR and
+ KVM_EXIT_EPR the corresponding
operations are complete (and guest state is consistent) only after userspace
has re-entered the kernel with KVM_RUN. The kernel side will first finish
incomplete operations and then check for pending signals. Userspace
@@ -2749,7 +2753,7 @@ Principles of Operation Book in the Chapter for Dynamic Address Translation
__u8 is_write;
} dcr;
-powerpc specific.
+Deprecated - was used for 440 KVM.
/* KVM_EXIT_OSI */
struct {
@@ -2931,8 +2935,8 @@ The fields in each entry are defined as follows:
this function/index combination
-6. Capabilities that can be enabled
------------------------------------
+6. Capabilities that can be enabled on vCPUs
+--------------------------------------------
There are certain capabilities that change the behavior of the virtual CPU or
the virtual machine when enabled. To enable them, please see section 4.37.
@@ -3091,3 +3095,43 @@ Parameters: none
This capability enables the in-kernel irqchip for s390. Please refer to
"4.24 KVM_CREATE_IRQCHIP" for details.
+
+7. Capabilities that can be enabled on VMs
+------------------------------------------
+
+There are certain capabilities that change the behavior of the virtual
+machine when enabled. To enable them, please see section 4.37. Below
+you can find a list of capabilities and what their effect on the VM
+is when enabling them.
+
+The following information is provided along with the description:
+
+ Architectures: which instruction set architectures provide this ioctl.
+ x86 includes both i386 and x86_64.
+
+ Parameters: what parameters are accepted by the capability.
+
+ Returns: the return value. General error numbers (EBADF, ENOMEM, EINVAL)
+ are not detailed, but errors with specific meanings are.
+
+
+7.1 KVM_CAP_PPC_ENABLE_HCALL
+
+Architectures: ppc
+Parameters: args[0] is the sPAPR hcall number
+ args[1] is 0 to disable, 1 to enable in-kernel handling
+
+This capability controls whether individual sPAPR hypercalls (hcalls)
+get handled by the kernel or not. Enabling or disabling in-kernel
+handling of an hcall is effective across the VM. On creation, an
+initial set of hcalls are enabled for in-kernel handling, which
+consists of those hcalls for which in-kernel handlers were implemented
+before this capability was implemented. If disabled, the kernel will
+not to attempt to handle the hcall, but will always exit to userspace
+to handle it. Note that it may not make sense to enable some and
+disable others of a group of related hcalls, but KVM does not prevent
+userspace from doing that.
+
+If the hcall number specified is not one that has an in-kernel
+implementation, the KVM_ENABLE_CAP ioctl will fail with an EINVAL
+error.

arch/arm/include/asm/kvm_asm.h

View file
diff --git a/arch/arm/include/asm/kvm_asm.h b/arch/arm/include/asm/kvm_asm.h
index 53b3c4a..3a67bec 100644
--- a/arch/arm/include/asm/kvm_asm.h
+++ b/arch/arm/include/asm/kvm_asm.h
@@ -61,6 +61,24 @@
#define ARM_EXCEPTION_FIQ 6
#define ARM_EXCEPTION_HVC 7
+/*
+ * The rr_lo_hi macro swaps a pair of registers depending on
+ * current endianness. It is used in conjunction with ldrd and strd
+ * instructions that load/store a 64-bit value from/to memory to/from
+ * a pair of registers which are used with the mrrc and mcrr instructions.
+ * If used with the ldrd/strd instructions, the a1 parameter is the first
+ * source/destination register and the a2 parameter is the second
+ * source/destination register. Note that the ldrd/strd instructions
+ * already swap the bytes within the words correctly according to the
+ * endianness setting, but the order of the registers need to be effectively
+ * swapped when used with the mrrc/mcrr instructions.
+ */
+#ifdef CONFIG_CPU_ENDIAN_BE8
+#define rr_lo_hi(a1, a2) a2, a1
+#else
+#define rr_lo_hi(a1, a2) a1, a2
+#endif
+
#ifndef __ASSEMBLY__
struct kvm;
struct kvm_vcpu;

arch/arm/include/asm/kvm_emulate.h

View file
diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h
index 0fa90c9..69b7469 100644
--- a/arch/arm/include/asm/kvm_emulate.h
+++ b/arch/arm/include/asm/kvm_emulate.h
@@ -185,9 +185,16 @@ static inline unsigned long vcpu_data_guest_to_host(struct kvm_vcpu *vcpu,
default:
return be32_to_cpu(data);
}
+ } else {
+ switch (len) {
+ case 1:
+ return data & 0xff;
+ case 2:
+ return le16_to_cpu(data & 0xffff);
+ default:
+ return le32_to_cpu(data);
+ }
}
-
- return data; /* Leave LE untouched */
}
static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu,
@@ -203,9 +210,16 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu,
default:
return cpu_to_be32(data);
}
+ } else {
+ switch (len) {
+ case 1:
+ return data & 0xff;
+ case 2:
+ return cpu_to_le16(data & 0xffff);
+ default:
+ return cpu_to_le32(data);
+ }
}
-
- return data; /* Leave LE untouched */
}
#endif /* __ARM_KVM_EMULATE_H__ */

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 193ceaf..6dfb404 100644
--- a/arch/arm/include/asm/kvm_host.h
+++ b/arch/arm/include/asm/kvm_host.h
@@ -225,10 +225,12 @@ static inline int kvm_arch_dev_ioctl_check_extension(long ext)
return 0;
}
+static inline void vgic_arch_setup(const struct vgic_params *vgic)
+{
+ BUG_ON(vgic->type != VGIC_V2);
+}
+
int kvm_perf_init(void);
int kvm_perf_teardown(void);
-u64 kvm_arm_timer_get_reg(struct kvm_vcpu *, u64 regid);
-int kvm_arm_timer_set_reg(struct kvm_vcpu *, u64 regid, u64 value);
-
#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 5c7aa3c..5cc0b0f 100644
--- a/arch/arm/include/asm/kvm_mmu.h
+++ b/arch/arm/include/asm/kvm_mmu.h
@@ -127,6 +127,18 @@ static inline void kvm_set_s2pmd_writable(pmd_t *pmd)
(__boundary - 1 < (end) - 1)? __boundary: (end); \
})
+static inline bool kvm_page_empty(void *ptr)
+{
+ struct page *ptr_page = virt_to_page(ptr);
+ return page_count(ptr_page) == 1;
+}
+
+
+#define kvm_pte_table_empty(ptep) kvm_page_empty(ptep)
+#define kvm_pmd_table_empty(pmdp) kvm_page_empty(pmdp)
+#define kvm_pud_table_empty(pudp) (0)
+
+
struct kvm;
#define kvm_flush_dcache_to_poc(a,l) __cpuc_flush_dcache_area((a), (l))

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 85598b5..713e807 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -182,13 +182,13 @@ int main(void)
DEFINE(VCPU_HYP_PC, offsetof(struct kvm_vcpu, arch.fault.hyp_pc));
#ifdef CONFIG_KVM_ARM_VGIC
DEFINE(VCPU_VGIC_CPU, offsetof(struct kvm_vcpu, arch.vgic_cpu));
- DEFINE(VGIC_CPU_HCR, offsetof(struct vgic_cpu, vgic_hcr));
- DEFINE(VGIC_CPU_VMCR, offsetof(struct vgic_cpu, vgic_vmcr));
- DEFINE(VGIC_CPU_MISR, offsetof(struct vgic_cpu, vgic_misr));
- DEFINE(VGIC_CPU_EISR, offsetof(struct vgic_cpu, vgic_eisr));
- DEFINE(VGIC_CPU_ELRSR, offsetof(struct vgic_cpu, vgic_elrsr));
- DEFINE(VGIC_CPU_APR, offsetof(struct vgic_cpu, vgic_apr));
- DEFINE(VGIC_CPU_LR, offsetof(struct vgic_cpu, vgic_lr));
+ DEFINE(VGIC_V2_CPU_HCR, offsetof(struct vgic_cpu, vgic_v2.vgic_hcr));
+ DEFINE(VGIC_V2_CPU_VMCR, offsetof(struct vgic_cpu, vgic_v2.vgic_vmcr));
+ DEFINE(VGIC_V2_CPU_MISR, offsetof(struct vgic_cpu, vgic_v2.vgic_misr));
+ DEFINE(VGIC_V2_CPU_EISR, offsetof(struct vgic_cpu, vgic_v2.vgic_eisr));
+ DEFINE(VGIC_V2_CPU_ELRSR, offsetof(struct vgic_cpu, vgic_v2.vgic_elrsr));
+ DEFINE(VGIC_V2_CPU_APR, offsetof(struct vgic_cpu, vgic_v2.vgic_apr));
+ DEFINE(VGIC_V2_CPU_LR, offsetof(struct vgic_cpu, vgic_v2.vgic_lr));
DEFINE(VGIC_CPU_NR_LR, offsetof(struct vgic_cpu, nr_lr));
#ifdef CONFIG_KVM_ARM_TIMER
DEFINE(VCPU_TIMER_CNTV_CTL, offsetof(struct kvm_vcpu, arch.timer_cpu.cntv_ctl));

arch/arm/kernel/hyp-stub.S

View file
diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S
index 56ce629..2a55373 100644
--- a/arch/arm/kernel/hyp-stub.S
+++ b/arch/arm/kernel/hyp-stub.S
@@ -134,9 +134,7 @@ ENTRY(__hyp_stub_install_secondary)
mcr p15, 4, r7, c1, c1, 3 @ HSTR
THUMB( orr r7, #(1 << 30) ) @ HSCTLR.TE
-#ifdef CONFIG_CPU_BIG_ENDIAN
- orr r7, #(1 << 9) @ HSCTLR.EE
-#endif
+ARM_BE8(orr r7, r7, #(1 << 25)) @ HSCTLR.EE
mcr p15, 4, r7, c1, c0, 0 @ HSCTLR
mrc p15, 4, r7, c1, c1, 1 @ HDCR

arch/arm/kvm/Kconfig

View file
diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index 4be5bb1..466bd29 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -23,7 +23,7 @@ config KVM
select HAVE_KVM_CPU_RELAX_INTERCEPT
select KVM_MMIO
select KVM_ARM_HOST
- depends on ARM_VIRT_EXT && ARM_LPAE && !CPU_BIG_ENDIAN
+ depends on ARM_VIRT_EXT && ARM_LPAE
---help---
Support hosting virtualized guest machines. You will also
need to select one or more of the processor modules below.

arch/arm/kvm/Makefile

View file
diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
index 789bca9..f7057ed 100644
--- a/arch/arm/kvm/Makefile
+++ b/arch/arm/kvm/Makefile
@@ -21,4 +21,5 @@ 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 coproc_a7.o mmio.o psci.o perf.o
obj-$(CONFIG_KVM_ARM_VGIC) += $(KVM)/arm/vgic.o
+obj-$(CONFIG_KVM_ARM_VGIC) += $(KVM)/arm/vgic-v2.o
obj-$(CONFIG_KVM_ARM_TIMER) += $(KVM)/arm/arch_timer.o

arch/arm/kvm/arm.c

View file
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 3c82b37..a99e0cd 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -155,16 +155,6 @@ int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
return VM_FAULT_SIGBUS;
}
-void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
- struct kvm_memory_slot *dont)
-{
-}
-
-int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
- unsigned long npages)
-{
- return 0;
-}
/**
* kvm_arch_destroy_vm - destroy the VM data structure
@@ -184,7 +174,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
}
}
-int kvm_dev_ioctl_check_extension(long ext)
+int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
{
int r;
switch (ext) {
@@ -225,33 +215,6 @@ long kvm_arch_dev_ioctl(struct file *filp,
return -EINVAL;
}
-void kvm_arch_memslots_updated(struct kvm *kvm)
-{
-}
-
-int kvm_arch_prepare_memory_region(struct kvm *kvm,
- struct kvm_memory_slot *memslot,
- struct kvm_userspace_memory_region *mem,
- enum kvm_mr_change change)
-{
- return 0;
-}
-
-void kvm_arch_commit_memory_region(struct kvm *kvm,
- struct kvm_userspace_memory_region *mem,
- const struct kvm_memory_slot *old,
- enum kvm_mr_change change)
-{
-}
-
-void kvm_arch_flush_shadow_all(struct kvm *kvm)
-{
-}
-
-void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
- struct kvm_memory_slot *slot)
-{
-}
struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
{

arch/arm/kvm/coproc.c

View file
diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c
index c58a351..37a0fe1 100644
--- a/arch/arm/kvm/coproc.c
+++ b/arch/arm/kvm/coproc.c
@@ -44,6 +44,31 @@ static u32 cache_levels;
/* CSSELR values; used to index KVM_REG_ARM_DEMUX_ID_CCSIDR */
#define CSSELR_MAX 12
+/*
+ * kvm_vcpu_arch.cp15 holds cp15 registers as an array of u32, but some
+ * of cp15 registers can be viewed either as couple of two u32 registers
+ * or one u64 register. Current u64 register encoding is that least
+ * significant u32 word is followed by most significant u32 word.
+ */
+static inline void vcpu_cp15_reg64_set(struct kvm_vcpu *vcpu,
+ const struct coproc_reg *r,
+ u64 val)
+{
+ vcpu->arch.cp15[r->reg] = val & 0xffffffff;
+ vcpu->arch.cp15[r->reg + 1] = val >> 32;
+}
+
+static inline u64 vcpu_cp15_reg64_get(struct kvm_vcpu *vcpu,
+ const struct coproc_reg *r)
+{
+ u64 val;
+
+ val = vcpu->arch.cp15[r->reg + 1];
+ val = val << 32;
+ val = val | vcpu->arch.cp15[r->reg];
+ return val;
+}
+
int kvm_handle_cp10_id(struct kvm_vcpu *vcpu, struct kvm_run *run)
{
kvm_inject_undefined(vcpu);
@@ -682,17 +707,23 @@ static struct coproc_reg invariant_cp15[] = {
{ CRn( 0), CRm( 0), Op1( 1), Op2( 7), is32, NULL, get_AIDR },
};
+/*
+ * Reads a register value from a userspace address to a kernel
+ * variable. Make sure that register size matches sizeof(*__val).
+ */
static int reg_from_user(void *val, const void __user *uaddr, u64 id)
{
- /* This Just Works because we are little endian. */
if (copy_from_user(val, uaddr, KVM_REG_SIZE(id)) != 0)
return -EFAULT;
return 0;
}
+/*
+ * Writes a register value to a userspace address from a kernel variable.
+ * Make sure that register size matches sizeof(*__val).
+ */
static int reg_to_user(void __user *uaddr, const void *val, u64 id)
{
- /* This Just Works because we are little endian. */
if (copy_to_user(uaddr, val, KVM_REG_SIZE(id)) != 0)
return -EFAULT;
return 0;
@@ -702,6 +733,7 @@ static int get_invariant_cp15(u64 id, void __user *uaddr)
{
struct coproc_params params;
const struct coproc_reg *r;
+ int ret;
if (!index_to_params(id, &params))
return -ENOENT;
@@ -710,7 +742,15 @@ static int get_invariant_cp15(u64 id, void __user *uaddr)
if (!r)
return -ENOENT;
- return reg_to_user(uaddr, &r->val, id);
+ ret = -ENOENT;
+ if (KVM_REG_SIZE(id) == 4) {
+ u32 val = r->val;
+
+ ret = reg_to_user(uaddr, &val, id);
+ } else if (KVM_REG_SIZE(id) == 8) {
+ ret = reg_to_user(uaddr, &r->val, id);
+ }
+ return ret;

This diff is incomplete. Download the complete patch.

arch/arm/kvm/guest.c

View file

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/interrupts.S

View file

This diff is incomplete. Download the complete patch.

arch/arm/kvm/interrupts_head.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/arm64/include/asm/debug-monitors.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/kvm_arm.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/kvm_asm.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/kvm_coproc.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/kvm_emulate.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/kvm_host.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/kvm_mmu.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/virt.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/asm-offsets.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/debug-monitors.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/Makefile

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/guest.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/handle_exit.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/hyp.S

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/sys_regs.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/vgic-v2-switch.S

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/vgic-v3-switch.S

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/kvm-ia64.c

View file

This diff is incomplete. Download the complete patch.

arch/mips/kvm/mips.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/Kconfig.debug

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/configs/ppc44x_defconfig

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/asm-compat.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/cache.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_44x.h

View before deletion

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/kvm_asm.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_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/mmu-book3e.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/ppc-opcode.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/asm/time.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 before deletion

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/44x_emulate.c

View before deletion

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/44x_tlb.c

View before deletion

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/44x_tlb.h

View before deletion

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_32_mmu.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_32_mmu_host.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_64_mmu_host.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_builtin.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_hv_ras.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_paired_singles.c

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_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.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/booke_emulate.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/bookehv_interrupts.S

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_host.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/emulate_loadstore.c

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/kvm/timing.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/timing.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/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/x86/kvm/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/irq.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/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.

include/kvm/arm_arch_timer.h

View file

This diff is incomplete. Download the complete patch.

include/kvm/arm_vgic.h

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/arm/vgic-v2.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/vgic-v3.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/vgic.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/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.