5.3.8-stable review
Subsystems (9)
Greg Kroah-Hartman
maintainerPATCH 151/197 mm: memcg: get number of pages on the LRU list in memcgroup base on lru_zone_size
In reply to Greg Kroah-HartmanFrom: Honglei Wang <[email protected]>
commit b11edebbc967ebf5c55b8f9e1d5bb6d68ec3a7fd upstream.
Commit 1a61ab8038e72 ("mm: memcontrol: replace zone summing with lruvec_page_state()") has made lruvec_page_state to use per-cpu counters instead of calculating it directly from lru_zone_size with an idea that this would be more effective.
Tim has reported that this is not really the case for their database benchmark which is showing an opposite results where lruvec_page_state is taking up a huge chunk of CPU cycles (about 25% of the system time which is roughly 7% of total cpu cycles) on 5.3 kernels. The workload is running on a larger machine (96cpus), it has many cgroups (500) and it is heavily direct reclaim bound.
Tim Chen said:
: The problem can also be reproduced by running simple multi-threaded : pmbench benchmark with a fast Optane SSD swap (see profile below). :
:
: 6.15% 3.08% pmbench [kernel.vmlinux] [k] lruvec_lru_size
: | : |--3.07%--lruvec_lru_size : | | : | |--2.11%--cpumask_next : | | | : | | --1.66%--find_next_bit : | | : | --0.57%--call_function_interrupt : | | : | --0.55%--smp_call_function_interrupt : | : |--1.59%--0x441f0fc3d009 : | _ops_rdtsc_init_base_freq : | access_histogram : | page_fault : | __do_page_fault : | handle_mm_fault : | __handle_mm_fault : | | : | --1.54%--do_swap_page : | swapin_readahead : | swap_cluster_readahead : | | : | --1.53%--read_swap_cache_async : | __read_swap_cache_async : | alloc_pages_vma : | __alloc_pages_nodemask : | __alloc_pages_slowpath : | try_to_free_pages : | do_try_to_free_pages : | shrink_node : | shrink_node_memcg : | | : | |--0.77%--lruvec_lru_size : | | : | --0.76%--inactive_list_is_low : | | : | --0.76%--lruvec_lru_size : | : --1.50%--measure_read : page_fault : __do_page_fault : handle_mm_fault : __handle_mm_fault : do_swap_page : swapin_readahead : swap_cluster_readahead : | : --1.48%--read_swap_cache_async : __read_swap_cache_async : alloc_pages_vma : __alloc_pages_nodemask : __alloc_pages_slowpath : try_to_free_pages : do_try_to_free_pages : shrink_node : shrink_node_memcg : | : |--0.75%--inactive_list_is_low : | | : | --0.75%--lruvec_lru_size : |
: --0.73%--lruvec_lru_size
The likely culprit is the cache traffic the lruvec_page_state_local generates. Dave Hansen says:
: I was thinking purely of the cache footprint. If it's reading : pn->lruvec_stat_local->count[idx] is three separate cachelines, so 192 : bytes of cache *96 CPUs = 18k of data, mostly read-only. 1 cgroup would : be 18k of data for the whole system and the caching would be pretty : efficient and all 18k would probably survive a tight page fault loop in : the L1. 500 cgroups would be ~90k of data per CPU thread which doesn't : fit in the L1 and probably wouldn't survive a tight page fault loop if : both logical threads were banging on different cgroups.
:
: It's just a theory, but it's why I noted the number of cgroups when I : initially saw this show up in profiles
Fix the regression by partially reverting the said commit and calculate the lru size explicitly.
--- mm/vmscan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
mm/vmscan.c +5 -4
@@ -354,12 +354,13 @@ unsigned long zone_reclaimable_pages(str*/ unsigned long lruvec_lru_size (struct lruvec *lruvec,enum lru_list lru,int zone_idx) { -unsigned long lru_size; +unsigned long lru_size =0 ;int zid; -if (!mem_cgroup_disabled ()) - lru_size =lruvec_page_state_local (lruvec,NR_LRU_BASE + lru); -else +if (!mem_cgroup_disabled ()) { +for (zid =0 ; zid <MAX_NR_ZONES ; zid++) + lru_size +=mem_cgroup_get_zone_lru_size (lruvec, lru, zid); + }else lru_size =node_page_state (lruvec_pgdat (lruvec),NR_LRU_BASE + lru);for (zid = zone_idx +1 ; zid <MAX_NR_ZONES ; zid++) {
Greg Kroah-Hartman
maintainerPATCH 152/197 mm: memblock: do not enforce current limit for memblock_phys* family
In reply to Greg Kroah-HartmanFrom: Mike Rapoport <[email protected]>
commit f3057ad767542be7bbac44e548cb44017178a163 upstream.
Until commit 92d12f9544b7 ("memblock: refactor internal allocation functions") the maximal address for memblock allocations was forced to memblock.current_limit only for the allocation functions returning virtual address. The changes introduced by that commit moved the limit enforcement into the allocation core and as a result the allocation functions returning physical address also started to limit allocations to memblock.current_limit.
This caused breakage of etnaviv GPU driver:
etnaviv etnaviv: bound 130000.gpu (ops gpu_ops)
etnaviv etnaviv: bound 134000.gpu (ops gpu_ops)
etnaviv etnaviv: bound 2204000.gpu (ops gpu_ops) etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108 etnaviv-gpu 130000.gpu: command buffer outside valid memory window etnaviv-gpu 134000.gpu: model: GC320, revision: 5007 etnaviv-gpu 134000.gpu: command buffer outside valid memory window etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215 etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0
Restore the behaviour of memblock_phys* family so that these functions will not enforce memblock.current_limit.
--- mm/memblock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/memblock.c +3 -3
@@ -1356,9 +1356,6 @@ static phys_addr_t __init memblock_alloc align =SMP_CACHE_BYTES ; } -if (end > memblock.current_limit) - end = memblock.current_limit; - again: found =memblock_find_in_range_node (size, align, start, end, nid, flags);
@@ -1469,6 +1466,9 @@ static void * __init memblock_alloc_inteif (WARN_ON_ONCE (slab_is_available ()))return kzalloc_node (size,GFP_NOWAIT , nid); +if (max_addr > memblock.current_limit) + max_addr = memblock.current_limit; + alloc =memblock_alloc_range_nid (size, align, min_addr, max_addr, nid);/* retry allocation without lower limit */
Greg Kroah-Hartman
maintainerPATCH 153/197 hugetlbfs: dont access uninitialized memmaps in pfn_range_valid_gigantic()
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
commit f231fe4235e22e18d847e05cbe705deaca56580a upstream.
Uninitialized memmaps contain garbage and in the worst case trigger kernel BUGs, especially with CONFIG_PAGE_POISONING. They should not get touched.
Let's make sure that we only consider online memory (managed by the buddy) that has initialized memmaps. ZONE_DEVICE is not applicable.
page_zone() will call page_to_nid(), which will trigger VM_BUG_ON_PGFLAGS(PagePoisoned(page), page) with CONFIG_PAGE_POISONING and CONFIG_DEBUG_VM_PGFLAGS when called on uninitialized memmaps. This can be the case when an offline memory block (e.g., never onlined) is spanned by a zone.
Note: As explained by Michal in [1], alloc_contig_range() will verify the range. So it boils down to the wrong access in this function.
[1] http://lkml.kernel.org/r/[email protected]
--- mm/hugetlb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
mm/hugetlb.c +2 -3
@@ -1084,11 +1084,10 @@ static bool pfn_range_valid_gigantic(strstruct page *page;for (i = start_pfn; i < end_pfn; i++) { -if (!pfn_valid (i)) + page =pfn_to_online_page (i); +if (!page)return false; - page =pfn_to_page (i); -if (page_zone (page) != z)return false;
Greg Kroah-Hartman
maintainerPATCH 154/197 mm/memory-failure: poison read receives SIGKILL instead of SIGBUS if mmaped more than once
In reply to Greg Kroah-HartmanFrom: Jane Chu <[email protected]>
commit 3d7fed4ad8ccb691d217efbb0f934e6a4df5ef91 upstream.
Mmap /dev/dax more than once, then read the poison location using address from one of the mappings. The other mappings due to not having the page mapped in will cause SIGKILLs delivered to the process. SIGKILL succeeds over SIGBUS, so user process loses the opportunity to handle the UE.
Although one may add MAP_POPULATE to mmap(2) to work around the issue, MAP_POPULATE makes mapping 128GB of pmem several magnitudes slower, so isn't always an option.
Details -
ndctl inject-error --block=10 --count=1 namespace6.0
./read_poison -x dax6.0 -o 5120 -m 2
mmaped address 0x7f5bb6600000
mmaped address 0x7f3cf3600000
doing local read at address 0x7f3cf3601400
Killed
Console messages in instrumented kernel -
mce: Uncorrected hardware memory error in user-access at edbe201400
Memory failure: tk->addr = 7f5bb6601000
Memory failure: address edbe201: call dev_pagemap_mapping_shift
dev_pagemap_mapping_shift: page edbe201: no PUD
Memory failure: tk->size_shift == 0
Memory failure: Unable to find user space address edbe201 in read_poison
Memory failure: tk->addr = 7f3cf3601000
Memory failure: address edbe201: call dev_pagemap_mapping_shift
Memory failure: tk->size_shift = 21
Memory failure: 0xedbe201: forcibly killing read_poison:22434 because of failure to unmap corrupted page
=> to deliver SIGKILL
Memory failure: 0xedbe201: Killing read_poison:22434 due to hardware memory corruption
=> to deliver SIGBUS
--- mm/memory-failure.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
mm/memory-failure.c +13 -9
@@ -199,7 +199,6 @@ struct to_kill {struct task_struct *tsk;unsigned long addr;short size_shift; -char addr_valid; };/*
@@ -324,22 +323,27 @@ static void add_to_kill(struct task_stru } } tk->addr =page_address_in_vma (p, vma); - tk->addr_valid =1 ;if (is_zone_device_page (p)) tk->size_shift =dev_pagemap_mapping_shift (p, vma);else tk->size_shift =compound_order (compound_head (p)) +PAGE_SHIFT ;/* -* In theory we don't have to kill when the page was -* munmaped. But it could be also a mremap. Since that's -* likely very rare kill anyways just out of paranoia, but use -* a SIGKILL because the error is not contained anymore. +* Send SIGKILL if "tk->addr == -EFAULT". Also, as +* "tk->size_shift" is always non-zero for !is_zone_device_page(), +* so "tk->size_shift == 0" effectively checks no mapping on +* ZONE_DEVICE. Indeed, when a devdax page is mmapped N times +* to a process' address space, it's possible not all N VMAs +* contain mappings for the page, but at least one VMA does. +* Only deliver SIGBUS with payload derived from the VMA that +* has a mapping for the page. */ -if (tk->addr == -EFAULT || tk->size_shift ==0 ) { +if (tk->addr == -EFAULT ) {pr_info ("Memory failure: Unable to find user space address %lx in %s\n" ,page_to_pfn (p), tsk->comm); - tk->addr_valid =0 ; + }else if (tk->size_shift ==0 ) { +kfree (tk); +return ; }get_task_struct (tsk); tk->tsk = tsk;
@@ -366,7 +370,7 @@ static void kill_procs(struct list_head* make sure the process doesn't catch the * signal and then access the memory. Just kill it. */ -if (fail || tk->addr_valid ==0 ) { +if (fail || tk->addr == -EFAULT ) {pr_err ("Memory failure: %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n" , pfn, tk->tsk->comm, tk->tsk->pid); do_send_sig_info(SIGKILL, SEND_SIG_PRIV,
Greg Kroah-Hartman
maintainerPATCH 155/197 zram: fix race between backing_dev_show and backing_dev_store
In reply to Greg Kroah-HartmanFrom: Chenwandun <[email protected]>
commit f7daefe4231e57381d92c2e2ad905a899c28e402 upstream.
CPU0: CPU1:backing_dev_show backing_dev_store
...... ......
file = zram->backing_dev;
down_read(&zram->init_lock); down_read(&zram->init_init_lock)
file_path(file, ...); zram->backing_dev = backing_dev;
up_read(&zram->init_lock); up_read(&zram->init_lock);gets the value of zram->backing_dev too early in backing_dev_show, which resultin the value being NULL at the beginning, and not NULL later.
backtrace:
d_path+0xcc/0x174 file_path+0x10/0x18 backing_dev_show+0x40/0xb4 dev_attr_show+0x20/0x54 sysfs_kf_seq_show+0x9c/0x10c kernfs_seq_show+0x28/0x30 seq_read+0x184/0x488 kernfs_fop_read+0x5c/0x1a4 __vfs_read+0x44/0x128 vfs_read+0xa0/0x138 SyS_read+0x54/0xb4
--- drivers/block/zram/zram_drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/block/zram/zram_drv.c +3 -2
@@ -413,13 +413,14 @@ static void reset_bdev(struct zram *zramstatic ssize_t backing_dev_show (struct device *dev,struct device_attribute *attr,char *buf) { +struct file *file;struct zram *zram =dev_to_zram (dev); -struct file *file = zram->backing_dev;char *p;ssize_t ret;down_read (&zram->init_lock); -if (!zram->backing_dev) { + file = zram->backing_dev; +if (!file) {memcpy (buf,"none\n" ,5 );up_read (&zram->init_lock);return 5 ;
Greg Kroah-Hartman
maintainerPATCH 156/197 xtensa: drop EXPORT_SYMBOL for outs*/ins*
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit 8b39da985194aac2998dd9e3a22d00b596cebf1e upstream.
Custom outs*/ins* implementations are long gone from the xtensa port, remove matching EXPORT_SYMBOLs.
This fixes the following build warnings issued by modpost since commit 15bfc2348d54 ("modpost: check for static EXPORT_SYMBOL* functions"):
WARNING: "insb" [vmlinux] is a static EXPORT_SYMBOL
WARNING: "insw" [vmlinux] is a static EXPORT_SYMBOL
WARNING: "insl" [vmlinux] is a static EXPORT_SYMBOL
WARNING: "outsb" [vmlinux] is a static EXPORT_SYMBOL
WARNING: "outsw" [vmlinux] is a static EXPORT_SYMBOL
WARNING: "outsl" [vmlinux] is a static EXPORT_SYMBOL
--- arch/xtensa/kernel/xtensa_ksyms.c | 7 ------- 1 file changed, 7 deletions(-)
arch/xtensa/kernel/xtensa_ksyms.c +0 -7
@@ -119,13 +119,6 @@ EXPORT_SYMBOL(__invalidate_icache_range)// FIXME EXPORT_SYMBOL(screen_info); #endif -EXPORT_SYMBOL (outsb); -EXPORT_SYMBOL (outsw); -EXPORT_SYMBOL (outsl); -EXPORT_SYMBOL (insb); -EXPORT_SYMBOL (insw); -EXPORT_SYMBOL (insl); -extern long common_exception_return;EXPORT_SYMBOL (common_exception_return);
Greg Kroah-Hartman
maintainerPATCH 157/197 xtensa: fix change_bit in exclusive access option
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit 775fd6bfefc66a8c33e91dd9687ed530643b954d upstream.
change_bit implementation for XCHAL_HAVE_EXCLUSIVE case changes all bits except the one required due to copy-paste error from clear_bit.
--- arch/xtensa/include/asm/bitops.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/xtensa/include/asm/bitops.h +1 -1
@@ -148,7 +148,7 @@ static inline void change_bit(unsigned i" getex %0\n" " beqz %0, 1b\n" : "=&a" (tmp) - : "a" (~mask), "a" (p) + : "a" (mask), "a" (p) : "memory"); }
Greg Kroah-Hartman
maintainerPATCH 158/197 s390/zcrypt: fix memleak at release
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 388bb19be8eab4674a660e0c97eaf60775362bc7 upstream.
If a process is interrupted while accessing the crypto device and the global ap_perms_mutex is contented, release() could return early and fail to free related resources.
--- drivers/s390/crypto/zcrypt_api.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/s390/crypto/zcrypt_api.c +1 -2
@@ -539,8 +539,7 @@ static int zcrypt_release(struct inode *if (filp->f_inode->i_cdev == &zcrypt_cdev) {struct zcdn_device *zcdndev; -if (mutex_lock_interruptible (&ap_perms_mutex)) -return -ERESTARTSYS ; +mutex_lock (&ap_perms_mutex); zcdndev =find_zcdndev_by_devt (filp->f_inode->i_rdev);mutex_unlock (&ap_perms_mutex);if (zcdndev) {
Greg Kroah-Hartman
maintainerPATCH 159/197 s390/kaslr: add support for R_390_GLOB_DAT relocation type
In reply to Greg Kroah-HartmanFrom: Gerald Schaefer <[email protected]>
commit ac49303d9ef0ad98b79867a380ef23480e48870b upstream.
Commit "bpf: Process in-kernel BTF" in linux-next introduced an undefined __weak symbol, which results in an R_390_GLOB_DAT relocation type. That is not yet handled by the KASLR relocation code, and the kernel stops with the message "Unknown relocation type".
Add code to detect and handle R_390_GLOB_DAT relocation types and undefined symbols.
--- arch/s390/boot/startup.c | 14 +++++++++++--- arch/s390/kernel/machine_kexec_reloc.c | 1 + 2 files changed, 12 insertions(+), 3 deletions(-)
arch/s390/boot/startup.c +11 -3
@@ -101,10 +101,18 @@ static void handle_relocs(unsigned long dynsym = (Elf64_Sym *) vmlinux.dynsym_start;for (rela = rela_start; rela < rela_end; rela++) { loc = rela->r_offset + offset; - val = rela->r_addend + offset; + val = rela->r_addend; r_sym =ELF64_R_SYM (rela->r_info); -if (r_sym) - val += dynsym[r_sym].st_value; +if (r_sym) { +if (dynsym[r_sym].st_shndx !=SHN_UNDEF ) + val += dynsym[r_sym].st_value + offset; + }else { +/* +* 0 == undefined symbol table index (STN_UNDEF), +* used for R_390_RELATIVE, only add KASLR offset +*/ + val += offset; + } r_type =ELF64_R_TYPE (rela->r_info); rc =arch_kexec_do_relocs (r_type, (void *) loc, val,0 );if (rc)
arch/s390/kernel/machine_kexec_reloc.c +1 -0
@@ -27,6 +27,7 @@ int arch_kexec_do_relocs(int r_type, voi *(u32 *)loc = val;break ;case R_390_64 :/* Direct 64 bit. */ +case R_390_GLOB_DAT : *(u64 *)loc = val;break ;case R_390_PC16 :/* PC relative 16 bit. */
Greg Kroah-Hartman
maintainerPATCH 160/197 lib/vdso: Make clock_getres() POSIX compliant again
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 1638b8f096ca165965189b9626564c933c79fe63 upstream.
A recent commit removed the NULL pointer check from the clock_getres() implementation causing a test case to fault.
POSIX requires an explicit NULL pointer check for clock_getres() aside of the validity check of the clock_id argument for obscure reasons.
Add it back for both 32bit and 64bit.
Note, this is only a partial revert of the offending commit which does not bring back the broken fallback invocation in the the 32bit compat implementations of clock_getres() and clock_gettime().
--- lib/vdso/gettimeofday.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
lib/vdso/gettimeofday.c +5 -4
@@ -214,9 +214,10 @@ int __cvdso_clock_getres_common(clockid_return -1 ; } - res->tv_sec =0 ; - res->tv_nsec = ns; - +if (likely (res)) { + res->tv_sec =0 ; + res->tv_nsec = ns; + }return 0 ; }
@@ -245,7 +246,7 @@ __cvdso_clock_getres_time32(clockid_t cl ret =clock_getres_fallback (clock, &ts);#endif -if (likely (!ret)) { +if (likely (!ret && res)) { res->tv_sec = ts.tv_sec; res->tv_nsec = ts.tv_nsec; }
Greg Kroah-Hartman
maintainerPATCH 161/197 parisc: Fix vmap memory leak in ioremap()/iounmap()
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
commit 513f7f747e1cba81f28a436911fba0b485878ebd upstream.
Sven noticed that calling ioremap() and iounmap() multiple times leads to a vmap memory leak:
vmap allocation for size 4198400 failed:
use vmalloc=<size> to increase size
It seems we missed calling vunmap() in iounmap().
--- arch/parisc/mm/ioremap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
arch/parisc/mm/ioremap.c +7 -5
@@ -3,7 +3,7 @@* arch/parisc/mm/ioremap.c * * (C) Copyright 1995 1996 Linus Torvalds -* (C) Copyright 2001-2006 Helge Deller <[email protected]> +* (C) Copyright 2001-2019 Helge Deller <[email protected]> * (C) Copyright 2005 Kyle McMartin <[email protected]> */
@@ -84,7 +84,7 @@ void __iomem * __ioremap(unsigned long p addr = (void __iomem *) area->addr;if (ioremap_page_range ((unsigned long )addr, (unsigned long )addr + size, phys_addr, pgprot)) { -vfree (addr); +vunmap (addr);return NULL ; }
@@ -92,9 +92,11 @@ void __iomem * __ioremap(unsigned long p }EXPORT_SYMBOL (__ioremap); -void iounmap (const volatile void __iomem *addr) +void iounmap (const volatile void __iomem *io_addr) { -if (addr > high_memory) -return vfree ((void *) (PAGE_MASK & (unsigned long __force ) addr)); +unsigned long addr = (unsigned long )io_addr &PAGE_MASK ; + +if (is_vmalloc_addr ((void *)addr)) +vunmap ((void *)addr); }EXPORT_SYMBOL (iounmap);
Greg Kroah-Hartman
maintainerPATCH 162/197 EDAC/ghes: Fix Use after free in ghes_edac remove path
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit 1e72e673b9d102ff2e8333e74b3308d012ddf75b upstream.
ghes_edac models a single logical memory controller, and uses a global ghes_init variable to ensure only the first ghes_edac_register() will do anything.
ghes_edac is registered the first time a GHES entry in the HEST is probed. There may be multiple entries, so subsequent attempts to register ghes_edac are silently ignored as the work has already been done.
When a GHES entry is unregistered, it calls ghes_edac_unregister(), which free()s the memory behind the global variables in ghes_edac.
But there may be multiple GHES entries, the next call to ghes_edac_unregister() will dereference the free()d memory, and attempt to free it a second time.
This may also be triggered on a platform with one GHES entry, if the driver is unbound/re-bound and unbound. The re-bind step will do nothing because of ghes_init, the second unbind will then do the same work as the first.
Doing the unregister work on the first call is unsafe, as another CPU may be processing a notification in ghes_edac_report_mem_error(), using the memory we are about to free.
ghes_init is already half of the reference counting. We only need to do the register work for the first call, and the unregister work for the last. Add the unregister check.
This means we no longer free ghes_edac's memory while there are GHES entries that may receive a notification.
This was detected by KASAN and DEBUG_TEST_DRIVER_REMOVE.
[ bp: merge into a single patch. ]
--- drivers/edac/ghes_edac.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/edac/ghes_edac.c +4 -0
@@ -553,7 +553,11 @@ void ghes_edac_unregister(struct ghes *gif (!ghes_pvt)return ; +if (atomic_dec_return (&ghes_init)) +return ; + mci = ghes_pvt->mci; + ghes_pvt =NULL ;edac_mc_del_mc (mci->pdev);edac_mc_free (mci); }
Greg Kroah-Hartman
maintainerPATCH 163/197 arm64: KVM: Trap VM ops when ARM64_WORKAROUND_CAVIUM_TX2_219_TVM is set
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit d3ec3a08fa700c8b46abb137dce4e2514a6f9668 upstream.
In order to workaround the TX2-219 erratum, it is necessary to trap TTBRx_EL1 accesses to EL2. This is done by setting HCR_EL2.TVM on guest entry, which has the side effect of trapping all the other VM-related sysregs as well.
To minimize the overhead, a fast path is used so that we don't have to go all the way back to the main sysreg handling code, unless the rest of the hypervisor expects to see these accesses.
--- arch/arm64/include/asm/cpucaps.h | 3 + arch/arm64/kvm/hyp/switch.c | 69 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 3 deletions(-)
arch/arm64/include/asm/cpucaps.h +2 -1
@@ -52,7 +52,8 @@#define ARM64_HAS_IRQ_PRIO_MASKING 42#define ARM64_HAS_DCPODP 43#define ARM64_WORKAROUND_1463225 44 +#define ARM64_WORKAROUND_CAVIUM_TX2_219_TVM 45 -#define ARM64_NCAPS 45 +#define ARM64_NCAPS 46#endif /* __ASM_CPUCAPS_H */
arch/arm64/kvm/hyp/switch.c +67 -2
93 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 164/197 arm64: Avoid Cavium TX2 erratum 219 when switching TTBR
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit 9405447ef79bc93101373e130f72e9e6cbf17dbb upstream.
As a PRFM instruction racing against a TTBR update can have undesirable effects on TX2, NOP-out such PRFM on cores that are affected by the TX2-219 erratum.
--- arch/arm64/include/asm/cpucaps.h | 3 ++- arch/arm64/kernel/cpu_errata.c | 5 +++++ arch/arm64/kernel/entry.S | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-)
arch/arm64/include/asm/cpucaps.h +2 -1
@@ -53,7 +53,8 @@#define ARM64_HAS_DCPODP 43#define ARM64_WORKAROUND_1463225 44#define ARM64_WORKAROUND_CAVIUM_TX2_219_TVM 45 +#define ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM 46 -#define ARM64_NCAPS 46 +#define ARM64_NCAPS 47#endif /* __ASM_CPUCAPS_H */
arch/arm64/kernel/cpu_errata.c +5 -0
@@ -851,6 +851,11 @@ const struct arm64_cpu_capabilities arm6 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, .matches = has_cortex_a76_erratum_1463225, }, + { + .desc = "Cavium ThunderX2 erratum 219 (PRFM removal)", + .capability = ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM, + ERRATA_MIDR_RANGE_LIST(tx2_family_cpus), + },#endif { }
arch/arm64/kernel/entry.S +2 -0
@@ -1070,7 +1070,9 @@ alternative_insn isb, nop, ARM64_WORKARO #else ldr x30, =vectors #endif +alternative_if_not ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM prfm plil1strm, [x30, #(1b - tramp_vectors)] +alternative_else_nop_endif msr vbar_el1, x30 add x30, x30, #(1b - tramp_vectors) isb
Greg Kroah-Hartman
maintainerPATCH 165/197 arm64: Enable workaround for Cavium TX2 erratum 219 when running SMT
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit 93916beb70143c46bf1d2bacf814be3a124b253b upstream.
It appears that the only case where we need to apply the TX2_219_TVM mitigation is when the core is in SMT mode. So let's condition the enabling on detecting a CPU whose MPIDR_EL1.Aff0 is non-zero.
--- arch/arm64/kernel/cpu_errata.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
arch/arm64/kernel/cpu_errata.c +33 -0
@@ -12,6 +12,7 @@#include <asm/cpu.h> #include <asm/cputype.h> #include <asm/cpufeature.h> +#include <asm/smp_plat.h> static bool __maybe_unused is_affected_midr_range (const struct arm64_cpu_capabilities *entry,int scope)
@@ -623,6 +624,30 @@ check_branch_predictor(const struct arm6return (need_wa >0 ); } +static const __maybe_unused struct midr_range tx2_family_cpus[] = { +MIDR_ALL_VERSIONS (MIDR_BRCM_VULCAN ), +MIDR_ALL_VERSIONS (MIDR_CAVIUM_THUNDERX2 ), + {}, +}; + +static bool __maybe_unused +needs_tx2_tvm_workaround (const struct arm64_cpu_capabilities *entry, +int scope) +{ +int i; + +if (!is_affected_midr_range_list (entry, scope) || + !is_hyp_mode_available ()) +return false; + +for_each_possible_cpu (i) { +if (MPIDR_AFFINITY_LEVEL (cpu_logical_map (i),0 ) !=0 ) +return true; + } + +return false; +} +#ifdef CONFIG_HARDEN_EL2_VECTORS static const struct midr_range arm64_harden_el2_vectors[] = {
@@ -857,6 +882,14 @@ const struct arm64_cpu_capabilities arm6 ERRATA_MIDR_RANGE_LIST(tx2_family_cpus), },#endif +#ifdef CONFIG_CAVIUM_TX2_ERRATUM_219 + { + .desc = "Cavium ThunderX2 erratum 219 (KVM guest sysreg trapping)", + .capability = ARM64_WORKAROUND_CAVIUM_TX2_219_TVM, + ERRATA_MIDR_RANGE_LIST(tx2_family_cpus), + .matches = needs_tx2_tvm_workaround, + }, +#endif { } };
Greg Kroah-Hartman
maintainerPATCH 166/197 arm64: Allow CAVIUM_TX2_ERRATUM_219 to be selected
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit 603afdc9438ac546181e843f807253d75d3dbc45 upstream.
Allow the user to select the workaround for TX2-219, and update the silicon-errata.rst file to reflect this.
--- Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 17 +++++++++++++++++ 2 files changed, 19 insertions(+)
Documentation/arm64/silicon-errata.rst +2 -0
@@ -107,6 +107,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | Cavium | ThunderX2 SMMUv3| #126 | N/A | +----------------+-----------------+-----------------+-----------------------------+ +| Cavium | ThunderX2 Core | #219 | CAVIUM_TX2_ERRATUM_219 | ++----------------+-----------------+-----------------+-----------------------------+ +----------------+-----------------+-----------------+-----------------------------+ | Freescale/NXP | LS2080A/LS1043A | A-008585 | FSL_ERRATUM_A008585 | +----------------+-----------------+-----------------+-----------------------------+
arch/arm64/Kconfig +17 -0
@@ -601,6 +601,23 @@ config CAVIUM_ERRATUM_30115 If unsure, say Y. +config CAVIUM_TX2_ERRATUM_219 + bool "Cavium ThunderX2 erratum 219: PRFM between TTBR change and ISB fails" + default y + help + On Cavium ThunderX2, a load, store or prefetch instruction between a + TTBR update and the corresponding context synchronizing operation can + cause a spurious Data Abort to be delivered to any hardware thread in + the CPU core. + + Work around the issue by avoiding the problematic code sequence and + trapping KVM guest TTBRx_EL1 writes to EL2 when SMT is enabled. The + trap handler performs the corresponding register access, skips the + instruction and ensures context synchronization by virtue of the + exception return. + + If unsure, say Y. + config QCOM_FALKOR_ERRATUM_1003 bool "Falkor E1003: Incorrect translation due to ASID change" default y
Greg Kroah-Hartman
maintainerPATCH 167/197 CIFS: avoid using MID 0xFFFF
In reply to Greg Kroah-HartmanFrom: Roberto Bergantinos Corpas <[email protected]>
commit 03d9a9fe3f3aec508e485dd3dcfa1e99933b4bdb upstream.
According to MS-CIFS specification MID 0xFFFF should not be used by the CIFS client, but we actually do. Besides, this has proven to cause races leading to oops between SendReceive2/cifs_demultiplex_thread. On SMB1, MID is a 2 byte value easy to reach in CurrentMid which may conflict with an oplock break notification request coming from server
--- fs/cifs/smb1ops.c | 3 +++ 1 file changed, 3 insertions(+)
fs/cifs/smb1ops.c +3 -0
@@ -171,6 +171,9 @@ cifs_get_next_mid(struct TCP_Server_Info/* we do not want to loop forever */ last_mid = cur_mid; cur_mid++; +/* avoid 0xFFFF MID */ +if (cur_mid ==0xffff ) + cur_mid++;/* * This nested loop looks more expensive than it is.
Greg Kroah-Hartman
maintainerPATCH 168/197 cifs: Fix missed free operations
In reply to Greg Kroah-HartmanFrom: Chuhong Yuan <[email protected]>
commit 783bf7b8b641167fb6f3f4f787f60ae62bad41b3 upstream.
cifs_setattr_nounix has two paths which miss free operations for xid and fullpath.
Use goto cifs_setattr_exit like other paths to fix them.
--- fs/cifs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/cifs/inode.c +2 -2
@@ -2465,9 +2465,9 @@ cifs_setattr_nounix(struct dentry *diren rc = tcon->ses->server->ops->flush (xid, tcon, &wfile->fid);cifsFileInfo_put (wfile);if (rc) -return rc; + goto cifs_setattr_exit; }else if (rc != -EBADF ) -return rc; + goto cifs_setattr_exit;else rc =0 ; }
Greg Kroah-Hartman
maintainerPATCH 169/197 CIFS: Fix use after free of file info structures
In reply to Greg Kroah-HartmanFrom: Pavel Shilovsky <[email protected]>
commit 1a67c415965752879e2e9fad407bc44fc7f25f23 upstream.
Currently the code assumes that if a file info entry belongs to lists of open file handles of an inode and a tcon then it has non-zero reference. The recent changes broke that assumption when putting the last reference of the file info. There may be a situation when a file is being deleted but nothing prevents another thread to reference it again and start using it. This happens because we do not hold the inode list lock while checking the number of references of the file info structure. Fix this by doing the proper locking when doing the check.
--- fs/cifs/file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/cifs/file.c +3 -3
@@ -405,10 +405,11 @@ void _cifsFileInfo_put(struct cifsFileInbool oplock_break_cancelled;spin_lock (&tcon->open_file_lock); - +spin_lock (&cifsi->open_file_lock);spin_lock (&cifs_file->file_info_lock);if (--cifs_file->count >0 ) {spin_unlock (&cifs_file->file_info_lock); +spin_unlock (&cifsi->open_file_lock);spin_unlock (&tcon->open_file_lock);return ; }
@@ -421,9 +422,7 @@ void _cifsFileInfo_put(struct cifsFileIncifs_add_pending_open_locked (&fid, cifs_file->tlink, &open);/* remove it from the lists */ -spin_lock (&cifsi->open_file_lock);list_del (&cifs_file->flist); -spin_unlock (&cifsi->open_file_lock);list_del (&cifs_file->tlist);atomic_dec (&tcon->num_local_opens);
@@ -440,6 +439,7 @@ void _cifsFileInfo_put(struct cifsFileIncifs_set_oplock_level (cifsi,0 ); } +spin_unlock (&cifsi->open_file_lock);spin_unlock (&tcon->open_file_lock); oplock_break_cancelled = wait_oplock_handler ?
Greg Kroah-Hartman
maintainerPATCH 170/197 perf/aux: Fix AUX output stopping
In reply to Greg Kroah-HartmanFrom: Alexander Shishkin <[email protected]>
commit f3a519e4add93b7b31a6616f0b09635ff2e6a159 upstream.
Commit:
8a58ddae2379 ("perf/core: Fix exclusive events' grouping")
allows CAP_EXCLUSIVE events to be grouped with other events. Since all of those also happen to be AUX events (which is not the case the other way around, because arch/s390), this changes the rules for stopping the
output: the AUX event may not be on its PMU's context any more, if it's grouped with a HW event, in which case it will be on that HW event's context instead. If that's the case, munmap() of the AUX buffer can't find and stop the AUX event, potentially leaving the last reference with the atomic context, which will then end up freeing the AUX buffer. This will then trip warnings:
Fix this by using the context's PMU context when looking for events to stop, instead of the event's PMU context.
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -6839,7 +6839,7 @@ static void __perf_event_output_stop(strstatic int __perf_pmu_output_stop (void *info) {struct perf_event *event = info; -struct pmu *pmu = event->pmu; +struct pmu *pmu = event->ctx->pmu;struct perf_cpu_context *cpuctx =this_cpu_ptr (pmu->pmu_cpu_context);struct remote_output ro = { .rb = event->rb,
Greg Kroah-Hartman
maintainerPATCH 171/197 tracing: Fix race in perf_trace_buf initialization
In reply to Greg Kroah-HartmanFrom: Prateek Sood <[email protected]>
commit 6b1340cc00edeadd52ebd8a45171f38c8de2a387 upstream.
A race condition exists while initialiazing perf_trace_buf from perf_trace_init() and perf_kprobe_init().
CPU0 CPU1perf_trace_init()
mutex_lock(&event_mutex)
perf_trace_event_init()
perf_trace_event_reg()
total_ref_count == 0
buf = alloc_percpu()
perf_trace_buf[i] = buf
tp_event->class->reg() //fails perf_kprobe_init()
goto fail perf_trace_event_init()
perf_trace_event_reg()
fail:
total_ref_count == 0
total_ref_count == 0 buf = alloc_percpu() perf_trace_buf[i] = buf tp_event->class->reg() total_ref_count++
free_percpu(perf_trace_buf[i])
perf_trace_buf[i] = NULL
Any subsequent call to perf_trace_event_reg() will observe total_ref_count > 0, causing the perf_trace_buf to be always NULL. This can result in perf_trace_buf getting accessed from perf_trace_buf_alloc() without being initialized. Acquiring event_mutex in perf_kprobe_init() before calling perf_trace_event_init() should fix this race.
The race caused the following bug:
Unable to handle kernel paging request at virtual address 0000003106f2003c Mem abort info: ESR = 0x96000045 Exception class = DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 Data abort info: ISV = 0, ISS = 0x00000045 CM = 0, WnR = 1 user pgtable: 4k pages, 39-bit VAs, pgdp = ffffffc034b9b000 [0000003106f2003c] pgd=0000000000000000, pud=0000000000000000 Internal error: Oops: 96000045 [#1] PREEMPT SMP Process syz-executor (pid: 18393, stack limit = 0xffffffc093190000) pstate: 80400005 (Nzcv daif +PAN -UAO) pc : __memset+0x20/0x1ac lr : memset+0x3c/0x50 sp : ffffffc09319fc50 __memset+0x20/0x1ac perf_trace_buf_alloc+0x140/0x1a0 perf_trace_sys_enter+0x158/0x310 syscall_trace_enter+0x348/0x7c0 el0_svc_common+0x11c/0x368 el0_svc_handler+0x12c/0x198 el0_svc+0x8/0xc
Ramdumps showed the following:
total_ref_count = 3
perf_trace_buf = (
0x0 -> NULL,
0x0 -> NULL,
0x0 -> NULL,
0x0 -> NULL)--- kernel/trace/trace_event_perf.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/trace/trace_event_perf.c +4 -0
@@ -272,9 +272,11 @@ int perf_kprobe_init(struct perf_event * goto out; } +mutex_lock (&event_mutex); ret =perf_trace_event_init (tp_event, p_event);if (ret)destroy_local_trace_kprobe (tp_event); +mutex_unlock (&event_mutex); out:kfree (func);return ret;
@@ -282,8 +284,10 @@ out:void perf_kprobe_destroy (struct perf_event *p_event) { +mutex_lock (&event_mutex);perf_trace_event_close (p_event);perf_trace_event_unreg (p_event); +mutex_unlock (&event_mutex);destroy_local_trace_kprobe (p_event->tp_event); }
Greg Kroah-Hartman
maintainerPATCH 172/197 fs/dax: Fix pmd vs pte conflict detection
In reply to Greg Kroah-HartmanFrom: Dan Williams <[email protected]>
commit 6370740e5f8ef12de7f9a9bf48a0393d202cd827 upstream.
Users reported a v5.3 performance regression and inability to establish huge page mappings. A revised version of the ndctl "dax.sh" huge page unit test identifies commit 23c84eb78375 "dax: Fix missed wakeup with PMD faults" as the source.
Update get_unlocked_entry() to check for NULL entries before checking the entry order, otherwise NULL is misinterpreted as a present pte conflict. The 'order' check needs to happen before the locked check as an unlocked entry at the wrong order must fallback to lookup the correct order.
--- fs/dax.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/dax.c +3 -2
@@ -220,10 +220,11 @@ static void *get_unlocked_entry(struct xfor (;;) { entry =xas_find_conflict (xas); +if (!entry ||WARN_ON_ONCE (!xa_is_value (entry))) +return entry;if (dax_entry_order (entry) < order)return XA_RETRY_ENTRY ; -if (!entry ||WARN_ON_ONCE (!xa_is_value (entry)) || - !dax_is_locked (entry)) +if (!dax_is_locked (entry))return entry; wq =dax_entry_waitqueue (xas, entry, &ewait.key);
Greg Kroah-Hartman
maintainerPATCH 173/197 dm cache: fix bugs when a GFP_NOWAIT allocation fails
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit 13bd677a472d534bf100bab2713efc3f9e3f5978 upstream.
GFP_NOWAIT allocation can fail anytime - it doesn't wait for memory being available and it fails if the mempool is exhausted and there is not enough memory.
If we go down this path:
map_bio -> mg_start -> alloc_migration -> mempool_alloc(GFP_NOWAIT)
we can see that map_bio() doesn't check the return value of mg_start(), and the bio is leaked.
If we go down this path:
map_bio -> mg_start -> mg_lock_writes -> alloc_prison_cell -> dm_bio_prison_alloc_cell_v2 -> mempool_alloc(GFP_NOWAIT) -> mg_lock_writes -> mg_complete
the bio is ended with an error - it is unacceptable because it could cause filesystem corruption if the machine ran out of memory temporarily.
Change GFP_NOWAIT to GFP_NOIO, so that the mempool code will properly wait until memory becomes available. mempool_alloc with GFP_NOIO can't fail, so remove the code paths that deal with allocation failure.
--- drivers/md/dm-cache-target.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-)
drivers/md/dm-cache-target.c +2 -26
@@ -542,7 +542,7 @@ static void wake_migration_worker(structstatic struct dm_bio_prison_cell_v2 *alloc_prison_cell (struct cache *cache) { -return dm_bio_prison_alloc_cell_v2 (cache->prison,GFP_NOWAIT ); +return dm_bio_prison_alloc_cell_v2 (cache->prison,GFP_NOIO ); }static void free_prison_cell (struct cache *cache,struct dm_bio_prison_cell_v2 *cell)
@@ -554,9 +554,7 @@ static struct dm_cache_migration *alloc_ {struct dm_cache_migration *mg; - mg =mempool_alloc (&cache->migration_pool,GFP_NOWAIT ); -if (!mg) -return NULL ; + mg =mempool_alloc (&cache->migration_pool,GFP_NOIO );memset (mg,0 ,sizeof (*mg));
@@ -664,10 +662,6 @@ static bool bio_detain_shared(struct cacstruct dm_bio_prison_cell_v2 *cell_prealloc, *cell; cell_prealloc =alloc_prison_cell (cache);/* FIXME: allow wait if calling from worker */ -if (!cell_prealloc) { -defer_bio (cache, bio); -return false; - }build_key (oblock, end, &key); r =dm_cell_get_v2 (cache->prison, &key,lock_level (bio), bio, cell_prealloc, &cell);
@@ -1493,11 +1487,6 @@ static int mg_lock_writes(struct dm_cachstruct dm_bio_prison_cell_v2 *prealloc; prealloc =alloc_prison_cell (cache); -if (!prealloc) { -DMERR_LIMIT ("%s: alloc_prison_cell failed" ,cache_device_name (cache)); -mg_complete (mg, false); -return -ENOMEM ; - }/* * Prevent writes to the block, but allow reads to continue.
@@ -1535,11 +1524,6 @@ static int mg_start(struct cache *cache, } mg =alloc_migration (cache); -if (!mg) { -policy_complete_background_work (cache->policy, op, false); -background_work_end (cache); -return -ENOMEM ; - } mg->op = op; mg->overwrite_bio = bio;
@@ -1628,10 +1612,6 @@ static int invalidate_lock(struct dm_cacstruct dm_bio_prison_cell_v2 *prealloc; prealloc =alloc_prison_cell (cache); -if (!prealloc) { -invalidate_complete (mg, false); -return -ENOMEM ; - }build_key (mg->invalidate_oblock,oblock_succ (mg->invalidate_oblock), &key); r = dm_cell_lock_v2(cache->prison, &key,
@@ -1669,10 +1649,6 @@ static int invalidate_start(struct cachereturn -EPERM ; mg =alloc_migration (cache); -if (!mg) { -background_work_end (cache); -return -ENOMEM ; - } mg->overwrite_bio = bio; mg->invalidate_cblock = cblock;
Greg Kroah-Hartman
maintainerPATCH 174/197 irqchip/sifive-plic: Switch to fasteoi flow
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit bb0fed1c60cccbe4063b455a7228818395dac86e upstream.
The SiFive PLIC interrupt controller seems to have all the HW features to support the fasteoi flow, but the driver seems to be stuck in a distant past. Bring it into the 21st century.
--- drivers/irqchip/irq-sifive-plic.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/irqchip/irq-sifive-plic.c +15 -14
@@ -97,7 +97,7 @@ static inline void plic_irq_toggle(const } } -static void plic_irq_enable (struct irq_data *d) +static void plic_irq_unmask (struct irq_data *d) {unsigned int cpu =cpumask_any_and (irq_data_get_affinity_mask (d), cpu_online_mask);
@@ -106,7 +106,7 @@ static void plic_irq_enable(struct irq_dplic_irq_toggle (cpumask_of (cpu), d->hwirq,1 ); } -static void plic_irq_disable (struct irq_data *d) +static void plic_irq_mask (struct irq_data *d) {plic_irq_toggle (cpu_possible_mask, d->hwirq,0 ); }
@@ -125,10 +125,8 @@ static int plic_set_affinity(struct irq_if (cpu >= nr_cpu_ids)return -EINVAL ; -if (!irqd_irq_disabled (d)) { -plic_irq_toggle (cpu_possible_mask, d->hwirq,0 ); -plic_irq_toggle (cpumask_of (cpu), d->hwirq,1 ); - } +plic_irq_toggle (cpu_possible_mask, d->hwirq,0 ); +plic_irq_toggle (cpumask_of (cpu), d->hwirq,1 );irq_data_update_effective_affinity (d,cpumask_of (cpu));
@@ -136,14 +134,18 @@ static int plic_set_affinity(struct irq_ }#endif +static void plic_irq_eoi (struct irq_data *d) +{ +struct plic_handler *handler =this_cpu_ptr (&plic_handlers); + +writel (d->hwirq, handler->hart_base +CONTEXT_CLAIM ); +} +static struct irq_chip plic_chip = { .name ="SiFive PLIC" , -/* -* There is no need to mask/unmask PLIC interrupts. They are "masked" -* by reading claim and "unmasked" when writing it back. -*/ - .irq_enable = plic_irq_enable, - .irq_disable = plic_irq_disable, + .irq_mask = plic_irq_mask, + .irq_unmask = plic_irq_unmask, + .irq_eoi = plic_irq_eoi, #ifdef CONFIG_SMP .irq_set_affinity = plic_set_affinity, #endif
@@ -152,7 +154,7 @@ static struct irq_chip plic_chip = {static int plic_irqdomain_map (struct irq_domain *d,unsigned int irq,irq_hw_number_t hwirq) { -irq_set_chip_and_handler (irq, &plic_chip, handle_simple_irq); +irq_set_chip_and_handler (irq, &plic_chip, handle_fasteoi_irq);irq_set_chip_data (irq,NULL );irq_set_noprobe (irq);return 0 ;
@@ -188,7 +190,6 @@ static void plic_handle_irq(struct pt_re hwirq); elsegeneric_handle_irq (irq ); -writel (hwirq, claim); }csr_set (sie,SIE_SEIE ); }
Greg Kroah-Hartman
maintainerPATCH 175/197 x86/boot/64: Make level2_kernel_pgt pages invalid outside kernel area
In reply to Greg Kroah-HartmanFrom: Steve Wahl <[email protected]>
commit 2aa85f246c181b1fa89f27e8e20c5636426be624 upstream.
Our hardware (UV aka Superdome Flex) has address ranges marked reserved by the BIOS. Access to these ranges is caught as an error, causing the BIOS to halt the system.
Initial page tables mapped a large range of physical addresses that were not checked against the list of BIOS reserved addresses, and sometimes included reserved addresses in part of the mapped range. Including the reserved range in the map allowed processor speculative accesses to the reserved range, triggering a BIOS halt.
Used early in booting, the page table level2_kernel_pgt addresses 1 GiB divided into 2 MiB pages, and it was set up to linearly map a full
1 GiB of physical addresses that included the physical address range
of the kernel image, as chosen by KASLR. But this also included a large range of unused addresses on either side of the kernel image. And unlike the kernel image's physical address range, this extra mapped space was not checked against the BIOS tables of usable RAM addresses. So there were times when the addresses chosen by KASLR would result in processor accessible mappings of BIOS reserved physical addresses.
The kernel code did not directly access any of this extra mapped space, but having it mapped allowed the processor to issue speculative accesses into reserved memory, causing system halts.
This was encountered somewhat rarely on a normal system boot, and much more often when starting the crash kernel if "crashkernel=512M,high" was specified on the command line (this heavily restricts the physical address of the crash kernel, in our case usually within 1 GiB of reserved space).
The solution is to invalidate the pages of this table outside the kernel image's space before the page table is activated. It fixes this problem on our hardware.
[ bp: Touchups. ]
--- arch/x86/kernel/head64.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
arch/x86/kernel/head64.c +20 -2
@@ -222,13 +222,31 @@ unsigned long __head __startup_64(unsign* we might write invalid pmds, when the kernel is relocated * cleanup_highmap() fixes this up along with the mappings * beyond _end. +* +* Only the region occupied by the kernel image has so far +* been checked against the table of usable memory regions +* provided by the firmware, so invalidate pages outside that +* region. A page table entry that maps to a reserved area of +* memory would allow processor speculation into that area, +* and on some hardware (particularly the UV platform) even +* speculative access to some reserved areas is caught as an +* error, causing the BIOS to halt the system. */ pmd =fixup_pointer (level2_kernel_pgt, physaddr); -for (i =0 ; i <PTRS_PER_PMD ; i++) { + +/* invalidate pages before the kernel image */ +for (i =0 ; i <pmd_index ((unsigned long )_text); i++) + pmd[i] &= ~_PAGE_PRESENT; + +/* fixup pages that are part of the kernel image */ +for (; i <=pmd_index ((unsigned long )_end); i++)if (pmd[i] & _PAGE_PRESENT) pmd[i] += load_delta; - } + +/* invalidate pages after the kernel image */ +for (; i <PTRS_PER_PMD ; i++) + pmd[i] &= ~_PAGE_PRESENT;/* * Fixup phys_base - remove the memory encryption mask to obtain
Greg Kroah-Hartman
maintainerPATCH 176/197 x86/apic/x2apic: Fix a NULL pointer deref when handling a dying cpu
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 7a22e03b0c02988e91003c505b34d752a51de344 upstream.
Check that the per-cpu cluster mask pointer has been set prior to clearing a dying cpu's bit. The per-cpu pointer is not set until the target cpu reaches smp_callin() during CPUHP_BRINGUP_CPU, whereas the teardown function, x2apic_dead_cpu(), is associated with the earlier CPUHP_X2APIC_PREPARE. If an error occurs before the cpu is awakened, e.g. if do_boot_cpu() itself fails, x2apic_dead_cpu() will dereference the NULL pointer and cause a panic.
smpboot: do_boot_cpu failed(-22) to wakeup CPU#1
BUG: kernel NULL pointer dereference, address: 0000000000000008 RIP: 0010:x2apic_dead_cpu+0x1a/0x30 Call Trace: cpuhp_invoke_callback+0x9a/0x580 _cpu_up+0x10d/0x140 do_cpu_up+0x69/0xb0 smp_init+0x63/0xa9 kernel_init_freeable+0xd7/0x229 ? rest_init+0xa0/0xa0 kernel_init+0xa/0x100 ret_from_fork+0x35/0x40
--- arch/x86/kernel/apic/x2apic_cluster.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/apic/x2apic_cluster.c +2 -1
@@ -158,7 +158,8 @@ static int x2apic_dead_cpu(unsigned int {struct cluster_mask *cmsk =per_cpu (cluster_masks, dead_cpu); -cpumask_clear_cpu (dead_cpu, &cmsk->mask); +if (cmsk) +cpumask_clear_cpu (dead_cpu, &cmsk->mask);free_cpumask_var (per_cpu (ipi_mask, dead_cpu));return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 177/197 x86/hyperv: Make vapic support x2apic mode
In reply to Greg Kroah-HartmanFrom: Roman Kagan <[email protected]>
commit e211288b72f15259da86eed6eca680758dbe9e74 upstream.
Now that there's Hyper-V IOMMU driver, Linux can switch to x2apic mode when supported by the vcpus.
However, the apic access functions for Hyper-V enlightened apic assume xapic mode only.
As a result, Linux fails to bring up secondary cpus when run as a guest in QEMU/KVM with both hv_apic and x2apic enabled.
According to Michael Kelley, when in x2apic mode, the Hyper-V synthetic apic MSRs behave exactly the same as the corresponding architectural x2apic MSRs, so there's no need to override the apic accessors. The only exception is hv_apic_eoi_write, which benefits from lazy EOI when available; however, its implementation works for both xapic and x2apic modes.
--- arch/x86/hyperv/hv_apic.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
arch/x86/hyperv/hv_apic.c +15 -5
@@ -260,11 +260,21 @@ void __init hv_apic_init(void) }if (ms_hyperv.hints &HV_X64_APIC_ACCESS_RECOMMENDED ) { -pr_info ("Hyper-V: Using MSR based APIC access\n" ); +pr_info ("Hyper-V: Using enlightened APIC (%s mode)" , +x2apic_enabled () ?"x2apic" :"xapic" ); +/* +* With x2apic, architectural x2apic MSRs are equivalent to the +* respective synthetic MSRs, so there's no need to override +* the apic accessors. The only exception is +* hv_apic_eoi_write, because it benefits from lazy EOI when +* available, but it works for both xapic and x2apic modes. +*/ apic_set_eoi_write (hv_apic_eoi_write); - apic->read = hv_apic_read; - apic->write = hv_apic_write; - apic->icr_write = hv_apic_icr_write; - apic->icr_read = hv_apic_icr_read; +if (!x2apic_enabled ()) { + apic->read = hv_apic_read; + apic->write = hv_apic_write; + apic->icr_write = hv_apic_icr_write; + apic->icr_read = hv_apic_icr_read; + } } }
Greg Kroah-Hartman
maintainerPATCH 178/197 pinctrl: cherryview: restore Strago DMI workaround for all versions
In reply to Greg Kroah-HartmanFrom: Dmitry Torokhov <[email protected]>
commit 260996c30f4f3a732f45045e3e0efe27017615e4 upstream.
This is essentially a revert of:
e3f72b749da2 pinctrl: cherryview: fix Strago DMI workaround 86c5dd6860a6 pinctrl: cherryview: limit Strago DMI workarounds to version 1.0
because even with 1.1 versions of BIOS there are some pins that are configured as interrupts but not claimed by any driver, and they sometimes fire up and result in interrupt storms that cause touchpad stop functioning and other issues.
Given that we are unlikely to qualify another firmware version for a while it is better to keep the workaround active on all Strago boards.
--- drivers/pinctrl/intel/pinctrl-cherryview.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/pinctrl/intel/pinctrl-cherryview.c +0 -4
@@ -1513,7 +1513,6 @@ static const struct dmi_system_id chv_no .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"GOOGLE" ), DMI_MATCH(DMI_PRODUCT_FAMILY, "Intel_Strago"), - DMI_MATCH(DMI_PRODUCT_VERSION, "1.0"), }, }, {
@@ -1521,7 +1520,6 @@ static const struct dmi_system_id chv_no .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), DMI_MATCH(DMI_PRODUCT_NAME, "Setzer"), - DMI_MATCH(DMI_PRODUCT_VERSION, "1.0"), }, }, {
@@ -1529,7 +1527,6 @@ static const struct dmi_system_id chv_no .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"GOOGLE" ), DMI_MATCH(DMI_PRODUCT_NAME, "Cyan"), - DMI_MATCH(DMI_PRODUCT_VERSION, "1.0"), }, }, {
@@ -1537,7 +1534,6 @@ static const struct dmi_system_id chv_no .matches = {DMI_MATCH (DMI_SYS_VENDOR ,"GOOGLE" ), DMI_MATCH(DMI_PRODUCT_NAME, "Celes"), - DMI_MATCH(DMI_PRODUCT_VERSION, "1.0"), }, }, {}
Greg Kroah-Hartman
maintainerPATCH 179/197 pinctrl: armada-37xx: fix control of pins 32 and up
In reply to Greg Kroah-HartmanFrom: Patrick Williams <[email protected]>
commit 20504fa1d2ffd5d03cdd9dc9c9dd4ed4579b97ef upstream.
The 37xx configuration registers are only 32 bits long, so pins 32-35 spill over into the next register. The calculation for the register address was done, but the bitmask was not, so any configuration to pin 32 or above resulted in a bitmask that overflowed and performed no action.
Fix the register / offset calculation to also adjust the offset.
--- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +9 -9
@@ -221,11 +221,11 @@ static const struct armada_37xx_pin_data };static inline void armada_37xx_update_reg (unsigned int *reg, -unsigned int offset) +unsigned int *offset) {/* We never have more than 2 registers */ -if (offset >=GPIO_PER_REG ) { - offset -=GPIO_PER_REG ; +if (*offset >=GPIO_PER_REG ) { + *offset -=GPIO_PER_REG ; *reg +=sizeof (u32); } }
@@ -376,7 +376,7 @@ static inline void armada_37xx_irq_updat {int offset =irqd_to_hwirq (d); -armada_37xx_update_reg (reg, offset); +armada_37xx_update_reg (reg, &offset); } static int armada_37xx_gpio_direction_input(struct gpio_chip *chip,
@@ -386,7 +386,7 @@ static int armada_37xx_gpio_direction_inunsigned int reg =OUTPUT_EN ;unsigned int mask; -armada_37xx_update_reg (®, offset); +armada_37xx_update_reg (®, &offset); mask =BIT (offset);return regmap_update_bits (info->regmap, reg, mask,0 );
@@ -399,7 +399,7 @@ static int armada_37xx_gpio_get_directiounsigned int reg =OUTPUT_EN ;unsigned int val, mask; -armada_37xx_update_reg (®, offset); +armada_37xx_update_reg (®, &offset); mask =BIT (offset);regmap_read (info->regmap, reg, &val);
@@ -413,7 +413,7 @@ static int armada_37xx_gpio_direction_ouunsigned int reg =OUTPUT_EN ;unsigned int mask, val, ret; -armada_37xx_update_reg (®, offset); +armada_37xx_update_reg (®, &offset); mask =BIT (offset); ret =regmap_update_bits (info->regmap, reg, mask, mask);
@@ -434,7 +434,7 @@ static int armada_37xx_gpio_get(struct gunsigned int reg =INPUT_VAL ;unsigned int val, mask; -armada_37xx_update_reg (®, offset); +armada_37xx_update_reg (®, &offset); mask =BIT (offset);regmap_read (info->regmap, reg, &val);
@@ -449,7 +449,7 @@ static void armada_37xx_gpio_set(structunsigned int reg =OUTPUT_VAL ;unsigned int mask, val; -armada_37xx_update_reg (®, offset); +armada_37xx_update_reg (®, &offset); mask =BIT (offset); val = value ? mask :0 ;
Greg Kroah-Hartman
maintainerPATCH 180/197 pinctrl: armada-37xx: swap polarity on LED group
In reply to Greg Kroah-HartmanFrom: Patrick Williams <[email protected]>
commit b835d6953009dc350d61402a854b5a7178d8c615 upstream.
The configuration registers for the LED group have inverted polarity, which puts the GPIO into open-drain state when used in GPIO mode. Switch to '0' for GPIO and '1' for LED modes.
--- drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +4 -4
@@ -183,10 +183,10 @@ static struct armada_37xx_pin_group armaPIN_GRP_EXTRA ("uart2" ,9 ,2 ,BIT (1 ) |BIT (13 ) |BIT (14 ) |BIT (19 ),BIT (1 ) |BIT (13 ) |BIT (14 ),BIT (1 ) |BIT (19 ),18 ,2 ,"gpio" ,"uart" ), -PIN_GRP_GPIO ("led0_od" ,11 ,1 ,BIT (20 ),"led" ), -PIN_GRP_GPIO ("led1_od" ,12 ,1 ,BIT (21 ),"led" ), -PIN_GRP_GPIO ("led2_od" ,13 ,1 ,BIT (22 ),"led" ), - PIN_GRP_GPIO("led3_od", 14, 1, BIT(23), "led"), +PIN_GRP_GPIO_2 ("led0_od" ,11 ,1 ,BIT (20 ),BIT (20 ),0 ,"led" ), +PIN_GRP_GPIO_2 ("led1_od" ,12 ,1 ,BIT (21 ),BIT (21 ),0 ,"led" ), +PIN_GRP_GPIO_2 ("led2_od" ,13 ,1 ,BIT (22 ),BIT (22 ),0 ,"led" ), + PIN_GRP_GPIO_2("led3_od", 14, 1, BIT(23), BIT(23), 0, "led"), };
Greg Kroah-Hartman
maintainerPATCH 181/197 btrfs: block-group: Fix a memory leak due to missing btrfs_put_block_group()
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit 4b654acdae850f48b8250b9a578a4eaa518c7a6f upstream.
In btrfs_read_block_groups(), if we have an invalid block group which has mixed type (DATA|METADATA) while the fs doesn't have MIXED_GROUPS feature, we error out without freeing the block group cache.
This patch will add the missing btrfs_put_block_group() to prevent memory leak.
Note for stable backports: the file to patch in versions <= 5.3 is fs/btrfs/extent-tree.c
--- fs/btrfs/extent-tree.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/extent-tree.c +1 -0
@@ -8117,6 +8117,7 @@ int btrfs_read_block_groups(struct btrfsbtrfs_err (info,"bg %llu is a mixed block group but filesystem hasn't enabled mixed block groups" , cache->key.objectid); +btrfs_put_block_group (cache); ret = -EINVAL ; goto error; }
Greg Kroah-Hartman
maintainerPATCH 182/197 Btrfs: add missing extents release on file extent cluster relocation error
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 44db1216efe37bf670f8d1019cdc41658d84baf5 upstream.
If we error out when finding a page at relocate_file_extent_cluster(), we need to release the outstanding extents counter on the relocation inode, set by the previous call to btrfs_delalloc_reserve_metadata(), otherwise the inode's block reserve size can never decrease to zero and metadata space is leaked. Therefore add a call to btrfs_delalloc_release_extents() in case we can't find the target page.
--- fs/btrfs/relocation.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/relocation.c +2 -0
@@ -3276,6 +3276,8 @@ static int relocate_file_extent_cluster(if (!page) {btrfs_delalloc_release_metadata (BTRFS_I (inode),PAGE_SIZE , true); +btrfs_delalloc_release_extents (BTRFS_I (inode), +PAGE_SIZE , true); ret = -ENOMEM ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 183/197 btrfs: dont needlessly create extent-refs kernel thread
In reply to Greg Kroah-HartmanFrom: David Sterba <[email protected]>
commit 80ed4548d0711d15ca51be5dee0ff813051cfc90 upstream.
The patch 32b593bfcb58 ("Btrfs: remove no longer used function to run delayed refs asynchronously") removed the async delayed refs but the thread has been created, without any use. Remove it to avoid resource consumption.
--- fs/btrfs/ctree.h | 2 -- fs/btrfs/disk-io.c | 6 ------ 2 files changed, 8 deletions(-)
fs/btrfs/ctree.h +0 -2
@@ -908,8 +908,6 @@ struct btrfs_fs_info {struct btrfs_workqueue *fixup_workers;struct btrfs_workqueue *delayed_workers; -/* the extent workers do delayed refs on the extent allocation tree */ -struct btrfs_workqueue *extent_workers;struct task_struct *transaction_kthread;struct task_struct *cleaner_kthread;u32 thread_pool_size;
fs/btrfs/disk-io.c +0 -6
@@ -2036,7 +2036,6 @@ static void btrfs_stop_all_workers(strucbtrfs_destroy_workqueue (fs_info->readahead_workers);btrfs_destroy_workqueue (fs_info->flush_workers);btrfs_destroy_workqueue (fs_info->qgroup_rescan_workers); -btrfs_destroy_workqueue (fs_info->extent_workers);/* * Now that all other work queues are destroyed, we can safely destroy * the queues used for metadata I/O, since tasks from those other work
@@ -2242,10 +2241,6 @@ static int btrfs_init_workqueues(struct max_active, 2); fs_info->qgroup_rescan_workers =btrfs_alloc_workqueue (fs_info,"qgroup-rescan" , flags,1 ,0 ); - fs_info->extent_workers = -btrfs_alloc_workqueue (fs_info,"extent-refs" , flags, -min_t (u64, fs_devices->num_devices, - max_active),8 ); if (!(fs_info->workers && fs_info->delalloc_workers && fs_info->submit_workers && fs_info->flush_workers &&
@@ -2256,7 +2251,6 @@ static int btrfs_init_workqueues(struct fs_info->endio_freespace_worker && fs_info->rmw_workers && fs_info->caching_workers && fs_info->readahead_workers && fs_info->fixup_workers && fs_info->delayed_workers && - fs_info->extent_workers && fs_info->qgroup_rescan_workers)) { return -ENOMEM; }
Greg Kroah-Hartman
maintainerPATCH 184/197 Btrfs: fix qgroup double free after failure to reserve metadata for delalloc
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit c7967fc1499beb9b70bb9d33525fb0b384af8883 upstream.
If we fail to reserve metadata for delalloc operations we end up releasing the previously reserved qgroup amount twice, once explicitly under the 'out_qgroup' label by calling btrfs_qgroup_free_meta_prealloc() and once again, under label 'out_fail', by calling btrfs_inode_rsv_release() with a value of 'true' for its 'qgroup_free' argument, which results in btrfs_qgroup_free_meta_prealloc() being called again, so we end up having a double free.
Also if we fail to reserve the necessary qgroup amount, we jump to the label 'out_fail', which calls btrfs_inode_rsv_release() and that in turns calls btrfs_qgroup_free_meta_prealloc(), even though we weren't able to reserve any qgroup amount. So we freed some amount we never reserved.
So fix this by removing the call to btrfs_inode_rsv_release() in the failure path, since it's not necessary at all as we haven't changed the inode's block reserve in any way at this point.
--- fs/btrfs/delalloc-space.c | 1 - 1 file changed, 1 deletion(-)
fs/btrfs/delalloc-space.c +0 -1
@@ -371,7 +371,6 @@ int btrfs_delalloc_reserve_metadata(stru out_qgroup:btrfs_qgroup_free_meta_prealloc (root, qgroup_reserve); out_fail: -btrfs_inode_rsv_release (inode, true);if (delalloc_lock)mutex_unlock (&inode->delalloc_mutex);return ret;
Greg Kroah-Hartman
maintainerPATCH 185/197 Btrfs: check for the full sync flag while holding the inode lock during fsync
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit ba0b084ac309283db6e329785c1dc4f45fdbd379 upstream.
We were checking for the full fsync flag in the inode before locking the inode, which is racy, since at that that time it might not be set but after we acquire the inode lock some other task set it. One case where this can happen is on a system low on memory and some concurrent task failed to allocate an extent map and therefore set the full sync flag on the inode, to force the next fsync to work in full mode.
A consequence of missing the full fsync flag set is hitting the problems fixed by commit 0c713cbab620 ("Btrfs: fix race between ranged fsync and writeback of adjacent ranges"), BUG_ON() when dropping extents from a log tree, hitting assertion failures at tree-log.c:copy_items() or all sorts of weird inconsistencies after replaying a log due to file extents items representing ranges that overlap.
So just move the check such that it's done after locking the inode and before starting writeback again.
--- fs/btrfs/file.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)
fs/btrfs/file.c +17 -19
@@ -2067,25 +2067,7 @@ int btrfs_sync_file(struct file *file, lstruct btrfs_trans_handle *trans;struct btrfs_log_ctx ctx;int ret =0 , err; -u64 len; -/* -* If the inode needs a full sync, make sure we use a full range to -* avoid log tree corruption, due to hole detection racing with ordered -* extent completion for adjacent ranges, and assertion failures during -* hole detection. -*/ -if (test_bit (BTRFS_INODE_NEEDS_FULL_SYNC , - &BTRFS_I (inode)->runtime_flags)) { - start =0 ; - end =LLONG_MAX ; - } - -/* -* The range length can be represented by u64, we have to do the typecasts -* to avoid signed overflow if it's [0, LLONG_MAX] eg. from fsync() -*/ - len = (u64 )end - (u64 )start +1 ;trace_btrfs_sync_file (file, datasync);btrfs_init_log_ctx (&ctx, inode);
@@ -2112,6 +2094,19 @@ int btrfs_sync_file(struct file *file, latomic_inc (&root->log_batch);/* +* If the inode needs a full sync, make sure we use a full range to +* avoid log tree corruption, due to hole detection racing with ordered +* extent completion for adjacent ranges, and assertion failures during +* hole detection. Do this while holding the inode lock, to avoid races +* with other tasks. +*/ +if (test_bit (BTRFS_INODE_NEEDS_FULL_SYNC , + &BTRFS_I (inode)->runtime_flags)) { + start =0 ; + end =LLONG_MAX ; + } + +/* * Before we acquired the inode's lock, someone may have dirtied more * pages in the target range. We need to make sure that writeback for * any such pages does not start while we are logging the inode, because
@@ -2138,8 +2133,11 @@ int btrfs_sync_file(struct file *file, l/* * We have to do this here to avoid the priority inversion of waiting on * IO of a lower priority task while holding a transaction open. +* +* Also, the range length can be represented by u64, we have to do the +* typecasts to avoid signed overflow if it's [0, LLONG_MAX]. */ - ret =btrfs_wait_ordered_range (inode, start, len); + ret =btrfs_wait_ordered_range (inode, start, (u64 )end - (u64 )start +1 );if (ret) {up_write (&BTRFS_I (inode)->dio_sem);inode_unlock (inode);
Greg Kroah-Hartman
maintainerPATCH 186/197 btrfs: tracepoints: Fix wrong parameter order for qgroup events
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit fd2b007eaec898564e269d1f478a2da0380ecf51 upstream.
[BUG]
For btrfs:qgroup_meta_reserve event, the trace event can output garbage:
qgroup_meta_reserve: 9c7f6acc-b342-4037-bc47-7f6e4d2232d7: refroot=5(FS_TREE) type=DATA diff=2
The diff should always be alinged to sector size (4k), so there is definitely something wrong.
[CAUSE]
For the wrong @diff, it's caused by wrong parameter order. The correct parameters are:
struct btrfs_root, s64 diff, int type.
However the parameters used are:
struct btrfs_root, int type, s64 diff.
--- fs/btrfs/qgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/qgroup.c +2 -2
@@ -3617,7 +3617,7 @@ int __btrfs_qgroup_reserve_meta(struct breturn 0 ;BUG_ON (num_bytes !=round_down (num_bytes, fs_info->nodesize)); -trace_qgroup_meta_reserve (root, type, (s64 )num_bytes); +trace_qgroup_meta_reserve (root, (s64 )num_bytes, type); ret =qgroup_reserve (root, num_bytes, enforce, type);if (ret <0 )return ret;
@@ -3664,7 +3664,7 @@ void __btrfs_qgroup_free_meta(struct btr*/ num_bytes =sub_root_meta_rsv (root, num_bytes, type);BUG_ON (num_bytes !=round_down (num_bytes, fs_info->nodesize)); -trace_qgroup_meta_reserve (root, type, -(s64 )num_bytes); +trace_qgroup_meta_reserve (root, -(s64 )num_bytes, type);btrfs_qgroup_free_refroot (fs_info, root->root_key.objectid, num_bytes, type); }
Greg Kroah-Hartman
maintainerPATCH 187/197 btrfs: tracepoints: Fix bad entry members of qgroup events
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit 1b2442b4ae0f234daeadd90e153b466332c466d8 upstream.
[BUG]
For btrfs:qgroup_meta_reserve event, the trace event can output garbage:
qgroup_meta_reserve: 9c7f6acc-b342-4037-bc47-7f6e4d2232d7: refroot=5(FS_TREE) type=DATA diff=2
qgroup_meta_reserve: 9c7f6acc-b342-4037-bc47-7f6e4d2232d7: refroot=5(FS_TREE) type=0x258792 diff=2
The @type can be completely garbage, as DATA type is not possible for trace_qgroup_meta_reserve() trace event.
[CAUSE]
Ther are several problems related to qgroup trace events:
- Unassigned entry member
Member entry::type of trace_qgroup_update_reserve() and trace_qgourp_meta_reserve() is not assigned
- Redundant entry member
Member entry::type is completely useless in
trace_qgroup_meta_convert()
--- include/trace/events/btrfs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/trace/events/btrfs.h +2 -1
@@ -1687,6 +1687,7 @@ TRACE_EVENT(qgroup_update_reserve, __entry->qgid = qgroup->qgroupid; __entry->cur_reserved = qgroup->rsv.values[type]; __entry->diff = diff; + __entry->type = type; ), TP_printk_btrfs("qgid=%llu type=%s cur_reserved=%llu diff=%lld",
@@ -1709,6 +1710,7 @@ TRACE_EVENT(qgroup_meta_reserve,TP_fast_assign_btrfs (root->fs_info, __entry->refroot = root->root_key.objectid; __entry->diff = diff; + __entry->type = type; ), TP_printk_btrfs("refroot=%llu(%s) type=%s diff=%lld",
@@ -1725,7 +1727,6 @@ TRACE_EVENT(qgroup_meta_convert,TP_STRUCT__entry_btrfs (__field (u64 ,refroot )__field ( s64, diff ) -__field ( int, type ) ), TP_fast_assign_btrfs(root->fs_info,
Greg Kroah-Hartman
maintainerPATCH 188/197 KVM: PPC: Book3S HV: XIVE: Ensure VP isnt already in use
In reply to Greg Kroah-HartmanFrom: Greg Kurz <[email protected]>
commit 12ade69c1eb9958b13374edf5ef742ea20ccffde upstream.
Connecting a vCPU to a XIVE KVM device means establishing a 1:1 association between a vCPU id and the offset (VP id) of a VP structure within a fixed size block of VPs. We currently try to enforce the 1:1 relationship by checking that a vCPU with the same id isn't already connected. This is good but unfortunately not enough because we don't map VP ids to raw vCPU ids but to packed vCPU ids, and the packing function kvmppc_pack_vcpu_id() isn't bijective by design. We got away with it because QEMU passes vCPU ids that fit well in the packing pattern. But nothing prevents userspace to come up with a forged vCPU id resulting in a packed id collision which causes the KVM device to associate two vCPUs to the same VP. This greatly confuses the irq layer and ultimately crashes the kernel, as shown below.
Example: a guest with 1 guest thread per core, a core stride of 8 and 300 vCPUs has vCPU ids 0,8,16...2392. If QEMU is patched to inject at some point an invalid vCPU id 348, which is the packed version of itself and 2392, we get:
genirq: Flags mismatch irq 199. 00010000 (kvm-2-2392) vs. 00010000 (kvm-2-348)
CPU: 24 PID: 88176 Comm: qemu-system-ppc Not tainted 5.3.0-xive-nr-servers-5.3-gku+ #38 Call Trace: [c000003f7f9937e0] [c000000000c0110c] dump_stack+0xb0/0xf4 (unreliable) [c000003f7f993820] [c0000000001cb480] __setup_irq+0xa70/0xad0 [c000003f7f9938d0] [c0000000001cb75c] request_threaded_irq+0x13c/0x260 [c000003f7f993940] [c00800000d44e7ac] kvmppc_xive_attach_escalation+0x104/0x270 [kvm] [c000003f7f9939d0] [c00800000d45013c] kvmppc_xive_connect_vcpu+0x424/0x620 [kvm] [c000003f7f993ac0] [c00800000d444428] kvm_arch_vcpu_ioctl+0x260/0x448 [kvm] [c000003f7f993b90] [c00800000d43593c] kvm_vcpu_ioctl+0x154/0x7c8 [kvm] [c000003f7f993d00] [c0000000004840f0] do_vfs_ioctl+0xe0/0xc30 [c000003f7f993db0] [c000000000484d44] ksys_ioctl+0x104/0x120 [c000003f7f993e00] [c000000000484d88] sys_ioctl+0x28/0x80 [c000003f7f993e20] [c00000000000b278] system_call+0x5c/0x68 xive-kvm: Failed to request escalation interrupt for queue 0 of VCPU 2392 ------------[ cut here ]------------ remove_proc_entry: removing non-empty directory 'irq/199', leaking at least 'kvm-2-348' WARNING: CPU: 24 PID: 88176 at /home/greg/Work/linux/kernel-kvm-ppc/fs/proc/generic.c:684 remove_proc_entry+0x1ec/0x200 Modules linked in: kvm_hv kvm dm_mod vhost_net vhost tap xt_CHECKSUM iptable_mangle xt_MASQUERADE iptable_nat nf_nat xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ipt_REJECT nf_reject_ipv4 tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter squashfs loop fuse i2c_dev sg ofpart ocxl powernv_flash at24 xts mtd uio_pdrv_genirq vmx_crypto opal_prd ipmi_powernv uio ipmi_devintf ipmi_msghandler ibmpowernv ib_iser rdma_cm iw_cm ib_cm ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables ext4 mbcache jbd2 raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor xor async_tx raid6_pq libcrc32c raid1 raid0 linear sd_mod ast i2c_algo_bit drm_vram_helper ttm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm ahci libahci libata tg3 drm_panel_orientation_quirks [last unloaded: kvm] CPU: 24 PID: 88176 Comm: qemu-system-ppc Not tainted 5.3.0-xive-nr-servers-5.3-gku+ #38 NIP: c00000000053b0cc LR: c00000000053b0c8 CTR: c0000000000ba3b0 REGS: c000003f7f9934b0 TRAP: 0700 Not tainted (5.3.0-xive-nr-servers-5.3-gku+) MSR: 9000000000029033 <SF,HV,EE,ME,IR,DR,RI,LE> CR: 48228222 XER: 20040000
CFAR: c000000000131a50 IRQMASK: 0
GPR00: c00000000053b0c8 c000003f7f993740 c0000000015ec500 0000000000000057
GPR04: 0000000000000001 0000000000000000 000049fb98484262 0000000000001bcf
GPR08: 0000000000000007 0000000000000007 0000000000000001 9000000000001033
GPR12: 0000000000008000 c000003ffffeb800 0000000000000000 000000012f4ce5a1
GPR16: 000000012ef5a0c8 0000000000000000 000000012f113bb0 0000000000000000
GPR20: 000000012f45d918 c000003f863758b0 c000003f86375870 0000000000000006
GPR24: c000003f86375a30 0000000000000007 c0002039373d9020 c0000000014c4a48
GPR28: 0000000000000001 c000003fe62a4f6b c00020394b2e9fab c000003fe62a4ec0 NIP [c00000000053b0cc] remove_proc_entry+0x1ec/0x200
LR [c00000000053b0c8] remove_proc_entry+0x1e8/0x200
Call Trace: [c000003f7f993740] [c00000000053b0c8] remove_proc_entry+0x1e8/0x200 (unreliable) [c000003f7f9937e0] [c0000000001d3654] unregister_irq_proc+0x114/0x150 [c000003f7f993880] [c0000000001c6284] free_desc+0x54/0xb0 [c000003f7f9938c0] [c0000000001c65ec] irq_free_descs+0xac/0x100 [c000003f7f993910] [c0000000001d1ff8] irq_dispose_mapping+0x68/0x80 [c000003f7f993940] [c00800000d44e8a4] kvmppc_xive_attach_escalation+0x1fc/0x270 [kvm] [c000003f7f9939d0] [c00800000d45013c] kvmppc_xive_connect_vcpu+0x424/0x620 [kvm] [c000003f7f993ac0] [c00800000d444428] kvm_arch_vcpu_ioctl+0x260/0x448 [kvm] [c000003f7f993b90] [c00800000d43593c] kvm_vcpu_ioctl+0x154/0x7c8 [kvm] [c000003f7f993d00] [c0000000004840f0] do_vfs_ioctl+0xe0/0xc30 [c000003f7f993db0] [c000000000484d44] ksys_ioctl+0x104/0x120 [c000003f7f993e00] [c000000000484d88] sys_ioctl+0x28/0x80 [c000003f7f993e20] [c00000000000b278] system_call+0x5c/0x68 Instruction dump: 2c230000 41820008 3923ff78 e8e900a0 3c82ff69 3c62ff8d 7fa6eb78 7fc5f378 3884f080 3863b948 4bbf6925 60000000 <0fe00000> 4bffff7c fba10088 4bbf6e41 ---[ end trace b925b67a74a1d8d1 ]--- BUG: Kernel NULL pointer dereference at 0x00000010 Faulting instruction address: 0xc00800000d44fc04 Oops: Kernel access of bad area, sig: 11 [#1] LE PAGE_SIZE=64K MMU=Radix MMU=Hash SMP NR_CPUS=2048 NUMA PowerNV Modules linked in: kvm_hv kvm dm_mod vhost_net vhost tap xt_CHECKSUM iptable_mangle xt_MASQUERADE iptable_nat nf_nat xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ipt_REJECT nf_reject_ipv4 tun bridge stp llc ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter squashfs loop fuse i2c_dev sg ofpart ocxl powernv_flash at24 xts mtd uio_pdrv_genirq vmx_crypto opal_prd ipmi_powernv uio ipmi_devintf ipmi_msghandler ibmpowernv ib_iser rdma_cm iw_cm ib_cm ib_core iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ip_tables ext4 mbcache jbd2 raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor xor async_tx raid6_pq libcrc32c raid1 raid0 linear sd_mod ast i2c_algo_bit drm_vram_helper ttm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm ahci libahci libata tg3 drm_panel_orientation_quirks [last unloaded: kvm] CPU: 24 PID: 88176 Comm: qemu-system-ppc Tainted: G W 5.3.0-xive-nr-servers-5.3-gku+ #38 NIP: c00800000d44fc04 LR: c00800000d44fc00 CTR: c0000000001cd970 REGS: c000003f7f9938e0 TRAP: 0300 Tainted: G W (5.3.0-xive-nr-servers-5.3-gku+) MSR: 9000000000009033 <SF,HV,EE,ME,IR,DR,RI,LE> CR: 24228882 XER: 20040000 CFAR: c0000000001cd9ac DAR: 0000000000000010 DSISR: 40000000 IRQMASK: 0
GPR00: c00800000d44fc00 c000003f7f993b70 c00800000d468300 0000000000000000
GPR04: 00000000000000c7 0000000000000000 0000000000000000 c000003ffacd06d8
GPR08: 0000000000000000 c000003ffacd0738 0000000000000000 fffffffffffffffd
GPR12: 0000000000000040 c000003ffffeb800 0000000000000000 000000012f4ce5a1
GPR16: 000000012ef5a0c8 0000000000000000 000000012f113bb0 0000000000000000
GPR20: 000000012f45d918 00007ffffe0d9a80 000000012f4f5df0 000000012ef8c9f8
GPR24: 0000000000000001 0000000000000000 c000003fe4501ed0 c000003f8b1d0000
GPR28: c0000033314689c0 c000003fe4501c00 c000003fe4501e70 c000003fe4501e90 NIP [c00800000d44fc04] kvmppc_xive_cleanup_vcpu+0xfc/0x210 [kvm] LR [c00800000d44fc00] kvmppc_xive_cleanup_vcpu+0xf8/0x210 [kvm]
Call Trace: [c000003f7f993b70] [c00800000d44fc00] kvmppc_xive_cleanup_vcpu+0xf8/0x210 [kvm] (unreliable) [c000003f7f993bd0] [c00800000d450bd4] kvmppc_xive_release+0xdc/0x1b0 [kvm] [c000003f7f993c30] [c00800000d436a98] kvm_device_release+0xb0/0x110 [kvm] [c000003f7f993c70] [c00000000046730c] __fput+0xec/0x320 [c000003f7f993cd0] [c000000000164ae0] task_work_run+0x150/0x1c0 [c000003f7f993d30] [c000000000025034] do_notify_resume+0x304/0x440 [c000003f7f993e20] [c00000000000dcc4] ret_from_except_lite+0x70/0x74 Instruction dump: 3bff0008 7fbfd040 419e0054 847e0004 2fa30000 419effec e93d0000 8929203c 2f890000 419effb8 4800821d e8410018 <e9230010> e9490008 9b2a0039 7c0004ac ---[ end trace b925b67a74a1d8d2 ]--- Kernel panic - not syncing: Fatal exception
This affects both XIVE and XICS-on-XIVE devices since the beginning.
Check the VP id instead of the vCPU id when a new vCPU is connected. The allocation of the XIVE CPU structure in kvmppc_xive_connect_vcpu() is moved after the check to avoid the need for rollback.
--- arch/powerpc/kvm/book3s_xive.c | 24 ++++++++++++++++-------- arch/powerpc/kvm/book3s_xive.h | 12 ++++++++++++ arch/powerpc/kvm/book3s_xive_native.c | 6 ++++-- 3 files changed, 32 insertions(+), 10 deletions(-)
arch/powerpc/kvm/book3s_xive.c +16 -8
@@ -1217,6 +1217,7 @@ int kvmppc_xive_connect_vcpu(struct kvm_struct kvmppc_xive *xive = dev->private;struct kvmppc_xive_vcpu *xc;int i, r = -EBUSY ; +u32 vp_id;pr_devel ("connect_vcpu(cpu=%d)\n" , cpu);
@@ -1228,25 +1229,32 @@ int kvmppc_xive_connect_vcpu(struct kvm_return -EPERM ;if (vcpu->arch.irq_type !=KVMPPC_IRQ_DEFAULT )return -EBUSY ; -if (kvmppc_xive_find_server (vcpu->kvm, cpu)) { -pr_devel ("Duplicate !\n" ); -return -EEXIST ; - }if (cpu >= (KVM_MAX_VCPUS * vcpu->kvm->arch.emul_smt_mode)) {pr_devel ("Out of bounds !\n" );return -EINVAL ; } - xc =kzalloc (sizeof (*xc),GFP_KERNEL ); -if (!xc) -return -ENOMEM ;/* We need to synchronize with queue provisioning */ mutex_lock (&xive->lock); + + vp_id =kvmppc_xive_vp (xive, cpu); +if (kvmppc_xive_vp_in_use (xive->kvm, vp_id)) { +pr_devel ("Duplicate !\n" ); + r = -EEXIST ; + goto bail; + } + + xc =kzalloc (sizeof (*xc),GFP_KERNEL ); +if (!xc) { + r = -ENOMEM ; + goto bail; + } + vcpu->arch.xive_vcpu = xc; xc->xive = xive; xc->vcpu = vcpu; xc->server_num = cpu; - xc->vp_id =kvmppc_xive_vp (xive, cpu); + xc->vp_id = vp_id; xc->mfrr =0xff ; xc->valid = true;
arch/powerpc/kvm/book3s_xive.h +12 -0
@@ -220,6 +220,18 @@ static inline u32 kvmppc_xive_vp(structreturn xive->vp_base +kvmppc_pack_vcpu_id (xive->kvm, server); } +static inline bool kvmppc_xive_vp_in_use (struct kvm *kvm,u32 vp_id) +{ +struct kvm_vcpu *vcpu =NULL ; +int i; + +kvm_for_each_vcpu (i, vcpu, kvm) { +if (vcpu->arch.xive_vcpu && vp_id == vcpu->arch.xive_vcpu->vp_id) +return true; + } +return false; +} +/* * Mapping between guest priorities and host priorities * is as follow.
arch/powerpc/kvm/book3s_xive_native.c +4 -2
@@ -106,6 +106,7 @@ int kvmppc_xive_native_connect_vcpu(strustruct kvmppc_xive *xive = dev->private;struct kvmppc_xive_vcpu *xc =NULL ;int rc; +u32 vp_id;pr_devel ("native_connect_vcpu(server=%d)\n" , server_num);
@@ -124,7 +125,8 @@ int kvmppc_xive_native_connect_vcpu(strumutex_lock (&xive->lock); -if (kvmppc_xive_find_server (vcpu->kvm, server_num)) { + vp_id =kvmppc_xive_vp (xive, server_num); +if (kvmppc_xive_vp_in_use (xive->kvm, vp_id)) {pr_devel ("Duplicate !\n" ); rc = -EEXIST ; goto bail;
@@ -141,7 +143,7 @@ int kvmppc_xive_native_connect_vcpu(stru xc->vcpu = vcpu; xc->server_num = server_num; - xc->vp_id =kvmppc_xive_vp (xive, server_num); + xc->vp_id = vp_id; xc->valid = true; vcpu->arch.irq_type =KVMPPC_IRQ_XIVE ;
Greg Kroah-Hartman
maintainerPATCH 189/197 memstick: jmb38x_ms: Fix an error handling path in jmb38x_ms_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
commit 28c9fac09ab0147158db0baeec630407a5e9b892 upstream.
If 'jmb38x_ms_count_slots()' returns 0, we must undo the previous 'pci_request_regions()' call.
Goto 'err_out_int' to fix it.
--- drivers/memstick/host/jmb38x_ms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memstick/host/jmb38x_ms.c +1 -1
@@ -941,7 +941,7 @@ static int jmb38x_ms_probe(struct pci_deif (!cnt) { rc = -ENODEV ; pci_dev_busy =1 ; - goto err_out; + goto err_out_int; } jm = kzalloc(sizeof(struct jmb38x_ms)
Greg Kroah-Hartman
maintainerPATCH 190/197 cpufreq: Avoid cpufreq_suspend() deadlock on system shutdown
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 65650b35133ff20f0c9ef0abd5c3c66dbce3ae57 upstream.
It is incorrect to set the cpufreq syscore shutdown callback pointer to cpufreq_suspend(), because that function cannot be run in the syscore stage of system shutdown for two reasons: (a) it may attempt to carry out actions depending on devices that have already been shut down at that point and (b) the RCU synchronization carried out by it may not be able to make progress then.
The latter issue has been present since commit 45975c7d21a1 ("rcu:
Define RCU-sched API in terms of RCU for Tree RCU PREEMPT builds"), but the former one has been there since commit 90de2a4aa9f3 ("cpufreq:
suspend cpufreq governors on shutdown") regardless.
Fix that by dropping cpufreq_syscore_ops altogether and making device_shutdown() call cpufreq_suspend() directly before shutting down devices, which is along the lines of what system-wide power management does.
--- drivers/base/core.c | 3 +++ drivers/cpufreq/cpufreq.c | 10 ---------- 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/base/core.c +3 -0
@@ -9,6 +9,7 @@*/ #include <linux/acpi.h> +#include <linux/cpufreq.h> #include <linux/device.h> #include <linux/err.h> #include <linux/fwnode.h>
@@ -3150,6 +3151,8 @@ void device_shutdown(void)wait_for_device_probe ();device_block_probing (); +cpufreq_suspend (); +spin_lock (&devices_kset->list_lock);/* * Walk the devices list backward, shutting down each in turn.
drivers/cpufreq/cpufreq.c +0 -10
@@ -2746,14 +2746,6 @@ int cpufreq_unregister_driver(struct cpu }EXPORT_SYMBOL_GPL (cpufreq_unregister_driver); -/* -* Stop cpufreq at shutdown to make sure it isn't holding any locks -* or mutexes when secondary CPUs are halted. -*/ -static struct syscore_ops cpufreq_syscore_ops = { - .shutdown = cpufreq_suspend, -}; -struct kobject *cpufreq_global_kobject;EXPORT_SYMBOL (cpufreq_global_kobject);
@@ -2765,8 +2757,6 @@ static int __init cpufreq_core_init(void cpufreq_global_kobject =kobject_create_and_add ("cpufreq" , &cpu_subsys.dev_root->kobj);BUG_ON (!cpufreq_global_kobject); -register_syscore_ops (&cpufreq_syscore_ops); -return 0 ; }module_param (off, int,0444 );
Greg Kroah-Hartman
maintainerPATCH 191/197 ceph: just skip unrecognized info in ceph_reply_info_extra
In reply to Greg Kroah-HartmanFrom: Jeff Layton <[email protected]>
commit 1d3f87233e26362fc3d4e59f0f31a71b570f90b9 upstream.
In the future, we're going to want to extend the ceph_reply_info_extra for create replies. Currently though, the kernel code doesn't accept an extra blob that is larger than the expected data.
Change the code to skip over any unrecognized fields at the end of the extra blob, rather than returning -EIO.
--- fs/ceph/mds_client.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
fs/ceph/mds_client.c +11 -10
@@ -384,8 +384,8 @@ static int parse_reply_info_readdir(void } done: -if (*p != end) - goto bad; +/* Skip over any unrecognized fields */ + *p = end;return 0 ; bad:
@@ -406,12 +406,10 @@ static int parse_reply_info_filelock(voi goto bad; info->filelock_reply = *p; - *p +=sizeof (*info->filelock_reply); -if (unlikely (*p != end)) - goto bad; +/* Skip over any unrecognized fields */ + *p = end;return 0 ; - bad:return -EIO ; }
@@ -425,18 +423,21 @@ static int parse_reply_info_create(void {if (features == (u64)-1 || (features &CEPH_FEATURE_REPLY_CREATE_INODE )) { +/* Malformed reply? */ if (*p == end) { info->has_create_ino = false; }else { info->has_create_ino = true; - info->ino =ceph_decode_64 (p); +ceph_decode_64_safe (p, end, info->ino, bad); } + }else { +if (*p != end) + goto bad; } -if (unlikely (*p != end)) - goto bad; +/* Skip over any unrecognized fields */ + *p = end;return 0 ; - bad:return -EIO ; }
Greg Kroah-Hartman
maintainerPATCH 192/197 xen/netback: fix error path of xenvif_connect_data()
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit 3d5c1a037d37392a6859afbde49be5ba6a70a6b3 upstream.
xenvif_connect_data() calls module_put() in case of error. This is wrong as there is no related module_get().
Remove the superfluous module_put().
--- drivers/net/xen-netback/interface.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/xen-netback/interface.c +0 -1
@@ -719,7 +719,6 @@ err_unmap:xenvif_unmap_frontend_data_rings (queue);netif_napi_del (&queue->napi); err: -module_put (THIS_MODULE );return err; }
Greg Kroah-Hartman
maintainerPATCH 193/197 PCI: PM: Fix pci_power_up()
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 45144d42f299455911cc29366656c7324a3a7c97 upstream.
There is an arbitrary difference between the system resume and runtime resume code paths for PCI devices regarding the delay to apply when switching the devices from D3cold to D0.
Namely, pci_restore_standard_config() used in the runtime resume code path calls pci_set_power_state() which in turn invokes __pci_start_power_transition() to power up the device through the platform firmware and that function applies the transition delay (as per PCI Express Base Specification Revision 2.0, Section 6.6.1). However, pci_pm_default_resume_early() used in the system resume code path calls pci_power_up() which doesn't apply the delay at all and that causes issues to occur during resume from suspend-to-idle on some systems where the delay is required.
Since there is no reason for that difference to exist, modify pci_power_up() to follow pci_set_power_state() more closely and invoke __pci_start_power_transition() from there to call the platform firmware to power up the device (in case that's necessary).
--- drivers/pci/pci.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/pci/pci.c +11 -13
@@ -959,19 +959,6 @@ void pci_refresh_power_state(struct pci_ }/** -* pci_power_up - Put the given device into D0 forcibly -* @dev: PCI device to power up -*/ -void pci_power_up (struct pci_dev *dev) -{ -if (platform_pci_power_manageable (dev)) -platform_pci_set_power_state (dev,PCI_D0 ); - -pci_raw_set_power_state (dev,PCI_D0 ); -pci_update_current_state (dev,PCI_D0 ); -} - -/** * pci_platform_power_transition - Use platform to change device power state * @dev: PCI device to handle. * @state: State to put the device into.
@@ -1154,6 +1141,17 @@ int pci_set_power_state(struct pci_dev *EXPORT_SYMBOL (pci_set_power_state);/** +* pci_power_up - Put the given device into D0 forcibly +* @dev: PCI device to power up +*/ +void pci_power_up (struct pci_dev *dev) +{ +__pci_start_power_transition (dev,PCI_D0 ); +pci_raw_set_power_state (dev,PCI_D0 ); +pci_update_current_state (dev,PCI_D0 ); +} + +/** * pci_choose_state - Choose the power state of a PCI device * @dev: PCI device to be suspended * @state: target sleep state for the whole system. This is the value
Greg Kroah-Hartman
maintainerPATCH 194/197 opp: of: drop incorrect lockdep_assert_held()
In reply to Greg Kroah-HartmanFrom: Viresh Kumar <[email protected]>
commit f2edbb6699b0bc6e4f789846b99007200546c6c2 upstream.
_find_opp_of_np() doesn't traverse the list of OPP tables but instead just the entries within an OPP table and so only requires to lock the OPP table itself.
The lockdep_assert_held() was added there by mistake and isn't really required.
--- drivers/opp/of.c | 2 -- 1 file changed, 2 deletions(-)
drivers/opp/of.c +0 -2
@@ -77,8 +77,6 @@ static struct dev_pm_opp *_find_opp_of_n {struct dev_pm_opp *opp; -lockdep_assert_held (&opp_table_lock); -mutex_lock (&opp_table->lock);list_for_each_entry (opp, &opp_table->opp_list, node) {
Greg Kroah-Hartman
maintainerPATCH 195/197 of: reserved_mem: add missing of_node_put() for proper ref-counting
In reply to Greg Kroah-HartmanFrom: Chris Goldsworthy <[email protected]>
commit 5dba51754b04a941a1064f584e7a7f607df3f9bc upstream.
Commit d698a388146c ("of: reserved-memory: ignore disabled memory-region nodes") added an early return in of_reserved_mem_device_init_by_idx(), but didn't call of_node_put() on a device_node whose ref-count was incremented in the call to of_parse_phandle() preceding the early exit.
--- drivers/of/of_reserved_mem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/of/of_reserved_mem.c +3 -1
@@ -324,8 +324,10 @@ int of_reserved_mem_device_init_by_idx(sif (!target)return -ENODEV ; -if (!of_device_is_available (target)) +if (!of_device_is_available (target)) { +of_node_put (target);return 0 ; + } rmem =__find_rmem (target);of_node_put (target);
Greg Kroah-Hartman
maintainerPATCH 196/197 blk-rq-qos: fix first node deletion of rq_qos_del()
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 307f4065b9d7c1e887e8bdfb2487e4638559fea1 upstream.
rq_qos_del() incorrectly assigns the node being deleted to the head if it was the first on the list in the !prev path. Fix it by iterating with ** instead.
--- block/blk-rq-qos.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
block/blk-rq-qos.h +5 -8
@@ -103,16 +103,13 @@ static inline void rq_qos_add(struct reqstatic inline void rq_qos_del (struct request_queue *q,struct rq_qos *rqos) { -struct rq_qos *cur, *prev =NULL ; -for (cur = q->rq_qos; cur; cur = cur->next) { -if (cur == rqos) { -if (prev) - prev->next = rqos->next; -else - q->rq_qos = cur; +struct rq_qos **cur; + +for (cur = &q->rq_qos; *cur; cur = &(*cur)->next) { +if (*cur == rqos) { + *cur = rqos->next;break ; } - prev = cur; }blk_mq_debugfs_unregister_rqos (rqos);
Greg Kroah-Hartman
maintainerPATCH 197/197 RDMA/cxgb4: Do not dma memory off of the stack
In reply to Greg Kroah-HartmanFrom: Greg KH <[email protected]>
commit 3840c5b78803b2b6cc1ff820100a74a092c40cbb upstream.
Nicolas pointed out that the cxgb4 driver is doing dma off of the stack, which is generally considered a very bad thing. On some architectures it could be a security problem, but odds are none of them actually run this driver, so it's just a "normal" bug.
Resolve this by allocating the memory for a message off of the heap instead of the stack. kmalloc() always will give us a proper memory location that DMA will work correctly from.
--- drivers/infiniband/hw/cxgb4/mem.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/infiniband/hw/cxgb4/mem.c +17 -11
@@ -275,13 +275,17 @@ static int write_tpt_entry(struct c4iw_r struct sk_buff *skb, struct c4iw_wr_wait *wr_waitp) { int err; -struct fw_ri_tpte tpt; +struct fw_ri_tpte *tpt;u32 stag_idx;static atomic_t key;if (c4iw_fatal_error (rdev))return -EIO ; + tpt =kmalloc (sizeof (*tpt),GFP_KERNEL ); +if (!tpt) +return -ENOMEM ; + stag_state = stag_state >0 ; stag_idx = (*stag) >>8 ;
@@ -291,6 +295,7 @@ static int write_tpt_entry(struct c4iw_rmutex_lock (&rdev->stats.lock); rdev->stats.stag.fail++;mutex_unlock (&rdev->stats.lock); +kfree (tpt);return -ENOMEM ; }mutex_lock (&rdev->stats.lock);
@@ -305,28 +310,28 @@ static int write_tpt_entry(struct c4iw_r/* write TPT entry */ if (reset_tpt_entry) -memset (&tpt,0 ,sizeof (tpt)); +memset (tpt,0 ,sizeof (*tpt));else { - tpt.valid_to_pdid =cpu_to_be32 (FW_RI_TPTE_VALID_F | + tpt->valid_to_pdid =cpu_to_be32 (FW_RI_TPTE_VALID_F |FW_RI_TPTE_STAGKEY_V ((*stag &FW_RI_TPTE_STAGKEY_M )) |FW_RI_TPTE_STAGSTATE_V (stag_state) |FW_RI_TPTE_STAGTYPE_V (type) |FW_RI_TPTE_PDID_V (pdid)); - tpt.locread_to_qpid =cpu_to_be32 (FW_RI_TPTE_PERM_V (perm) | + tpt->locread_to_qpid =cpu_to_be32 (FW_RI_TPTE_PERM_V (perm) | (bind_enabled ?FW_RI_TPTE_MWBINDEN_F :0 ) |FW_RI_TPTE_ADDRTYPE_V ((zbva ?FW_RI_ZERO_BASED_TO :FW_RI_VA_BASED_TO ))|FW_RI_TPTE_PS_V (page_size)); - tpt.nosnoop_pbladdr = !pbl_size ?0 :cpu_to_be32 ( + tpt->nosnoop_pbladdr = !pbl_size ?0 :cpu_to_be32 (FW_RI_TPTE_PBLADDR_V (PBL_OFF (rdev, pbl_addr)>>3 )); - tpt.len_lo =cpu_to_be32 ((u32)(len &0xffffffffUL )); - tpt.va_hi =cpu_to_be32 ((u32)(to >>32 )); - tpt.va_lo_fbo =cpu_to_be32 ((u32)(to &0xffffffffUL )); - tpt.dca_mwbcnt_pstag =cpu_to_be32 (0 ); - tpt.len_hi =cpu_to_be32 ((u32)(len >>32 )); + tpt->len_lo =cpu_to_be32 ((u32)(len &0xffffffffUL )); + tpt->va_hi =cpu_to_be32 ((u32)(to >>32 )); + tpt->va_lo_fbo =cpu_to_be32 ((u32)(to &0xffffffffUL )); + tpt->dca_mwbcnt_pstag =cpu_to_be32 (0 ); + tpt->len_hi =cpu_to_be32 ((u32)(len >>32 )); } err =write_adapter_mem (rdev, stag_idx + (rdev->lldi.vr->stag.start >>5 ), -sizeof (tpt), &tpt, skb, wr_waitp); +sizeof (*tpt), tpt, skb, wr_waitp);if (reset_tpt_entry) {c4iw_put_resource (&rdev->resource.tpt_table, stag_idx);
@@ -334,6 +339,7 @@ static int write_tpt_entry(struct c4iw_r rdev->stats.stag.cur -=32 ;mutex_unlock (&rdev->stats.lock); } +kfree (tpt);return err; }
stable-rc/linux-5.3.y boot: 141 boots: 0 failed, 134 passed with 7 offline (v5.3.7-198-g740177dc0d52)
stable-rc/linux-5.3.y boot: 141 boots: 0 failed, 134 passed with 7 offline (v5.3.7-198-g740177dc0d52)
Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-5.3.y/kernel/v5.3.7-198-g740177dc0d52/
Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-5.3.y/kernel/v5.3.7-198-g740177dc0d52/
Tree: stable-rc
Branch: linux-5.3.y
Git Describe: v5.3.7-198-g740177dc0d52
Git Commit: 740177dc0d52947b60a2566de1f76404c4466c6a
Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Tested: 82 unique boards, 25 SoC families, 17 builds out of 208
Offline Platforms:
arm:
multi_v7_defconfig:
gcc-8
qcom-apq8064-cm-qs600: 1 offline lab
sun5i-r8-chip: 1 offline lab
sun7i-a20-bananapi: 1 offline lab
sunxi_defconfig:
gcc-8
sun5i-r8-chip: 1 offline lab
sun7i-a20-bananapi: 1 offline lab
davinci_all_defconfig:
gcc-8
dm365evm,legacy: 1 offline lab
qcom_defconfig:
gcc-8
qcom-apq8064-cm-qs600: 1 offline lab---
For more info write to <[email protected]>
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.3.8 release. There are 197 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue 29 Oct 2019 08:27:02 PM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.3.8-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.3.y
and the diffstat can be found below.thanks,
greg k-h
Compiled, booted, and no regressions found on my x86_64 system.
Thanks,
Didik Setiawan
Greg Kroah-Hartman
maintainerQuoted 15 lines · Didik Setiawan
Quoted 14 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.3.8 release. There are 197 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue 29 Oct 2019 08:27:02 PM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.3.8-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.3.y
and the diffstat can be found below.
Quoted 5 lines
Quoted 3 lines
thanks,
greg k-h
Compiled, booted, and no regressions found on my
x86_64system.
Thanks for testing all of these and letting me know.
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.3.8 release. There are 197 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue 29 Oct 2019 08:27:02 PM UTC. Anything received after that time might be too late.
Build results:
total: 158 pass: 158 fail: 0 Qemu test results: total: 391 pass: 391 fail: 0
Guenter
Jon Hunter
maintainerQuoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.3.8 release. There are 197 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue 29 Oct 2019 08:27:02 PM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.3.8-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.3.y
and the diffstat can be found below.thanks,
greg k-h
All tests are passing for Tegra ...
Test results for stable-v5.3:
12 builds: 12 pass, 0 fail
22 boots: 22 pass, 0 fail
38 tests: 38 pass, 0 failLinux version: 5.3.8-rc1-g740177dc0d52
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04Cheers
Jon
Signature · 1 line
nvpublic
Greg Kroah-Hartman
maintainerQuoted 23 lines · Jon Hunter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.3.8 release. There are 197 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue 29 Oct 2019 08:27:02 PM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.3.8-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.3.y
and the diffstat can be found below.thanks,
greg k-h
All tests are passing for Tegra ...
Test results for stable-v5.3:
Quoted 9 lines
12 builds: 12 pass, 0 fail 22 boots: 22 pass, 0 fail 38 tests: 38 pass, 0 failLinux version: 5.3.8-rc1-g740177dc0d52
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,tegra194-p2972-0000, tegra20-ventana, tegra210-p2371-2180, tegra30-cardhu-a04
THanks for testing all of these and letting me know.
greg k-h
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.3.8 release. There are 197 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue 29 Oct 2019 08:27:02 PM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.3.8-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.3.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
Note:
The new test case from LTP version upgrade syscalls sync_file_range02 is an intermittent failure. We are investigating this case.
The listed fixes in the below section are due to LTP upgrade to v20190930.
Summary
------------------------------------------------------------------------
kernel: 5.3.8-rc2
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git branch: linux-5.3.y
git commit: 96dab4347cbe9212292cb3934e4d16cf1dab94c3
git describe: v5.3.7-197-g96dab4347cbe
Test details: https://qa-reports.linaro.org/lkft/linux-stable-rc-5.3-oe/build/v5.3.7-197-g96dab4347cbe
No regressions (compared to build v5.3.6-112-gcbb18cd3e478)
Fixes (compared to build v5.3.6-112-gcbb18cd3e478)
------------------------------------------------------------------------
ltp-syscalls-tests:
* clock_getres01
* ioctl_ns05
* ioctl_ns06
* shmctl01
* ustat02
Ran 16437 total tests in the following environments and test suites.
Environments
--------------
- dragonboard-410c
- hi6220-hikey
- i386
- juno-r2
- qemu_arm
- qemu_arm64
- qemu_i386
- qemu_x86_64
- x15
- x86
Test Suites
-----------
* build
* install-android-platform-tools-r2600
* kselftest
* libgpiod
* libhugetlbfs
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-cpuhotplug-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* perf
* spectre-meltdown-checker-test
* v4l2-compliance
* network-basic-tests
* ltp-open-posix-tests
* ssuite
* kselftest-vsyscall-mode-none
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org