From 4463d21ab3b628aad580f3cc7519467cf33dd3fb Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 May 2019 13:28:58 +0200 Subject: [PATCH] 4.19-stable patches added patches: ext4-don-t-update-s_rev_level-if-not-required.patch ext4-fix-block-validity-checks-for-journal-inodes-using-indirect-blocks.patch ext4-fix-compile-error-when-using-buffer_trace.patch ext4-unsigned-int-compared-against-zero.patch iov_iter-optimize-page_copy_sane.patch kbuild-turn-auto.conf.cmd-into-a-mandatory-include-file.patch libnvdimm-namespace-fix-label-tracking-error.patch pstore-allocate-compression-during-late_initcall.patch pstore-centralize-init-exit-routines.patch pstore-refactor-compression-initialization.patch xen-pvh-set-xen_domain_type-to-hvm-in-xen_pvh_init.patch --- ...t-update-s_rev_level-if-not-required.patch | 92 ++++++++++ ...journal-inodes-using-indirect-blocks.patch | 42 +++++ ...ompile-error-when-using-buffer_trace.patch | 39 +++++ ...4-unsigned-int-compared-against-zero.patch | 35 ++++ .../iov_iter-optimize-page_copy_sane.patch | 56 +++++++ ...nf.cmd-into-a-mandatory-include-file.patch | 92 ++++++++++ ...m-namespace-fix-label-tracking-error.patch | 158 ++++++++++++++++++ ...ate-compression-during-late_initcall.patch | 67 ++++++++ ...pstore-centralize-init-exit-routines.patch | 102 +++++++++++ ...-refactor-compression-initialization.patch | 111 ++++++++++++ queue-4.19/series | 11 ++ ...n_domain_type-to-hvm-in-xen_pvh_init.patch | 34 ++++ 12 files changed, 839 insertions(+) create mode 100644 queue-4.19/ext4-don-t-update-s_rev_level-if-not-required.patch create mode 100644 queue-4.19/ext4-fix-block-validity-checks-for-journal-inodes-using-indirect-blocks.patch create mode 100644 queue-4.19/ext4-fix-compile-error-when-using-buffer_trace.patch create mode 100644 queue-4.19/ext4-unsigned-int-compared-against-zero.patch create mode 100644 queue-4.19/iov_iter-optimize-page_copy_sane.patch create mode 100644 queue-4.19/kbuild-turn-auto.conf.cmd-into-a-mandatory-include-file.patch create mode 100644 queue-4.19/libnvdimm-namespace-fix-label-tracking-error.patch create mode 100644 queue-4.19/pstore-allocate-compression-during-late_initcall.patch create mode 100644 queue-4.19/pstore-centralize-init-exit-routines.patch create mode 100644 queue-4.19/pstore-refactor-compression-initialization.patch create mode 100644 queue-4.19/xen-pvh-set-xen_domain_type-to-hvm-in-xen_pvh_init.patch diff --git a/queue-4.19/ext4-don-t-update-s_rev_level-if-not-required.patch b/queue-4.19/ext4-don-t-update-s_rev_level-if-not-required.patch new file mode 100644 index 00000000000..7ba2cbf7785 --- /dev/null +++ b/queue-4.19/ext4-don-t-update-s_rev_level-if-not-required.patch @@ -0,0 +1,92 @@ +From c9e716eb9b3455a83ed7c5f5a81256a3da779a95 Mon Sep 17 00:00:00 2001 +From: Andreas Dilger +Date: Thu, 14 Feb 2019 17:52:18 -0500 +Subject: ext4: don't update s_rev_level if not required + +From: Andreas Dilger + +commit c9e716eb9b3455a83ed7c5f5a81256a3da779a95 upstream. + +Don't update the superblock s_rev_level during mount if it isn't +actually necessary, only if superblock features are being set by +the kernel. This was originally added for ext3 since it always +set the INCOMPAT_RECOVER and HAS_JOURNAL features during mount, +but this is not needed since no journal mode was added to ext4. + +That will allow Geert to mount his 20-year-old ext2 rev 0.0 m68k +filesystem, as a testament of the backward compatibility of ext4. + +Fixes: 0390131ba84f ("ext4: Allow ext4 to run without a journal") +Signed-off-by: Andreas Dilger +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/ext4.h | 6 +++++- + fs/ext4/inode.c | 1 - + fs/ext4/super.c | 1 - + 3 files changed, 5 insertions(+), 3 deletions(-) + +--- a/fs/ext4/ext4.h ++++ b/fs/ext4/ext4.h +@@ -1670,6 +1670,8 @@ static inline void ext4_clear_state_flag + #define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */ + #define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000 + ++extern void ext4_update_dynamic_rev(struct super_block *sb); ++ + #define EXT4_FEATURE_COMPAT_FUNCS(name, flagname) \ + static inline bool ext4_has_feature_##name(struct super_block *sb) \ + { \ +@@ -1678,6 +1680,7 @@ static inline bool ext4_has_feature_##na + } \ + static inline void ext4_set_feature_##name(struct super_block *sb) \ + { \ ++ ext4_update_dynamic_rev(sb); \ + EXT4_SB(sb)->s_es->s_feature_compat |= \ + cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname); \ + } \ +@@ -1695,6 +1698,7 @@ static inline bool ext4_has_feature_##na + } \ + static inline void ext4_set_feature_##name(struct super_block *sb) \ + { \ ++ ext4_update_dynamic_rev(sb); \ + EXT4_SB(sb)->s_es->s_feature_ro_compat |= \ + cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname); \ + } \ +@@ -1712,6 +1716,7 @@ static inline bool ext4_has_feature_##na + } \ + static inline void ext4_set_feature_##name(struct super_block *sb) \ + { \ ++ ext4_update_dynamic_rev(sb); \ + EXT4_SB(sb)->s_es->s_feature_incompat |= \ + cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname); \ + } \ +@@ -2679,7 +2684,6 @@ do { \ + + #endif + +-extern void ext4_update_dynamic_rev(struct super_block *sb); + extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb, + __u32 compat); + extern int ext4_update_rocompat_feature(handle_t *handle, +--- a/fs/ext4/inode.c ++++ b/fs/ext4/inode.c +@@ -5324,7 +5324,6 @@ static int ext4_do_update_inode(handle_t + err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh); + if (err) + goto out_brelse; +- ext4_update_dynamic_rev(sb); + ext4_set_feature_large_file(sb); + ext4_handle_sync(handle); + err = ext4_handle_dirty_super(handle, sb); +--- a/fs/ext4/super.c ++++ b/fs/ext4/super.c +@@ -2259,7 +2259,6 @@ static int ext4_setup_super(struct super + es->s_max_mnt_count = cpu_to_le16(EXT4_DFL_MAX_MNT_COUNT); + le16_add_cpu(&es->s_mnt_count, 1); + ext4_update_tstamp(es, s_mtime); +- ext4_update_dynamic_rev(sb); + if (sbi->s_journal) + ext4_set_feature_journal_needs_recovery(sb); + diff --git a/queue-4.19/ext4-fix-block-validity-checks-for-journal-inodes-using-indirect-blocks.patch b/queue-4.19/ext4-fix-block-validity-checks-for-journal-inodes-using-indirect-blocks.patch new file mode 100644 index 00000000000..dd17d556175 --- /dev/null +++ b/queue-4.19/ext4-fix-block-validity-checks-for-journal-inodes-using-indirect-blocks.patch @@ -0,0 +1,42 @@ +From 170417c8c7bb2cbbdd949bf5c443c0c8f24a203b Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Wed, 15 May 2019 00:51:19 -0400 +Subject: ext4: fix block validity checks for journal inodes using indirect blocks + +From: Theodore Ts'o + +commit 170417c8c7bb2cbbdd949bf5c443c0c8f24a203b upstream. + +Commit 345c0dbf3a30 ("ext4: protect journal inode's blocks using +block_validity") failed to add an exception for the journal inode in +ext4_check_blockref(), which is the function used by ext4_get_branch() +for indirect blocks. This caused attempts to read from the ext3-style +journals to fail with: + +[ 848.968550] EXT4-fs error (device sdb7): ext4_get_branch:171: inode #8: block 30343695: comm jbd2/sdb7-8: invalid block + +Fix this by adding the missing exception check. + +Fixes: 345c0dbf3a30 ("ext4: protect journal inode's blocks using block_validity") +Reported-by: Arthur Marsh +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/block_validity.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/fs/ext4/block_validity.c ++++ b/fs/ext4/block_validity.c +@@ -276,6 +276,11 @@ int ext4_check_blockref(const char *func + __le32 *bref = p; + unsigned int blk; + ++ if (ext4_has_feature_journal(inode->i_sb) && ++ (inode->i_ino == ++ le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_journal_inum))) ++ return 0; ++ + while (bref < p+max) { + blk = le32_to_cpu(*bref++); + if (blk && diff --git a/queue-4.19/ext4-fix-compile-error-when-using-buffer_trace.patch b/queue-4.19/ext4-fix-compile-error-when-using-buffer_trace.patch new file mode 100644 index 00000000000..4b4c9cb4361 --- /dev/null +++ b/queue-4.19/ext4-fix-compile-error-when-using-buffer_trace.patch @@ -0,0 +1,39 @@ +From ddccb6dbe780d68133191477571cb7c69e17bb8c Mon Sep 17 00:00:00 2001 +From: "zhangyi (F)" +Date: Thu, 21 Feb 2019 11:29:10 -0500 +Subject: ext4: fix compile error when using BUFFER_TRACE +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: zhangyi (F) + +commit ddccb6dbe780d68133191477571cb7c69e17bb8c upstream. + +Fix compile error below when using BUFFER_TRACE. + +fs/ext4/inode.c: In function ‘ext4_expand_extra_isize’: +fs/ext4/inode.c:5979:19: error: request for member ‘bh’ in something not a structure or union + BUFFER_TRACE(iloc.bh, "get_write_access"); + +Fixes: c03b45b853f58 ("ext4, project: expand inode extra size if possible") +Signed-off-by: zhangyi (F) +Signed-off-by: Theodore Ts'o +Reviewed-by: Jan Kara +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/inode.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/ext4/inode.c ++++ b/fs/ext4/inode.c +@@ -5975,7 +5975,7 @@ int ext4_expand_extra_isize(struct inode + + ext4_write_lock_xattr(inode, &no_expand); + +- BUFFER_TRACE(iloc.bh, "get_write_access"); ++ BUFFER_TRACE(iloc->bh, "get_write_access"); + error = ext4_journal_get_write_access(handle, iloc->bh); + if (error) { + brelse(iloc->bh); diff --git a/queue-4.19/ext4-unsigned-int-compared-against-zero.patch b/queue-4.19/ext4-unsigned-int-compared-against-zero.patch new file mode 100644 index 00000000000..85dc8e9d304 --- /dev/null +++ b/queue-4.19/ext4-unsigned-int-compared-against-zero.patch @@ -0,0 +1,35 @@ +From fbbbbd2f28aec991f3fbc248df211550fbdfd58c Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Fri, 10 May 2019 22:06:38 -0400 +Subject: ext4: unsigned int compared against zero + +From: Colin Ian King + +commit fbbbbd2f28aec991f3fbc248df211550fbdfd58c upstream. + +There are two cases where u32 variables n and err are being checked +for less than zero error values, the checks is always false because +the variables are not signed. Fix this by making the variables ints. + +Addresses-Coverity: ("Unsigned compared against 0") +Fixes: 345c0dbf3a30 ("ext4: protect journal inode's blocks using block_validity") +Signed-off-by: Colin Ian King +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/block_validity.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/fs/ext4/block_validity.c ++++ b/fs/ext4/block_validity.c +@@ -142,7 +142,8 @@ static int ext4_protect_reserved_inode(s + struct inode *inode; + struct ext4_sb_info *sbi = EXT4_SB(sb); + struct ext4_map_blocks map; +- u32 i = 0, err = 0, num, n; ++ u32 i = 0, num; ++ int err = 0, n; + + if ((ino < EXT4_ROOT_INO) || + (ino > le32_to_cpu(sbi->s_es->s_inodes_count))) diff --git a/queue-4.19/iov_iter-optimize-page_copy_sane.patch b/queue-4.19/iov_iter-optimize-page_copy_sane.patch new file mode 100644 index 00000000000..29787d80217 --- /dev/null +++ b/queue-4.19/iov_iter-optimize-page_copy_sane.patch @@ -0,0 +1,56 @@ +From 6daef95b8c914866a46247232a048447fff97279 Mon Sep 17 00:00:00 2001 +From: Eric Dumazet +Date: Tue, 26 Feb 2019 10:42:39 -0800 +Subject: iov_iter: optimize page_copy_sane() + +From: Eric Dumazet + +commit 6daef95b8c914866a46247232a048447fff97279 upstream. + +Avoid cache line miss dereferencing struct page if we can. + +page_copy_sane() mostly deals with order-0 pages. + +Extra cache line miss is visible on TCP recvmsg() calls dealing +with GRO packets (typically 45 page frags are attached to one skb). + +Bringing the 45 struct pages into cpu cache while copying the data +is not free, since the freeing of the skb (and associated +page frags put_page()) can happen after cache lines have been evicted. + +Signed-off-by: Eric Dumazet +Cc: Al Viro +Signed-off-by: Al Viro +Cc: Matthew Wilcox +Signed-off-by: Greg Kroah-Hartman + +--- + lib/iov_iter.c | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +--- a/lib/iov_iter.c ++++ b/lib/iov_iter.c +@@ -817,8 +817,21 @@ EXPORT_SYMBOL(_copy_from_iter_full_nocac + + static inline bool page_copy_sane(struct page *page, size_t offset, size_t n) + { +- struct page *head = compound_head(page); +- size_t v = n + offset + page_address(page) - page_address(head); ++ struct page *head; ++ size_t v = n + offset; ++ ++ /* ++ * The general case needs to access the page order in order ++ * to compute the page size. ++ * However, we mostly deal with order-0 pages and thus can ++ * avoid a possible cache line miss for requests that fit all ++ * page orders. ++ */ ++ if (n <= v && v <= PAGE_SIZE) ++ return true; ++ ++ head = compound_head(page); ++ v += (page - head) << PAGE_SHIFT; + + if (likely(n <= v && v <= (PAGE_SIZE << compound_order(head)))) + return true; diff --git a/queue-4.19/kbuild-turn-auto.conf.cmd-into-a-mandatory-include-file.patch b/queue-4.19/kbuild-turn-auto.conf.cmd-into-a-mandatory-include-file.patch new file mode 100644 index 00000000000..18470d2e325 --- /dev/null +++ b/queue-4.19/kbuild-turn-auto.conf.cmd-into-a-mandatory-include-file.patch @@ -0,0 +1,92 @@ +From d2f8ae0e4c5c754f1b2a7b8388d19a1a977e698a Mon Sep 17 00:00:00 2001 +From: Masahiro Yamada +Date: Sun, 12 May 2019 11:13:48 +0900 +Subject: kbuild: turn auto.conf.cmd into a mandatory include file + +From: Masahiro Yamada + +commit d2f8ae0e4c5c754f1b2a7b8388d19a1a977e698a upstream. + +syncconfig is responsible for keeping auto.conf up-to-date, so if it +fails for any reason, the build must be terminated immediately. + +However, since commit 9390dff66a52 ("kbuild: invoke syncconfig if +include/config/auto.conf.cmd is missing"), Kbuild continues running +even after syncconfig fails. + +You can confirm this by intentionally making syncconfig error out: + +# diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c +# index 08ba146..307b9de 100644 +# --- a/scripts/kconfig/confdata.c +# +++ b/scripts/kconfig/confdata.c +# @@ -1023,6 +1023,9 @@ int conf_write_autoconf(int overwrite) +# FILE *out, *tristate, *out_h; +# int i; +# +# + if (overwrite) +# + return 1; +# + +# if (!overwrite && is_present(autoconf_name)) +# return 0; + +Then, syncconfig fails, but Make would not stop: + + $ make -s mrproper allyesconfig defconfig + $ make + scripts/kconfig/conf --syncconfig Kconfig + + *** Error during sync of the configuration. + + make[2]: *** [scripts/kconfig/Makefile;69: syncconfig] Error 1 + make[1]: *** [Makefile;557: syncconfig] Error 2 + make: *** [include/config/auto.conf.cmd] Deleting file 'include/config/tristate.conf' + make: Failed to remake makefile 'include/config/auto.conf'. + SYSTBL arch/x86/include/generated/asm/syscalls_32.h + SYSHDR arch/x86/include/generated/asm/unistd_32_ia32.h + SYSHDR arch/x86/include/generated/asm/unistd_64_x32.h + SYSTBL arch/x86/include/generated/asm/syscalls_64.h + [ continue running ... ] + +The reason is in the behavior of a pattern rule with multi-targets. + + %/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG) + $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig + +GNU Make knows this rule is responsible for making all the three files +simultaneously. As far as examined, auto.conf.cmd is the target in +question when this rule is invoked. It is probably because auto.conf.cmd +is included below the inclusion of auto.conf. + +The inclusion of auto.conf is mandatory, while that of auto.conf.cmd +is optional. GNU Make does not care about the failure in the process +of updating optional include files. + +I filed this issue (https://savannah.gnu.org/bugs/?56301) in case this +behavior could be improved somehow in future releases of GNU Make. +Anyway, it is quite easy to fix our Makefile. + +Given that auto.conf is already a mandatory include file, there is no +reason to stick auto.conf.cmd optional. Make it mandatory as well. + +Cc: linux-stable # 5.0+ +Fixes: 9390dff66a52 ("kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing") +Signed-off-by: Masahiro Yamada +[commented out diff above to keep patch happy - gregkh] +Signed-off-by: Greg Kroah-Hartman + +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/Makefile ++++ b/Makefile +@@ -623,7 +623,7 @@ ifeq ($(may-sync-config),1) + # Read in dependencies to all Kconfig* files, make sure to run syncconfig if + # changes are detected. This should be included after arch/$(SRCARCH)/Makefile + # because some architectures define CROSS_COMPILE there. +--include include/config/auto.conf.cmd ++include include/config/auto.conf.cmd + + # To avoid any implicit rule to kick in, define an empty command + $(KCONFIG_CONFIG): ; diff --git a/queue-4.19/libnvdimm-namespace-fix-label-tracking-error.patch b/queue-4.19/libnvdimm-namespace-fix-label-tracking-error.patch new file mode 100644 index 00000000000..31fd8ac0ea3 --- /dev/null +++ b/queue-4.19/libnvdimm-namespace-fix-label-tracking-error.patch @@ -0,0 +1,158 @@ +From c4703ce11c23423d4b46e3d59aef7979814fd608 Mon Sep 17 00:00:00 2001 +From: Dan Williams +Date: Tue, 30 Apr 2019 21:51:21 -0700 +Subject: libnvdimm/namespace: Fix label tracking error + +From: Dan Williams + +commit c4703ce11c23423d4b46e3d59aef7979814fd608 upstream. + +Users have reported intermittent occurrences of DIMM initialization +failures due to duplicate allocations of address capacity detected in +the labels, or errors of the form below, both have the same root cause. + + nd namespace1.4: failed to track label: 0 + WARNING: CPU: 17 PID: 1381 at drivers/nvdimm/label.c:863 + + RIP: 0010:__pmem_label_update+0x56c/0x590 [libnvdimm] + Call Trace: + ? nd_pmem_namespace_label_update+0xd6/0x160 [libnvdimm] + nd_pmem_namespace_label_update+0xd6/0x160 [libnvdimm] + uuid_store+0x17e/0x190 [libnvdimm] + kernfs_fop_write+0xf0/0x1a0 + vfs_write+0xb7/0x1b0 + ksys_write+0x57/0xd0 + do_syscall_64+0x60/0x210 + +Unfortunately those reports were typically with a busy parallel +namespace creation / destruction loop making it difficult to see the +components of the bug. However, Jane provided a simple reproducer using +the work-in-progress sub-section implementation. + +When ndctl is reconfiguring a namespace it may take an existing defunct +/ disabled namespace and reconfigure it with a new uuid and other +parameters. Critically namespace_update_uuid() takes existing address +resources and renames them for the new namespace to use / reconfigure as +it sees fit. The bug is that this rename only happens in the resource +tracking tree. Existing labels with the old uuid are not reaped leading +to a scenario where multiple active labels reference the same span of +address range. + +Teach namespace_update_uuid() to flag any references to the old uuid for +reaping at the next label update attempt. + +Cc: +Fixes: bf9bccc14c05 ("libnvdimm: pmem label sets and namespace instantiation") +Link: https://github.com/pmem/ndctl/issues/91 +Reported-by: Jane Chu +Reported-by: Jeff Moyer +Reported-by: Erwin Tsaur +Cc: Johannes Thumshirn +Signed-off-by: Dan Williams +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/nvdimm/label.c | 29 ++++++++++++++++------------- + drivers/nvdimm/namespace_devs.c | 15 +++++++++++++++ + drivers/nvdimm/nd.h | 4 ++++ + 3 files changed, 35 insertions(+), 13 deletions(-) + +--- a/drivers/nvdimm/label.c ++++ b/drivers/nvdimm/label.c +@@ -623,6 +623,17 @@ static const guid_t *to_abstraction_guid + return &guid_null; + } + ++static void reap_victim(struct nd_mapping *nd_mapping, ++ struct nd_label_ent *victim) ++{ ++ struct nvdimm_drvdata *ndd = to_ndd(nd_mapping); ++ u32 slot = to_slot(ndd, victim->label); ++ ++ dev_dbg(ndd->dev, "free: %d\n", slot); ++ nd_label_free_slot(ndd, slot); ++ victim->label = NULL; ++} ++ + static int __pmem_label_update(struct nd_region *nd_region, + struct nd_mapping *nd_mapping, struct nd_namespace_pmem *nspm, + int pos, unsigned long flags) +@@ -630,9 +641,9 @@ static int __pmem_label_update(struct nd + struct nd_namespace_common *ndns = &nspm->nsio.common; + struct nd_interleave_set *nd_set = nd_region->nd_set; + struct nvdimm_drvdata *ndd = to_ndd(nd_mapping); +- struct nd_label_ent *label_ent, *victim = NULL; + struct nd_namespace_label *nd_label; + struct nd_namespace_index *nsindex; ++ struct nd_label_ent *label_ent; + struct nd_label_id label_id; + struct resource *res; + unsigned long *free; +@@ -701,18 +712,10 @@ static int __pmem_label_update(struct nd + list_for_each_entry(label_ent, &nd_mapping->labels, list) { + if (!label_ent->label) + continue; +- if (memcmp(nspm->uuid, label_ent->label->uuid, +- NSLABEL_UUID_LEN) != 0) +- continue; +- victim = label_ent; +- list_move_tail(&victim->list, &nd_mapping->labels); +- break; +- } +- if (victim) { +- dev_dbg(ndd->dev, "free: %d\n", slot); +- slot = to_slot(ndd, victim->label); +- nd_label_free_slot(ndd, slot); +- victim->label = NULL; ++ if (test_and_clear_bit(ND_LABEL_REAP, &label_ent->flags) ++ || memcmp(nspm->uuid, label_ent->label->uuid, ++ NSLABEL_UUID_LEN) == 0) ++ reap_victim(nd_mapping, label_ent); + } + + /* update index */ +--- a/drivers/nvdimm/namespace_devs.c ++++ b/drivers/nvdimm/namespace_devs.c +@@ -1248,12 +1248,27 @@ static int namespace_update_uuid(struct + for (i = 0; i < nd_region->ndr_mappings; i++) { + struct nd_mapping *nd_mapping = &nd_region->mapping[i]; + struct nvdimm_drvdata *ndd = to_ndd(nd_mapping); ++ struct nd_label_ent *label_ent; + struct resource *res; + + for_each_dpa_resource(ndd, res) + if (strcmp(res->name, old_label_id.id) == 0) + sprintf((void *) res->name, "%s", + new_label_id.id); ++ ++ mutex_lock(&nd_mapping->lock); ++ list_for_each_entry(label_ent, &nd_mapping->labels, list) { ++ struct nd_namespace_label *nd_label = label_ent->label; ++ struct nd_label_id label_id; ++ ++ if (!nd_label) ++ continue; ++ nd_label_gen_id(&label_id, nd_label->uuid, ++ __le32_to_cpu(nd_label->flags)); ++ if (strcmp(old_label_id.id, label_id.id) == 0) ++ set_bit(ND_LABEL_REAP, &label_ent->flags); ++ } ++ mutex_unlock(&nd_mapping->lock); + } + kfree(*old_uuid); + out: +--- a/drivers/nvdimm/nd.h ++++ b/drivers/nvdimm/nd.h +@@ -113,8 +113,12 @@ struct nd_percpu_lane { + spinlock_t lock; + }; + ++enum nd_label_flags { ++ ND_LABEL_REAP, ++}; + struct nd_label_ent { + struct list_head list; ++ unsigned long flags; + struct nd_namespace_label *label; + }; + diff --git a/queue-4.19/pstore-allocate-compression-during-late_initcall.patch b/queue-4.19/pstore-allocate-compression-during-late_initcall.patch new file mode 100644 index 00000000000..5b3e20e6a06 --- /dev/null +++ b/queue-4.19/pstore-allocate-compression-during-late_initcall.patch @@ -0,0 +1,67 @@ +From 416031653eb55f844e3547fb8f8576399a800da0 Mon Sep 17 00:00:00 2001 +From: "Joel Fernandes (Google)" +Date: Wed, 17 Oct 2018 03:13:55 -0700 +Subject: pstore: Allocate compression during late_initcall() + +From: Joel Fernandes (Google) + +commit 416031653eb55f844e3547fb8f8576399a800da0 upstream. + +ramoops's call of pstore_register() was recently moved to run during +late_initcall() because the crypto backend may not have been ready during +postcore_initcall(). This meant early-boot crash dumps were not getting +caught by pstore any more. + +Instead, lets allow calls to pstore_register() earlier, and once crypto +is ready we can initialize the compression. + +Reported-by: Sai Prakash Ranjan +Signed-off-by: Joel Fernandes (Google) +Tested-by: Sai Prakash Ranjan +Fixes: cb3bee0369bc ("pstore: Use crypto compress API") +[kees: trivial rebase] +Signed-off-by: Kees Cook +Tested-by: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman + +--- + fs/pstore/platform.c | 10 +++++++++- + fs/pstore/ram.c | 2 +- + 2 files changed, 10 insertions(+), 2 deletions(-) + +--- a/fs/pstore/platform.c ++++ b/fs/pstore/platform.c +@@ -786,13 +786,21 @@ static int __init pstore_init(void) + + pstore_choose_compression(); + ++ /* ++ * Check if any pstore backends registered earlier but did not ++ * initialize compression because crypto was not ready. If so, ++ * initialize compression now. ++ */ ++ if (psinfo && !tfm) ++ allocate_buf_for_compression(); ++ + ret = pstore_init_fs(); + if (ret) + return ret; + + return 0; + } +-module_init(pstore_init) ++late_initcall(pstore_init); + + static void __exit pstore_exit(void) + { +--- a/fs/pstore/ram.c ++++ b/fs/pstore/ram.c +@@ -956,7 +956,7 @@ static int __init ramoops_init(void) + + return ret; + } +-late_initcall(ramoops_init); ++postcore_initcall(ramoops_init); + + static void __exit ramoops_exit(void) + { diff --git a/queue-4.19/pstore-centralize-init-exit-routines.patch b/queue-4.19/pstore-centralize-init-exit-routines.patch new file mode 100644 index 00000000000..2e62bde73a1 --- /dev/null +++ b/queue-4.19/pstore-centralize-init-exit-routines.patch @@ -0,0 +1,102 @@ +From cb095afd44768bf495894b9ad063bd078e4bb201 Mon Sep 17 00:00:00 2001 +From: Kees Cook +Date: Thu, 18 Oct 2018 11:17:42 -0700 +Subject: pstore: Centralize init/exit routines + +From: Kees Cook + +commit cb095afd44768bf495894b9ad063bd078e4bb201 upstream. + +In preparation for having additional actions during init/exit, this moves +the init/exit into platform.c, centralizing the logic to make call outs +to the fs init/exit. + +Signed-off-by: Kees Cook +Tested-by: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman + +--- + fs/pstore/inode.c | 11 ++--------- + fs/pstore/internal.h | 5 +++-- + fs/pstore/platform.c | 23 +++++++++++++++++++++++ + 3 files changed, 28 insertions(+), 11 deletions(-) + +--- a/fs/pstore/inode.c ++++ b/fs/pstore/inode.c +@@ -482,12 +482,10 @@ static struct file_system_type pstore_fs + .kill_sb = pstore_kill_sb, + }; + +-static int __init init_pstore_fs(void) ++int __init pstore_init_fs(void) + { + int err; + +- pstore_choose_compression(); +- + /* Create a convenient mount point for people to access pstore */ + err = sysfs_create_mount_point(fs_kobj, "pstore"); + if (err) +@@ -500,14 +498,9 @@ static int __init init_pstore_fs(void) + out: + return err; + } +-module_init(init_pstore_fs) + +-static void __exit exit_pstore_fs(void) ++void __exit pstore_exit_fs(void) + { + unregister_filesystem(&pstore_fs_type); + sysfs_remove_mount_point(fs_kobj, "pstore"); + } +-module_exit(exit_pstore_fs) +- +-MODULE_AUTHOR("Tony Luck "); +-MODULE_LICENSE("GPL"); +--- a/fs/pstore/internal.h ++++ b/fs/pstore/internal.h +@@ -37,7 +37,8 @@ extern bool pstore_is_mounted(void); + extern void pstore_record_init(struct pstore_record *record, + struct pstore_info *psi); + +-/* Called during module_init() */ +-extern void __init pstore_choose_compression(void); ++/* Called during pstore init/exit. */ ++int __init pstore_init_fs(void); ++void __exit pstore_exit_fs(void); + + #endif +--- a/fs/pstore/platform.c ++++ b/fs/pstore/platform.c +@@ -780,8 +780,31 @@ void __init pstore_choose_compression(vo + } + } + ++static int __init pstore_init(void) ++{ ++ int ret; ++ ++ pstore_choose_compression(); ++ ++ ret = pstore_init_fs(); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++module_init(pstore_init) ++ ++static void __exit pstore_exit(void) ++{ ++ pstore_exit_fs(); ++} ++module_exit(pstore_exit) ++ + module_param(compress, charp, 0444); + MODULE_PARM_DESC(compress, "Pstore compression to use"); + + module_param(backend, charp, 0444); + MODULE_PARM_DESC(backend, "Pstore backend to use"); ++ ++MODULE_AUTHOR("Tony Luck "); ++MODULE_LICENSE("GPL"); diff --git a/queue-4.19/pstore-refactor-compression-initialization.patch b/queue-4.19/pstore-refactor-compression-initialization.patch new file mode 100644 index 00000000000..68158dd703d --- /dev/null +++ b/queue-4.19/pstore-refactor-compression-initialization.patch @@ -0,0 +1,111 @@ +From 95047b0519c17a28e09df5f38750f5354e3db4c4 Mon Sep 17 00:00:00 2001 +From: Kees Cook +Date: Wed, 17 Oct 2018 14:00:12 -0700 +Subject: pstore: Refactor compression initialization + +From: Kees Cook + +commit 95047b0519c17a28e09df5f38750f5354e3db4c4 upstream. + +This refactors compression initialization slightly to better handle +getting potentially called twice (via early pstore_register() calls +and later pstore_init()) and improves the comments and reporting to be +more verbose. + +Signed-off-by: Kees Cook +Tested-by: Guenter Roeck +Signed-off-by: Greg Kroah-Hartman + +--- + fs/pstore/platform.c | 48 +++++++++++++++++++++++++++++++++--------------- + 1 file changed, 33 insertions(+), 15 deletions(-) + +--- a/fs/pstore/platform.c ++++ b/fs/pstore/platform.c +@@ -274,36 +274,56 @@ static int pstore_decompress(void *in, v + + static void allocate_buf_for_compression(void) + { ++ struct crypto_comp *ctx; ++ int size; ++ char *buf; ++ ++ /* Skip if not built-in or compression backend not selected yet. */ + if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS) || !zbackend) + return; + ++ /* Skip if no pstore backend yet or compression init already done. */ ++ if (!psinfo || tfm) ++ return; ++ + if (!crypto_has_comp(zbackend->name, 0, 0)) { +- pr_err("No %s compression\n", zbackend->name); ++ pr_err("Unknown compression: %s\n", zbackend->name); + return; + } + +- big_oops_buf_sz = zbackend->zbufsize(psinfo->bufsize); +- if (big_oops_buf_sz <= 0) ++ size = zbackend->zbufsize(psinfo->bufsize); ++ if (size <= 0) { ++ pr_err("Invalid compression size for %s: %d\n", ++ zbackend->name, size); + return; ++ } + +- big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL); +- if (!big_oops_buf) { +- pr_err("allocate compression buffer error!\n"); ++ buf = kmalloc(size, GFP_KERNEL); ++ if (!buf) { ++ pr_err("Failed %d byte compression buffer allocation for: %s\n", ++ size, zbackend->name); + return; + } + +- tfm = crypto_alloc_comp(zbackend->name, 0, 0); +- if (IS_ERR_OR_NULL(tfm)) { +- kfree(big_oops_buf); +- big_oops_buf = NULL; +- pr_err("crypto_alloc_comp() failed!\n"); ++ ctx = crypto_alloc_comp(zbackend->name, 0, 0); ++ if (IS_ERR_OR_NULL(ctx)) { ++ kfree(buf); ++ pr_err("crypto_alloc_comp('%s') failed: %ld\n", zbackend->name, ++ PTR_ERR(ctx)); + return; + } ++ ++ /* A non-NULL big_oops_buf indicates compression is available. */ ++ tfm = ctx; ++ big_oops_buf_sz = size; ++ big_oops_buf = buf; ++ ++ pr_info("Using compression: %s\n", zbackend->name); + } + + static void free_buf_for_compression(void) + { +- if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && !IS_ERR_OR_NULL(tfm)) ++ if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm) + crypto_free_comp(tfm); + kfree(big_oops_buf); + big_oops_buf = NULL; +@@ -774,7 +794,6 @@ void __init pstore_choose_compression(vo + for (step = zbackends; step->name; step++) { + if (!strcmp(compress, step->name)) { + zbackend = step; +- pr_info("using %s compression\n", zbackend->name); + return; + } + } +@@ -791,8 +810,7 @@ static int __init pstore_init(void) + * initialize compression because crypto was not ready. If so, + * initialize compression now. + */ +- if (psinfo && !tfm) +- allocate_buf_for_compression(); ++ allocate_buf_for_compression(); + + ret = pstore_init_fs(); + if (ret) diff --git a/queue-4.19/series b/queue-4.19/series index 5a5009844a4..12cfaa2ed12 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -92,3 +92,14 @@ alsa-hda-realtek-fix-for-lenovo-b50-70-inverted-internal-microphone-bug.patch jbd2-fix-potential-double-free.patch kvm-x86-skip-efer-vs.-guest-cpuid-checks-for-host-initiated-writes.patch kvm-lapic-busy-wait-for-timer-to-expire-when-using-hv_timer.patch +kbuild-turn-auto.conf.cmd-into-a-mandatory-include-file.patch +xen-pvh-set-xen_domain_type-to-hvm-in-xen_pvh_init.patch +libnvdimm-namespace-fix-label-tracking-error.patch +iov_iter-optimize-page_copy_sane.patch +pstore-centralize-init-exit-routines.patch +pstore-allocate-compression-during-late_initcall.patch +pstore-refactor-compression-initialization.patch +ext4-unsigned-int-compared-against-zero.patch +ext4-fix-block-validity-checks-for-journal-inodes-using-indirect-blocks.patch +ext4-fix-compile-error-when-using-buffer_trace.patch +ext4-don-t-update-s_rev_level-if-not-required.patch diff --git a/queue-4.19/xen-pvh-set-xen_domain_type-to-hvm-in-xen_pvh_init.patch b/queue-4.19/xen-pvh-set-xen_domain_type-to-hvm-in-xen_pvh_init.patch new file mode 100644 index 00000000000..f49b24fee6a --- /dev/null +++ b/queue-4.19/xen-pvh-set-xen_domain_type-to-hvm-in-xen_pvh_init.patch @@ -0,0 +1,34 @@ +From c9f804d64bb93c8dbf957df1d7e9de11380e522d Mon Sep 17 00:00:00 2001 +From: Roger Pau Monne +Date: Tue, 23 Apr 2019 15:04:15 +0200 +Subject: xen/pvh: set xen_domain_type to HVM in xen_pvh_init +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Roger Pau Monne + +commit c9f804d64bb93c8dbf957df1d7e9de11380e522d upstream. + +Or else xen_domain() returns false despite xen_pvh being set. + +Signed-off-by: Roger Pau Monné +Reviewed-by: Boris Ostrovsky +Signed-off-by: Boris Ostrovsky +Cc: stable@vger.kernel.org # 4.19+ +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/xen/enlighten_pvh.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/arch/x86/xen/enlighten_pvh.c ++++ b/arch/x86/xen/enlighten_pvh.c +@@ -97,6 +97,7 @@ void __init xen_prepare_pvh(void) + } + + xen_pvh = 1; ++ xen_domain_type = XEN_HVM_DOMAIN; + xen_start_flags = pvh_start_info.flags; + + msr = cpuid_ebx(xen_cpuid_base() + 2); -- 2.47.2