]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.14-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Oct 2019 08:04:15 +0000 (10:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Oct 2019 08:04:15 +0000 (10:04 +0200)
added patches:
fuse-fix-missing-unlock_page-in-fuse_writepage.patch
kvm-x86-always-stop-emulation-on-page-fault.patch
kvm-x86-manually-calculate-reserved-bits-when-loading-pdptrs.patch
kvm-x86-set-ctxt-have_exception-in-x86_decode_insn.patch
parisc-disable-hp-hsc-pci-cards-to-prevent-kernel-crash.patch
x86-retpolines-fix-up-backport-of-a9d57ef15cbe.patch

queue-4.14/fuse-fix-missing-unlock_page-in-fuse_writepage.patch [new file with mode: 0644]
queue-4.14/kvm-x86-always-stop-emulation-on-page-fault.patch [new file with mode: 0644]
queue-4.14/kvm-x86-manually-calculate-reserved-bits-when-loading-pdptrs.patch [new file with mode: 0644]
queue-4.14/kvm-x86-set-ctxt-have_exception-in-x86_decode_insn.patch [new file with mode: 0644]
queue-4.14/parisc-disable-hp-hsc-pci-cards-to-prevent-kernel-crash.patch [new file with mode: 0644]
queue-4.14/series
queue-4.14/x86-retpolines-fix-up-backport-of-a9d57ef15cbe.patch [new file with mode: 0644]

diff --git a/queue-4.14/fuse-fix-missing-unlock_page-in-fuse_writepage.patch b/queue-4.14/fuse-fix-missing-unlock_page-in-fuse_writepage.patch
new file mode 100644 (file)
index 0000000..13264ce
--- /dev/null
@@ -0,0 +1,32 @@
+From d5880c7a8620290a6c90ced7a0e8bd0ad9419601 Mon Sep 17 00:00:00 2001
+From: Vasily Averin <vvs@virtuozzo.com>
+Date: Fri, 13 Sep 2019 18:17:11 +0300
+Subject: fuse: fix missing unlock_page in fuse_writepage()
+
+From: Vasily Averin <vvs@virtuozzo.com>
+
+commit d5880c7a8620290a6c90ced7a0e8bd0ad9419601 upstream.
+
+unlock_page() was missing in case of an already in-flight write against the
+same page.
+
+Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
+Fixes: ff17be086477 ("fuse: writepage: skip already in flight")
+Cc: <stable@vger.kernel.org> # v3.13
+Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/fuse/file.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/fs/fuse/file.c
++++ b/fs/fuse/file.c
+@@ -1699,6 +1699,7 @@ static int fuse_writepage(struct page *p
+               WARN_ON(wbc->sync_mode == WB_SYNC_ALL);
+               redirty_page_for_writepage(wbc, page);
++              unlock_page(page);
+               return 0;
+       }
diff --git a/queue-4.14/kvm-x86-always-stop-emulation-on-page-fault.patch b/queue-4.14/kvm-x86-always-stop-emulation-on-page-fault.patch
new file mode 100644 (file)
index 0000000..8b224a4
--- /dev/null
@@ -0,0 +1,52 @@
+From 8530a79c5a9f4e29e6ffb35ec1a79d81f4968ec8 Mon Sep 17 00:00:00 2001
+From: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
+Date: Tue, 27 Aug 2019 13:07:09 +0000
+Subject: KVM: x86: always stop emulation on page fault
+
+From: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
+
+commit 8530a79c5a9f4e29e6ffb35ec1a79d81f4968ec8 upstream.
+
+inject_emulated_exception() returns true if and only if nested page
+fault happens. However, page fault can come from guest page tables
+walk, either nested or not nested. In both cases we should stop an
+attempt to read under RIP and give guest to step over its own page
+fault handler.
+
+This is also visible when an emulated instruction causes a #GP fault
+and the VMware backdoor is enabled.  To handle the VMware backdoor,
+KVM intercepts #GP faults; with only the next patch applied,
+x86_emulate_instruction() injects a #GP but returns EMULATE_FAIL
+instead of EMULATE_DONE.   EMULATE_FAIL causes handle_exception_nmi()
+(or gp_interception() for SVM) to re-inject the original #GP because it
+thinks emulation failed due to a non-VMware opcode.  This patch prevents
+the issue as x86_emulate_instruction() will return EMULATE_DONE after
+injecting the #GP.
+
+Fixes: 6ea6e84309ca ("KVM: x86: inject exceptions produced by x86_decode_insn")
+Cc: stable@vger.kernel.org
+Cc: Denis Lunev <den@virtuozzo.com>
+Cc: Roman Kagan <rkagan@virtuozzo.com>
+Cc: Denis Plotnikov <dplotnikov@virtuozzo.com>
+Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kvm/x86.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/arch/x86/kvm/x86.c
++++ b/arch/x86/kvm/x86.c
+@@ -5892,8 +5892,10 @@ int x86_emulate_instruction(struct kvm_v
+                       if (reexecute_instruction(vcpu, cr2, write_fault_to_spt,
+                                               emulation_type))
+                               return EMULATE_DONE;
+-                      if (ctxt->have_exception && inject_emulated_exception(vcpu))
++                      if (ctxt->have_exception) {
++                              inject_emulated_exception(vcpu);
+                               return EMULATE_DONE;
++                      }
+                       if (emulation_type & EMULTYPE_SKIP)
+                               return EMULATE_FAIL;
+                       return handle_emulation_failure(vcpu);
diff --git a/queue-4.14/kvm-x86-manually-calculate-reserved-bits-when-loading-pdptrs.patch b/queue-4.14/kvm-x86-manually-calculate-reserved-bits-when-loading-pdptrs.patch
new file mode 100644 (file)
index 0000000..0c5d7af
--- /dev/null
@@ -0,0 +1,75 @@
+From 16cfacc8085782dab8e365979356ce1ca87fd6cc Mon Sep 17 00:00:00 2001
+From: Sean Christopherson <sean.j.christopherson@intel.com>
+Date: Tue, 3 Sep 2019 16:36:45 -0700
+Subject: KVM: x86: Manually calculate reserved bits when loading PDPTRS
+
+From: Sean Christopherson <sean.j.christopherson@intel.com>
+
+commit 16cfacc8085782dab8e365979356ce1ca87fd6cc upstream.
+
+Manually generate the PDPTR reserved bit mask when explicitly loading
+PDPTRs.  The reserved bits that are being tracked by the MMU reflect the
+current paging mode, which is unlikely to be PAE paging in the vast
+majority of flows that use load_pdptrs(), e.g. CR0 and CR4 emulation,
+__set_sregs(), etc...  This can cause KVM to incorrectly signal a bad
+PDPTR, or more likely, miss a reserved bit check and subsequently fail
+a VM-Enter due to a bad VMCS.GUEST_PDPTR.
+
+Add a one off helper to generate the reserved bits instead of sharing
+code across the MMU's calculations and the PDPTR emulation.  The PDPTR
+reserved bits are basically set in stone, and pushing a helper into
+the MMU's calculation adds unnecessary complexity without improving
+readability.
+
+Oppurtunistically fix/update the comment for load_pdptrs().
+
+Note, the buggy commit also introduced a deliberate functional change,
+"Also remove bit 5-6 from rsvd_bits_mask per latest SDM.", which was
+effectively (and correctly) reverted by commit cd9ae5fe47df ("KVM: x86:
+Fix page-tables reserved bits").  A bit of SDM archaeology shows that
+the SDM from late 2008 had a bug (likely a copy+paste error) where it
+listed bits 6:5 as AVL and A for PDPTEs used for 4k entries but reserved
+for 2mb entries.  I.e. the SDM contradicted itself, and bits 6:5 are and
+always have been reserved.
+
+Fixes: 20c466b56168d ("KVM: Use rsvd_bits_mask in load_pdptrs()")
+Cc: stable@vger.kernel.org
+Cc: Nadav Amit <nadav.amit@gmail.com>
+Reported-by: Doug Reiland <doug.reiland@intel.com>
+Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
+Reviewed-by: Peter Xu <peterx@redhat.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kvm/x86.c |   11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+--- a/arch/x86/kvm/x86.c
++++ b/arch/x86/kvm/x86.c
+@@ -563,8 +563,14 @@ static int kvm_read_nested_guest_page(st
+                                      data, offset, len, access);
+ }
++static inline u64 pdptr_rsvd_bits(struct kvm_vcpu *vcpu)
++{
++      return rsvd_bits(cpuid_maxphyaddr(vcpu), 63) | rsvd_bits(5, 8) |
++             rsvd_bits(1, 2);
++}
++
+ /*
+- * Load the pae pdptrs.  Return true is they are all valid.
++ * Load the pae pdptrs.  Return 1 if they are all valid, 0 otherwise.
+  */
+ int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3)
+ {
+@@ -583,8 +589,7 @@ int load_pdptrs(struct kvm_vcpu *vcpu, s
+       }
+       for (i = 0; i < ARRAY_SIZE(pdpte); ++i) {
+               if ((pdpte[i] & PT_PRESENT_MASK) &&
+-                  (pdpte[i] &
+-                   vcpu->arch.mmu.guest_rsvd_check.rsvd_bits_mask[0][2])) {
++                  (pdpte[i] & pdptr_rsvd_bits(vcpu))) {
+                       ret = 0;
+                       goto out;
+               }
diff --git a/queue-4.14/kvm-x86-set-ctxt-have_exception-in-x86_decode_insn.patch b/queue-4.14/kvm-x86-set-ctxt-have_exception-in-x86_decode_insn.patch
new file mode 100644 (file)
index 0000000..1f963dd
--- /dev/null
@@ -0,0 +1,53 @@
+From c8848cee74ff05638e913582a476bde879c968ad Mon Sep 17 00:00:00 2001
+From: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
+Date: Tue, 27 Aug 2019 13:07:08 +0000
+Subject: KVM: x86: set ctxt->have_exception in x86_decode_insn()
+
+From: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
+
+commit c8848cee74ff05638e913582a476bde879c968ad upstream.
+
+x86_emulate_instruction() takes into account ctxt->have_exception flag
+during instruction decoding, but in practice this flag is never set in
+x86_decode_insn().
+
+Fixes: 6ea6e84309ca ("KVM: x86: inject exceptions produced by x86_decode_insn")
+Cc: stable@vger.kernel.org
+Cc: Denis Lunev <den@virtuozzo.com>
+Cc: Roman Kagan <rkagan@virtuozzo.com>
+Cc: Denis Plotnikov <dplotnikov@virtuozzo.com>
+Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kvm/emulate.c |    2 ++
+ arch/x86/kvm/x86.c     |    6 ++++++
+ 2 files changed, 8 insertions(+)
+
+--- a/arch/x86/kvm/emulate.c
++++ b/arch/x86/kvm/emulate.c
+@@ -5298,6 +5298,8 @@ done_prefixes:
+                                       ctxt->memopp->addr.mem.ea + ctxt->_eip);
+ done:
++      if (rc == X86EMUL_PROPAGATE_FAULT)
++              ctxt->have_exception = true;
+       return (rc != X86EMUL_CONTINUE) ? EMULATION_FAILED : EMULATION_OK;
+ }
+--- a/arch/x86/kvm/x86.c
++++ b/arch/x86/kvm/x86.c
+@@ -5893,6 +5893,12 @@ int x86_emulate_instruction(struct kvm_v
+                                               emulation_type))
+                               return EMULATE_DONE;
+                       if (ctxt->have_exception) {
++                              /*
++                               * #UD should result in just EMULATION_FAILED, and trap-like
++                               * exception should not be encountered during decode.
++                               */
++                              WARN_ON_ONCE(ctxt->exception.vector == UD_VECTOR ||
++                                           exception_type(ctxt->exception.vector) == EXCPT_TRAP);
+                               inject_emulated_exception(vcpu);
+                               return EMULATE_DONE;
+                       }
diff --git a/queue-4.14/parisc-disable-hp-hsc-pci-cards-to-prevent-kernel-crash.patch b/queue-4.14/parisc-disable-hp-hsc-pci-cards-to-prevent-kernel-crash.patch
new file mode 100644 (file)
index 0000000..b0e7471
--- /dev/null
@@ -0,0 +1,73 @@
+From 5fa1659105fac63e0f3c199b476025c2e04111ce Mon Sep 17 00:00:00 2001
+From: Helge Deller <deller@gmx.de>
+Date: Thu, 5 Sep 2019 16:44:17 +0200
+Subject: parisc: Disable HP HSC-PCI Cards to prevent kernel crash
+
+From: Helge Deller <deller@gmx.de>
+
+commit 5fa1659105fac63e0f3c199b476025c2e04111ce upstream.
+
+The HP Dino PCI controller chip can be used in two variants: as on-board
+controller (e.g. in B160L), or on an Add-On card ("Card-Mode") to bridge
+PCI components to systems without a PCI bus, e.g. to a HSC/GSC bus.  One
+such Add-On card is the HP HSC-PCI Card which has one or more DEC Tulip
+PCI NIC chips connected to the on-card Dino PCI controller.
+
+Dino in Card-Mode has a big disadvantage: All PCI memory accesses need
+to go through the DINO_MEM_DATA register, so Linux drivers will not be
+able to use the ioremap() function. Without ioremap() many drivers will
+not work, one example is the tulip driver which then simply crashes the
+kernel if it tries to access the ports on the HP HSC card.
+
+This patch disables the HP HSC card if it finds one, and as such
+fixes the kernel crash on a HP D350/2 machine.
+
+Signed-off-by: Helge Deller <deller@gmx.de>
+Noticed-by: Phil Scarr <phil.scarr@pm.me>
+Cc: stable@vger.kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/parisc/dino.c |   24 ++++++++++++++++++++++++
+ 1 file changed, 24 insertions(+)
+
+--- a/drivers/parisc/dino.c
++++ b/drivers/parisc/dino.c
+@@ -160,6 +160,15 @@ struct dino_device
+       (struct dino_device *)__pdata; })
++/* Check if PCI device is behind a Card-mode Dino. */
++static int pci_dev_is_behind_card_dino(struct pci_dev *dev)
++{
++      struct dino_device *dino_dev;
++
++      dino_dev = DINO_DEV(parisc_walk_tree(dev->bus->bridge));
++      return is_card_dino(&dino_dev->hba.dev->id);
++}
++
+ /*
+  * Dino Configuration Space Accessor Functions
+  */
+@@ -442,6 +451,21 @@ static void quirk_cirrus_cardbus(struct
+ }
+ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_6832, quirk_cirrus_cardbus );
++#ifdef CONFIG_TULIP
++static void pci_fixup_tulip(struct pci_dev *dev)
++{
++      if (!pci_dev_is_behind_card_dino(dev))
++              return;
++      if (!(pci_resource_flags(dev, 1) & IORESOURCE_MEM))
++              return;
++      pr_warn("%s: HP HSC-PCI Cards with card-mode Dino not yet supported.\n",
++              pci_name(dev));
++      /* Disable this card by zeroing the PCI resources */
++      memset(&dev->resource[0], 0, sizeof(dev->resource[0]));
++      memset(&dev->resource[1], 0, sizeof(dev->resource[1]));
++}
++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_DEC, PCI_ANY_ID, pci_fixup_tulip);
++#endif /* CONFIG_TULIP */
+ static void __init
+ dino_bios_init(void)
index 44309b0d51ea2cf8d52ab49ce307f8a27fb56235..3d124daa114d77c4a3725916b21f1fc4936aaf2a 100644 (file)
@@ -145,3 +145,9 @@ printk-do-not-lose-last-line-in-kmsg-buffer-dump.patch
 ib-hfi1-define-variables-as-unsigned-long-to-fix-kasan-warning.patch
 randstruct-check-member-structs-in-is_pure_ops_struct.patch
 alsa-hda-realtek-fixup-mute-led-on-hp-spectre-x360.patch
