]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.14-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Jul 2015 18:31:26 +0000 (11:31 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Jul 2015 18:31:26 +0000 (11:31 -0700)
added patches:
arm-arm64-kvm-correct-kvm_arm_vcpu_init-power-off-option.patch
arm-arm64-kvm-don-t-allow-creating-vcpus-after-vgic_initialized.patch
arm-arm64-kvm-don-t-clear-the-vcpu_power_off-flag.patch
arm-arm64-kvm-drop-inappropriate-use-of-kvm_is_mmio_pfn.patch
arm-arm64-kvm-introduce-stage2_unmap_vm.patch
arm-arm64-kvm-reset-the-hcr-on-each-vcpu-when-resetting-the.patch

queue-3.14/arm-arm64-kvm-correct-kvm_arm_vcpu_init-power-off-option.patch [new file with mode: 0644]
queue-3.14/arm-arm64-kvm-don-t-allow-creating-vcpus-after-vgic_initialized.patch [new file with mode: 0644]
queue-3.14/arm-arm64-kvm-don-t-clear-the-vcpu_power_off-flag.patch [new file with mode: 0644]
queue-3.14/arm-arm64-kvm-drop-inappropriate-use-of-kvm_is_mmio_pfn.patch [new file with mode: 0644]
queue-3.14/arm-arm64-kvm-introduce-stage2_unmap_vm.patch [new file with mode: 0644]
queue-3.14/arm-arm64-kvm-reset-the-hcr-on-each-vcpu-when-resetting-the.patch [new file with mode: 0644]
queue-3.14/series

diff --git a/queue-3.14/arm-arm64-kvm-correct-kvm_arm_vcpu_init-power-off-option.patch b/queue-3.14/arm-arm64-kvm-correct-kvm_arm_vcpu_init-power-off-option.patch
new file mode 100644 (file)
index 0000000..3ff5943
--- /dev/null
@@ -0,0 +1,49 @@
+From 3ad8b3de526a76fbe9466b366059e4958957b88f Mon Sep 17 00:00:00 2001
+From: Christoffer Dall <christoffer.dall@linaro.org>
+Date: Thu, 16 Oct 2014 16:14:43 +0200
+Subject: arm/arm64: KVM: Correct KVM_ARM_VCPU_INIT power off option
+
+From: Christoffer Dall <christoffer.dall@linaro.org>
+
+commit 3ad8b3de526a76fbe9466b366059e4958957b88f upstream.
+
+The implementation of KVM_ARM_VCPU_INIT is currently not doing what
+userspace expects, namely making sure that a vcpu which may have been
+turned off using PSCI is returned to its initial state, which would be
+powered on if userspace does not set the KVM_ARM_VCPU_POWER_OFF flag.
+
+Implement the expected functionality and clarify the ABI.
+
+Acked-by: Marc Zyngier <marc.zyngier@arm.com>
+Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
+Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ Documentation/virtual/kvm/api.txt |    3 ++-
+ arch/arm/kvm/arm.c                |    2 ++
+ 2 files changed, 4 insertions(+), 1 deletion(-)
+
+--- a/Documentation/virtual/kvm/api.txt
++++ b/Documentation/virtual/kvm/api.txt
+@@ -2344,7 +2344,8 @@ should be created before this ioctl is i
+ Possible features:
+       - KVM_ARM_VCPU_POWER_OFF: Starts the CPU in a power-off state.
+-        Depends on KVM_CAP_ARM_PSCI.
++        Depends on KVM_CAP_ARM_PSCI.  If not set, the CPU will be powered on
++        and execute guest code when KVM_RUN is called.
+       - KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode.
+         Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only).
+--- a/arch/arm/kvm/arm.c
++++ b/arch/arm/kvm/arm.c
+@@ -680,6 +680,8 @@ static int kvm_arch_vcpu_ioctl_vcpu_init
+        */
+       if (test_bit(KVM_ARM_VCPU_POWER_OFF, vcpu->arch.features))
+               vcpu->arch.pause = true;
++      else
++              vcpu->arch.pause = false;
+       return 0;
+ }
diff --git a/queue-3.14/arm-arm64-kvm-don-t-allow-creating-vcpus-after-vgic_initialized.patch b/queue-3.14/arm-arm64-kvm-don-t-allow-creating-vcpus-after-vgic_initialized.patch
new file mode 100644 (file)
index 0000000..b5ce520
--- /dev/null
@@ -0,0 +1,38 @@
+From 716139df2517fbc3f2306dbe8eba0fa88dca0189 Mon Sep 17 00:00:00 2001
+From: Christoffer Dall <christoffer.dall@linaro.org>
+Date: Tue, 9 Dec 2014 14:33:45 +0100
+Subject: arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized
+
+From: Christoffer Dall <christoffer.dall@linaro.org>
+
+commit 716139df2517fbc3f2306dbe8eba0fa88dca0189 upstream.
+
+When the vgic initializes its internal state it does so based on the
+number of VCPUs available at the time.  If we allow KVM to create more
+VCPUs after the VGIC has been initialized, we are likely to error out in
+unfortunate ways later, perform buffer overflows etc.
+
+Acked-by: Marc Zyngier <marc.zyngier@arm.com>
+Reviewed-by: Eric Auger <eric.auger@linaro.org>
+Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
+Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/kvm/arm.c |    5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/arch/arm/kvm/arm.c
++++ b/arch/arm/kvm/arm.c
+@@ -220,6 +220,11 @@ struct kvm_vcpu *kvm_arch_vcpu_create(st
+       int err;
+       struct kvm_vcpu *vcpu;
++      if (irqchip_in_kernel(kvm) && vgic_initialized(kvm)) {
++              err = -EBUSY;
++              goto out;
++      }
++
+       vcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
+       if (!vcpu) {
+               err = -ENOMEM;
diff --git a/queue-3.14/arm-arm64-kvm-don-t-clear-the-vcpu_power_off-flag.patch b/queue-3.14/arm-arm64-kvm-don-t-clear-the-vcpu_power_off-flag.patch
new file mode 100644 (file)
index 0000000..6e06519
--- /dev/null
@@ -0,0 +1,34 @@
+From 03f1d4c17edb31b41b14ca3a749ae38d2dd6639d Mon Sep 17 00:00:00 2001
+From: Christoffer Dall <christoffer.dall@linaro.org>
+Date: Tue, 2 Dec 2014 15:27:51 +0100
+Subject: arm/arm64: KVM: Don't clear the VCPU_POWER_OFF flag
+
+From: Christoffer Dall <christoffer.dall@linaro.org>
+
+commit 03f1d4c17edb31b41b14ca3a749ae38d2dd6639d upstream.
+
+If a VCPU was originally started with power off (typically to be brought
+up by PSCI in SMP configurations), there is no need to clear the
+POWER_OFF flag in the kernel, as this flag is only tested during the
+init ioctl itself.
+
+Acked-by: Marc Zyngier <marc.zyngier@arm.com>
+Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
+Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/kvm/arm.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/arm/kvm/arm.c
++++ b/arch/arm/kvm/arm.c
+@@ -678,7 +678,7 @@ static int kvm_arch_vcpu_ioctl_vcpu_init
+       /*
+        * Handle the "start in power-off" case by marking the VCPU as paused.
+        */
+-      if (__test_and_clear_bit(KVM_ARM_VCPU_POWER_OFF, vcpu->arch.features))
++      if (test_bit(KVM_ARM_VCPU_POWER_OFF, vcpu->arch.features))
+               vcpu->arch.pause = true;
+       return 0;
diff --git a/queue-3.14/arm-arm64-kvm-drop-inappropriate-use-of-kvm_is_mmio_pfn.patch b/queue-3.14/arm-arm64-kvm-drop-inappropriate-use-of-kvm_is_mmio_pfn.patch
new file mode 100644 (file)
index 0000000..0e09e6e
--- /dev/null
@@ -0,0 +1,47 @@
+From 07a9748c78cfc39b54f06125a216b67b9c8f09ed Mon Sep 17 00:00:00 2001
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Date: Mon, 10 Nov 2014 08:33:55 +0000
+Subject: arm/arm64: kvm: drop inappropriate use of kvm_is_mmio_pfn()
+
+From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+
+commit 07a9748c78cfc39b54f06125a216b67b9c8f09ed upstream.
+
+Instead of using kvm_is_mmio_pfn() to decide whether a host region
+should be stage 2 mapped with device attributes, add a new static
+function kvm_is_device_pfn() that disregards RAM pages with the
+reserved bit set, as those should usually not be mapped as device
+memory.
+
+Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
+Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/kvm/mmu.c |    7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+--- a/arch/arm/kvm/mmu.c
++++ b/arch/arm/kvm/mmu.c
+@@ -755,6 +755,11 @@ static bool kvm_is_write_fault(struct kv
+       return kvm_vcpu_dabt_iswrite(vcpu);
+ }
++static bool kvm_is_device_pfn(unsigned long pfn)
++{
++      return !pfn_valid(pfn);
++}
++
+ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
+                         struct kvm_memory_slot *memslot,
+                         unsigned long fault_status)
+@@ -825,7 +830,7 @@ static int user_mem_abort(struct kvm_vcp
+       if (is_error_pfn(pfn))
+               return -EFAULT;
+-      if (kvm_is_mmio_pfn(pfn))
++      if (kvm_is_device_pfn(pfn))
+               mem_type = PAGE_S2_DEVICE;
+       spin_lock(&kvm->mmu_lock);
diff --git a/queue-3.14/arm-arm64-kvm-introduce-stage2_unmap_vm.patch b/queue-3.14/arm-arm64-kvm-introduce-stage2_unmap_vm.patch
new file mode 100644 (file)
index 0000000..cff29b9
--- /dev/null
@@ -0,0 +1,144 @@
+From 957db105c99792ae8ef61ffc9ae77d910f6471da Mon Sep 17 00:00:00 2001
+From: Christoffer Dall <christoffer.dall@linaro.org>
+Date: Thu, 27 Nov 2014 10:35:03 +0100
+Subject: arm/arm64: KVM: Introduce stage2_unmap_vm
+
+From: Christoffer Dall <christoffer.dall@linaro.org>
+
+commit 957db105c99792ae8ef61ffc9ae77d910f6471da upstream.
+
+Introduce a new function to unmap user RAM regions in the stage2 page
+tables.  This is needed on reboot (or when the guest turns off the MMU)
+to ensure we fault in pages again and make the dcache, RAM, and icache
+coherent.
+
+Using unmap_stage2_range for the whole guest physical range does not
+work, because that unmaps IO regions (such as the GIC) which will not be
+recreated or in the best case faulted in on a page-by-page basis.
+
+Call this function on secondary and subsequent calls to the
+KVM_ARM_VCPU_INIT ioctl so that a reset VCPU will detect the guest
+Stage-1 MMU is off when faulting in pages and make the caches coherent.
+
+Acked-by: Marc Zyngier <marc.zyngier@arm.com>
+Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
+Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/include/asm/kvm_mmu.h   |    1 
+ arch/arm/kvm/arm.c               |    7 ++++
+ arch/arm/kvm/mmu.c               |   65 +++++++++++++++++++++++++++++++++++++++
+ arch/arm64/include/asm/kvm_mmu.h |    1 
+ 4 files changed, 74 insertions(+)
+
+--- a/arch/arm/include/asm/kvm_mmu.h
++++ b/arch/arm/include/asm/kvm_mmu.h
+@@ -47,6 +47,7 @@ int create_hyp_io_mappings(void *from, v
+ void free_boot_hyp_pgd(void);
+ void free_hyp_pgds(void);
++void stage2_unmap_vm(struct kvm *kvm);
+ int kvm_alloc_stage2_pgd(struct kvm *kvm);
+ void kvm_free_stage2_pgd(struct kvm *kvm);
+ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
+--- a/arch/arm/kvm/arm.c
++++ b/arch/arm/kvm/arm.c
+@@ -675,6 +675,13 @@ static int kvm_arch_vcpu_ioctl_vcpu_init
+       if (ret)
+               return ret;
++      /*
++       * Ensure a rebooted VM will fault in RAM pages and detect if the
++       * guest MMU is turned off and flush the caches as needed.
++       */
++      if (vcpu->arch.has_run_once)
++              stage2_unmap_vm(vcpu->kvm);
++
+       vcpu_reset_hcr(vcpu);
+       /*
+--- a/arch/arm/kvm/mmu.c
++++ b/arch/arm/kvm/mmu.c
+@@ -556,6 +556,71 @@ static void unmap_stage2_range(struct kv
+       unmap_range(kvm, kvm->arch.pgd, start, size);
+ }
++static void stage2_unmap_memslot(struct kvm *kvm,
++                               struct kvm_memory_slot *memslot)
++{
++      hva_t hva = memslot->userspace_addr;
++      phys_addr_t addr = memslot->base_gfn << PAGE_SHIFT;
++      phys_addr_t size = PAGE_SIZE * memslot->npages;
++      hva_t reg_end = hva + size;
++
++      /*
++       * A memory region could potentially cover multiple VMAs, and any holes
++       * between them, so iterate over all of them to find out if we should
++       * unmap any of them.
++       *
++       *     +--------------------------------------------+
++       * +---------------+----------------+   +----------------+
++       * |   : VMA 1     |      VMA 2     |   |    VMA 3  :    |
++       * +---------------+----------------+   +----------------+
++       *     |               memory region                |
++       *     +--------------------------------------------+
++       */
++      do {
++              struct vm_area_struct *vma = find_vma(current->mm, hva);
++              hva_t vm_start, vm_end;
++
++              if (!vma || vma->vm_start >= reg_end)
++                      break;
++
++              /*
++               * Take the intersection of this VMA with the memory region
++               */
++              vm_start = max(hva, vma->vm_start);
++              vm_end = min(reg_end, vma->vm_end);
++
++              if (!(vma->vm_flags & VM_PFNMAP)) {
++                      gpa_t gpa = addr + (vm_start - memslot->userspace_addr);
++                      unmap_stage2_range(kvm, gpa, vm_end - vm_start);
++              }
++              hva = vm_end;
++      } while (hva < reg_end);
++}
++
++/**
++ * stage2_unmap_vm - Unmap Stage-2 RAM mappings
++ * @kvm: The struct kvm pointer
++ *
++ * Go through the memregions and unmap any reguler RAM
++ * backing memory already mapped to the VM.
++ */
++void stage2_unmap_vm(struct kvm *kvm)
++{
++      struct kvm_memslots *slots;
++      struct kvm_memory_slot *memslot;
++      int idx;
++
++      idx = srcu_read_lock(&kvm->srcu);
++      spin_lock(&kvm->mmu_lock);
++
++      slots = kvm_memslots(kvm);
++      kvm_for_each_memslot(memslot, slots)
++              stage2_unmap_memslot(kvm, memslot);
++
++      spin_unlock(&kvm->mmu_lock);
++      srcu_read_unlock(&kvm->srcu, idx);
++}
++
+ /**
+  * kvm_free_stage2_pgd - free all stage-2 tables
+  * @kvm:      The KVM struct pointer for the VM.
+--- a/arch/arm64/include/asm/kvm_mmu.h
++++ b/arch/arm64/include/asm/kvm_mmu.h
+@@ -74,6 +74,7 @@ int create_hyp_io_mappings(void *from, v
+ void free_boot_hyp_pgd(void);
+ void free_hyp_pgds(void);
++void stage2_unmap_vm(struct kvm *kvm);
+ int kvm_alloc_stage2_pgd(struct kvm *kvm);
+ void kvm_free_stage2_pgd(struct kvm *kvm);
+ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
diff --git a/queue-3.14/arm-arm64-kvm-reset-the-hcr-on-each-vcpu-when-resetting-the.patch b/queue-3.14/arm-arm64-kvm-reset-the-hcr-on-each-vcpu-when-resetting-the.patch
new file mode 100644 (file)
index 0000000..2050e9b
--- /dev/null
@@ -0,0 +1,90 @@
+From b856a59141b1066d3c896a0d0231f84dabd040af Mon Sep 17 00:00:00 2001
+From: Christoffer Dall <christoffer.dall@linaro.org>
+Date: Thu, 16 Oct 2014 17:21:16 +0200
+Subject: arm/arm64: KVM: Reset the HCR on each vcpu when resetting the
+ vcpu
+
+From: Christoffer Dall <christoffer.dall@linaro.org>
+
+commit b856a59141b1066d3c896a0d0231f84dabd040af upstream.
+
+When userspace resets the vcpu using KVM_ARM_VCPU_INIT, we should also
+reset the HCR, because we now modify the HCR dynamically to
+enable/disable trapping of guest accesses to the VM registers.
+
+This is crucial for reboot of VMs working since otherwise we will not be
+doing the necessary cache maintenance operations when faulting in pages
+with the guest MMU off.
+
+Acked-by: Marc Zyngier <marc.zyngier@arm.com>
+Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
+Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/arm/include/asm/kvm_emulate.h   |    5 +++++
+ arch/arm/kvm/arm.c                   |    2 ++
+ arch/arm/kvm/guest.c                 |    1 -
+ arch/arm64/include/asm/kvm_emulate.h |    5 +++++
+ arch/arm64/kvm/guest.c               |    1 -
+ 5 files changed, 12 insertions(+), 2 deletions(-)
+
+--- a/arch/arm/include/asm/kvm_emulate.h
++++ b/arch/arm/include/asm/kvm_emulate.h
+@@ -33,6 +33,11 @@ void kvm_inject_undefined(struct kvm_vcp
+ void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr);
+ void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr);
++static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu)
++{
++      vcpu->arch.hcr = HCR_GUEST_MASK;
++}
++
+ static inline bool vcpu_mode_is_32bit(struct kvm_vcpu *vcpu)
+ {
+       return 1;
+--- a/arch/arm/kvm/arm.c
++++ b/arch/arm/kvm/arm.c
+@@ -675,6 +675,8 @@ static int kvm_arch_vcpu_ioctl_vcpu_init
+       if (ret)
+               return ret;
++      vcpu_reset_hcr(vcpu);
++
+       /*
+        * Handle the "start in power-off" case by marking the VCPU as paused.
+        */
+--- a/arch/arm/kvm/guest.c
++++ b/arch/arm/kvm/guest.c
+@@ -38,7 +38,6 @@ struct kvm_stats_debugfs_item debugfs_en
+ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
+ {
+-      vcpu->arch.hcr = HCR_GUEST_MASK;
+       return 0;
+ }
+--- a/arch/arm64/include/asm/kvm_emulate.h
++++ b/arch/arm64/include/asm/kvm_emulate.h
+@@ -38,6 +38,11 @@ void kvm_inject_undefined(struct kvm_vcp
+ void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr);
+ void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr);
++static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu)
++{
++      vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS;
++}
++
+ static inline unsigned long *vcpu_pc(const struct kvm_vcpu *vcpu)
+ {
+       return (unsigned long *)&vcpu_gp_regs(vcpu)->regs.pc;
+--- a/arch/arm64/kvm/guest.c
++++ b/arch/arm64/kvm/guest.c
+@@ -38,7 +38,6 @@ struct kvm_stats_debugfs_item debugfs_en
+ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
+ {
+-      vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS;
+       return 0;
+ }
index d377d601d5b49f3a43cf9ba9373c1576fb4a2b5e..fac6bf95897e4335c227d7b7630263791614de1e 100644 (file)
@@ -26,3 +26,9 @@ arm-kvm-strict_mm_typechecks-fix-for-user_mem_abort.patch
 arm64-kvm-fix-unmapping-with-48-bit-vas.patch
 arm-arm64-kvm-vgic-fix-error-code-in-kvm_vgic_create.patch
 arm64-kvm-fix-assembler-compatibility-of-macros.patch
+arm-arm64-kvm-drop-inappropriate-use-of-kvm_is_mmio_pfn.patch
+arm-arm64-kvm-don-t-clear-the-vcpu_power_off-flag.patch
+arm-arm64-kvm-correct-kvm_arm_vcpu_init-power-off-option.patch
+arm-arm64-kvm-reset-the-hcr-on-each-vcpu-when-resetting-the.patch
+arm-arm64-kvm-introduce-stage2_unmap_vm.patch
+arm-arm64-kvm-don-t-allow-creating-vcpus-after-vgic_initialized.patch