]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.18-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Dec 2017 09:25:13 +0000 (10:25 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Dec 2017 09:25:13 +0000 (10:25 +0100)
added patches:
btrfs-clear-space-cache-inode-generation-always.patch
kvm-x86-exit-to-user-mode-on-ud-intercept-when-emulator-requires.patch
kvm-x86-inject-exceptions-produced-by-x86_decode_insn.patch

queue-3.18/btrfs-clear-space-cache-inode-generation-always.patch [new file with mode: 0644]
queue-3.18/kvm-x86-exit-to-user-mode-on-ud-intercept-when-emulator-requires.patch [new file with mode: 0644]
queue-3.18/kvm-x86-inject-exceptions-produced-by-x86_decode_insn.patch [new file with mode: 0644]
queue-3.18/series

diff --git a/queue-3.18/btrfs-clear-space-cache-inode-generation-always.patch b/queue-3.18/btrfs-clear-space-cache-inode-generation-always.patch
new file mode 100644 (file)
index 0000000..057e309
--- /dev/null
@@ -0,0 +1,59 @@
+From 8e138e0d92c6c9d3d481674fb14e3439b495be37 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <jbacik@fb.com>
+Date: Fri, 17 Nov 2017 14:50:46 -0500
+Subject: btrfs: clear space cache inode generation always
+
+From: Josef Bacik <jbacik@fb.com>
+
+commit 8e138e0d92c6c9d3d481674fb14e3439b495be37 upstream.
+
+We discovered a box that had double allocations, and suspected the space
+cache may be to blame.  While auditing the write out path I noticed that
+if we've already setup the space cache we will just carry on.  This
+means that any error we hit after cache_save_setup before we go to
+actually write the cache out we won't reset the inode generation, so
+whatever was already written will be considered correct, except it'll be
+stale.  Fix this by _always_ resetting the generation on the block group
+inode, this way we only ever have valid or invalid cache.
+
+With this patch I was no longer able to reproduce cache corruption with
+dm-log-writes and my bpf error injection tool.
+
+Signed-off-by: Josef Bacik <jbacik@fb.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/btrfs/extent-tree.c |   14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -3219,13 +3219,6 @@ again:
+               goto again;
+       }
+-      /* We've already setup this transaction, go ahead and exit */
+-      if (block_group->cache_generation == trans->transid &&
+-          i_size_read(inode)) {
+-              dcs = BTRFS_DC_SETUP;
+-              goto out_put;
+-      }
+-
+       /*
+        * We want to set the generation to 0, that way if anything goes wrong
+        * from here on out we know not to trust this cache when we load up next
+@@ -3235,6 +3228,13 @@ again:
+       ret = btrfs_update_inode(trans, root, inode);
+       WARN_ON(ret);
++      /* We've already setup this transaction, go ahead and exit */
++      if (block_group->cache_generation == trans->transid &&
++          i_size_read(inode)) {
++              dcs = BTRFS_DC_SETUP;
++              goto out_put;
++      }
++
+       if (i_size_read(inode) > 0) {
+               ret = btrfs_check_trunc_cache_free_space(root,
+                                       &root->fs_info->global_block_rsv);
diff --git a/queue-3.18/kvm-x86-exit-to-user-mode-on-ud-intercept-when-emulator-requires.patch b/queue-3.18/kvm-x86-exit-to-user-mode-on-ud-intercept-when-emulator-requires.patch
new file mode 100644 (file)
index 0000000..578e6c5
--- /dev/null
@@ -0,0 +1,54 @@
+From 61cb57c9ed631c95b54f8e9090c89d18b3695b3c Mon Sep 17 00:00:00 2001
+From: Liran Alon <liran.alon@oracle.com>
+Date: Sun, 5 Nov 2017 16:56:32 +0200
+Subject: KVM: x86: Exit to user-mode on #UD intercept when emulator requires
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Liran Alon <liran.alon@oracle.com>
+
+commit 61cb57c9ed631c95b54f8e9090c89d18b3695b3c upstream.
+
+Instruction emulation after trapping a #UD exception can result in an
+MMIO access, for example when emulating a MOVBE on a processor that
+doesn't support the instruction.  In this case, the #UD vmexit handler
+must exit to user mode, but there wasn't any code to do so.  Add it for
+both VMX and SVM.
+
+Signed-off-by: Liran Alon <liran.alon@oracle.com>
+Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
+Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
+Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kvm/svm.c |    2 ++
+ arch/x86/kvm/vmx.c |    2 ++
+ 2 files changed, 4 insertions(+)
+
+--- a/arch/x86/kvm/svm.c
++++ b/arch/x86/kvm/svm.c
+@@ -1785,6 +1785,8 @@ static int ud_interception(struct vcpu_s
+       int er;
+       er = emulate_instruction(&svm->vcpu, EMULTYPE_TRAP_UD);
++      if (er == EMULATE_USER_EXIT)
++              return 0;
+       if (er != EMULATE_DONE)
+               kvm_queue_exception(&svm->vcpu, UD_VECTOR);
+       return 1;
+--- a/arch/x86/kvm/vmx.c
++++ b/arch/x86/kvm/vmx.c
+@@ -4899,6 +4899,8 @@ static int handle_exception(struct kvm_v
+       if (is_invalid_opcode(intr_info)) {
+               er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD);
++              if (er == EMULATE_USER_EXIT)
++                      return 0;
+               if (er != EMULATE_DONE)
+                       kvm_queue_exception(vcpu, UD_VECTOR);
+               return 1;
diff --git a/queue-3.18/kvm-x86-inject-exceptions-produced-by-x86_decode_insn.patch b/queue-3.18/kvm-x86-inject-exceptions-produced-by-x86_decode_insn.patch
new file mode 100644 (file)
index 0000000..992e538
--- /dev/null
@@ -0,0 +1,53 @@
+From 6ea6e84309ca7e0e850b3083e6b09344ee15c290 Mon Sep 17 00:00:00 2001
+From: Paolo Bonzini <pbonzini@redhat.com>
+Date: Fri, 10 Nov 2017 10:49:38 +0100
+Subject: KVM: x86: inject exceptions produced by x86_decode_insn
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Paolo Bonzini <pbonzini@redhat.com>
+
+commit 6ea6e84309ca7e0e850b3083e6b09344ee15c290 upstream.
+
+Sometimes, a processor might execute an instruction while another
+processor is updating the page tables for that instruction's code page,
+but before the TLB shootdown completes.  The interesting case happens
+if the page is in the TLB.
+
+In general, the processor will succeed in executing the instruction and
+nothing bad happens.  However, what if the instruction is an MMIO access?
+If *that* happens, KVM invokes the emulator, and the emulator gets the
+updated page tables.  If the update side had marked the code page as non
+present, the page table walk then will fail and so will x86_decode_insn.
+
+Unfortunately, even though kvm_fetch_guest_virt is correctly returning
+X86EMUL_PROPAGATE_FAULT, x86_decode_insn's caller treats the failure as
+a fatal error if the instruction cannot simply be reexecuted (as is the
+case for MMIO).  And this in fact happened sometimes when rebooting
+Windows 2012r2 guests.  Just checking ctxt->have_exception and injecting
+the exception if true is enough to fix the case.
+
+Thanks to Eduardo Habkost for helping in the debugging of this issue.
+
+Reported-by: Yanan Fu <yfu@redhat.com>
+Cc: Eduardo Habkost <ehabkost@redhat.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kvm/x86.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/arch/x86/kvm/x86.c
++++ b/arch/x86/kvm/x86.c
+@@ -5372,6 +5372,8 @@ 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))
++                              return EMULATE_DONE;
+                       if (emulation_type & EMULTYPE_SKIP)
+                               return EMULATE_FAIL;
+                       return handle_emulation_failure(vcpu);
index a4ad08c96cce26dd889d112e85659717866a7968..454a192fe121e934097c5d363ec633acfce85272 100644 (file)
@@ -2,3 +2,6 @@ netlink-add-a-start-callback-for-starting-a-netlink-dump.patch
 ipsec-fix-aborted-xfrm-policy-dump-crash.patch
 mm-thp-do-not-make-page-table-dirty-unconditionally-in-touch_pd.patch
 mm-madvise.c-fix-madvise-infinite-loop-under-special-circumstances.patch
+btrfs-clear-space-cache-inode-generation-always.patch
+kvm-x86-exit-to-user-mode-on-ud-intercept-when-emulator-requires.patch
+kvm-x86-inject-exceptions-produced-by-x86_decode_insn.patch