+fuse-fix-missing-unlock_page-in-fuse_writepage.patch
+parisc-disable-hp-hsc-pci-cards-to-prevent-kernel-crash.patch
+x86-retpolines-fix-up-backport-of-a9d57ef15cbe.patch
+kvm-x86-always-stop-emulation-on-page-fault.patch
+kvm-x86-set-ctxt-have_exception-in-x86_decode_insn.patch
+kvm-x86-manually-calculate-reserved-bits-when-loading-pdptrs.patch
diff --git a/queue-4.14/x86-retpolines-fix-up-backport-of-a9d57ef15cbe.patch b/queue-4.14/x86-retpolines-fix-up-backport-of-a9d57ef15cbe.patch
new file mode 100644 (file)
index 0000000..5fc7ab2
--- /dev/null
@@ -0,0 +1,42 @@
+From natechancellor@gmail.com  Thu Oct  3 09:54:59 2019
+From: Nathan Chancellor <natechancellor@gmail.com>
+Date: Sun, 29 Sep 2019 11:32:06 -0700
+Subject: x86/retpolines: Fix up backport of a9d57ef15cbe
+To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Sasha Levin <sashal@kernel.org>
+Cc: stable@vger.kernel.org, x86@kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor <natechancellor@gmail.com>
+Message-ID: <20190929183206.922721-1-natechancellor@gmail.com>
+
+From: Nathan Chancellor <natechancellor@gmail.com>
+
+Commit a9d57ef15cbe ("x86/retpolines: Disable switch jump tables when
+retpolines are enabled") added -fno-jump-tables to workaround a GCC issue
+while deliberately avoiding adding this flag when CONFIG_CC_IS_CLANG is
+set, which is defined by the kconfig system when CC=clang is provided.
+
+However, this symbol was added in 4.18 in commit 469cb7376c06 ("kconfig:
+add CC_IS_CLANG and CLANG_VERSION") so it is always undefined in 4.14,
+meaning -fno-jump-tables gets added when using Clang.
+
+Fix this up by using the equivalent $(cc-name) comparison, which matches
+what upstream did until commit 076f421da5d4 ("kbuild: replace cc-name
+test with CONFIG_CC_IS_CLANG").
+
+Fixes: e28951100515 ("x86/retpolines: Disable switch jump tables when retpolines are enabled")
+Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/x86/Makefile
++++ b/arch/x86/Makefile
+@@ -249,7 +249,7 @@ ifdef CONFIG_RETPOLINE
+   # retpoline builds, however, gcc does not for x86. This has
+   # only been fixed starting from gcc stable version 8.4.0 and
+   # onwards, but not for older ones. See gcc bug #86952.
+-  ifndef CONFIG_CC_IS_CLANG
++  ifneq ($(cc-name), clang)
+     KBUILD_CFLAGS += $(call cc-option,-fno-jump-tables)
+   endif
+ endif