5.5.3-stable review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 145/367 dm thin metadata: use pool locking at end of dm_pool_metadata_close
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 44d8ebf436399a40fcd10dd31b29d37823d62fcc upstream.
Ensure that the pool is locked during calls to __commit_transaction and __destroy_persistent_data_objects. Just being consistent with locking, but reality is dm_pool_metadata_close is called once pool is being destroyed so access to pool shouldn't be contended.
Also, use pmd_write_lock_in_core rather than __pmd_write_lock in dm_pool_commit_metadata and rename __pmd_write_lock to pmd_write_lock_in_core -- there was no need for the alias.
In addition, verify that the pool is locked in __commit_transaction().
--- drivers/md/dm-thin-metadata.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/md/dm-thin-metadata.c +6 -4
@@ -387,16 +387,15 @@ static int subtree_equal(void *context,* Variant that is used for in-core only changes or code that * shouldn't put the pool in service on its own (e.g. commit). */ -static inline void __pmd_write_lock (struct dm_pool_metadata *pmd) +static inline void pmd_write_lock_in_core (struct dm_pool_metadata *pmd) __acquires(pmd->root_lock) {down_write (&pmd->root_lock); } -#define pmd_write_lock_in_core (pmd) __pmd_write_lock((pmd))static inline void pmd_write_lock (struct dm_pool_metadata *pmd) { -__pmd_write_lock (pmd); +pmd_write_lock_in_core (pmd);if (unlikely (!pmd->in_service)) pmd->in_service = true; }
@@ -831,6 +830,7 @@ static int __commit_transaction(struct d* We need to know if the thin_disk_superblock exceeds a 512-byte sector. */ BUILD_BUG_ON (sizeof (struct thin_disk_superblock ) >512 ); +BUG_ON (!rwsem_is_locked (&pmd->root_lock));if (unlikely (!pmd->in_service))return 0 ;
@@ -953,6 +953,7 @@ int dm_pool_metadata_close(struct dm_pooreturn -EBUSY ; } +pmd_write_lock_in_core (pmd);if (!dm_bm_is_read_only (pmd->bm) && !pmd->fail_io) { r =__commit_transaction (pmd);if (r <0 )
@@ -961,6 +962,7 @@ int dm_pool_metadata_close(struct dm_poo }if (!pmd->fail_io)__destroy_persistent_data_objects (pmd); +pmd_write_unlock (pmd);kfree (pmd);return 0 ;
@@ -1841,7 +1843,7 @@ int dm_pool_commit_metadata(struct dm_po* Care is taken to not have commit be what * triggers putting the thin-pool in-service. */ -__pmd_write_lock (pmd); +pmd_write_lock_in_core (pmd);if (pmd->fail_io) goto out;
Greg Kroah-Hartman
maintainerPATCH 146/367 dm thin: fix use-after-free in metadata_pre_commit_callback
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit a4a8d286586d4b28c8517a51db8d86954aadc74b upstream.
dm-thin uses struct pool to hold the state of the pool. There may be multiple pool_c's pointing to a given pool, each pool_c represents a loaded target. pool_c's may be created and destroyed arbitrarily and the pool contains a reference count of pool_c's pointing to it.
Since commit 694cfe7f31db3 ("dm thin: Flush data device before committing metadata") a pointer to pool_c is passed to dm_pool_register_pre_commit_callback and this function stores it in pmd->pre_commit_context. If this pool_c is freed, but pool is not (because there is another pool_c referencing it), we end up in a situation where pmd->pre_commit_context structure points to freed pool_c. It causes a crash in metadata_pre_commit_callback.
Fix this by moving the dm_pool_register_pre_commit_callback() from pool_ctr() to pool_preresume(). This way the in-core thin-pool metadata is only ever armed with callback data whose lifetime matches the active thin-pool target.
In should be noted that this fix preserves the ability to load a thin-pool table that uses a different data block device (that contains the same data) -- though it is unclear if that capability is still useful and/or needed.
--- drivers/md/dm-thin.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/md/dm-thin.c +3 -4
@@ -3408,10 +3408,6 @@ static int pool_ctr(struct dm_target *tiif (r) goto out_flags_changed; -dm_pool_register_pre_commit_callback (pt->pool->pmd, - metadata_pre_commit_callback, - pt); - pt->callbacks.congested_fn = pool_is_congested;dm_table_add_target_callbacks (ti->table, &pt->callbacks);
@@ -3574,6 +3570,9 @@ static int pool_preresume(struct dm_targif (r)return r; +dm_pool_register_pre_commit_callback (pool->pmd, + metadata_pre_commit_callback, pt); + r =maybe_resize_data_dev (ti, &need_commit1);if (r)return r;
Greg Kroah-Hartman
maintainerPATCH 332/367 net: stmmac: fix missing IFF_MULTICAST check in dwmac4_set_filter
In reply to Greg Kroah-HartmanFrom: "Verma, Aashish" <[email protected]>
[ Upstream commit 2ba31cd93784b61813226d259fd94a221ecd9d61 ]
Without checking for IFF_MULTICAST flag, it is wrong to assume multicast filtering is always enabled. By checking against IFF_MULTICAST, now the driver behaves correctly when the multicast support is toggled by below command:-
ip link set <devname> multicast off|on
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +1 -1
@@ -420,7 +420,7 @@ static void dwmac4_set_filter(struct mac value |=GMAC_PACKET_FILTER_PM ;/* Set all the bits of the HASH tab */ memset (mc_filter,0xff ,sizeof (mc_filter)); - }else if (!netdev_mc_empty (dev)) { + }else if (!netdev_mc_empty (dev) && (dev->flags &IFF_MULTICAST )) {struct netdev_hw_addr *ha;/* Hash filter for multicast */
Greg Kroah-Hartman
maintainerPATCH 330/367 net: stmmac: fix incorrect GMAC_VLAN_TAG register writting in GMAC4+
In reply to Greg Kroah-HartmanFrom: "Tan, Tee Min" <[email protected]>
[ Upstream commit 9eeeb3c9de4e3aeaa2bec097162f09305dd9f4c3 ]
It should always do a read of current value of GMAC_VLAN_TAG instead of directly overwriting the register value.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +4 -3
@@ -736,11 +736,14 @@ static void dwmac4_update_vlan_hash(stru __le16 perfect_match, bool is_double) { void __iomem *ioaddr = hw->pcsr; +u32 value;writel (hash, ioaddr +GMAC_VLAN_HASH_TABLE ); + value =readl (ioaddr +GMAC_VLAN_TAG ); +if (hash) { -u32 value =GMAC_VLAN_VTHM |GMAC_VLAN_ETV ; + value |=GMAC_VLAN_VTHM |GMAC_VLAN_ETV ;if (is_double) { value |=GMAC_VLAN_EDVLP ; value |=GMAC_VLAN_ESVL ;
@@ -759,8 +762,6 @@ static void dwmac4_update_vlan_hash(struwritel (value | perfect_match, ioaddr +GMAC_VLAN_TAG ); }else { -u32 value =readl (ioaddr +GMAC_VLAN_TAG ); - value &= ~(GMAC_VLAN_VTHM |GMAC_VLAN_ETV ); value &= ~(GMAC_VLAN_EDVLP |GMAC_VLAN_ESVL ); value &= ~GMAC_VLAN_DOVLTC ;
Greg Kroah-Hartman
maintainerPATCH 275/367 virtio-pci: check name when counting MSI-X vectors
In reply to Greg Kroah-HartmanFrom: Daniel Verkamp <[email protected]>
commit 303090b513fd1ee45aa1536b71a3838dc054bc05 upstream.
VQs without a name specified are not valid; they are skipped in the later loop that assigns MSI-X vectors to queues, but the per_vq_vectors loop above that counts the required number of vectors previously still counted any queue with a non-NULL callback as needing a vector.
Add a check to the per_vq_vectors loop so that vectors with no name are not counted to make the two loops consistent. This prevents over-counting unnecessary vectors (e.g. for features which were not negotiated with the device).
--- drivers/virtio/virtio_pci_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio_pci_common.c +1 -1
@@ -294,7 +294,7 @@ static int vp_find_vqs_msix(struct virti/* Best option: one for change interrupt, one per vq. */ nvectors =1 ;for (i =0 ; i < nvqs; ++i) -if (callbacks[i]) +if (names[i] && callbacks[i]) ++nvectors; }else {/* Second best: one for change, shared for all vqs. */
Greg Kroah-Hartman
maintainerPATCH 134/367 f2fs: fix dcache lookup of !casefolded directories
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 5515eae647426169e4b7969271fb207881eba7f6 upstream.
Do the name comparison for non-casefolded directories correctly.
This is analogous to ext4's commit 66883da1eee8 ("ext4: fix dcache lookup of !casefolded directories").
--- fs/f2fs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/dir.c +1 -1
@@ -1073,7 +1073,7 @@ static int f2fs_d_compare(const struct dif (!IS_CASEFOLDED (dentry->d_parent->d_inode)) {if (len != name->len)return -1 ; -return memcmp (str, name, len); +return memcmp (str, name->name, len); }return f2fs_ci_compare (dentry->d_parent->d_inode, name, &qstr, false);
Greg Kroah-Hartman
maintainerPATCH 126/367 scsi: qla2xxx: Fix mtcp dump collection failure
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit 641e0efddcbde52461e017136acd3ce7f2ef0c14 upstream.
MTCP dump failed due to MB Reg 10 was picking garbage data from stack memory.
--- drivers/scsi/qla2xxx/qla_mbx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_mbx.c +1 -2
@@ -6152,9 +6152,8 @@ qla2x00_dump_mctp_data(scsi_qla_host_t * mcp->mb[7 ] =LSW (MSD (req_dma)); mcp->mb[8 ] =MSW (addr);/* Setting RAM ID to valid */ - mcp->mb[10 ] |=BIT_7 ;/* For MCTP RAM ID is 0x40 */ - mcp->mb[10 ] |=0x40 ; + mcp->mb[10 ] =BIT_7 |0x40 ; mcp->out_mb |=MBX_10 |MBX_8 |MBX_7 |MBX_6 |MBX_5 |MBX_4 |MBX_3 |MBX_2 |MBX_1 |MBX_0 ;
Greg Kroah-Hartman
maintainerPATCH 75/367 KVM: arm/arm64: Correct AArch32 SPSR on exception entry
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
commit 1cfbb484de158e378e8971ac40f3082e53ecca55 upstream.
Confusingly, there are three SPSR layouts that a kernel may need to deal with:
(1) An AArch64 SPSR_ELx view of an AArch64 pstate
(2) An AArch64 SPSR_ELx view of an AArch32 pstate
(3) An AArch32 SPSR_* view of an AArch32 pstate
When the KVM AArch32 support code deals with SPSR_{EL2,HYP}, it's either dealing with #2 or #3 consistently. On arm64 the PSR_AA32_* definitions match the AArch64 SPSR_ELx view, and on arm the PSR_AA32_* definitions match the AArch32 SPSR_* view.
However, when we inject an exception into an AArch32 guest, we have to synthesize the AArch32 SPSR_* that the guest will see. Thus, an AArch64 host needs to synthesize layout #3 from layout #2.
This patch adds a new host_spsr_to_spsr32() helper for this, and makes use of it in the KVM AArch32 support code. For arm64 we need to shuffle the DIT bit around, and remove the SS bit, while for arm we can use the value as-is.
I've open-coded the bit manipulation for now to avoid having to rework the existing PSR_* definitions into PSR64_AA32_* and PSR32_AA32_* definitions. I hope to perform a more thorough refactoring in future so that we can handle pstate view manipulation more consistently across the kernel tree.
--- arch/arm/include/asm/kvm_emulate.h | 5 +++++ arch/arm64/include/asm/kvm_emulate.h | 32 ++++++++++++++++++++++++++++++++ virt/kvm/arm/aarch32.c | 6 +++--- 3 files changed, 40 insertions(+), 3 deletions(-)
arch/arm/include/asm/kvm_emulate.h +5 -0
@@ -53,6 +53,11 @@ static inline void vcpu_write_spsr(struc *__vcpu_spsr (vcpu) = v; } +static inline unsigned long host_spsr_to_spsr32 (unsigned long spsr) +{ +return spsr; +} +static inline unsigned long vcpu_get_reg (struct kvm_vcpu *vcpu,u8 reg_num) {
arch/arm64/include/asm/kvm_emulate.h +32 -0
@@ -219,6 +219,38 @@ static inline void vcpu_write_spsr(strucvcpu_gp_regs (vcpu)->spsr[KVM_SPSR_EL1 ] = v; } +/* +* The layout of SPSR for an AArch32 state is different when observed from an +* AArch64 SPSR_ELx or an AArch32 SPSR_*. This function generates the AArch32 +* view given an AArch64 view. +* +* In ARM DDI 0487E.a see: +* +* - The AArch64 view (SPSR_EL2) in section C5.2.18, page C5-426 +* - The AArch32 view (SPSR_abt) in section G8.2.126, page G8-6256 +* - The AArch32 view (SPSR_und) in section G8.2.132, page G8-6280 +* +* Which show the following differences: +* +* | Bit | AA64 | AA32 | Notes | +* +-----+------+------+-----------------------------| +* | 24 | DIT | J | J is RES0 in ARMv8 | +* | 21 | SS | DIT | SS doesn't exist in AArch32 | +* +* ... and all other bits are (currently) common. +*/ +static inline unsigned long host_spsr_to_spsr32 (unsigned long spsr) +{ +const unsigned long overlap =BIT (24 ) |BIT (21 ); +unsigned long dit = !!(spsr &PSR_AA32_DIT_BIT ); + + spsr &= ~overlap; + + spsr |= dit <<21 ; + +return spsr; +} +static inline bool vcpu_mode_priv (const struct kvm_vcpu *vcpu) {u32 mode;
virt/kvm/arm/aarch32.c +3 -3
@@ -129,15 +129,15 @@ static unsigned long get_except32_cpsr(sstatic void prepare_fault32 (struct kvm_vcpu *vcpu,u32 mode,u32 vect_offset) { -unsigned long new_spsr_value = *vcpu_cpsr (vcpu); -bool is_thumb = (new_spsr_value &PSR_AA32_T_BIT ); +unsigned long spsr = *vcpu_cpsr (vcpu); +bool is_thumb = (spsr &PSR_AA32_T_BIT );u32 return_offset = return_offsets[vect_offset >>2 ][is_thumb];u32 sctlr =vcpu_cp15 (vcpu, c1_SCTLR); *vcpu_cpsr (vcpu) =get_except32_cpsr (vcpu, mode);/* Note: These now point to the banked copies */ -vcpu_write_spsr (vcpu, new_spsr_value); +vcpu_write_spsr (vcpu,host_spsr_to_spsr32 (spsr)); *vcpu_reg32 (vcpu,14 ) = *vcpu_pc (vcpu) + return_offset;/* Branch to exception vector */
Greg Kroah-Hartman
maintainerPATCH 92/367 PCI: keystone: Fix link training retries initiation
In reply to Greg Kroah-HartmanFrom: Yurii Monakov <[email protected]>
commit 6df19872d881641e6394f93ef2938cffcbdae5bb upstream.
ks_pcie_stop_link() function does not clear LTSSM_EN_VAL bit so link training was not triggered more than once after startup. In configurations where link can be unstable during early boot, for example, under low temperature, it will never be established.
--- drivers/pci/controller/dwc/pci-keystone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-keystone.c +1 -1
@@ -510,7 +510,7 @@ static void ks_pcie_stop_link(struct dw_/* Disable Link training */ val =ks_pcie_app_readl (ks_pcie,CMD_STATUS ); val &= ~LTSSM_EN_VAL ; -ks_pcie_app_writel (ks_pcie,CMD_STATUS ,LTSSM_EN_VAL | val); +ks_pcie_app_writel (ks_pcie,CMD_STATUS , val); }static int ks_pcie_start_link (struct dw_pcie *pci)
Greg Kroah-Hartman
maintainerPATCH 90/367 PCI: tegra: Fix return value check of pm_runtime_get_sync()
In reply to Greg Kroah-HartmanFrom: David Engraf <[email protected]>
commit 885199148442f56b880995d703d2ed03b6481a3c upstream.
pm_runtime_get_sync() returns the device's usage counter. This might be >0 if the device is already powered up or CONFIG_PM is disabled.
Abort probe function on real error only.
--- drivers/pci/controller/pci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-tegra.c +1 -1
@@ -2798,7 +2798,7 @@ static int tegra_pcie_probe(struct platfpm_runtime_enable (pcie->dev); err =pm_runtime_get_sync (pcie->dev); -if (err) { +if (err <0 ) {dev_err (dev,"fail to enable pcie controller: %d\n" , err); goto teardown_msi; }
Greg Kroah-Hartman
maintainerPATCH 82/367 s390/mm: fix dynamic pagetable upgrade for hugetlbfs
In reply to Greg Kroah-HartmanFrom: Gerald Schaefer <[email protected]>
commit 5f490a520bcb393389a4d44bec90afcb332eb112 upstream.
Commit ee71d16d22bb ("s390/mm: make TASK_SIZE independent from the number of page table levels") changed the logic of TASK_SIZE and also removed the arch_mmap_check() implementation for s390. This combination has a subtle effect on how get_unmapped_area() for hugetlbfs pages works. It is now possible that a user process establishes a hugetlbfs mapping at an address above 4 TB, without triggering a dynamic pagetable upgrade from 3 to 4 levels.
This is because hugetlbfs mappings will not use mm->get_unmapped_area, but rather file->f_op->get_unmapped_area, which currently is the generic implementation of hugetlb_get_unmapped_area() that does not know about s390 dynamic pagetable upgrades, but with the new definition of TASK_SIZE, it will now allow mappings above 4 TB.
Subsequent access to such a mapped address above 4 TB will result in a page fault loop, because the CPU cannot translate such a large address with 3 pagetable levels. The fault handler will try to map in a hugepage at the address, but due to the folded pagetable logic it will end up with creating entries in the 3 level pagetable, possibly overwriting existing mappings, and then it all repeats when the access is retried.
Apart from the page fault loop, this can have various nasty effects, e.g. kernel panic from one of the BUG_ON() checks in memory management code, or even data loss if an existing mapping gets overwritten.
Fix this by implementing HAVE_ARCH_HUGETLB_UNMAPPED_AREA support for s390, providing an s390 version for hugetlb_get_unmapped_area() with pagetable upgrade support similar to arch_get_unmapped_area(), which will then be used instead of the generic version.
--- arch/s390/include/asm/page.h | 2 arch/s390/mm/hugetlbpage.c | 100 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-)
arch/s390/include/asm/page.h +2 -0
@@ -33,6 +33,8 @@#define ARCH_HAS_PREPARE_HUGEPAGE #define ARCH_HAS_HUGEPAGE_CLEAR_FLUSH +#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA +#include <asm/setup.h> #ifndef __ASSEMBLY__
arch/s390/mm/hugetlbpage.c +99 -1
115 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 32/367 tracing/kprobes: Have uname use __get_str() in print_fmt
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (VMware) <[email protected]>
commit 20279420ae3a8ef4c5d9fedc360a2c37a1dbdf1b upstream.
Thomas Richter reported:
Quoted 8 lines
Test case 66 'Use
vfs_getnameprobe to get syscall args filenames' is broken on s390, but works on x86. The test case fails with:[root@m35lp76 perf]# perf test -F 66
66: Usevfs_getnameprobe to get syscall args filenames
:Recording open file:
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.004 MB /tmp/__perf_test.perf.data.TCdYj\
Quoted 4 lines
(20 samples) ]Looking at perf.data file for
vfs_getnamerecords for the file we touched:
FAILED!
[root@m35lp76 perf]#
The root cause was the print_fmt of the kprobe event that referenced the "ustring"
Quoted 10 lines
Setting up the kprobe event using perf command:
# ./perf probe "vfs_getname=getname_flags:72 pathname=filename:ustring"generates this format file:
[root@m35lp76 perf]# cat /sys/kernel/debug/tracing/events/probe/\
vfs_getname/format
name:vfs_getname
ID: 1172
format:
Quoted 9 lines
field:unsigned short common_type; offset:0; size:2; signed:0;
field:unsigned char common_flags; offset:2; size:1; signed:0;
field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
field:int common_pid; offset:4; size:4; signed:1;
field:unsigned long __probe_ip; offset:8; size:8; signed:0;
field:__data_loc char[] pathname; offset:16; size:4; signed:1;
print fmt: "(%lx) pathname=\"%s\"", REC->__probe_ip, REC->pathnameInstead of using "__get_str(pathname)" it referenced it directly.
--- kernel/trace/trace_probe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/trace/trace_probe.c +4 -2
@@ -876,7 +876,8 @@ static int __set_print_fmt(struct trace_for (i =0 ; i < tp->nr_args; i++) { parg = tp->args + i;if (parg->count) { -if (strcmp (parg->type->name,"string" ) ==0 ) +if ((strcmp (parg->type->name,"string" ) ==0 ) || + (strcmp (parg->type->name,"ustring" ) ==0 )) fmt =", __get_str(%s[%d])" ;else fmt =", REC->%s[%d]" ;
@@ -884,7 +885,8 @@ static int __set_print_fmt(struct trace_ pos +=snprintf (buf + pos,LEN_OR_ZERO , fmt, parg->name, j); }else { -if (strcmp (parg->type->name,"string" ) ==0 ) +if ((strcmp (parg->type->name,"string" ) ==0 ) || + (strcmp (parg->type->name,"ustring" ) ==0 )) fmt =", __get_str(%s)" ;else fmt =", REC->%s" ;
Greg Kroah-Hartman
maintainerPATCH 64/367 lib/test_kasan.c: fix memory leak in kmalloc_oob_krealloc_more()
In reply to Greg Kroah-HartmanFrom: Gustavo A. R. Silva <[email protected]>
commit 3e21d9a501bf99aee2e5835d7f34d8c823f115b5 upstream.
In case memory resources for _ptr2_ were allocated, release them before return.
Notice that in case _ptr1_ happens to be NULL, krealloc() behaves exactly like kmalloc().
Addresses-Coverity-ID: 1490594 ("Resource leak")
--- lib/test_kasan.c | 1 + 1 file changed, 1 insertion(+)
lib/test_kasan.c +1 -0
@@ -158,6 +158,7 @@ static noinline void __init kmalloc_oob_if (!ptr1 || !ptr2) {pr_err ("Allocation failed\n" );kfree (ptr1); +kfree (ptr2);return ; }
Greg Kroah-Hartman
maintainerPATCH 46/367 objtool: Silence build output
In reply to Greg Kroah-HartmanFrom: Olof Johansson <[email protected]>
commit 6ec14aa7a58a1c2fb303692f8cb1ff82d9abd10a upstream.
The sync-check.sh script prints out the path due to a "cd -" at the end of the script, even on silent builds. This isn't even needed, since the script is executed in our build instead of sourced (so it won't change the working directory of the surrounding build anyway).
Just remove the cd to make the build silent.
--- tools/objtool/sync-check.sh | 2 -- 1 file changed, 2 deletions(-)
tools/objtool/sync-check.sh +0 -2
@@ -48,5 +48,3 @@ check arch/x86/include/asm/inat.h '- check arch/x86/include/asm/insn.h '-I "^#include [\"<]\(asm/\)*inat.h[\">]"' check arch/x86/lib/inat.c '-I "^#include [\"<]\(../include/\)*asm/insn.h[\">]"' check arch/x86/lib/insn.c '-I "^#include [\"<]\(../include/\)*asm/in\(at\|sn\).h[\">]" -I "^#include [\"<]\(../include/\)*asm/emulate_prefix.h[\">]"' - -cd -
Greg Kroah-Hartman
maintainerPATCH 45/367 usb: typec: tcpci: mask event interrupts when remove driver
In reply to Greg Kroah-HartmanFrom: Jun Li <[email protected]>
commit 3ba76256fc4e2a0d7fb26cc95459041ea0e88972 upstream.
This is to prevent any possible events generated while unregister tpcm port.
--- drivers/usb/typec/tcpm/tcpci.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/typec/tcpm/tcpci.c +6 -0
@@ -591,6 +591,12 @@ static int tcpci_probe(struct i2c_clientstatic int tcpci_remove (struct i2c_client *client) {struct tcpci_chip *chip =i2c_get_clientdata (client); +int err; + +/* Disable chip interrupts before unregistering port */ + err =tcpci_write16 (chip->tcpci,TCPC_ALERT_MASK ,0 ); +if (err <0 ) +return err;tcpci_unregister_port (chip->tcpci);
Greg Kroah-Hartman
maintainerPATCH 26/367 bnxt_en: Fix logic that disables Bus Master during firmware reset.
In reply to Greg Kroah-HartmanFrom: Vasundhara Volam <[email protected]>
[ Upstream commit d407302895d3f3ca3a333c711744a95e0b1b0150 ]
The current logic that calls pci_disable_device() in __bnxt_close_nic() during firmware reset is flawed. If firmware is still alive, we're disabling the device too early, causing some firmware commands to not reach the firmware.
Fix it by moving the logic to bnxt_reset_close(). If firmware is in fatal condition, we call pci_disable_device() before we free any of the rings to prevent DMA corruption of the freed rings. If firmware is still alive, we call pci_disable_device() after the last firmware message has been sent.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +7 -4
@@ -9312,10 +9312,6 @@ static void __bnxt_close_nic(struct bnxtbnxt_debug_dev_exit (bp);bnxt_disable_napi (bp);del_timer_sync (&bp->timer); -if (test_bit (BNXT_STATE_IN_FW_RESET , &bp->state) && -pci_is_enabled (bp->pdev)) -pci_disable_device (bp->pdev); -bnxt_free_skbs (bp);/* Save ring stats before shutdown */
@@ -10093,9 +10089,16 @@ static void bnxt_reset(struct bnxt *bp,static void bnxt_fw_reset_close (struct bnxt *bp) {bnxt_ulp_stop (bp); +/* When firmware is fatal state, disable PCI device to prevent +* any potential bad DMAs before freeing kernel memory. +*/ +if (test_bit (BNXT_STATE_FW_FATAL_COND , &bp->state)) +pci_disable_device (bp->pdev);__bnxt_close_nic (bp, true, false);bnxt_clear_int_mode (bp);bnxt_hwrm_func_drv_unrgtr (bp); +if (pci_is_enabled (bp->pdev)) +pci_disable_device (bp->pdev);bnxt_free_ctx_mem (bp);kfree (bp->ctx); bp->ctx =NULL ;
Greg Kroah-Hartman
maintainerPATCH 41/367 Bluetooth: btusb: Disable runtime suspend on Realtek devices
In reply to Greg Kroah-HartmanFrom: Kai-Heng Feng <[email protected]>
commit 7ecacafc240638148567742cca41aa7144b4fe1e upstream.
After commit 9e45524a0111 ("Bluetooth: btusb: Fix suspend issue for Realtek devices") both WiFi and Bluetooth stop working after reboot:
[ 34.322617] usb 1-8: reset full-speed USB device number 3 using xhci_hcd [ 34.450401] usb 1-8: device descriptor read/64, error -71 [ 34.694375] usb 1-8: device descriptor read/64, error -71 ... [ 44.599111] rtw_pci 0000:02:00.0: failed to poll offset=0x5 mask=0x3 value=0x0 [ 44.599113] rtw_pci 0000:02:00.0: mac power on failed [ 44.599114] rtw_pci 0000:02:00.0: failed to power on mac [ 44.599114] rtw_pci 0000:02:00.0: leave idle state failed [ 44.599492] rtw_pci 0000:02:00.0: failed to leave ips state [ 44.599493] rtw_pci 0000:02:00.0: failed to leave idle state
That commit removed USB_QUIRK_RESET_RESUME, which not only resets the USB device after resume, it also prevents the device from being runtime suspended by USB core. My experiment shows if the Realtek btusb device ever runtime suspends once, the entire wireless module becomes useless after reboot.
So let's explicitly disable runtime suspend on Realtek btusb device for now.
--- drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/bluetooth/btusb.c +4 -0
@@ -3832,6 +3832,10 @@ static int btusb_probe(struct usb_interf* (DEVICE_REMOTE_WAKEUP) */ set_bit (BTUSB_WAKEUP_DISABLE , &data->flags); + + err =usb_autopm_get_interface (intf); +if (err <0 ) + goto out_free_dev; }if (id->driver_info &BTUSB_AMP ) {
Greg Kroah-Hartman
maintainerPATCH 39/367 nvmet: Fix controller use after free
In reply to Greg Kroah-HartmanFrom: Israel Rukshin <[email protected]>
commit 1a3f540d63152b8db0a12de508bfa03776217d83 upstream.
After nvmet_install_queue() sets sq->ctrl calling to nvmet_sq_destroy() reduces the controller refcount. In case nvmet_install_queue() fails, calling to nvmet_ctrl_put() is done twice (at nvmet_sq_destroy and nvmet_execute_io_connect/nvmet_execute_admin_connect) instead of once for the queue which leads to use after free of the controller. Fix this by set NULL at sq->ctrl in case of a failure at nvmet_install_queue().
The bug leads to the following Call Trace:
[65857.994862] refcount_t: underflow; use-after-free. [65858.108304] Workqueue: events nvmet_rdma_release_queue_work [nvmet_rdma] [65858.115557] RIP: 0010:refcount_warn_saturate+0xe5/0xf0 [65858.208141] Call Trace: [65858.211203] nvmet_sq_destroy+0xe1/0xf0 [nvmet] [65858.216383] nvmet_rdma_release_queue_work+0x37/0xf0 [nvmet_rdma] [65858.223117] process_one_work+0x167/0x370 [65858.227776] worker_thread+0x49/0x3e0 [65858.232089] kthread+0xf5/0x130 [65858.235895] ? max_active_store+0x80/0x80 [65858.240504] ? kthread_bind+0x10/0x10 [65858.244832] ret_from_fork+0x1f/0x30 [65858.249074] ---[ end trace f82d59250b54beb7 ]---
--- drivers/nvme/target/fabrics-cmd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/nvme/target/fabrics-cmd.c +9 -4
@@ -109,6 +109,7 @@ static u16 nvmet_install_queue(struct nvu16 qid =le16_to_cpu (c->qid);u16 sqsize =le16_to_cpu (c->sqsize);struct nvmet_ctrl *old; +u16 ret; old =cmpxchg (&req->sq->ctrl,NULL , ctrl);if (old) {
@@ -119,7 +120,8 @@ static u16 nvmet_install_queue(struct nvif (!sqsize) {pr_warn ("queue size zero!\n" ); req->error_loc = offsetof(struct nvmf_connect_command , sqsize); -return NVME_SC_CONNECT_INVALID_PARAM |NVME_SC_DNR ; + ret =NVME_SC_CONNECT_INVALID_PARAM |NVME_SC_DNR ; + goto err; }/* note: convert queue size from 0's-based value to 1's-based value */
@@ -132,16 +134,19 @@ static u16 nvmet_install_queue(struct nv }if (ctrl->ops->install_queue) { -u16 ret = ctrl->ops->install_queue (req->sq); - + ret = ctrl->ops->install_queue (req->sq);if (ret) {pr_err ("failed to install queue %d cntlid %d ret %x\n" , qid, ctrl->cntlid, ret); -return ret; + goto err; } }return 0 ; + +err: + req->sq->ctrl =NULL ; +return ret; }static void nvmet_execute_admin_connect (struct nvmet_req *req)
Greg Kroah-Hartman
maintainercover 5.5.3-stable review
This is the start of the stable review cycle for the 5.5.3 release. There are 367 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 Wed, 12 Feb 2020 12:18:57 +0000. 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.5.3-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.5.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 5.5.3-rc1
Christophe Leroy <[email protected]>
powerpc/kuap: Fix set direction in allow/prevent_user_access()
Stephen Rothwell <[email protected]>
regulator fix for "regulator: core: Add regulator_is_equal() helper"
Tudor Ambarus <[email protected]>
crypto: atmel-tdes - Map driver data flags to Mode Register
Tudor Ambarus <[email protected]>
crypto: atmel-aes - Fix CTR counter overflow when multiple fragments
Tudor Ambarus <[email protected]>
crypto: atmel-aes - Fix saving of IV for CTR mode
Tudor Ambarus <[email protected]>
crypto: atmel-{aes,tdes} - Do not save IV for ECB mode
Arnd Bergmann <[email protected]>
IB/core: Fix build failure without hugepages
David Howells <[email protected]>
rxrpc: Fix service call disconnection
Sean Christopherson <[email protected]>
KVM: Play nice with read-only memslots when querying host page size
Sean Christopherson <[email protected]>
KVM: Use vcpu-specific gva->hva translation when querying host page size
Miaohe Lin <[email protected]>
KVM: nVMX: vmread should not set rflags to specify success in case of #PF
Marios Pomonis <[email protected]>
KVM: x86: Protect exit_reason from being used in Spectre-v1/L1TF attacks
Jens Axboe <[email protected]>
io_uring: prevent potential eventfd recursion on poll
Sasha Levin <[email protected]>
io_uring: enable option to only trigger eventfd for async completions
Wayne Lin <[email protected]>
drm/dp_mst: Remove VCPI while disabling topology mgr
Song Liu <[email protected]>
perf/cgroups: Install cgroup events to correct cpuctx
Song Liu <[email protected]>
perf/core: Fix mlock accounting in perf_mmap()
Konstantin Khlebnikov <[email protected]>
clocksource: Prevent double add_timer_on() for watchdog_timer
Thomas Gleixner <[email protected]>
x86/apic/msi: Plug non-maskable MSI affinity race
Aurelien Aptel <[email protected]>
cifs: fix mode bits from dir listing when mounted with modefromsid
Ronnie Sahlberg <[email protected]>
cifs: fail i/o on soft mounts if sessionsetup errors out
Tariq Toukan <[email protected]>
net/mlx5e: TX, Error completion is for last WQE in batch
Heiner Kallweit <[email protected]>
r8169: fix performance regression related to PCIe max read request size
Tariq Toukan <[email protected]>
net/mlx5: Deprecate usage of generic TLS HW capability bit
Maor Gottlieb <[email protected]>
net/mlx5: Fix deadlock in fs_core
Ido Schimmel <[email protected]>
drop_monitor: Do not cancel uninitialized work item
Sudarsana Reddy Kalluru <[email protected]>
qed: Fix timestamping issue for L2 unicast ptp packets.
Eric Dumazet <[email protected]>
ipv6/addrconf: fix potential NULL deref in inet6_set_link_af()
Vinicius Costa Gomes <[email protected]>
taprio: Fix dropping packets when using taprio + ETF offloading
Vinicius Costa Gomes <[email protected]>
taprio: Use taprio_reset_tc() to reset Traffic Classes configuration
Vinicius Costa Gomes <[email protected]>
taprio: Add missing policy validation for flags
Vinicius Costa Gomes <[email protected]>
taprio: Fix still allowing changing the flags during runtime
Vinicius Costa Gomes <[email protected]>
taprio: Fix enabling offload with wrong number of traffic classes
Voon Weifeng <[email protected]>
net: stmmac: update pci platform data to use phy_interface
Tan, Tee Min <[email protected]>
net: stmmac: xgmac: fix missing IFF_MULTICAST checki in dwxgmac2_set_filter
Verma, Aashish <[email protected]>
net: stmmac: fix missing IFF_MULTICAST check in dwmac4_set_filter
Ong Boon Leong <[email protected]>
net: stmmac: xgmac: fix incorrect XGMAC_VLAN_TAG register writting
Tan, Tee Min <[email protected]>
net: stmmac: fix incorrect GMAC_VLAN_TAG register writting in GMAC4+
Harini Katakam <[email protected]>
net: macb: Limit maximum GEM TX length in TSO
Harini Katakam <[email protected]>
net: macb: Remove unnecessary alignment check for TSO
Raed Salem <[email protected]>
net/mlx5: IPsec, fix memory leak at mlx5_fpga_ipsec_delete_sa_ctx
Raed Salem <[email protected]>
net/mlx5: IPsec, Fix esp modify function attribute
Florian Fainelli <[email protected]>
net: systemport: Avoid RBUF stuck in Wake-on-LAN mode
Dejin Zheng <[email protected]>
net: stmmac: fix a possible endless loop
Cong Wang <[email protected]>
net_sched: fix a resource leak in tcindex_set_parms()
Lorenzo Bianconi <[email protected]>
net: mvneta: move rx_dropped and rx_errors in per-cpu stats
Razvan Stefanescu <[email protected]>
net: dsa: microchip: enable module autoprobe
Florian Fainelli <[email protected]>
net: dsa: bcm_sf2: Only 7278 supports 2Gb/sec IMP port
Florian Fainelli <[email protected]>
net: dsa: b53: Always use dev->vlan_enabled in b53_configure_vlan()
Madalin Bucur <[email protected]>
dpaa_eth: support all modes with rate adapting PHYs
Jacob Keller <[email protected]>
devlink: report 0 after hitting end in region read
Eric Dumazet <[email protected]>
bonding/alb: properly access headers in bond_alb_xmit()
Thomas Gleixner <[email protected]>
x86/timer: Don't skip PIT setup when APIC is disabled or in legacy mode
Andrii Nakryiko <[email protected]>
libbpf: Extract and generalize CPU mask parsing logic
Alexei Starovoitov <[email protected]>
bpf: Fix trampoline usage in preempt
Linus Walleij <[email protected]>
mfd: ab8500: Fix ab8500-clk typo
Matti Vaittinen <[email protected]>
mfd: bd70528: Fix hour register mask
Andreas Kemnade <[email protected]>
mfd: rn5t618: Mark ADC control register volatile
Marco Felsch <[email protected]>
mfd: da9062: Fix watchdog compatible string
Cezary Rojewski <[email protected]>
ASoC: Intel: skl_hda_dsp_common: Fix global-out-of-bounds bug
Marek Vasut <[email protected]>
ASoC: sgtl5000: Fix VDDA and VDDIO comparison
Marek Vasut <[email protected]>
regulator: core: Add regulator_is_equal() helper
Quanyang Wang <[email protected]>
ubifs: Fix memory leak from c->sup_node
Dan Carpenter <[email protected]>
ubi: Fix an error pointer dereference in error handling code
Sascha Hauer <[email protected]>
ubi: fastmap: Fix inverted logic in seen selfcheck
David Hildenbrand <[email protected]>
virtio_balloon: Fix memory leaks on errors in virtballoon_probe()
David Hildenbrand <[email protected]>
virtio-balloon: Fix memory leak when unloading while hinting is in progress
Trond Myklebust <[email protected]>
nfsd: Return the correct number of bytes written to the file
Arnd Bergmann <[email protected]>
nfsd: fix jiffies/time_t mixup in LRU list
Arnd Bergmann <[email protected]>
nfsd: fix delay timer on 32-bit architectures
Jérôme Pouiller <[email protected]>
staging: wfx: revert unexpected change in debugfs output
Yishai Hadas <[email protected]>
IB/core: Fix ODP with IB_ACCESS_HUGETLB handling
Yishai Hadas <[email protected]>
IB/core: Fix ODP get user pages flow
Prabhath Sajeepa <[email protected]>
IB/mlx5: Fix outstanding_pi index for GSI qps
Nathan Chancellor <[email protected]>
net: tulip: Adjust indentation in {dmfe, uli526x}_init_module
Nathan Chancellor <[email protected]>
net: smc911x: Adjust indentation in smc911x_phy_configure
Nathan Chancellor <[email protected]>
ppp: Adjust indentation into ppp_async_input
Nathan Chancellor <[email protected]>
NFC: pn544: Adjust indentation in pn544_hci_check_presence
Nathan Chancellor <[email protected]>
drm: msm: mdp4: Adjust indentation in mdp4_dsi_encoder_enable
Nathan Chancellor <[email protected]>
powerpc/44x: Adjust indentation in ibm4xx_denali_fixup_memsize
Nathan Chancellor <[email protected]>
ext2: Adjust indentation in ext2_fill_super
Nathan Chancellor <[email protected]>
phy: qualcomm: Adjust indentation in read_poll_timeout
Vignesh Raghavendra <[email protected]>
mtd: spi-nor: Split mt25qu512a (n25q512a) entry into two
Arnd Bergmann <[email protected]>
compat: scsi: sg: fix v3 compat read/write interface
Asutosh Das <[email protected]>
scsi: ufs: Recheck bkops level if bkops is disabled
Nathan Chancellor <[email protected]>
scsi: qla4xxx: Adjust indentation in qla4xxx_mem_free
Nathan Chancellor <[email protected]>
scsi: csiostor: Adjust indentation in csio_device_reset
Bart Van Assche <[email protected]>
scsi: qla2xxx: Fix the endianness of the qla82xx_get_fw_size() return type
Jerome Brunet <[email protected]>
ASoC: meson: axg-fifo: fix fifo threshold setup
Erdem Aktas <[email protected]>
percpu: Separate decrypted varaibles anytime encryption can be enabled
Casey Schaufler <[email protected]>
broken ping to ipv6 linklocal addresses on debian buster
Miklos Szeredi <[email protected]>
fix up iter on short count in fuse_direct_io()
Daniel Verkamp <[email protected]>
virtio-pci: check name when counting MSI-X vectors
Daniel Verkamp <[email protected]>
virtio-balloon: initialize all vq callbacks
Matt Coffin <[email protected]>
drm/amdgpu/smu_v11_0: Correct behavior of restoring default tables (v2)
Alex Deucher <[email protected]>
drm/amdgpu/navi10: add OD_RANGE for navi overclocking
Alex Deucher <[email protected]>
drm/amdgpu: fetch default VDDC curve voltages (v2)
Lyude Paul <[email protected]>
drm/amd/dm/mst: Ignore payload update failures
Evan Quan <[email protected]>
drm/amd/powerplay: fix navi10 system intermittent reboot issue V2
Thierry Reding <[email protected]>
drm/tegra: Reuse IOVA mapping where possible
Thierry Reding <[email protected]>
drm/tegra: Relax IOMMU usage criteria on old Tegra
Alex Deucher <[email protected]>
drm/amdgpu/navi: fix index for OD MCLK
Stephen Warren <[email protected]>
clk: tegra: Mark fuse clock as critical
Peter Zijlstra <[email protected]>
mm/mmu_gather: invalidate TLB correctly on batch allocation failure and flush
Niklas Cassel <[email protected]>
arm64: dts: qcom: qcs404-evb: Set vdd_apc regulator in high power mode
David Hildenbrand <[email protected]>
mm/page_alloc.c: fix uninitialized memmaps on a partially populated last section
Gang He <[email protected]>
ocfs2: fix oops when writing cloned file
Paolo Bonzini <[email protected]>
KVM: x86: use raw clock values consistently
Paolo Bonzini <[email protected]>
KVM: x86: reorganize pvclock_gtod_data members
Christian Borntraeger <[email protected]>
KVM: s390: do not clobber registers during guest reset/store status
Sean Christopherson <[email protected]>
KVM: x86: Revert "KVM: X86: Fix fpu state crash in kvm guest"
Sean Christopherson <[email protected]>
KVM: x86: Ensure guest's FPU state is loaded when accessing for emulation
Sean Christopherson <[email protected]>
KVM: x86: Handle TIF_NEED_FPU_LOAD in kvm_{load,put}_guest_fpu()
Paolo Bonzini <[email protected]>
KVM: x86: fix overlap between SPTE_MMIO_MASK and generation
Sean Christopherson <[email protected]>
KVM: x86: Free wbinvd_dirty_mask if vCPU creation fails
Sean Christopherson <[email protected]>
KVM: x86: Don't let userspace set host-reserved cr4 bits
Sean Christopherson <[email protected]>
KVM: VMX: Add non-canonical check on writes to RTIT address MSRs
Sean Christopherson <[email protected]>
KVM: x86: Use gpa_t for cr2/gpa to fix TDP support on 32-bit KVM
Boris Ostrovsky <[email protected]>
x86/KVM: Clean up host's steal time structure
Boris Ostrovsky <[email protected]>
x86/kvm: Cache gfn to pfn translation
Boris Ostrovsky <[email protected]>
x86/KVM: Make sure KVM_VCPU_FLUSH_TLB flag is not missed
Boris Ostrovsky <[email protected]>
x86/kvm: Introduce kvm_(un)map_gfn()
Paolo Bonzini <[email protected]>
KVM: x86: use CPUID to locate host page table reserved bits
Boris Ostrovsky <[email protected]>
x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit
Sean Christopherson <[email protected]>
KVM: x86/mmu: Apply max PA check for MMIO sptes to 32-bit KVM
John Allen <[email protected]>
kvm/svm: PKU not currently supported
Sean Christopherson <[email protected]>
KVM: PPC: Book3S PR: Free shared page if mmu initialization fails
Sean Christopherson <[email protected]>
KVM: PPC: Book3S HV: Uninit vCPU if vcore creation fails
Sean Christopherson <[email protected]>
KVM: x86: Fix potential put_fpu() w/o load_fpu() on MPX platform
Marios Pomonis <[email protected]>
KVM: x86: Protect MSR-based index computations in fixed_msr_to_seg_unit() from Spectre-v1/L1TF attacks
Marios Pomonis <[email protected]>
KVM: x86: Protect x86_decode_insn from Spectre-v1/L1TF attacks
Marios Pomonis <[email protected]>
KVM: x86: Protect MSR-based index computations from Spectre-v1/L1TF attacks in x86.c
Marios Pomonis <[email protected]>
KVM: x86: Protect ioapic_read_indirect() from Spectre-v1/L1TF attacks
Marios Pomonis <[email protected]>
KVM: x86: Protect MSR-based index computations in pmu.h from Spectre-v1/L1TF attacks
Marios Pomonis <[email protected]>
KVM: x86: Protect ioapic_write_indirect() from Spectre-v1/L1TF attacks
Marios Pomonis <[email protected]>
KVM: x86: Protect kvm_hv_msr_[get|set]_crash_data() from Spectre-v1/L1TF attacks
Marios Pomonis <[email protected]>
KVM: x86: Protect kvm_lapic_reg_write() from Spectre-v1/L1TF attacks
Marios Pomonis <[email protected]>
KVM: x86: Protect DR-based index computations from Spectre-v1/L1TF attacks
Marios Pomonis <[email protected]>
KVM: x86: Protect pmu_intel.c from Spectre-v1/L1TF attacks
Marios Pomonis <[email protected]>
KVM: x86: Refactor prefix decoding to prevent Spectre-v1/L1TF attacks
Marios Pomonis <[email protected]>
KVM: x86: Refactor picdev_write() to prevent Spectre-v1/L1TF attacks
Jens Axboe <[email protected]>
aio: prevent potential eventfd recursion on poll
Jens Axboe <[email protected]>
eventfd: track eventfd_signal() recursion depth
Jens Axboe <[email protected]>
io_uring: spin for sq thread to idle on shutdown
Jens Axboe <[email protected]>
io_uring: don't map read/write iovec potentially twice
Coly Li <[email protected]>
bcache: add readahead cache policy options via sysfs interface
Vladis Dronov <[email protected]>
watchdog: fix UAF in reboot notifier handling in watchdog core code
Boris Ostrovsky <[email protected]>
xen/gntdev: Do not use mm notifiers with autotranslating guests
Juergen Gross <[email protected]>
xen/balloon: Support xend-based toolstack take two
Gavin Shan <[email protected]>
tools/kvm_stat: Fix kvm_exit filter name
Sean Young <[email protected]>
media: rc: ensure lirc is initialized before registering input device
Johan Hovold <[email protected]>
media: iguanair: fix endpoint sanity check
Ville Syrjälä <[email protected]>
drm/rect: Avoid division by zero
Peter Rosin <[email protected]>
drm: atmel-hlcdc: prefer a lower pixel-clock than requested
Claudiu Beznea <[email protected]>
drm: atmel-hlcdc: enable clock before configuring timing engine
Claudiu Beznea <[email protected]>
drm: atmel-hlcdc: use double rate for pixel clock only if supported
Andreas Gruenbacher <[email protected]>
gfs2: fix O_SYNC write handling
Christoph Hellwig <[email protected]>
gfs2: move setting current->backing_dev_info
Abhi Das <[email protected]>
gfs2: fix gfs2_find_jhead that returns uninitialized jhead with seq 0
Roberto Bergantinos Corpas <[email protected]>
sunrpc: expiry_time should be seconds not timeval
Brian Norris <[email protected]>
mwifiex: fix unbalanced locking in mwifiex_process_country_ie()
Luca Coelho <[email protected]>
iwlwifi: don't throw error when trying to remove IGTK
Stephen Warren <[email protected]>
ARM: tegra: Enable PLLP bypass during Tegra124 LP1
Filipe Manana <[email protected]>
Btrfs: send, fix emission of invalid clone operations within the same file
Nikolay Borisov <[email protected]>
btrfs: Correctly handle empty trees in find_first_clear_extent_bit
Josef Bacik <[email protected]>
btrfs: flush write bio if we loop in extent_write_cache_pages
Filipe Manana <[email protected]>
Btrfs: fix race between adding and putting tree mod seq elements and nodes
Josef Bacik <[email protected]>
btrfs: free block groups after free'ing fs trees
Josef Bacik <[email protected]>
btrfs: drop log root for dropped roots
Josef Bacik <[email protected]>
btrfs: set trans->drity in btrfs_commit_transaction
Filipe Manana <[email protected]>
Btrfs: fix infinite loop during fsync after rename operations
Filipe Manana <[email protected]>
Btrfs: make deduplication with range including the last block work
Filipe Manana <[email protected]>
Btrfs: fix missing hole after hole punching and fsync when using NO_HOLES
Eric Biggers <[email protected]>
ext4: fix race conditions in ->d_compare() and ->d_hash()
Eric Biggers <[email protected]>
ext4: fix deadlock allocating crypto bounce page from mempool
Vasily Averin <[email protected]>
jbd2_seq_info_next should increase position index
Trond Myklebust <[email protected]>
nfsd: fix filecache lookup
Trond Myklebust <[email protected]>
NFS: Directory page cache pages need to be locked when read
Trond Myklebust <[email protected]>
NFS: Fix memory leaks and corruption in readdir
Arun Easi <[email protected]>
scsi: qla2xxx: Fix unbound NVME response length
Michael Ellerman <[email protected]>
powerpc/futex: Fix incorrect user access blocking
Chuhong Yuan <[email protected]>
crypto: picoxcell - adjust the position of tasklet_init and fix missed tasklet_kill
Herbert Xu <[email protected]>
crypto: api - Fix race condition in crypto_spawn_alg
Tudor Ambarus <[email protected]>
crypto: atmel-aes - Fix counter overflow in CTR mode
Eric Biggers <[email protected]>
crypto: hisilicon - select CRYPTO_SKCIPHER, not CRYPTO_BLKCIPHER
Herbert Xu <[email protected]>
crypto: pcrypt - Do not clear MAY_SLEEP flag in original request
Ard Biesheuvel <[email protected]>
crypto: arm64/ghash-neon - bump priority to 150
Ard Biesheuvel <[email protected]>
crypto: ccp - set max RSA modulus size for v3 platform devices as well
Jonathan Cameron <[email protected]>
crypto: hisilicon - Use the offset fields in sqe to avoid need to split scatterlists
Jonathan Cameron <[email protected]>
crypto: hisilicon - Fix issue with wrong number of sg elements after dma map
Herbert Xu <[email protected]>
crypto: api - fix unexpectedly getting generic implementation
Corentin Labbe <[email protected]>
crypto: sun8i-ce - fix removal of module
Corentin Labbe <[email protected]>
crypto: amlogic - fix removal of module
Corentin Labbe <[email protected]>
crypto: sun8i-ss - fix removal of module
Lorenz Bauer <[email protected]>
selftests: bpf: Ignore FIN packets for reuseport tests
Lorenz Bauer <[email protected]>
selftests: bpf: Use a temporary file in test_sockmap
Hangbin Liu <[email protected]>
selftests/bpf: Skip perf hw events test if the setup disabled it
Alexei Starovoitov <[email protected]>
selftests/bpf: Fix test_attach_probe
Prashant Bhole <[email protected]>
samples/bpf: Reintroduce missed build targets
Jesper Dangaard Brouer <[email protected]>
samples/bpf: Xdp_redirect_cpu fix missing tracepoint attach
Toke Høiland-Jørgensen <[email protected]>
samples/bpf: Don't try to remove user's homedir on clean
Davide Caratti <[email protected]>
tc-testing: fix eBPF tests failure on linux fresh clones
Andrii Nakryiko <[email protected]>
libbpf: Fix realloc usage in bpf_core_find_cands
Toke Høiland-Jørgensen <[email protected]>
libbpf: Add missing newline in opts validation macro
Amol Grover <[email protected]>
bpf, devmap: Pass lockdep expression to RCU lists
Yoshiki Komachi <[email protected]>
flow_dissector: Fix to use new variables for port ranges in bpf hook
Andrii Nakryiko <[email protected]>
selftests/bpf: Fix perf_buffer test on systems w/ offline CPUs
Andrii Nakryiko <[email protected]>
libbpf: Don't attach perf_buffer to offline/missing CPUs
Andrii Nakryiko <[email protected]>
libbpf: Fix printf compilation warnings on ppc64le arch
Thadeu Lima de Souza Cascardo <[email protected]>
libbpf: Fix readelf output parsing for Fedora
Björn Töpel <[email protected]>
riscv, bpf: Fix broken BPF tail calls
Nikolay Borisov <[email protected]>
btrfs: Handle another split brain scenario with metadata uuid feature
Josef Bacik <[email protected]>
btrfs: fix improper setting of scanned for range cyclic write cache pages
Herbert Xu <[email protected]>
crypto: pcrypt - Avoid deadlock by using per-instance padata queues
Steven Rostedt (VMware) <[email protected]>
ftrace: Protect ftrace_graph_hash with ftrace_sync
Steven Rostedt (VMware) <[email protected]>
ftrace: Add comment to why rcu_dereference_sched() is open coded
Amol Grover <[email protected]>
tracing: Annotate ftrace_graph_notrace_hash pointer with __rcu
Amol Grover <[email protected]>
tracing: Annotate ftrace_graph_hash pointer with __rcu
Pierre-Louis Bossart <[email protected]>
ASoC: SOF: core: release resources on errors in probe_continue
Ranjani Sridharan <[email protected]>
ASoC: SOF: Introduce state machine for FW boot
Mike Snitzer <[email protected]>
dm: fix potential for q->make_request_fn NULL pointer
Mike Snitzer <[email protected]>
dm thin: fix use-after-free in metadata_pre_commit_callback
Mike Snitzer <[email protected]>
dm thin metadata: use pool locking at end of dm_pool_metadata_close
Milan Broz <[email protected]>
dm crypt: fix benbi IV constructor crash if used in authenticated mode
Mikulas Patocka <[email protected]>
dm crypt: fix GFP flags passed to skcipher_request_alloc()
Mikulas Patocka <[email protected]>
dm writecache: fix incorrect flush sequence when doing SSD mode commit
Joe Thornber <[email protected]>
dm space map common: fix to ensure new block isn't already in use
Dmitry Fomichev <[email protected]>
dm zoned: support zone sizes smaller than 128MiB
Chen-Yu Tsai <[email protected]>
ARM: dma-api: fix max_pfn off-by-one error in __dma_supported()
Michael Ellerman <[email protected]>
of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc
Rafael J. Wysocki <[email protected]>
cpufreq: Avoid creating excessively large stack frames
Rafael J. Wysocki <[email protected]>
PM: core: Fix handling of devices deleted during system-wide resume
Eric Biggers <[email protected]>
f2fs: fix race conditions in ->d_compare() and ->d_hash()
Eric Biggers <[email protected]>
f2fs: fix dcache lookup of !casefolded directories
Chengguang Xu <[email protected]>
f2fs: code cleanup for f2fs_statfs_project()
Chengguang Xu <[email protected]>
f2fs: fix miscounted block limit in f2fs_statfs_project()
Miklos Szeredi <[email protected]>
ovl: fix lseek overflow on 32bit
Amir Goldstein <[email protected]>
ovl: fix wrong WARN_ON() in ovl_cache_update_ino()
Sven Van Asbroeck <[email protected]>
power: supply: ltc2941-battery-gauge: fix use-after-free
Samuel Holland <[email protected]>
power: supply: axp20x_ac_power: Fix reporting online status
Thomas Renninger <[email protected]>
cpupower: Revert library ABI changes from commit ae2917093fb60bdc1ed3e
Quinn Tran <[email protected]>
scsi: qla2xxx: Fix mtcp dump collection failure
Quinn Tran <[email protected]>
scsi: qla2xxx: Fix stuck login session using prli_pend_timer
Anand Lodnoor <[email protected]>
scsi: megaraid_sas: Do not initiate OCR if controller is not in ready state
Gao Xiang <[email protected]>
erofs: fix out-of-bound read for shifted uncompressed block
Geert Uytterhoeven <[email protected]>
scripts/find-unused-docs: Fix massive false positives
Filipe Manana <[email protected]>
fs: allow deduplication of eof block into the end of the destination file
Herbert Xu <[email protected]>
padata: Remove broken queue flushing
Gilad Ben-Yossef <[email protected]>
crypto: ccree - fix PM race condition
Ofir Drang <[email protected]>
crypto: ccree - fix FDE descriptor sequence
Gilad Ben-Yossef <[email protected]>
crypto: ccree - fix pm wrongful error reporting
Gilad Ben-Yossef <[email protected]>
crypto: ccree - fix AEAD decrypt auth fail
Gilad Ben-Yossef <[email protected]>
crypto: ccree - fix backlog memory leak
Herbert Xu <[email protected]>
crypto: api - Check spawn->alg under lock in crypto_drop_spawn
Bitan Biswas <[email protected]>
nvmem: core: fix memory abort in cleanup path
Peng Fan <[email protected]>
nvmem: imx: scu: fix write SIP
Samuel Holland <[email protected]>
mfd: axp20x: Mark AXP20X_VBUS_IPSOUT_MGMT as volatile
Tianyu Lan <[email protected]>
hv_balloon: Balloon up according to request page number
Pierre-Louis Bossart <[email protected]>
ASoC: SOF: core: free trace on errors
Jaroslav Kysela <[email protected]>
ASoC: topology: fix soc_tplg_fe_link_create() - link->dobj initialization order
Jon Hunter <[email protected]>
ASoC: tegra: Revert 24 and 32 bit support
Michał Mirosław <[email protected]>
mmc: sdhci-of-at91: fix memleak on clk_get failure
Zhihao Cheng <[email protected]>
ubifs: Fix deadlock in concurrent bulk-read and writepage
Eric Biggers <[email protected]>
ubifs: Fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag
Sascha Hauer <[email protected]>
ubifs: Fix wrong memory allocation
Eric Biggers <[email protected]>
ubifs: don't trigger assertion on invalid no-key filename
Eric Biggers <[email protected]>
fscrypt: don't print name of busy file when removing key
Stephen Boyd <[email protected]>
alarmtimer: Unregister wakeup source when module get fails
Steve French <[email protected]>
smb3: fix default permissions on new files when mounting with modefromsid
Hans de Goede <[email protected]>
ACPI / battery: Deal better with neither design nor full capacity not being reported
Hans de Goede <[email protected]>
ACPI / battery: Use design-cap for capacity calculations if full-cap is not available
Hans de Goede <[email protected]>
ACPI / battery: Deal with design or full capacity being reported as -1
Hans de Goede <[email protected]>
ACPI: video: Do not export a non working backlight interface on MSI MS-7721 boards
Linus Walleij <[email protected]>
mmc: spi: Toggle SPI polarity, do not hardcode it
Kishon Vijay Abraham I <[email protected]>
PCI: keystone: Fix error handling when "num-viewport" DT property is not populated
Yurii Monakov <[email protected]>
PCI: keystone: Fix link training retries initiation
Yurii Monakov <[email protected]>
PCI: keystone: Fix outbound region mapping
David Engraf <[email protected]>
PCI: tegra: Fix return value check of pm_runtime_get_sync()
Kuppuswamy Sathyanarayanan <[email protected]>
PCI/ATS: Use PF PASID for VFs
Christophe Leroy <[email protected]>
powerpc/32s: Fix CPU wake-up from sleep mode
Christophe Leroy <[email protected]>
powerpc/32s: Fix bad_kuap_fault()
Pingfan Liu <[email protected]>
powerpc/pseries: Advance pfn if section is not present in lmb_is_removable()
Sukadev Bhattiprolu <[email protected]>
powerpc/xmon: don't access ASDR in VMs
Christophe Leroy <[email protected]>
powerpc/ptdump: Fix W+X verification
Aneesh Kumar K.V <[email protected]>
powerpc/mmu_gather: enable RCU_TABLE_FREE even for !SMP case
Gerald Schaefer <[email protected]>
s390/mm: fix dynamic pagetable upgrade for hugetlbfs
Wang Xuerui <[email protected]>
MIPS: asm: local: add barriers for Loongson
Thomas Bogendoerfer <[email protected]>
MIPS: SGI-IP30: Check for valid pointer before using it
Alexander Lobakin <[email protected]>
MIPS: boot: fix typo in 'vmlinux.lzma.its' target
Alexander Lobakin <[email protected]>
MIPS: fix indentation of the 'RELOCS' message
Alexander Lobakin <[email protected]>
MIPS: syscalls: fix indentation of the 'SYSNR' message
Christoffer Dall <[email protected]>
KVM: arm64: Only sign-extend MMIO up to register width
Mark Rutland <[email protected]>
KVM: arm/arm64: Correct AArch32 SPSR on exception entry
Mark Rutland <[email protected]>
KVM: arm/arm64: Correct CPSR on exception entry
Mark Rutland <[email protected]>
KVM: arm64: Correct PSTATE on exception entry
Mark Rutland <[email protected]>
arm64: acpi: fix DAIF manipulation with pNMI
Nikhil Mahale <[email protected]>
ALSA: hda - Fix DP-MST support for NVIDIA codecs
Yong Zhi <[email protected]>
ALSA: hda: Add JasperLake PCI ID and codec vid
Hans de Goede <[email protected]>
ALSA: hda: Add Clevo W65_67SB the power_save blacklist
Takashi Iwai <[email protected]>
ALSA: hda: Apply aligned MMIO access only conditionally
Mika Westerberg <[email protected]>
platform/x86: intel_scu_ipc: Fix interrupt support
Pawan Gupta <[email protected]>
x86/cpu: Update cached HLE state on write to TSX_CTRL_CPUID_CLEAR
Kevin Hao <[email protected]>
irqdomain: Fix a memory leak in irq_domain_push_irq()
Gustavo A. R. Silva <[email protected]>
lib/test_kasan.c: fix memory leak in kmalloc_oob_krealloc_more()
Helen Koike <[email protected]>
media: v4l2-rect.h: fix v4l2_rect_map_inside() top/left adjustments
Arnd Bergmann <[email protected]>
media: v4l2-core: compat: ignore native command codes
John Hubbard <[email protected]>
media/v4l2-core: set pages dirty upon releasing DMA buffers
Yang Shi <[email protected]>
mm: move_pages: report the number of non-attempted pages
Wei Yang <[email protected]>
mm: thp: don't need care deferred split queue in memcg charge move path
Dan Williams <[email protected]>
mm/memory_hotplug: fix remove_memory() lockdep splat
Wei Yang <[email protected]>
mm/migrate.c: also overwrite error when it is bigger than zero
Amir Goldstein <[email protected]>
utimes: Clamp the timestamps in notify_change()
Pingfan Liu <[email protected]>
mm/sparse.c: reset section's mem_map when fully deactivated
Theodore Ts'o <[email protected]>
memcg: fix a crash in wb_workfn when a device disappears
Takashi Iwai <[email protected]>
ALSA: dummy: Fix PCM format loop in proc output
Takashi Iwai <[email protected]>
ALSA: usb-audio: Annotate endianess in Scarlett gen2 quirk
Takashi Iwai <[email protected]>
ALSA: usb-audio: Fix endianess in descriptor validation
Bryan O'Donoghue <[email protected]>
usb: gadget: f_ecm: Use atomic_t to track in-flight request
Bryan O'Donoghue <[email protected]>
usb: gadget: f_ncm: Use atomic_t to track in-flight request
Roger Quadros <[email protected]>
usb: gadget: legacy: set max_speed to super-speed
Peter Chen <[email protected]>
usb: gadget: f_fs: set req->num_sgs as 0 for non-sg transfer
Olof Johansson <[email protected]>
objtool: Silence build output
Jun Li <[email protected]>
usb: typec: tcpci: mask event interrupts when remove driver
Thinh Nguyen <[email protected]>
usb: dwc3: gadget: Delay starting transfer
Thinh Nguyen <[email protected]>
usb: dwc3: gadget: Check END_TRANSFER completion
Navid Emamdoost <[email protected]>
brcmfmac: Fix memory leak in brcmf_usbdev_qinit
Kai-Heng Feng <[email protected]>
Bluetooth: btusb: Disable runtime suspend on Realtek devices
Colin Ian King <[email protected]>
Bluetooth: btusb: fix memory leak on fw
Israel Rukshin <[email protected]>
nvmet: Fix controller use after free
Israel Rukshin <[email protected]>
nvmet: Fix error print message at nvmet_install_queue function
Paul E. McKenney <[email protected]>
rcu: Use READ_ONCE() for ->expmask in rcu_read_unlock_special()
Paul E. McKenney <[email protected]>
srcu: Apply *_ONCE() to ->srcu_last_gp_end
Eric Dumazet <[email protected]>
rcu: Avoid data-race in rcu_gp_fqs_check_wake()
Paul E. McKenney <[email protected]>
rcu: Use *_ONCE() to protect lockless ->expmask accesses
Mathieu Desnoyers <[email protected]>
tracing: Fix sched switch start/stop refcount racy updates
Steven Rostedt (VMware) <[email protected]>
tracing/kprobes: Have uname use __get_str() in print_fmt
Lu Shuaibing <[email protected]>
ipc/msg.c: consolidate all xxxctl_down() functions
Takashi Iwai <[email protected]>
ALSA: pcm: Fix memory leak at closing a stream without hw_free
Kadlecsik József <[email protected]>
netfilter: ipset: fix suspicious RCU usage in find_set_and_id
Oliver Neukum <[email protected]>
mfd: dln2: More sanity checking for endpoints
Will Deacon <[email protected]>
media: uvcvideo: Avoid cyclic entity chains due to malformed USB descriptors
Vasundhara Volam <[email protected]>
bnxt_en: Fix logic that disables Bus Master during firmware reset.
Taehee Yoo <[email protected]>
netdevsim: fix stack-out-of-bounds in nsim_dev_debugfs_init()
Lukas Bulwahn <[email protected]>
MAINTAINERS: correct entries for ISDN/mISDN section
Shannon Nelson <[email protected]>
ionic: fix rxq comp packet type mask
Michael Chan <[email protected]>
bnxt_en: Fix RDMA driver failure with SRIOV after firmware reset.
Michael Walle <[email protected]>
net: phy: at803x: disable vddio regulator
Michael Chan <[email protected]>
bnxt_en: Refactor logic to re-enable SRIOV after firmware reset detected.
David Howells <[email protected]>
rxrpc: Fix NULL pointer deref due to call->conn being cleared on disconnect
David Howells <[email protected]>
rxrpc: Fix missing active use pinning of rxrpc_local object
David Howells <[email protected]>
rxrpc: Fix insufficient receive notification generation
David Howells <[email protected]>
rxrpc: Fix use-after-free in rxrpc_put_local()
Eric Dumazet <[email protected]>
cls_rsvp: fix rsvp_policy
Eric Dumazet <[email protected]>
tcp: clear tp->segs_{in|out} in tcp_disconnect()Eric Dumazet <[email protected]>
tcp: clear tp->data_segs{in|out} in tcp_disconnect()Eric Dumazet <[email protected]>
tcp: clear tp->delivered in tcp_disconnect()
Eric Dumazet <[email protected]>
tcp: clear tp->total_retrans in tcp_disconnect()
Nicolin Chen <[email protected]>
net: stmmac: Delete txtimer in suspend()
Michael Chan <[email protected]>
bnxt_en: Fix TC queue mapping.
Lorenzo Bianconi <[email protected]>
net: mvneta: fix XDP support if sw bm is used as fallback
Leon Romanovsky <[email protected]>
net/core: Do not clear VF index for node/port GUIDs query
Cong Wang <[email protected]>
net_sched: fix an OOB access in cls_tcindex
Eric Dumazet <[email protected]>
net: hsr: fix possible NULL deref in hsr_handle_frame()
Ridge Kennedy <[email protected]>
l2tp: Allow duplicate session creation with UDP
Taehee Yoo <[email protected]>
gtp: use __GFP_NOWARN to avoid memalloc warning
Vasundhara Volam <[email protected]>
bnxt_en: Move devlink_register before registering netdev
Arnd Bergmann <[email protected]>
sparc32: fix struct ipc64_perm type definition
-------------
Diffstat:
MAINTAINERS | 6 +- Makefile | 4 +- arch/Kconfig | 3 - arch/arm/include/asm/kvm_emulate.h | 22 ++ arch/arm/include/asm/kvm_mmio.h | 2 + arch/arm/mach-tegra/sleep-tegra30.S | 11 + arch/arm/mm/dma-mapping.c | 2 +- arch/arm64/boot/dts/qcom/qcs404-evb.dtsi | 1 + arch/arm64/crypto/ghash-ce-glue.c | 2 +- arch/arm64/include/asm/daifflags.h | 11 +- arch/arm64/include/asm/kvm_emulate.h | 37 ++ arch/arm64/include/asm/kvm_mmio.h | 6 +- arch/arm64/include/asm/ptrace.h | 1 + arch/arm64/include/uapi/asm/ptrace.h | 1 + arch/arm64/kernel/acpi.c | 2 +- arch/arm64/kvm/inject_fault.c | 70 +++- arch/mips/Makefile.postlink | 2 +- arch/mips/boot/Makefile | 2 +- arch/mips/include/asm/local.h | 4 + arch/mips/kernel/syscalls/Makefile | 2 +- arch/mips/sgi-ip30/ip30-irq.c | 5 +- arch/powerpc/Kconfig | 4 +- arch/powerpc/boot/4xx.c | 2 +- arch/powerpc/include/asm/book3s/32/kup.h | 22 +- arch/powerpc/include/asm/book3s/32/pgalloc.h | 8 - arch/powerpc/include/asm/book3s/64/kup-radix.h | 14 +- arch/powerpc/include/asm/book3s/64/pgalloc.h | 2 - arch/powerpc/include/asm/futex.h | 10 +- arch/powerpc/include/asm/kup.h | 36 +- arch/powerpc/include/asm/nohash/32/kup-8xx.h | 7 +- arch/powerpc/include/asm/nohash/pgalloc.h | 8 - arch/powerpc/include/asm/tlb.h | 11 + arch/powerpc/include/asm/uaccess.h | 4 +- arch/powerpc/kernel/entry_32.S | 3 +- arch/powerpc/kvm/book3s_hv.c | 4 +- arch/powerpc/kvm/book3s_pr.c | 4 +- arch/powerpc/kvm/book3s_xive_native.c | 2 +- arch/powerpc/mm/book3s64/pgtable.c | 7 - arch/powerpc/mm/fault.c | 2 +- arch/powerpc/mm/ptdump/ptdump.c | 4 +- arch/powerpc/platforms/pseries/hotplug-memory.c | 4 +- arch/powerpc/xmon/xmon.c | 9 +- arch/riscv/net/bpf_jit_comp.c | 13 +- arch/s390/include/asm/page.h | 2 + arch/s390/kvm/kvm-s390.c | 6 +- arch/s390/mm/hugetlbpage.c | 100 ++++- arch/sparc/Kconfig | 1 - arch/sparc/include/asm/tlb_64.h | 9 + arch/sparc/include/uapi/asm/ipcbuf.h | 22 +- arch/x86/include/asm/apic.h | 10 + arch/x86/include/asm/kvm_host.h | 13 +- arch/x86/include/asm/x86_init.h | 2 + arch/x86/kernel/apic/apic.c | 23 +- arch/x86/kernel/apic/msi.c | 128 +++++- arch/x86/kernel/cpu/tsx.c | 13 +- arch/x86/kernel/time.c | 12 +- arch/x86/kernel/x86_init.c | 1 + arch/x86/kvm/cpuid.c | 4 +- arch/x86/kvm/emulate.c | 66 +++- arch/x86/kvm/hyperv.c | 10 +- arch/x86/kvm/i8259.c | 6 +- arch/x86/kvm/ioapic.c | 15 +- arch/x86/kvm/lapic.c | 13 +- arch/x86/kvm/mmu/mmu.c | 107 ++--- arch/x86/kvm/mmu/paging_tmpl.h | 25 +- arch/x86/kvm/mmutrace.h | 12 +- arch/x86/kvm/mtrr.c | 8 +- arch/x86/kvm/pmu.h | 18 +- arch/x86/kvm/svm.c | 6 + arch/x86/kvm/vmx/capabilities.h | 5 + arch/x86/kvm/vmx/nested.c | 4 +- arch/x86/kvm/vmx/pmu_intel.c | 24 +- arch/x86/kvm/vmx/vmx.c | 58 +-- arch/x86/kvm/x86.c | 263 ++++++++----- arch/x86/kvm/x86.h | 2 +- arch/x86/xen/enlighten_pv.c | 1 + block/scsi_ioctl.c | 29 +- crypto/algapi.c | 46 ++- crypto/api.c | 7 +- crypto/internal.h | 1 - crypto/pcrypt.c | 37 +- drivers/acpi/battery.c | 75 +++- drivers/acpi/video_detect.c | 13 + drivers/base/power/main.c | 42 +- drivers/bluetooth/btusb.c | 6 +- drivers/clk/tegra/clk-tegra-periph.c | 6 +- drivers/cpufreq/cppc_cpufreq.c | 2 +- drivers/cpufreq/cpufreq-nforce2.c | 2 +- drivers/cpufreq/cpufreq.c | 147 ++++--- drivers/cpufreq/freq_table.c | 4 +- drivers/cpufreq/gx-suspmod.c | 2 +- drivers/cpufreq/intel_pstate.c | 38 +- drivers/cpufreq/longrun.c | 6 +- drivers/cpufreq/pcc-cpufreq.c | 2 +- drivers/cpufreq/sh-cpufreq.c | 2 +- drivers/cpufreq/unicore2-cpufreq.c | 2 +- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 4 +- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 4 +- drivers/crypto/amlogic/amlogic-gxl-core.c | 4 +- drivers/crypto/atmel-aes.c | 87 +++-- drivers/crypto/atmel-tdes.c | 151 +++---- drivers/crypto/ccp/ccp-dev-v3.c | 1 + drivers/crypto/ccree/cc_aead.c | 2 +- drivers/crypto/ccree/cc_cipher.c | 48 ++- drivers/crypto/ccree/cc_driver.h | 1 + drivers/crypto/ccree/cc_pm.c | 30 +- drivers/crypto/ccree/cc_request_mgr.c | 51 +-- drivers/crypto/ccree/cc_request_mgr.h | 8 - drivers/crypto/hisilicon/Kconfig | 3 +- drivers/crypto/hisilicon/sgl.c | 13 +- drivers/crypto/hisilicon/zip/zip.h | 4 + drivers/crypto/hisilicon/zip/zip_crypto.c | 92 ++--- drivers/crypto/picoxcell_crypto.c | 15 +- .../drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 13 +- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 18 + drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 2 + drivers/gpu/drm/amd/powerplay/inc/smu_types.h | 2 + .../gpu/drm/amd/powerplay/inc/smu_v11_0_ppsmc.h | 5 +- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 176 ++++++++- drivers/gpu/drm/amd/powerplay/smu_internal.h | 3 + drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 6 + drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 28 +- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 18 +- drivers/gpu/drm/drm_dp_mst_topology.c | 12 + drivers/gpu/drm/drm_rect.c | 7 +- drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c | 2 +- drivers/gpu/drm/tegra/drm.c | 49 ++- drivers/gpu/drm/tegra/gem.c | 10 +- drivers/gpu/drm/tegra/plane.c | 44 ++- drivers/gpu/host1x/job.c | 32 +- drivers/hv/hv_balloon.c | 13 +- drivers/infiniband/core/umem_odp.c | 22 +- drivers/infiniband/hw/mlx5/gsi.c | 3 +- drivers/md/bcache/bcache.h | 3 + drivers/md/bcache/request.c | 17 +- drivers/md/bcache/sysfs.c | 22 ++ drivers/md/dm-crypt.c | 12 +- drivers/md/dm-thin-metadata.c | 10 +- drivers/md/dm-thin.c | 7 +- drivers/md/dm-writecache.c | 42 +- drivers/md/dm-zoned-metadata.c | 23 +- drivers/md/dm.c | 9 +- drivers/md/persistent-data/dm-space-map-common.c | 27 ++ drivers/md/persistent-data/dm-space-map-common.h | 2 + drivers/md/persistent-data/dm-space-map-disk.c | 6 +- drivers/md/persistent-data/dm-space-map-metadata.c | 5 +- drivers/media/rc/iguanair.c | 2 +- drivers/media/rc/rc-main.c | 27 +- drivers/media/usb/uvc/uvc_driver.c | 12 + drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 148 +++---- drivers/media/v4l2-core/videobuf-dma-sg.c | 5 +- drivers/mfd/ab8500-core.c | 4 +- drivers/mfd/axp20x.c | 2 +- drivers/mfd/da9062-core.c | 2 +- drivers/mfd/dln2.c | 13 +- drivers/mfd/rn5t618.c | 1 + drivers/mmc/host/mmc_spi.c | 11 +- drivers/mmc/host/sdhci-of-at91.c | 9 +- drivers/mtd/spi-nor/spi-nor.c | 9 +- drivers/mtd/ubi/fastmap.c | 23 +- drivers/net/bonding/bond_alb.c | 44 ++- drivers/net/dsa/b53/b53_common.c | 2 +- drivers/net/dsa/bcm_sf2.c | 4 +- drivers/net/dsa/microchip/ksz9477_spi.c | 6 + drivers/net/ethernet/broadcom/bcmsysport.c | 3 + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 49 ++- drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 1 - drivers/net/ethernet/cadence/macb_main.c | 14 +- drivers/net/ethernet/dec/tulip/dmfe.c | 7 +- drivers/net/ethernet/dec/tulip/uli526x.c | 4 +- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 14 +- drivers/net/ethernet/marvell/mvneta.c | 41 +- .../net/ethernet/mellanox/mlx5/core/accel/tls.h | 2 +- .../mellanox/mlx5/core/en_accel/tls_rxtx.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 16 +- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 33 +- .../net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 3 +- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 15 +- drivers/net/ethernet/mellanox/mlx5/core/fw.c | 2 +- drivers/net/ethernet/pensando/ionic/ionic_if.h | 2 +- drivers/net/ethernet/qlogic/qed/qed_ptp.c | 4 +- drivers/net/ethernet/realtek/r8169_main.c | 6 + drivers/net/ethernet/smsc/smc911x.c | 2 +- .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 1 + drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 9 +- .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 10 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 + drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 14 +- drivers/net/gtp.c | 4 +- drivers/net/netdevsim/dev.c | 2 +- drivers/net/phy/at803x.c | 11 + drivers/net/ppp/ppp_async.c | 18 +- .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 1 + drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 10 +- drivers/net/wireless/marvell/mwifiex/sta_ioctl.c | 1 + drivers/nfc/pn544/pn544.c | 2 +- drivers/nvme/target/fabrics-cmd.c | 15 +- drivers/nvmem/core.c | 8 +- drivers/nvmem/imx-ocotp-scu.c | 6 +- drivers/of/Kconfig | 4 + drivers/of/address.c | 6 +- drivers/pci/ats.c | 6 +- drivers/pci/controller/dwc/pci-keystone.c | 6 +- drivers/pci/controller/pci-tegra.c | 2 +- drivers/phy/qualcomm/phy-qcom-apq8064-sata.c | 2 +- drivers/platform/x86/intel_scu_ipc.c | 21 +- drivers/power/supply/axp20x_ac_power.c | 31 +- drivers/power/supply/ltc2941-battery-gauge.c | 2 +- drivers/regulator/helpers.c | 14 + drivers/scsi/csiostor/csio_scsi.c | 2 +- drivers/scsi/megaraid/megaraid_sas_base.c | 3 +- drivers/scsi/megaraid/megaraid_sas_fusion.c | 3 +- drivers/scsi/megaraid/megaraid_sas_fusion.h | 1 + drivers/scsi/qla2xxx/qla_dbg.c | 6 - drivers/scsi/qla2xxx/qla_dbg.h | 6 + drivers/scsi/qla2xxx/qla_def.h | 5 + drivers/scsi/qla2xxx/qla_init.c | 34 +- drivers/scsi/qla2xxx/qla_isr.c | 12 + drivers/scsi/qla2xxx/qla_mbx.c | 3 +- drivers/scsi/qla2xxx/qla_nx.c | 7 +- drivers/scsi/qla2xxx/qla_target.c | 1 + drivers/scsi/qla4xxx/ql4_os.c | 2 +- drivers/scsi/sg.c | 126 +++--- drivers/scsi/ufs/ufshcd.c | 3 + drivers/staging/wfx/debug.c | 2 +- drivers/usb/dwc3/core.h | 2 + drivers/usb/dwc3/ep0.c | 4 +- drivers/usb/dwc3/gadget.c | 17 +- drivers/usb/gadget/function/f_ecm.c | 16 +- drivers/usb/gadget/function/f_fs.c | 2 + drivers/usb/gadget/function/f_ncm.c | 17 +- drivers/usb/gadget/legacy/cdc2.c | 2 +- drivers/usb/gadget/legacy/g_ffs.c | 2 +- drivers/usb/gadget/legacy/multi.c | 2 +- drivers/usb/gadget/legacy/ncm.c | 2 +- drivers/usb/typec/tcpm/tcpci.c | 6 + drivers/virtio/virtio_balloon.c | 19 +- drivers/virtio/virtio_pci_common.c | 2 +- drivers/watchdog/watchdog_core.c | 35 ++ drivers/watchdog/watchdog_dev.c | 36 +- drivers/xen/gntdev.c | 24 +- drivers/xen/xen-balloon.c | 2 +- fs/aio.c | 20 +- fs/attr.c | 23 +- fs/btrfs/ctree.c | 8 +- fs/btrfs/ctree.h | 6 +- fs/btrfs/delayed-ref.c | 8 +- fs/btrfs/disk-io.c | 12 +- fs/btrfs/extent_io.c | 55 ++- fs/btrfs/ioctl.c | 3 +- fs/btrfs/send.c | 3 +- fs/btrfs/tests/btrfs-tests.c | 1 - fs/btrfs/tests/extent-io-tests.c | 9 + fs/btrfs/transaction.c | 30 +- fs/btrfs/tree-log.c | 432 +++++++-------------- fs/btrfs/volumes.c | 17 +- fs/cifs/cifsacl.c | 20 + fs/cifs/cifsproto.h | 1 + fs/cifs/readdir.c | 3 +- fs/cifs/smb2pdu.c | 21 +- fs/configfs/inode.c | 9 +- fs/crypto/keyring.c | 15 +- fs/erofs/decompressor.c | 22 +- fs/eventfd.c | 15 + fs/ext2/super.c | 6 +- fs/ext4/dir.c | 9 +- fs/ext4/page-io.c | 19 +- fs/f2fs/dir.c | 11 +- fs/f2fs/file.c | 18 +- fs/f2fs/super.c | 18 +- fs/fs-writeback.c | 2 +- fs/fuse/file.c | 5 +- fs/gfs2/file.c | 72 ++-- fs/gfs2/lops.c | 2 +- fs/io_uring.c | 71 +++- fs/jbd2/journal.c | 1 + fs/nfs/dir.c | 47 ++- fs/nfsd/filecache.c | 6 + fs/nfsd/nfs4layouts.c | 2 +- fs/nfsd/nfs4state.c | 2 +- fs/nfsd/state.h | 2 +- fs/nfsd/vfs.c | 1 + fs/ntfs/inode.c | 18 +- fs/ocfs2/file.c | 14 +- fs/overlayfs/file.c | 2 +- fs/overlayfs/readdir.c | 8 +- fs/read_write.c | 10 +- fs/ubifs/dir.c | 2 + fs/ubifs/file.c | 22 +- fs/ubifs/ioctl.c | 3 +- fs/ubifs/sb.c | 2 +- fs/ubifs/super.c | 2 + fs/utimes.c | 4 +- include/asm-generic/tlb.h | 22 +- include/linux/backing-dev.h | 10 + include/linux/cpufreq.h | 32 +- include/linux/eventfd.h | 14 + include/linux/irq.h | 18 + include/linux/irqdomain.h | 7 + include/linux/kvm_host.h | 13 +- include/linux/kvm_types.h | 9 +- include/linux/mfd/rohm-bd70528.h | 2 +- include/linux/mlx5/mlx5_ifc.h | 7 +- include/linux/padata.h | 34 +- include/linux/percpu-defs.h | 3 +- include/linux/regulator/consumer.h | 7 + include/media/v4l2-rect.h | 8 +- include/net/ipx.h | 5 - include/scsi/sg.h | 30 ++ include/sound/hdaudio.h | 77 ++-- include/trace/events/writeback.h | 37 +- include/uapi/linux/io_uring.h | 1 + ipc/msg.c | 19 +- kernel/bpf/devmap.c | 3 +- kernel/bpf/trampoline.c | 10 + kernel/events/core.c | 17 +- kernel/irq/debugfs.c | 1 + kernel/irq/irqdomain.c | 1 + kernel/irq/msi.c | 5 +- kernel/padata.c | 275 ++++++++----- kernel/rcu/srcutree.c | 7 +- kernel/rcu/tree_exp.h | 19 +- kernel/rcu/tree_plugin.h | 13 +- kernel/time/alarmtimer.c | 8 +- kernel/time/clocksource.c | 11 +- kernel/trace/ftrace.c | 15 +- kernel/trace/trace.h | 29 +- kernel/trace/trace_probe.c | 6 +- kernel/trace/trace_sched_switch.c | 4 +- lib/test_kasan.c | 1 + mm/backing-dev.c | 1 + mm/memcontrol.c | 18 - mm/memory_hotplug.c | 9 +- mm/migrate.c | 27 +- mm/mmu_gather.c | 16 +- mm/page_alloc.c | 14 +- mm/sparse.c | 2 +- net/core/devlink.c | 6 + net/core/drop_monitor.c | 4 +- net/core/flow_dissector.c | 11 +- net/core/rtnetlink.c | 4 +- net/hsr/hsr_slave.c | 2 + net/ipv4/tcp.c | 6 + net/ipv6/addrconf.c | 3 + net/l2tp/l2tp_core.c | 7 +- net/netfilter/ipset/ip_set_core.c | 41 +- net/rxrpc/af_rxrpc.c | 2 + net/rxrpc/ar-internal.h | 11 + net/rxrpc/call_object.c | 4 +- net/rxrpc/conn_client.c | 3 +- net/rxrpc/conn_event.c | 30 +- net/rxrpc/conn_object.c | 3 +- net/rxrpc/input.c | 6 +- net/rxrpc/local_object.c | 23 +- net/rxrpc/output.c | 27 +- net/rxrpc/peer_event.c | 42 +- net/sched/cls_rsvp.h | 6 +- net/sched/cls_tcindex.c | 43 +- net/sched/sch_taprio.c | 92 +++-- net/sunrpc/auth_gss/svcauth_gss.c | 4 + samples/bpf/Makefile | 4 +- samples/bpf/xdp_redirect_cpu_user.c | 59 ++- scripts/find-unused-docs.sh | 2 +- security/smack/smack_lsm.c | 41 +- sound/core/pcm_native.c | 24 +- sound/drivers/dummy.c | 2 +- sound/pci/hda/hda_intel.c | 4 + sound/pci/hda/hda_tegra.c | 1 + sound/pci/hda/patch_hdmi.c | 95 +++-- sound/soc/codecs/sgtl5000.c | 3 +- sound/soc/intel/boards/skl_hda_dsp_common.c | 21 +- sound/soc/meson/axg-fifo.c | 27 +- sound/soc/meson/axg-fifo.h | 6 +- sound/soc/meson/axg-frddr.c | 24 +- sound/soc/meson/axg-toddr.c | 21 +- sound/soc/soc-topology.c | 7 +- sound/soc/sof/core.c | 87 +++-- sound/soc/sof/intel/hda-loader.c | 1 - sound/soc/sof/intel/hda.c | 4 +- sound/soc/sof/ipc.c | 17 +- sound/soc/sof/loader.c | 19 +- sound/soc/sof/pm.c | 25 +- sound/soc/sof/sof-priv.h | 11 +- sound/soc/tegra/tegra30_i2s.c | 25 +- sound/usb/mixer_scarlett_gen2.c | 46 +-- sound/usb/validate.c | 6 +- tools/kvm/kvm_stat/kvm_stat | 8 +- tools/lib/bpf/Makefile | 2 + tools/lib/bpf/libbpf.c | 198 ++++++---- tools/lib/bpf/libbpf_internal.h | 4 +- tools/objtool/sync-check.sh | 2 - tools/power/cpupower/lib/cpufreq.c | 78 +++- tools/power/cpupower/lib/cpufreq.h | 20 +- tools/power/cpupower/utils/cpufreq-info.c | 12 +- .../selftests/bpf/prog_tests/attach_probe.c | 7 +- .../testing/selftests/bpf/prog_tests/perf_buffer.c | 29 +- .../bpf/prog_tests/stacktrace_build_id_nmi.c | 8 +- .../bpf/progs/test_select_reuseport_kern.c | 6 + tools/testing/selftests/bpf/test_sockmap.c | 15 +- .../tc-testing/plugin-lib/buildebpfPlugin.py | 2 +- virt/kvm/arm/aarch32.c | 117 +++++- virt/kvm/arm/mmio.c | 6 + virt/kvm/async_pf.c | 10 +- virt/kvm/kvm_main.c | 117 +++++- 404 files changed, 5002 insertions(+), 2744 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 12/367 tcp: clear tp->delivered in tcp_disconnect()
From: Eric Dumazet <[email protected]>
[ Upstream commit 2fbdd56251b5c62f96589f39eded277260de7267 ]
tp->delivered needs to be cleared in tcp_disconnect().
tcp_disconnect() is rarely used, but it is worth fixing it.
--- net/ipv4/tcp.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/tcp.c +1 -0
@@ -2621,6 +2621,7 @@ int tcp_disconnect(struct sock *sk, int tp->snd_cwnd =TCP_INIT_CWND ; tp->snd_cwnd_cnt =0 ; tp->window_clamp =0 ; + tp->delivered =0 ; tp->delivered_ce =0 ;tcp_set_ca_state (sk, TCP_CA_Open); tp->is_sack_reneg =0 ;
Greg Kroah-Hartman
maintainerPATCH 341/367 qed: Fix timestamping issue for L2 unicast ptp packets.
In reply to Greg Kroah-HartmanFrom: Sudarsana Reddy Kalluru <[email protected]>
[ Upstream commit 0202d293c2faecba791ba4afc5aec086249c393d ]
commit cedeac9df4b8 ("qed: Add support for Timestamping the unicast PTP packets.") handles the timestamping of L4 ptp packets only. This patch adds driver changes to detect/timestamp both L2/L4 unicast PTP packets.
--- drivers/net/ethernet/qlogic/qed/qed_ptp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_ptp.c +2 -2
@@ -44,8 +44,8 @@/* Add/subtract the Adjustment_Value when making a Drift adjustment */ #define QED_DRIFT_CNTR_DIRECTION_SHIFT 31#define QED_TIMESTAMP_MASK BIT(16) -/* Param mask for Hardware to detect/timestamp the unicast PTP packets */ -#define QED_PTP_UCAST_PARAM_MASK 0xF +/* Param mask for Hardware to detect/timestamp the L2/L4 unicast PTP packets */ +#define QED_PTP_UCAST_PARAM_MASK 0x70Fstatic enum qed_resc_lock qed_ptcdev_to_resc (struct qed_hwfn *p_hwfn) {
Greg Kroah-Hartman
maintainerPATCH 342/367 drop_monitor: Do not cancel uninitialized work item
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit dfa7f709596be5ca46c070d4f8acbb344322056a ]
Drop monitor uses a work item that takes care of constructing and sending netlink notifications to user space. In case drop monitor never started to monitor, then the work item is uninitialized and not associated with a function.
Therefore, a stop command from user space results in canceling an uninitialized work item which leads to the following warning [1].
Fix this by not processing a stop command if drop monitor is not currently monitoring.
[1]
[ 31.735402] ------------[ cut here ]------------ [ 31.736470] WARNING: CPU: 0 PID: 143 at kernel/workqueue.c:3032 __flush_work+0x89f/0x9f0 ... [ 31.738120] CPU: 0 PID: 143 Comm: dwdump Not tainted 5.5.0-custom-09491-g16d4077796b8 #727 [ 31.741968] RIP: 0010:__flush_work+0x89f/0x9f0 ... [ 31.760526] Call Trace: [ 31.771689] __cancel_work_timer+0x2a6/0x3b0 [ 31.776809] net_dm_cmd_trace+0x300/0xef0 [ 31.777549] genl_rcv_msg+0x5c6/0xd50 [ 31.781005] netlink_rcv_skb+0x13b/0x3a0 [ 31.784114] genl_rcv+0x29/0x40 [ 31.784720] netlink_unicast+0x49f/0x6a0 [ 31.787148] netlink_sendmsg+0x7cf/0xc80 [ 31.790426] ____sys_sendmsg+0x620/0x770 [ 31.793458] ___sys_sendmsg+0xfd/0x170 [ 31.802216] __sys_sendmsg+0xdf/0x1a0 [ 31.806195] do_syscall_64+0xa0/0x540 [ 31.806885] entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- net/core/drop_monitor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/drop_monitor.c +3 -1
@@ -1004,8 +1004,10 @@ static void net_dm_hw_monitor_stop(struc {int cpu; -if (!monitor_hw) +if (!monitor_hw) {NL_SET_ERR_MSG_MOD (extack,"Hardware monitoring already disabled" ); +return ; + } monitor_hw = false;
Greg Kroah-Hartman
maintainerPATCH 339/367 taprio: Fix dropping packets when using taprio + ETF offloading
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit bfabd41da34180d05382312533a3adc2e012dee0 ]
When using taprio offloading together with ETF offloading, configured like this, for example:
$ tc qdisc replace dev $IFACE parent root handle 100 taprio \
num_tc 4 \
map 2 2 1 0 3 2 2 2 2 2 2 2 2 2 2 2 \
queues 1@0 1@1 1@2 1@3 \
base-time $BASE_TIME \
sched-entry S 01 1000000 \
sched-entry S 0e 1000000 \
flags 0x2$ tc qdisc replace dev $IFACE parent 100:1 etf \
offload delta 300000 clockid CLOCK_TAIDuring enqueue, it works out that the verification added for the "txtime" assisted mode is run when using taprio + ETF offloading, the only thing missing is initializing the 'next_txtime' of all the cycle entries. (if we don't set 'next_txtime' all packets from SO_TXTIME sockets are dropped)
--- net/sched/sch_taprio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/sch_taprio.c +2 -2
@@ -1522,9 +1522,9 @@ static int taprio_change(struct Qdisc *s goto unlock; } -if (TXTIME_ASSIST_IS_ENABLED (q->flags)) { -setup_txtime (q, new_admin, start); +setup_txtime (q, new_admin, start); +if (TXTIME_ASSIST_IS_ENABLED (q->flags)) {if (!oper) {rcu_assign_pointer (q->oper_sched, new_admin); err =0 ;
Greg Kroah-Hartman
maintainerPATCH 338/367 taprio: Use taprio_reset_tc() to reset Traffic Classes configuration
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 7c16680a08ee1e444a67d232c679ccf5b30fad16 ]
When destroying the current taprio instance, which can happen when the creation of one fails, we should reset the traffic class configuration back to the default state.
netdev_reset_tc() is a better way because in addition to setting the number of traffic classes to zero, it also resets the priority to traffic classes mapping to the default value.
--- net/sched/sch_taprio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_taprio.c +1 -1
@@ -1588,7 +1588,7 @@ static void taprio_destroy(struct Qdisc } q->qdiscs =NULL ; -netdev_set_num_tc (dev,0 ); +netdev_reset_tc (dev);if (q->oper_sched)call_rcu (&q->oper_sched->rcu, taprio_free_sched_cb);
Greg Kroah-Hartman
maintainerPATCH 337/367 taprio: Add missing policy validation for flags
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 49c684d79cfdc3032344bf6f3deeea81c4efedbf ]
netlink policy validation for the 'flags' argument was missing.
--- net/sched/sch_taprio.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_taprio.c +1 -0
@@ -767,6 +767,7 @@ static const struct nla_policy taprio_po [TCA_TAPRIO_ATTR_SCHED_CLOCKID] = { .type = NLA_S32 }, [TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME] = { .type = NLA_S64 }, [TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION] = { .type = NLA_S64 }, + [TCA_TAPRIO_ATTR_FLAGS] = { .type = NLA_U32 }, }; static int fill_sched_entry(struct nlattr **tb, struct sched_entry *entry,
Greg Kroah-Hartman
maintainerPATCH 364/367 crypto: atmel-aes - Fix CTR counter overflow when multiple fragments
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
[ Upstream commit 3907ccfaec5d9965e306729936fc732c94d2c1e7 ]
The CTR transfer works in fragments of data of maximum 1 MByte because of the 16 bit CTR counter embedded in the IP. Fix the CTR counter overflow handling for messages larger than 1 MByte.
--- drivers/crypto/atmel-aes.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/crypto/atmel-aes.c +7 -1
@@ -121,7 +121,7 @@ struct atmel_aes_ctr_ctx {size_t offset;struct scatterlist src[2 ];struct scatterlist dst[2 ]; -u16 blocks; +u32 blocks; };struct atmel_aes_gcm_ctx {
@@ -528,6 +528,12 @@ static void atmel_aes_ctr_update_req_iv(struct atmel_aes_dev *dd)unsigned int ivsize =crypto_skcipher_ivsize (skcipher);int i; +/* +* The CTR transfer works in fragments of data of maximum 1 MByte +* because of the 16 bit CTR counter embedded in the IP. When reaching +* here, ctx->blocks contains the number of blocks of the last fragment +* processed, there is no need to explicit cast it to u16. +*/ for (i =0 ; i < ctx->blocks; i++)crypto_inc ((u8 *)ctx->iv,AES_BLOCK_SIZE );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 363/367 crypto: atmel-aes - Fix saving of IV for CTR mode
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
[ Upstream commit 371731ec2179d5810683406e7fc284b41b127df7 ]
The req->iv of the skcipher_request is expected to contain the last used IV. Update the req->iv for CTR mode.
--- drivers/crypto/atmel-aes.c | 43 +++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 12 deletions(-)
drivers/crypto/atmel-aes.c +31 -12
@@ -121,6 +121,7 @@ struct atmel_aes_ctr_ctx {size_t offset;struct scatterlist src[2 ];struct scatterlist dst[2 ]; +u16 blocks; };struct atmel_aes_gcm_ctx {
@@ -513,6 +514,26 @@ static void atmel_aes_set_iv_as_last_ciphertext_block(struct atmel_aes_dev *dd) } } +static inline struct atmel_aes_ctr_ctx * +atmel_aes_ctr_ctx_cast (struct atmel_aes_base_ctx *ctx) +{ + return container_of(ctx, struct atmel_aes_ctr_ctx, base); +} + +static void atmel_aes_ctr_update_req_iv (struct atmel_aes_dev *dd) +{ +struct atmel_aes_ctr_ctx *ctx =atmel_aes_ctr_ctx_cast (dd->ctx); +struct skcipher_request *req =skcipher_request_cast (dd->areq); +struct crypto_skcipher *skcipher =crypto_skcipher_reqtfm (req); +unsigned int ivsize =crypto_skcipher_ivsize (skcipher); +int i; + +for (i =0 ; i < ctx->blocks; i++) +crypto_inc ((u8 *)ctx->iv,AES_BLOCK_SIZE ); + +memcpy (req->iv, ctx->iv, ivsize); +} +static inline int atmel_aes_complete (struct atmel_aes_dev *dd,int err) {struct skcipher_request *req =skcipher_request_cast (dd->areq);
@@ -527,8 +548,12 @@ static inline int atmel_aes_complete(struct atmel_aes_dev *dd, int err) dd->flags &= ~AES_FLAGS_BUSY ;if (!dd->ctx->is_aead && - (rctx->mode &AES_FLAGS_OPMODE_MASK ) !=AES_FLAGS_ECB ) -atmel_aes_set_iv_as_last_ciphertext_block (dd); + (rctx->mode &AES_FLAGS_OPMODE_MASK ) !=AES_FLAGS_ECB ) { +if ((rctx->mode &AES_FLAGS_OPMODE_MASK ) !=AES_FLAGS_CTR ) +atmel_aes_set_iv_as_last_ciphertext_block (dd); +else +atmel_aes_ctr_update_req_iv (dd); + }if (dd->is_async) dd->areq->complete (dd->areq, err);
@@ -1007,12 +1032,6 @@ static int atmel_aes_start(struct atmel_aes_dev *dd) atmel_aes_transfer_complete); } -static inline struct atmel_aes_ctr_ctx * -atmel_aes_ctr_ctx_cast (struct atmel_aes_base_ctx *ctx) -{ - return container_of(ctx, struct atmel_aes_ctr_ctx, base); -} -static int atmel_aes_ctr_transfer (struct atmel_aes_dev *dd) {struct atmel_aes_ctr_ctx *ctx =atmel_aes_ctr_ctx_cast (dd->ctx);
@@ -1020,7 +1039,7 @@ static int atmel_aes_ctr_transfer(struct atmel_aes_dev *dd)struct scatterlist *src, *dst;size_t datalen;u32 ctr; -u16 blocks, start, end; +u16 start, end;bool use_dma, fragmented = false;/* Check for transfer completion. */
@@ -1030,14 +1049,14 @@ static int atmel_aes_ctr_transfer(struct atmel_aes_dev *dd)/* Compute data length. */ datalen = req->cryptlen - ctx->offset; - blocks =DIV_ROUND_UP (datalen,AES_BLOCK_SIZE ); + ctx->blocks =DIV_ROUND_UP (datalen,AES_BLOCK_SIZE ); ctr =be32_to_cpu (ctx->iv[3 ]);/* Check 16bit counter overflow. */ start = ctr &0xffff ; - end = start + blocks -1 ; + end = start + ctx->blocks -1 ; -if (blocks >>16 || end < start) { +if (ctx->blocks >>16 || end < start) { ctr |=0xffff ; datalen =AES_BLOCK_SIZE * (0x10000 - start); fragmented = true;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 336/367 taprio: Fix still allowing changing the flags during runtime
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit a9d6227436f32142209f4428f2dc616761485112 ]
Because 'q->flags' starts as zero, and zero is a valid value, we aren't able to detect the transition from zero to something else during "runtime".
The solution is to initialize 'q->flags' with an invalid value, so we can detect if 'q->flags' was set by the user or not.
To better solidify the behavior, 'flags' handling is moved to a separate function. The behavior is:
- 'flags' if unspecified by the user, is assumed to be zero;
- 'flags' cannot change during "runtime" (i.e. a change() request cannot modify it);
With this new function we can remove taprio_flags, which should reduce the risk of future accidents.
Allowing flags to be changed was causing the following RCU stall:
[ 1730.558249] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: [ 1730.558258] rcu: 6-...0: (190 ticks this GP) idle=922/0/0x1 softirq=25580/25582 fqs=16250 [ 1730.558264] (detected by 2, t=65002 jiffies, g=33017, q=81) [ 1730.558269] Sending NMI from CPU 2 to CPUs 6: [ 1730.559277] NMI backtrace for cpu 6 [ 1730.559277] CPU: 6 PID: 0 Comm: swapper/6 Tainted: G E 5.5.0-rc6+ #35 [ 1730.559278] Hardware name: Gigabyte Technology Co., Ltd. Z390 AORUS ULTRA/Z390 AORUS ULTRA-CF, BIOS F7 03/14/2019 [ 1730.559278] RIP: 0010:__hrtimer_run_queues+0xe2/0x440 [ 1730.559278] Code: 48 8b 43 28 4c 89 ff 48 8b 75 c0 48 89 45 c8 e8 f4 bb 7c 00 0f 1f 44 00 00 65 8b 05 40 31 f0 68 89 c0 48 0f a3 05 3e 5c 25 01 <0f> 82 fc 01 00 00 48 8b 45 c8 48 89 df ff d0 89 45 c8 0f 1f 44 00 [ 1730.559279] RSP: 0018:ffff9970802d8f10 EFLAGS: 00000083 [ 1730.559279] RAX: 0000000000000006 RBX: ffff8b31645bff38 RCX: 0000000000000000 [ 1730.559280] RDX: 0000000000000000 RSI: ffffffff9710f2ec RDI: ffffffff978daf0e [ 1730.559280] RBP: ffff9970802d8f68 R08: 0000000000000000 R09: 0000000000000000 [ 1730.559280] R10: 0000018336d7944e R11: 0000000000000001 R12: ffff8b316e39f9c0 [ 1730.559281] R13: ffff8b316e39f940 R14: ffff8b316e39f998 R15: ffff8b316e39f7c0 [ 1730.559281] FS: 0000000000000000(0000) GS:ffff8b316e380000(0000) knlGS:0000000000000000 [ 1730.559281] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1730.559281] CR2: 00007f1105303760 CR3: 0000000227210005 CR4: 00000000003606e0 [ 1730.559282] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1730.559282] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 1730.559282] Call Trace: [ 1730.559282] <IRQ> [ 1730.559283] ? taprio_dequeue_soft+0x2d0/0x2d0 [sch_taprio] [ 1730.559283] hrtimer_interrupt+0x104/0x220 [ 1730.559283] ? irqtime_account_irq+0x34/0xa0 [ 1730.559283] smp_apic_timer_interrupt+0x6d/0x230 [ 1730.559284] apic_timer_interrupt+0xf/0x20 [ 1730.559284] </IRQ> [ 1730.559284] RIP: 0010:cpu_idle_poll+0x35/0x1a0 [ 1730.559285] Code: 88 82 ff 65 44 8b 25 12 7d 73 68 0f 1f 44 00 00 e8 90 c3 89 ff fb 65 48 8b 1c 25 c0 7e 01 00 48 8b 03 a8 08 74 0b eb 1c f3 90 <48> 8b 03 a8 08 75 13 8b 05 be a8 a8 00 85 c0 75 ed e8 75 48 84 ff [ 1730.559285] RSP: 0018:ffff997080137ea8 EFLAGS: 00000202 ORIG_RAX: ffffffffffffff13 [ 1730.559285] RAX: 0000000000000001 RBX: ffff8b316bc3c580 RCX: 0000000000000000 [ 1730.559286] RDX: 0000000000000001 RSI: 000000002819aad9 RDI: ffffffff978da730 [ 1730.559286] RBP: ffff997080137ec0 R08: 0000018324a6d387 R09: 0000000000000000 [ 1730.559286] R10: 0000000000000400 R11: 0000000000000001 R12: 0000000000000006 [ 1730.559286] R13: ffff8b316bc3c580 R14: 0000000000000000 R15: 0000000000000000 [ 1730.559287] ? cpu_idle_poll+0x20/0x1a0 [ 1730.559287] ? cpu_idle_poll+0x20/0x1a0 [ 1730.559287] do_idle+0x4d/0x1f0 [ 1730.559287] ? complete+0x44/0x50 [ 1730.559288] cpu_startup_entry+0x1b/0x20 [ 1730.559288] start_secondary+0x142/0x180 [ 1730.559288] secondary_startup_64+0xb6/0xc0 [ 1776.686313] nvme nvme0: I/O 96 QID 1 timeout, completion polled
--- net/sched/sch_taprio.c | 61 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 20 deletions(-)
net/sched/sch_taprio.c +41 -20
@@ -31,6 +31,7 @@ static DEFINE_SPINLOCK(taprio_list_lock)#define TXTIME_ASSIST_IS_ENABLED (flags) ((flags) & TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST)#define FULL_OFFLOAD_IS_ENABLED (flags) ((flags) & TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD) +#define TAPRIO_FLAGS_INVALID U32_MAXstruct sched_entry {struct list_head list;
@@ -1367,6 +1368,33 @@ static int taprio_mqprio_cmp(const strucreturn 0 ; } +/* The semantics of the 'flags' argument in relation to 'change()' +* requests, are interpreted following two rules (which are applied in +* this order): (1) an omitted 'flags' argument is interpreted as +* zero; (2) the 'flags' of a "running" taprio instance cannot be +* changed. +*/ +static int taprio_new_flags (const struct nlattr *attr,u32 old, +struct netlink_ext_ack *extack) +{ +u32 new =0 ; + +if (attr) + new =nla_get_u32 (attr); + +if (old !=TAPRIO_FLAGS_INVALID && old != new) { +NL_SET_ERR_MSG_MOD (extack,"Changing 'flags' of a running schedule is not supported" ); +return -EOPNOTSUPP ; + } + +if (!taprio_flags_valid (new)) { +NL_SET_ERR_MSG_MOD (extack,"Specified 'flags' are not valid" ); +return -EINVAL ; + } + +return new; +} +static int taprio_change (struct Qdisc *sch,struct nlattr *opt,struct netlink_ext_ack *extack) {
@@ -1375,7 +1403,6 @@ static int taprio_change(struct Qdisc *sstruct taprio_sched *q =qdisc_priv (sch);struct net_device *dev =qdisc_dev (sch);struct tc_mqprio_qopt *mqprio =NULL ; -u32 taprio_flags =0 ;unsigned long flags;ktime_t start;int i, err;
@@ -1388,21 +1415,14 @@ static int taprio_change(struct Qdisc *sif (tb[TCA_TAPRIO_ATTR_PRIOMAP ]) mqprio =nla_data (tb[TCA_TAPRIO_ATTR_PRIOMAP ]); -if (tb[TCA_TAPRIO_ATTR_FLAGS ]) { - taprio_flags =nla_get_u32 (tb[TCA_TAPRIO_ATTR_FLAGS ]); - -if (q->flags !=0 && q->flags != taprio_flags) { -NL_SET_ERR_MSG_MOD (extack,"Changing 'flags' of a running schedule is not supported" ); -return -EOPNOTSUPP ; - }else if (!taprio_flags_valid (taprio_flags)) { -NL_SET_ERR_MSG_MOD (extack,"Specified 'flags' are not valid" ); -return -EINVAL ; - } + err =taprio_new_flags (tb[TCA_TAPRIO_ATTR_FLAGS ], + q->flags, extack); +if (err <0 ) +return err; - q->flags = taprio_flags; - } + q->flags = err; - err =taprio_parse_mqprio_opt (dev, mqprio, extack, taprio_flags); + err =taprio_parse_mqprio_opt (dev, mqprio, extack, q->flags);if (err <0 )return err;
@@ -1457,7 +1477,7 @@ static int taprio_change(struct Qdisc *s mqprio->prio_tc_map[i]); } -if (FULL_OFFLOAD_IS_ENABLED (taprio_flags)) +if (FULL_OFFLOAD_IS_ENABLED (q->flags)) err =taprio_enable_offload (dev, mqprio, q, new_admin, extack);else err =taprio_disable_offload (dev, q, extack);
@@ -1477,14 +1497,14 @@ static int taprio_change(struct Qdisc *s q->txtime_delay =nla_get_u32 (tb[TCA_TAPRIO_ATTR_TXTIME_DELAY ]); } -if (!TXTIME_ASSIST_IS_ENABLED (taprio_flags) && - !FULL_OFFLOAD_IS_ENABLED (taprio_flags) && +if (!TXTIME_ASSIST_IS_ENABLED (q->flags) && + !FULL_OFFLOAD_IS_ENABLED (q->flags) && !hrtimer_active (&q->advance_timer)) {hrtimer_init (&q->advance_timer, q->clockid,HRTIMER_MODE_ABS ); q->advance_timer.function = advance_sched; } -if (FULL_OFFLOAD_IS_ENABLED (taprio_flags)) { +if (FULL_OFFLOAD_IS_ENABLED (q->flags)) { q->dequeue = taprio_dequeue_offload; q->peek = taprio_peek_offload; }else {
@@ -1501,7 +1521,7 @@ static int taprio_change(struct Qdisc *s goto unlock; } -if (TXTIME_ASSIST_IS_ENABLED (taprio_flags)) { +if (TXTIME_ASSIST_IS_ENABLED (q->flags)) {setup_txtime (q, new_admin, start);if (!oper) {
@@ -1528,7 +1548,7 @@ static int taprio_change(struct Qdisc *sspin_unlock_irqrestore (&q->current_entry_lock, flags); -if (FULL_OFFLOAD_IS_ENABLED (taprio_flags)) +if (FULL_OFFLOAD_IS_ENABLED (q->flags))taprio_offload_config_changed (q); }
@@ -1597,6 +1617,7 @@ static int taprio_init(struct Qdisc *sch* and get the valid one on taprio_change(). */ q->clockid =-1 ; + q->flags =TAPRIO_FLAGS_INVALID ;spin_lock (&taprio_list_lock);list_add (&q->taprio_list, &taprio_list);
Greg Kroah-Hartman
maintainerPATCH 360/367 rxrpc: Fix service call disconnection
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit b39a934ec72fa2b5a74123891f25273a38378b90 ]
The recent patch that substituted a flag on an rxrpc_call for the connection pointer being NULL as an indication that a call was disconnected puts the set_bit in the wrong place for service calls. This is only a problem if a call is implicitly terminated by a new call coming in on the same connection channel instead of a terminating ACK packet.
In such a case, rxrpc_input_implicit_end_call() calls __rxrpc_disconnect_call(), which is now (incorrectly) setting the disconnection bit, meaning that when rxrpc_release_call() is later called, it doesn't call rxrpc_disconnect_call() and so the call isn't removed from the peer's error distribution list and the list gets corrupted.
KASAN finds the issue as an access after release on a call, but the position at which it occurs is confusing as it appears to be related to a different call (the call site is where the latter call is being removed from the error distribution list and either the next or pprev pointer points to a previously released call).
Fix this by moving the setting of the flag from __rxrpc_disconnect_call() to rxrpc_disconnect_call() in the same place that the connection pointer was being cleared.
--- net/rxrpc/conn_object.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/rxrpc/conn_object.c +1 -2
@@ -171,8 +171,6 @@ void __rxrpc_disconnect_call(struct rxrpc_connection *conn,_enter ("%d,%x" , conn->debug_id, call->cid); -set_bit (RXRPC_CALL_DISCONNECTED , &call->flags); -if (rcu_access_pointer (chan->call) == call) {/* Save the result of the call so that we can repeat it if necessary * through the channel, whilst disposing of the actual call record.
@@ -225,6 +223,7 @@ void rxrpc_disconnect_call(struct rxrpc_call *call)__rxrpc_disconnect_call (conn, call);spin_unlock (&conn->channel_lock); +set_bit (RXRPC_CALL_DISCONNECTED , &call->flags); conn->idle_timestamp = jiffies; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 361/367 IB/core: Fix build failure without hugepages
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 74f75cda754eb69a77f910ceb5bc85f8e9ba56a5 ]
HPAGE_SHIFT is only defined on architectures that support hugepages:
drivers/infiniband/core/umem_odp.c: In function 'ib_umem_odp_get':drivers/infiniband/core/umem_odp.c:245:26: error: 'HPAGE_SHIFT' undeclared (first use in this function); did you mean 'PAGE_SHIFT'?
Enclose this in an #ifdef.
--- drivers/infiniband/core/umem_odp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/core/umem_odp.c +3 -2
@@ -241,10 +241,11 @@ struct ib_umem_odp *ib_umem_odp_get(struct ib_udata *udata, unsigned long addr, umem_odp->umem.owning_mm = mm = current->mm; umem_odp->notifier.ops = ops; + umem_odp->page_shift =PAGE_SHIFT ; +#ifdef CONFIG_HUGETLB_PAGE if (access &IB_ACCESS_HUGETLB ) umem_odp->page_shift =HPAGE_SHIFT ; -else - umem_odp->page_shift =PAGE_SHIFT ; +#endif umem_odp->tgid =get_task_pid (current->group_leader,PIDTYPE_PID ); ret =ib_init_umem_odp (umem_odp, ops);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 359/367 KVM: Play nice with read-only memslots when querying host page size
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit 42cde48b2d39772dba47e680781a32a6c4b7dc33 ]
Avoid the "writable" check in __gfn_to_hva_many(), which will always fail on read-only memslots due to gfn_to_hva() assuming writes. Functionally, this allows x86 to create large mappings for read-only memslots that are backed by HugeTLB mappings.
Note, the changelog for commit 05da45583de9 ("KVM: MMU: large page support") states "If the largepage contains write-protected pages, a large pte is not used.", but "write-protected" refers to pages that are temporarily read-only, e.g. read-only memslots didn't even exist at the time.
--- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
virt/kvm/kvm_main.c +1 -1
@@ -1413,7 +1413,7 @@ unsigned long kvm_host_page_size(struct kvm_vcpu *vcpu, gfn_t gfn) size =PAGE_SIZE ; - addr =kvm_vcpu_gfn_to_hva (vcpu, gfn); + addr =kvm_vcpu_gfn_to_hva_prot (vcpu, gfn,NULL );if (kvm_is_error_hva (addr))return PAGE_SIZE ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 357/367 KVM: nVMX: vmread should not set rflags to specify success in case of #PF
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
[ Upstream commit a4d956b9390418623ae5d07933e2679c68b6f83c ]
In case writing to vmread destination operand result in a #PF, vmread should not call nested_vmx_succeed() to set rflags to specify success. Similar to as done in VMPTRST (See handle_vmptrst()).
--- arch/x86/kvm/vmx/nested.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/nested.c +3 -1
@@ -4807,8 +4807,10 @@ static int handle_vmread(struct kvm_vcpu *vcpu) vmx_instruction_info, true, len, &gva))return 1 ;/* _system ok, nested_vmx_check_permission has verified cpl=0 */ -if (kvm_write_guest_virt_system (vcpu, gva, &field_value, len, &e)) +if (kvm_write_guest_virt_system (vcpu, gva, &field_value, len, &e)) {kvm_inject_page_fault (vcpu, &e); +return 1 ; + } }return nested_vmx_succeed (vcpu);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 353/367 drm/dp_mst: Remove VCPI while disabling topology mgr
In reply to Greg Kroah-HartmanFrom: Wayne Lin <[email protected]>
[ Upstream commit 64e62bdf04ab8529f45ed0a85122c703035dec3a ]
[Why]
This patch is trying to address the issue observed when hotplug DP daisy chain monitors.
e.g.
src-mstb-mstb-sst -> src (unplug) mstb-mstb-sst -> src-mstb-mstb-sst (plug in again)
Once unplug a DP MST capable device, driver will call drm_dp_mst_topology_mgr_set_mst() to disable MST. In this function, it cleans data of topology manager while disabling mst_state. However, it doesn't clean up the proposed_vcpis of topology manager. If proposed_vcpi is not reset, once plug in MST daisy chain monitors later, code will fail at checking port validation while trying to allocate payloads.
When MST capable device is plugged in again and try to allocate payloads by calling drm_dp_update_payload_part1(), this function will iterate over all proposed virtual channels to see if any proposed VCPI's num_slots is greater than 0. If any proposed VCPI's num_slots is greater than 0 and the port which the specific virtual channel directed to is not in the topology, code then fails at the port validation. Since there are stale VCPI allocations from the previous topology enablement in proposed_vcpi[], code will fail at port validation and reurn EINVAL.
[How]
Clean up the data of stale proposed_vcpi[] and reset mgr->proposed_vcpis to NULL while disabling mst in drm_dp_mst_topology_mgr_set_mst().
Changes since v1:
*Add on more details in commit message to describe the issue which the patch is trying to fix
--- drivers/gpu/drm/drm_dp_mst_topology.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/drm_dp_mst_topology.c +12 -0
@@ -3435,6 +3435,7 @@ static int drm_dp_get_vc_payload_bw(u8 dp_link_bw, u8 dp_link_count)int drm_dp_mst_topology_mgr_set_mst (struct drm_dp_mst_topology_mgr *mgr,bool mst_state) {int ret =0 ; +int i =0 ;struct drm_dp_mst_branch *mstb =NULL ;mutex_lock (&mgr->lock);
@@ -3495,10 +3496,21 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms/* this can fail if the device is gone */ drm_dp_dpcd_writeb (mgr->aux,DP_MSTM_CTRL ,0 ); ret =0 ; +mutex_lock (&mgr->payload_lock);memset (mgr->payloads,0 , mgr->max_payloads *sizeof (struct drm_dp_payload )); mgr->payload_mask =0 ;set_bit (0 , &mgr->payload_mask); +for (i =0 ; i < mgr->max_payloads; i++) { +struct drm_dp_vcpi *vcpi = mgr->proposed_vcpis[i]; + +if (vcpi) { + vcpi->vcpi =0 ; + vcpi->num_slots =0 ; + } + mgr->proposed_vcpis[i] =NULL ; + } mgr->vcpi_mask =0 ; +mutex_unlock (&mgr->payload_lock); } out_unlock:
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 335/367 taprio: Fix enabling offload with wrong number of traffic classes
In reply to Greg Kroah-HartmanFrom: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 5652e63df3303c2a702bac25fbf710b9cb64dfba ]
If the driver implementing taprio offloading depends on the value of the network device number of traffic classes (dev->num_tc) for whatever reason, it was going to receive the value zero. The value was only set after the offloading function is called.
So, moving setting the number of traffic classes to before the offloading function is called fixes this issue. This is safe because this only happens when taprio is instantiated (we don't allow this configuration to be changed without first removing taprio).
--- net/sched/sch_taprio.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
net/sched/sch_taprio.c +13 -13
@@ -1444,6 +1444,19 @@ static int taprio_change(struct Qdisc *staprio_set_picos_per_byte (dev, q); +if (mqprio) { +netdev_set_num_tc (dev, mqprio->num_tc); +for (i =0 ; i < mqprio->num_tc; i++) +netdev_set_tc_queue (dev, i, + mqprio->count[i], + mqprio->offset[i]); + +/* Always use supplied priority mappings */ +for (i =0 ; i <=TC_BITMASK ; i++) +netdev_set_prio_tc_map (dev, i, + mqprio->prio_tc_map[i]); + } +if (FULL_OFFLOAD_IS_ENABLED (taprio_flags)) err =taprio_enable_offload (dev, mqprio, q, new_admin, extack);else
@@ -1471,19 +1484,6 @@ static int taprio_change(struct Qdisc *s q->advance_timer.function = advance_sched; } -if (mqprio) { -netdev_set_num_tc (dev, mqprio->num_tc); -for (i =0 ; i < mqprio->num_tc; i++) -netdev_set_tc_queue (dev, i, - mqprio->count[i], - mqprio->offset[i]); - -/* Always use supplied priority mappings */ -for (i =0 ; i <=TC_BITMASK ; i++) -netdev_set_prio_tc_map (dev, i, - mqprio->prio_tc_map[i]); - } -if (FULL_OFFLOAD_IS_ENABLED (taprio_flags)) { q->dequeue = taprio_dequeue_offload; q->peek = taprio_peek_offload;
Greg Kroah-Hartman
maintainerPATCH 350/367 clocksource: Prevent double add_timer_on() for watchdog_timer
In reply to Greg Kroah-HartmanFrom: Konstantin Khlebnikov <[email protected]>
commit febac332a819f0e764aa4da62757ba21d18c182b upstream.
Kernel crashes inside QEMU/KVM are observed:
kernel BUG at kernel/time/timer.c:1154! BUG_ON(timer_pending(timer) || !timer->function) in add_timer_on().
At the same time another cpu got:
general protection fault: 0000 [#1] SMP PTI of poinson pointer 0xdead000000000200 in:
__hlist_del at include/linux/list.h:681
(inlined by) detach_timer at kernel/time/timer.c:818 (inlined by) expire_timers at kernel/time/timer.c:1355 (inlined by) __run_timers at kernel/time/timer.c:1686 (inlined by) run_timer_softirq at kernel/time/timer.c:1699
Unfortunately kernel logs are badly scrambled, stacktraces are lost.
Printing the timer->function before the BUG_ON() pointed to clocksource_watchdog().
The execution of clocksource_watchdog() can race with a sequence of clocksource_stop_watchdog() .. clocksource_start_watchdog():
expire_timers()
detach_timer(timer, true);
timer->entry.pprev = NULL;
raw_spin_unlock_irq(&base->lock);
call_timer_fn
clocksource_watchdog()
clocksource_watchdog_kthread() or clocksource_unbind() spin_lock_irqsave(&watchdog_lock, flags); clocksource_stop_watchdog(); del_timer(&watchdog_timer); watchdog_running = 0; spin_unlock_irqrestore(&watchdog_lock, flags); spin_lock_irqsave(&watchdog_lock, flags); clocksource_start_watchdog(); add_timer_on(&watchdog_timer, ...); watchdog_running = 1; spin_unlock_irqrestore(&watchdog_lock, flags);
spin_lock(&watchdog_lock);
add_timer_on(&watchdog_timer, ...);
BUG_ON(timer_pending(timer) || !timer->function);
timer_pending() -> true
BUG()I.e. inside clocksource_watchdog() watchdog_timer could be already armed.
Check timer_pending() before calling add_timer_on(). This is sufficient as all operations are synchronized by watchdog_lock.
--- kernel/time/clocksource.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/time/clocksource.c +9 -2
@@ -293,8 +293,15 @@ static void clocksource_watchdog(struct next_cpu =cpumask_next (raw_smp_processor_id (), cpu_online_mask);if (next_cpu >= nr_cpu_ids) next_cpu =cpumask_first (cpu_online_mask); - watchdog_timer.expires +=WATCHDOG_INTERVAL ; -add_timer_on (&watchdog_timer, next_cpu); + +/* +* Arm timer if not already pending: could race with concurrent +* pair clocksource_stop_watchdog() clocksource_start_watchdog(). +*/ +if (!timer_pending (&watchdog_timer)) { + watchdog_timer.expires +=WATCHDOG_INTERVAL ; +add_timer_on (&watchdog_timer, next_cpu); + } out:spin_unlock (&watchdog_lock); }
Greg Kroah-Hartman
maintainerPATCH 349/367 x86/apic/msi: Plug non-maskable MSI affinity race
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 6f1a4891a5928a5969c87fa5a584844c983ec823 upstream.
Evan tracked down a subtle race between the update of the MSI message and the device raising an interrupt internally on PCI devices which do not support MSI masking. The update of the MSI message is non-atomic and consists of either 2 or 3 sequential 32bit wide writes to the PCI config space.
- Write address low 32bits
- Write address high 32bits (If supported by device)
- Write data
When an interrupt is migrated then both address and data might change, so the kernel attempts to mask the MSI interrupt first. But for MSI masking is optional, so there exist devices which do not provide it. That means that if the device raises an interrupt internally between the writes then a MSI message is sent built from half updated state.
On x86 this can lead to spurious interrupts on the wrong interrupt vector when the affinity setting changes both address and data. As a consequence the device interrupt can be lost causing the device to become stuck or malfunctioning.
Evan tried to handle that by disabling MSI accross an MSI message update. That's not feasible because disabling MSI has issues on its own:
If MSI is disabled the PCI device is routing an interrupt to the legacy INTx mechanism. The INTx delivery can be disabled, but the disablement is not working on all devices.
Some devices lose interrupts when both MSI and INTx delivery are disabled.
Another way to solve this would be to enforce the allocation of the same vector on all CPUs in the system for this kind of screwed devices. That could be done, but it would bring back the vector space exhaustion problems which got solved a few years ago.
Fortunately the high address (if supported by the device) is only relevant when X2APIC is enabled which implies interrupt remapping. In the interrupt remapping case the affinity setting is happening at the interrupt remapping unit and the PCI MSI message is programmed only once when the PCI device is initialized.
That makes it possible to solve it with a two step update:
1) Target the MSI msg to the new vector on the current target CPU
2) Target the MSI msg to the new vector on the new target CPU
In both cases writing the MSI message is only changing a single 32bit word which prevents the issue of inconsistency.
After writing the final destination it is necessary to check whether the device issued an interrupt while the intermediate state #1 (new vector, current CPU) was in effect.
This is possible because the affinity change is always happening on the current target CPU. The code runs with interrupts disabled, so the interrupt can be detected by checking the IRR of the local APIC. If the vector is pending in the IRR then the interrupt is retriggered on the new target CPU by sending an IPI for the associated vector on the target CPU.
This can cause spurious interrupts on both the local and the new target CPU.
1) If the new vector is not in use on the local CPU and the device affected by the affinity change raised an interrupt during the transitional state (step #1 above) then interrupt entry code will ignore that spurious interrupt. The vector is marked so that the 'No irq handler for vector' warning is supressed once.
2) If the new vector is in use already on the local CPU then the IRR check might see an pending interrupt from the device which is using this vector. The IPI to the new target CPU will then invoke the handler of the device, which got the affinity change, even if that device did not issue an interrupt
3) If the new vector is in use already on the local CPU and the device affected by the affinity change raised an interrupt during the transitional state (step #1 above) then the handler of the device which uses that vector on the local CPU will be invoked.
expose issues in device driver interrupt handlers which are not prepared to handle a spurious interrupt correctly. This not a regression, it's just exposing something which was already broken as spurious interrupts can happen for a lot of reasons and all driver handlers need to be able to deal with them.
--- arch/x86/include/asm/apic.h | 8 ++ arch/x86/kernel/apic/msi.c | 128 ++++++++++++++++++++++++++++++++++++++++++-- include/linux/irq.h | 18 ++++++ include/linux/irqdomain.h | 7 ++ kernel/irq/debugfs.c | 1 kernel/irq/msi.c | 5 + 6 files changed, 163 insertions(+), 4 deletions(-)
arch/x86/include/asm/apic.h +8 -0
@@ -454,6 +454,14 @@ static inline void ack_APIC_irq(void)apic_eoi (); } + +static inline bool lapic_vector_set_in_irr (unsigned int vector) +{ +u32 irr =apic_read (APIC_IRR + (vector /32 *0x10 )); + +return !!(irr & (1U << (vector %32 ))); +} +static inline unsigned default_get_apic_id (unsigned long x) {unsigned int ver =GET_APIC_VERSION (apic_read (APIC_LVR ));
arch/x86/kernel/apic/msi.c +125 -3
153 lines not on this page · raw message
include/linux/irq.h +18 -0
@@ -209,6 +209,8 @@ struct irq_data {* IRQD_SINGLE_TARGET - IRQ allows only a single affinity target * IRQD_DEFAULT_TRIGGER_SET - Expected trigger already been set * IRQD_CAN_RESERVE - Can use reservation mode +* IRQD_MSI_NOMASK_QUIRK - Non-maskable MSI quirk for affinity change +* required */ enum {IRQD_TRIGGER_MASK =0xf ,
@@ -231,6 +233,7 @@ enum {IRQD_SINGLE_TARGET = (1 <<24 ),IRQD_DEFAULT_TRIGGER_SET = (1 <<25 ),IRQD_CAN_RESERVE = (1 <<26 ), + IRQD_MSI_NOMASK_QUIRK = (1 << 27), };#define __irqd_to_state (d) ACCESS_PRIVATE((d)->common, state_use_accessors)
@@ -390,6 +393,21 @@ static inline bool irqd_can_reserve(strureturn __irqd_to_state (d) &IRQD_CAN_RESERVE ; } +static inline void irqd_set_msi_nomask_quirk (struct irq_data *d) +{ +__irqd_to_state (d) |=IRQD_MSI_NOMASK_QUIRK ; +} + +static inline void irqd_clr_msi_nomask_quirk (struct irq_data *d) +{ +__irqd_to_state (d) &= ~IRQD_MSI_NOMASK_QUIRK ; +} + +static inline bool irqd_msi_nomask_quirk (struct irq_data *d) +{ +return __irqd_to_state (d) &IRQD_MSI_NOMASK_QUIRK ; +} +#undef __irqd_to_statestatic inline irq_hw_number_t irqd_to_hwirq (struct irq_data *d)
include/linux/irqdomain.h +7 -0
@@ -207,6 +207,13 @@ enum {IRQ_DOMAIN_FLAG_MSI_REMAP = (1 <<5 ),/* +* Quirk to handle MSI implementations which do not provide +* masking. Currently known to affect x86, but partially +* handled in core code. +*/ + IRQ_DOMAIN_MSI_NOMASK_QUIRK = (1 << 6), + +/* * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved * for implementation specific purposes and ignored by the * core code.
kernel/irq/debugfs.c +1 -0
@@ -114,6 +114,7 @@ static const struct irq_bit_descr irqdatBIT_MASK_DESCR (IRQD_AFFINITY_MANAGED ),BIT_MASK_DESCR (IRQD_MANAGED_SHUTDOWN ),BIT_MASK_DESCR (IRQD_CAN_RESERVE ), +BIT_MASK_DESCR (IRQD_MSI_NOMASK_QUIRK ), BIT_MASK_DESCR(IRQD_FORWARDED_TO_VCPU),
kernel/irq/msi.c +4 -1
@@ -453,8 +453,11 @@ int msi_domain_alloc_irqs(struct irq_domcontinue ; irq_data =irq_domain_get_irq_data (domain, desc->irq); -if (!can_reserve) +if (!can_reserve) {irqd_clr_can_reserve (irq_data); +if (domain->flags &IRQ_DOMAIN_MSI_NOMASK_QUIRK ) +irqd_set_msi_nomask_quirk (irq_data); + } ret =irq_domain_activate_irq (irq_data, can_reserve);if (ret) goto cleanup;
Greg Kroah-Hartman
maintainerPATCH 347/367 cifs: fail i/o on soft mounts if sessionsetup errors out
In reply to Greg Kroah-HartmanFrom: Ronnie Sahlberg <[email protected]>
commit b0dd940e582b6a60296b9847a54012a4b080dc72 upstream.
RHBZ: 1579050
If we have a soft mount we should fail commands for session-setup failures (such as the password having changed/ account being deleted/ ...) and return an error back to the application.
--- fs/cifs/smb2pdu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +8 -2
@@ -350,9 +350,14 @@ smb2_reconnect(__le16 smb2_command, stru } rc =cifs_negotiate_protocol (0 , tcon->ses); -if (!rc && tcon->ses->need_reconnect) +if (!rc && tcon->ses->need_reconnect) { rc =cifs_setup_session (0 , tcon->ses, nls_codepage); - +if ((rc == -EACCES ) && !tcon->retry) { + rc = -EHOSTDOWN ; +mutex_unlock (&tcon->ses->session_mutex); + goto failed; + } + }if (rc || !tcon->need_reconnect) {mutex_unlock (&tcon->ses->session_mutex); goto out;
@@ -397,6 +402,7 @@ out:case SMB2_SET_INFO : rc = -EAGAIN ; } +failed:unload_nls (nls_codepage);return rc; }
Greg Kroah-Hartman
maintainerPATCH 343/367 net/mlx5: Fix deadlock in fs_core
In reply to Greg Kroah-HartmanFrom: Maor Gottlieb <[email protected]>
[ Upstream commit c1948390d78b5183ee9b7dd831efd7f6ac496ab0 ]
free_match_list could be called when the flow table is already locked. We need to pass this notation to tree_put_node.
It fixes the following lockdep warnning:
[ 1797.268537] ============================================
[ 1797.276837] WARNING: possible recursive locking detected
[ 1797.285101] 5.5.0-rc5+ #10 Not tainted
[ 1797.291641] --------------------------------------------
[ 1797.299917] handler10/9296 is trying to acquire lock:
[ 1797.307885] ffff889ad399a0a0 (&node->lock){++++}, at:
tree_put_node+0x1d5/0x210 [mlx5_core]
[ 1797.319694]
[ 1797.319694] but task is already holding lock:
[ 1797.330904] ffff889ad399a0a0 (&node->lock){++++}, at:
nested_down_write_ref_node.part.33+0x1a/0x60 [mlx5_core]
[ 1797.344707]
[ 1797.344707] other info that might help us debug this:
[ 1797.356952] Possible unsafe locking scenario:
[ 1797.356952]
[ 1797.368333] CPU0
[ 1797.373357] ----
[ 1797.378364] lock(&node->lock);
[ 1797.384222] lock(&node->lock);
[ 1797.390031]
[ 1797.390031] *** DEADLOCK ***
[ 1797.390031]
[ 1797.403003] May be due to missing lock nesting notation
[ 1797.403003]
[ 1797.414691] 3 locks held by handler10/9296:
[ 1797.421465] #0: ffff889cf2c5a110 (&block->cb_lock){++++}, at:
tc_setup_cb_add+0x70/0x250
[ 1797.432810] #1: ffff88a030081490 (&comp->sem){++++}, at:
mlx5_devcom_get_peer_data+0x4c/0xb0 [mlx5_core]
[ 1797.445829] #2: ffff889ad399a0a0 (&node->lock){++++}, at:
nested_down_write_ref_node.part.33+0x1a/0x60 [mlx5_core]
[ 1797.459913]
[ 1797.459913] stack backtrace:
[ 1797.469436] CPU: 1 PID: 9296 Comm: handler10 Kdump: loaded Not
tainted 5.5.0-rc5+ #10
[ 1797.480643] Hardware name: Dell Inc. PowerEdge R730/072T6D, BIOS
2.4.3 01/17/2017
[ 1797.491480] Call Trace:
[ 1797.496701] dump_stack+0x96/0xe0
[ 1797.502864] __lock_acquire.cold.63+0xf8/0x212
[ 1797.510301] ? lockdep_hardirqs_on+0x250/0x250
[ 1797.517701] ? mark_held_locks+0x55/0xa0
[ 1797.524547] ? quarantine_put+0xb7/0x160
[ 1797.531422] ? lockdep_hardirqs_on+0x17d/0x250
[ 1797.538913] lock_acquire+0xd6/0x1f0
[ 1797.545529] ? tree_put_node+0x1d5/0x210 [mlx5_core]
[ 1797.553701] down_write+0x94/0x140
[ 1797.560206] ? tree_put_node+0x1d5/0x210 [mlx5_core]
[ 1797.568464] ? down_write_killable_nested+0x170/0x170
[ 1797.576925] ? del_hw_flow_group+0xde/0x1f0 [mlx5_core]
[ 1797.585629] tree_put_node+0x1d5/0x210 [mlx5_core]
[ 1797.593891] ? free_match_list.part.25+0x147/0x170 [mlx5_core]
[ 1797.603389] free_match_list.part.25+0xe0/0x170 [mlx5_core]
[ 1797.612654] _mlx5_add_flow_rules+0x17e2/0x20b0 [mlx5_core]
[ 1797.621838] ? lock_acquire+0xd6/0x1f0
[ 1797.629028] ? esw_get_prio_table+0xb0/0x3e0 [mlx5_core]
[ 1797.637981] ? alloc_insert_flow_group+0x420/0x420 [mlx5_core]
[ 1797.647459] ? try_to_wake_up+0x4c7/0xc70
[ 1797.654881] ? lock_downgrade+0x350/0x350
[ 1797.662271] ? __mutex_unlock_slowpath+0xb1/0x3f0
[ 1797.670396] ? find_held_lock+0xac/0xd0
[ 1797.677540] ? mlx5_add_flow_rules+0xdc/0x360 [mlx5_core]
[ 1797.686467] mlx5_add_flow_rules+0xdc/0x360 [mlx5_core]
[ 1797.695134] ? _mlx5_add_flow_rules+0x20b0/0x20b0 [mlx5_core]
[ 1797.704270] ? irq_exit+0xa5/0x170
[ 1797.710764] ? retint_kernel+0x10/0x10
[ 1797.717698] ? mlx5_eswitch_set_rule_source_port.isra.9+0x122/0x230
[mlx5_core]
[ 1797.728708] mlx5_eswitch_add_offloaded_rule+0x465/0x6d0 [mlx5_core]
[ 1797.738713] ? mlx5_eswitch_get_prio_range+0x30/0x30 [mlx5_core]
[ 1797.748384] ? mlx5_fc_stats_work+0x670/0x670 [mlx5_core]
[ 1797.757400] mlx5e_tc_offload_fdb_rules.isra.27+0x24/0x90 [mlx5_core]
[ 1797.767665] mlx5e_tc_add_fdb_flow+0xaf8/0xd40 [mlx5_core]
[ 1797.776886] ? mlx5e_encap_put+0xd0/0xd0 [mlx5_core]
[ 1797.785562] ? mlx5e_alloc_flow.isra.43+0x18c/0x1c0 [mlx5_core]
[ 1797.795353] __mlx5e_add_fdb_flow+0x2e2/0x440 [mlx5_core]
[ 1797.804558] ? mlx5e_tc_update_neigh_used_value+0x8c0/0x8c0
[mlx5_core]
[ 1797.815093] ? wait_for_completion+0x260/0x260
[ 1797.823272] mlx5e_configure_flower+0xe94/0x1620 [mlx5_core]
[ 1797.832792] ? __mlx5e_add_fdb_flow+0x440/0x440 [mlx5_core]
[ 1797.842096] ? down_read+0x11a/0x2e0
[ 1797.849090] ? down_write+0x140/0x140
[ 1797.856142] ? mlx5e_rep_indr_setup_block_cb+0xc0/0xc0 [mlx5_core]
[ 1797.866027] tc_setup_cb_add+0x11a/0x250
[ 1797.873339] fl_hw_replace_filter+0x25e/0x320 [cls_flower]
[ 1797.882385] ? fl_hw_destroy_filter+0x1c0/0x1c0 [cls_flower]
[ 1797.891607] fl_change+0x1d54/0x1fb6 [cls_flower]
[ 1797.899772] ? __rhashtable_insert_fast.constprop.50+0x9f0/0x9f0
[cls_flower]
[ 1797.910728] ? lock_downgrade+0x350/0x350
[ 1797.918187] ? __radix_tree_lookup+0xa5/0x130
[ 1797.926046] ? fl_set_key+0x1590/0x1590 [cls_flower]
[ 1797.934611] ? __rhashtable_insert_fast.constprop.50+0x9f0/0x9f0
[cls_flower]
[ 1797.945673] tc_new_tfilter+0xcd1/0x1240
[ 1797.953138] ? tc_del_tfilter+0xb10/0xb10
[ 1797.960688] ? avc_has_perm_noaudit+0x92/0x320
[ 1797.968721] ? avc_has_perm_noaudit+0x1df/0x320
[ 1797.976816] ? avc_has_extended_perms+0x990/0x990
[ 1797.985090] ? mark_lock+0xaa/0x9e0
[ 1797.991988] ? match_held_lock+0x1b/0x240
[ 1797.999457] ? match_held_lock+0x1b/0x240
[ 1798.006859] ? find_held_lock+0xac/0xd0
[ 1798.014045] ? symbol_put_addr+0x40/0x40
[ 1798.021317] ? rcu_read_lock_sched_held+0xd0/0xd0
[ 1798.029460] ? tc_del_tfilter+0xb10/0xb10
[ 1798.036810] rtnetlink_rcv_msg+0x4d5/0x620
[ 1798.044236] ? rtnl_bridge_getlink+0x460/0x460
[ 1798.052034] ? lockdep_hardirqs_on+0x250/0x250
[ 1798.059837] ? match_held_lock+0x1b/0x240
[ 1798.067146] ? find_held_lock+0xac/0xd0
[ 1798.074246] netlink_rcv_skb+0xc6/0x1f0
[ 1798.081339] ? rtnl_bridge_getlink+0x460/0x460
[ 1798.089104] ? netlink_ack+0x440/0x440
[ 1798.096061] netlink_unicast+0x2d4/0x3b0
[ 1798.103189] ? netlink_attachskb+0x3f0/0x3f0
[ 1798.110724] ? _copy_from_iter_full+0xda/0x370
[ 1798.118415] netlink_sendmsg+0x3ba/0x6a0
[ 1798.125478] ? netlink_unicast+0x3b0/0x3b0
[ 1798.132705] ? netlink_unicast+0x3b0/0x3b0
[ 1798.139880] sock_sendmsg+0x94/0xa0
[ 1798.146332] ____sys_sendmsg+0x36c/0x3f0
[ 1798.153251] ? copy_msghdr_from_user+0x165/0x230
[ 1798.160941] ? kernel_sendmsg+0x30/0x30
[ 1798.167738] ___sys_sendmsg+0xeb/0x150
[ 1798.174411] ? sendmsg_copy_msghdr+0x30/0x30
[ 1798.181649] ? lock_downgrade+0x350/0x350
[ 1798.188559] ? rcu_read_lock_sched_held+0xd0/0xd0
[ 1798.196239] ? __fget+0x21d/0x320
[ 1798.202335] ? do_dup2+0x2a0/0x2a0
[ 1798.208499] ? lock_downgrade+0x350/0x350
[ 1798.215366] ? __fget_light+0xd6/0xf0
[ 1798.221808] ? syscall_trace_enter+0x369/0x5d0
[ 1798.229112] __sys_sendmsg+0xd3/0x160
[ 1798.235511] ? __sys_sendmsg_sock+0x60/0x60
[ 1798.242478] ? syscall_trace_enter+0x233/0x5d0
[ 1798.249721] ? syscall_slow_exit_work+0x280/0x280
[ 1798.257211] ? do_syscall_64+0x1e/0x2e0
[ 1798.263680] do_syscall_64+0x72/0x2e0
[ 1798.269950] entry_SYSCALL_64_after_hwframe+0x49/0xbe--- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +8 -7
@@ -1555,16 +1555,16 @@ struct match_list_head {struct match_list first; }; -static void free_match_list (struct match_list_head *head) +static void free_match_list (struct match_list_head *head,bool ft_locked) {if (!list_empty (&head->list)) {struct match_list *iter, *match_tmp;list_del (&head->first.list); -tree_put_node (&head->first.g->node, false); +tree_put_node (&head->first.g->node, ft_locked);list_for_each_entry_safe (iter, match_tmp, &head->list, list) { -tree_put_node (&iter->g->node, false); +tree_put_node (&iter->g->node, ft_locked);list_del (&iter->list);kfree (iter); }
@@ -1573,7 +1573,8 @@ static void free_match_list(struct matchstatic int build_match_list (struct match_list_head *match_head,struct mlx5_flow_table *ft, -const struct mlx5_flow_spec *spec) +const struct mlx5_flow_spec *spec, +bool ft_locked) {struct rhlist_head *tmp, *list;struct mlx5_flow_group *g;
@@ -1598,7 +1599,7 @@ static int build_match_list(struct match curr_match =kmalloc (sizeof (*curr_match),GFP_ATOMIC );if (!curr_match) { -free_match_list (match_head); +free_match_list (match_head, ft_locked); err = -ENOMEM ; goto out; }
@@ -1778,7 +1779,7 @@ search_again_locked: version =atomic_read (&ft->node.version);/* Collect all fgs which has a matching match_criteria */ - err =build_match_list (&match_head, ft, spec); + err =build_match_list (&match_head, ft, spec, take_write);if (err) {if (take_write)up_write_ref_node (&ft->node, false);
@@ -1792,7 +1793,7 @@ search_again_locked: rule =try_add_to_existing_fg (ft, &match_head.list, spec, flow_act, dest, dest_num, version); -free_match_list (&match_head); +free_match_list (&match_head, take_write);if (!IS_ERR (rule) || (PTR_ERR (rule) != -ENOENT &&PTR_ERR (rule) != -EAGAIN )) {if (take_write)
Greg Kroah-Hartman
maintainerPATCH 346/367 net/mlx5e: TX, Error completion is for last WQE in batch
In reply to Greg Kroah-HartmanFrom: Tariq Toukan <[email protected]>
[ Upstream commit b57e66ad42d051ed31319c28ed1b62b191299a29 ]
For a cyclic work queue, when not requesting a completion per WQE, a single CQE might indicate the completion of several WQEs. However, in case some WQE in the batch causes an error, then an error completion is issued, breaking the batch, and pointing to the offending WQE in the wqe_counter field.
Hence, WQE-specific error CQE handling (like printing, breaking, etc...) should be performed only for the last WQE in batch.
--- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 16 ++++++----- drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 33 ++++++++++-------------- 2 files changed, 23 insertions(+), 26 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +9 -7
@@ -613,13 +613,6 @@ void mlx5e_poll_ico_cq(struct mlx5e_cq * wqe_counter =be16_to_cpu (cqe->wqe_counter); -if (unlikely (get_cqe_opcode (cqe) !=MLX5_CQE_REQ )) { -netdev_WARN_ONCE (cq->channel->netdev, -"Bad OP in ICOSQ CQE: 0x%x\n" ,get_cqe_opcode (cqe)); -if (!test_and_set_bit (MLX5E_SQ_STATE_RECOVERING , &sq->state)) -queue_work (cq->channel->priv->wq, &sq->recover_work); -break ; - } do { struct mlx5e_sq_wqe_info *wi; u16 ci;
@@ -629,6 +622,15 @@ void mlx5e_poll_ico_cq(struct mlx5e_cq * ci =mlx5_wq_cyc_ctr2ix (&sq->wq, sqcc); wi = &sq->db.ico_wqe[ci]; +if (last_wqe &&unlikely (get_cqe_opcode (cqe) !=MLX5_CQE_REQ )) { +netdev_WARN_ONCE (cq->channel->netdev, +"Bad OP in ICOSQ CQE: 0x%x\n" , +get_cqe_opcode (cqe)); +if (!test_and_set_bit (MLX5E_SQ_STATE_RECOVERING , &sq->state)) +queue_work (cq->channel->priv->wq, &sq->recover_work); +break ; + } +if (likely (wi->opcode ==MLX5_OPCODE_UMR )) { sqcc +=MLX5E_UMR_WQEBBS ; wi->umr.rq->mpwqe.umr_completed++;
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +14 -19
@@ -451,34 +451,17 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *c i =0 ; do { + struct mlx5e_tx_wqe_info *wi; u16 wqe_counter; bool last_wqe; + u16 ci; mlx5_cqwq_pop(&cq->wq); wqe_counter = be16_to_cpu(cqe->wqe_counter); - if (unlikely(get_cqe_opcode(cqe) == MLX5_CQE_REQ_ERR)) { - if (!test_and_set_bit(MLX5E_SQ_STATE_RECOVERING, - &sq->state)) { - struct mlx5e_tx_wqe_info *wi; - u16 ci; - - ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sqcc); - wi = &sq->db.wqe_info[ci]; - mlx5e_dump_error_cqe(sq, - (struct mlx5_err_cqe *)cqe); - mlx5_wq_cyc_wqe_dump(&sq->wq, ci, wi->num_wqebbs); - queue_work(cq->channel->priv->wq, - &sq->recover_work); - } - stats->cqe_err++; - } - do { - struct mlx5e_tx_wqe_info *wi; struct sk_buff *skb; - u16 ci; int j; last_wqe = (sqcc == wqe_counter);
@@ -516,6 +499,18 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cnapi_consume_skb (skb, napi_budget); }while (!last_wqe); +if (unlikely (get_cqe_opcode (cqe) ==MLX5_CQE_REQ_ERR )) { +if (!test_and_set_bit (MLX5E_SQ_STATE_RECOVERING , + &sq->state)) { +mlx5e_dump_error_cqe (sq, + (struct mlx5_err_cqe *)cqe); +mlx5_wq_cyc_wqe_dump (&sq->wq, ci, wi->num_wqebbs); +queue_work (cq->channel->priv->wq, + &sq->recover_work); + } + stats->cqe_err++; + } + }while ((++i <MLX5E_TX_CQ_POLL_BUDGET ) && (cqe =mlx5_cqwq_get_cqe (&cq->wq))); stats->cqes += i;
Greg Kroah-Hartman
maintainerPATCH 344/367 net/mlx5: Deprecate usage of generic TLS HW capability bit
In reply to Greg Kroah-HartmanFrom: Tariq Toukan <[email protected]>
[ Upstream commit 61c00cca41aeeaa8e5263c2f81f28534bc1efafb ]
Deprecate the generic TLS cap bit, use the new TX-specific TLS cap bit instead.
--- drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/fw.c | 2 +- include/linux/mlx5/mlx5_ifc.h | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h +1 -1
@@ -45,7 +45,7 @@ void mlx5_ktls_destroy_key(struct mlx5_cstatic inline bool mlx5_accel_is_ktls_device (struct mlx5_core_dev *mdev) { -if (!MLX5_CAP_GEN (mdev, tls)) +if (!MLX5_CAP_GEN (mdev, tls_tx))return false;if (!MLX5_CAP_GEN (mdev, log_max_dek))
drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c +1 -1
@@ -269,7 +269,7 @@ struct sk_buff *mlx5e_tls_handle_tx_skb(int datalen;u32 skb_seq; -if (MLX5_CAP_GEN (sq->channel->mdev, tls)) { +if (MLX5_CAP_GEN (sq->channel->mdev, tls_tx)) { skb =mlx5e_ktls_handle_tx_skb (netdev, sq, skb, wqe, pi); goto out; }
drivers/net/ethernet/mellanox/mlx5/core/fw.c +1 -1
@@ -239,7 +239,7 @@ int mlx5_query_hca_caps(struct mlx5_corereturn err; } -if (MLX5_CAP_GEN (dev, tls)) { +if (MLX5_CAP_GEN (dev, tls_tx)) { err =mlx5_core_get_caps (dev,MLX5_CAP_TLS );if (err)return err;
include/linux/mlx5/mlx5_ifc.h +4 -3
@@ -1418,14 +1418,15 @@ struct mlx5_ifc_cmd_hca_cap_bits {u8 reserved_at_440[0x20 ]; -u8 tls[0x1 ]; -u8 reserved_at_461[0x2 ]; +u8 reserved_at_460[0x3 ];u8 log_max_uctx[0x5 ];u8 reserved_at_468[0x3 ];u8 log_max_umem[0x5 ];u8 max_num_eqs[0x10 ]; -u8 reserved_at_480[0x3 ]; +u8 reserved_at_480[0x1 ]; +u8 tls_tx[0x1 ]; +u8 reserved_at_482[0x1 ];u8 log_max_l2_table[0x5 ];u8 reserved_at_488[0x8 ];u8 log_uar_page_sz[0x10 ];
Greg Kroah-Hartman
maintainerPATCH 289/367 drm: msm: mdp4: Adjust indentation in mdp4_dsi_encoder_enable
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 251e3cb1418ff3f5061ee31335e346e852b16573 upstream.
Clang warns:
../drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c:124:3: warning:
misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
mdp4_crtc_set_config(encoder->crtc,
^
../drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c:121:2: note:
previous statement is here
if (mdp4_dsi_encoder->enabled)
^This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c +1 -1
@@ -121,7 +121,7 @@ static void mdp4_dsi_encoder_enable(struif (mdp4_dsi_encoder->enabled)return ; - mdp4_crtc_set_config(encoder->crtc, + mdp4_crtc_set_config(encoder->crtc, MDP4_DMA_CONFIG_PACK_ALIGN_MSB | MDP4_DMA_CONFIG_DEFLKR_EN | MDP4_DMA_CONFIG_DITHER_EN |
Greg Kroah-Hartman
maintainerPATCH 298/367 nfsd: fix delay timer on 32-bit architectures
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 2561c92b12f4f4e386d453556685f75775c0938b upstream.
The nfsd4_cb_layout_done() function takes a 'time_t' value, multiplied by NSEC_PER_SEC*2 to get a nanosecond value.
This works fine on 64-bit architectures, but on 32-bit, any value over 1 second results in a signed integer overflow with unexpected results.
Cast one input to a 64-bit type in order to produce the same result that we have on 64-bit architectures, regarless of the type of nfsd4_lease.
--- fs/nfsd/nfs4layouts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4layouts.c +1 -1
@@ -675,7 +675,7 @@ nfsd4_cb_layout_done(struct nfsd4_callba/* Client gets 2 lease periods to return it */ cutoff =ktime_add_ns (task->tk_start, - nn->nfsd4_lease *NSEC_PER_SEC *2 ); + (u64 )nn->nfsd4_lease *NSEC_PER_SEC *2 );if (ktime_before (now, cutoff)) {rpc_delay (task,HZ /100 );/* 10 mili-seconds */
Greg Kroah-Hartman
maintainerPATCH 296/367 IB/core: Fix ODP with IB_ACCESS_HUGETLB handling
In reply to Greg Kroah-HartmanFrom: Yishai Hadas <[email protected]>
commit 9ff1b6466a291a33389c4a9c7f3f9b64d62df40a upstream.
As VMAs for a given range might not be available as part of the registration phase in ODP.
ib_init_umem_odp() considered the expected page shift value that was previously set and initializes its internals accordingly.
If memory isn't backed by physical contiguous pages aligned to a hugepage boundary an error will be set as part of the page fault flow and come back to the user as some failed RDMA operation.
--- drivers/infiniband/core/umem_odp.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/infiniband/core/umem_odp.c +4 -17
@@ -241,22 +241,10 @@ struct ib_umem_odp *ib_umem_odp_get(stru umem_odp->umem.owning_mm = mm = current->mm; umem_odp->notifier.ops = ops; - umem_odp->page_shift =PAGE_SHIFT ; -if (access &IB_ACCESS_HUGETLB ) { -struct vm_area_struct *vma; -struct hstate *h; - -down_read (&mm->mmap_sem); - vma =find_vma (mm,ib_umem_start (umem_odp)); -if (!vma || !is_vm_hugetlb_page (vma)) { -up_read (&mm->mmap_sem); - ret = -EINVAL ; - goto err_free; - } - h =hstate_vma (vma); - umem_odp->page_shift =huge_page_shift (h); -up_read (&mm->mmap_sem); - } +if (access &IB_ACCESS_HUGETLB ) + umem_odp->page_shift =HPAGE_SHIFT ; +else + umem_odp->page_shift =PAGE_SHIFT ; umem_odp->tgid =get_task_pid (current->group_leader,PIDTYPE_PID ); ret =ib_init_umem_odp (umem_odp, ops);
@@ -266,7 +254,6 @@ struct ib_umem_odp *ib_umem_odp_get(stru err_put_pid:put_pid (umem_odp->tgid); -err_free:kfree (umem_odp);return ERR_PTR (ret); }
Greg Kroah-Hartman
maintainerPATCH 297/367 staging: wfx: revert unexpected change in debugfs output
In reply to Greg Kroah-HartmanFrom: Jérôme Pouiller <[email protected]>
commit 8b08b6a8c31f18c3657405410e4c3f6bc4fa75f1 upstream.
It appears that commit 8c7128c4cf4e ("staging: align to fix warnings of line over 80 characters") do slightly more than what is explained in commit log.
Especially, it changes the output of the file rx_stats from debugfs.
Quoted 1 line
From some point of view, this file can be considered as a part of the
API. Any change on it should be clearly announced.
Since the change introduced does not seems to have any justification, revert it.
--- drivers/staging/wfx/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wfx/debug.c +1 -1
@@ -145,7 +145,7 @@ static int wfx_rx_stats_show(struct seq_ st->pwr_clk_freq, st->is_ext_pwr_clk ? "yes" : "no");seq_printf (seq, -"N. of frames: %d, PER (x10e4): %d, Throughput: %dKbps/s\n" , +"Num. of frames: %d, PER (x10e4): %d, Throughput: %dKbps/s\n" , st->nb_rx_frame, st->per_total, st->throughput);seq_puts (seq," Num. of PER RSSI SNR CFO\n" );seq_puts (seq," frames (x10e4) (dBm) (dB) (kHz)\n" );
Greg Kroah-Hartman
maintainerPATCH 294/367 IB/mlx5: Fix outstanding_pi index for GSI qps
In reply to Greg Kroah-HartmanFrom: Prabhath Sajeepa <[email protected]>
commit b5671afe5e39ed71e94eae788bacdcceec69db09 upstream.
Commit b0ffeb537f3a ("IB/mlx5: Fix iteration overrun in GSI qps") changed the way outstanding WRs are tracked for the GSI QP. But the fix did not cover the case when a call to ib_post_send() fails and updates index to track outstanding.
Since the prior commmit outstanding_pi should not be bounded otherwise the loop generate_completions() will fail.
--- drivers/infiniband/hw/mlx5/gsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/gsi.c +1 -2
@@ -507,8 +507,7 @@ int mlx5_ib_gsi_post_send(struct ib_qp * ret =ib_post_send (tx_qp, &cur_wr.wr, bad_wr);if (ret) {/* Undo the effect of adding the outstanding wr */ - gsi->outstanding_pi = (gsi->outstanding_pi -1 ) % - gsi->cap.max_send_wr; + gsi->outstanding_pi--; goto err; }spin_unlock_irqrestore (&gsi->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 331/367 net: stmmac: xgmac: fix incorrect XGMAC_VLAN_TAG register writting
In reply to Greg Kroah-HartmanFrom: Ong Boon Leong <[email protected]>
[ Upstream commit 907a076881f171254219faad05f46ac5baabedfb ]
We should always do a read of current value of XGMAC_VLAN_TAG instead of directly overwriting the register value.
--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +6 -2
@@ -569,7 +569,9 @@ static void dwxgmac2_update_vlan_hash(stwritel (value, ioaddr +XGMAC_PACKET_FILTER ); - value =XGMAC_VLAN_VTHM |XGMAC_VLAN_ETV ; + value =readl (ioaddr +XGMAC_VLAN_TAG ); + + value |=XGMAC_VLAN_VTHM |XGMAC_VLAN_ETV ;if (is_double) { value |=XGMAC_VLAN_EDVLP ; value |=XGMAC_VLAN_ESVL ;
@@ -584,7 +586,9 @@ static void dwxgmac2_update_vlan_hash(stwritel (value, ioaddr +XGMAC_PACKET_FILTER ); - value =XGMAC_VLAN_ETV ; + value =readl (ioaddr +XGMAC_VLAN_TAG ); + + value |=XGMAC_VLAN_ETV ;if (is_double) { value |=XGMAC_VLAN_EDVLP ; value |=XGMAC_VLAN_ESVL ;
Greg Kroah-Hartman
maintainerPATCH 328/367 net: macb: Remove unnecessary alignment check for TSO
In reply to Greg Kroah-HartmanFrom: Harini Katakam <[email protected]>
[ Upstream commit 41c1ef978c8d0259c6636e6d2d854777e92650eb ]
The IP TSO implementation does NOT require the length to be a multiple of 8. That is only a requirement for UFO as per IP documentation. Hence, exit macb_features_check function in the beginning if the protocol is not UDP. Only when it is UDP, proceed further to the alignment checks. Update comments to reflect the same. Also remove dead code checking for protocol TCP when calculating header length.
--- drivers/net/ethernet/cadence/macb_main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +3 -5
@@ -1752,16 +1752,14 @@ static netdev_features_t macb_features_c/* Validate LSO compatibility */ -/* there is only one buffer */ -if (!skb_is_nonlinear (skb)) +/* there is only one buffer or protocol is not UDP */ +if (!skb_is_nonlinear (skb) || (ip_hdr (skb)->protocol !=IPPROTO_UDP ))return features;/* length of header */ hdrlen =skb_transport_offset (skb); -if (ip_hdr (skb)->protocol ==IPPROTO_TCP ) - hdrlen +=tcp_hdrlen (skb); -/* For LSO: +/* For UFO only: * When software supplies two or more payload buffers all payload buffers * apart from the last must be a multiple of 8 bytes in size. */
Greg Kroah-Hartman
maintainerPATCH 325/367 net: systemport: Avoid RBUF stuck in Wake-on-LAN mode
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 263a425a482fc495d6d3f9a29b9103a664c38b69 ]
After a number of suspend and resume cycles, it is possible for the RBUF to be stuck in Wake-on-LAN mode, despite the MPD enable bit being cleared which instructed the RBUF to exit that mode.
Avoid creating that problematic condition by clearing the RX_EN and TX_EN bits in the UniMAC prior to disable the Magic Packet Detector logic which is guaranteed to make the RBUF exit Wake-on-LAN mode.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/bcmsysport.c +3 -0
@@ -2728,6 +2728,9 @@ static int __maybe_unused bcm_sysport_reumac_reset (priv); +/* Disable the UniMAC RX/TX */ +umac_enable_set (priv,CMD_RX_EN |CMD_TX_EN ,0 ); +/* We may have been suspended and never received a WOL event that * would turn off MPD detection, take care of that now */
Greg Kroah-Hartman
maintainerPATCH 324/367 net: stmmac: fix a possible endless loop
In reply to Greg Kroah-HartmanFrom: Dejin Zheng <[email protected]>
[ Upstream commit 7d10f0774f9e32aa2f2e012f7fcb312a2ce422b9 ]
It forgot to reduce the value of the variable retry in a while loop in the ethqos_configure() function. It may cause an endless loop and without timeout.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +1 -0
@@ -413,6 +413,7 @@ static int ethqos_configure(struct qcom_ dll_lock =rgmii_readl (ethqos,SDC4_STATUS );if (dll_lock &SDC4_STATUS_DLL_LOCK )break ; + retry--; }while (retry >0 );if (!retry) dev_err(ðqos->pdev->dev,
Greg Kroah-Hartman
maintainerPATCH 320/367 net: dsa: bcm_sf2: Only 7278 supports 2Gb/sec IMP port
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit de34d7084edd069dac5aa010cfe32bd8c4619fa6 ]
The 7445 switch clocking profiles do not allow us to run the IMP port at 2Gb/sec in a way that it is reliable and consistent. Make sure that the setting is only applied to the 7278 family.
--- drivers/net/dsa/bcm_sf2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/dsa/bcm_sf2.c +3 -1
@@ -68,7 +68,9 @@ static void bcm_sf2_imp_setup(struct dsa/* Force link status for IMP port */ reg =core_readl (priv, offset); - reg |= (MII_SW_OR |LINK_STS |GMII_SPEED_UP_2G ); + reg |= (MII_SW_OR |LINK_STS ); +if (priv->type ==BCM7278_DEVICE_ID ) + reg |=GMII_SPEED_UP_2G ;core_writel (priv, reg, offset);/* Enable Broadcast, Multicast, Unicast forwarding to IMP port */
Greg Kroah-Hartman
maintainerPATCH 318/367 dpaa_eth: support all modes with rate adapting PHYs
In reply to Greg Kroah-HartmanFrom: Madalin Bucur <[email protected]>
[ Upstream commit 73a21fa817f0cc8022dc6226250a86bca727a56d ]
Stop removing modes that are not supported on the system interface when the connected PHY is capable of rate adaptation. This addresses an issue with the LS1046ARDB board 10G interface no longer working with an 1G link partner after autonegotiation support was added for the Aquantia PHY on board in
commit 09c4c57f7bc4 ("net: phy: aquantia: add support for auto-negotiation configuration")
Before this commit the values advertised by the PHY were not influenced by the dpaa_eth driver removal of system-side unsupported modes as the aqr_config_aneg() was basically a no-op. After this commit, the modes removed by the dpaa_eth driver were no longer advertised thus autonegotiation with 1G link partners failed.
--- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +11 -3
@@ -2453,6 +2453,9 @@ static void dpaa_adjust_link(struct net_ mac_dev->adjust_link (mac_dev); } +/* The Aquantia PHYs are capable of performing rate adaptation */ +#define PHY_VEND_AQUANTIA 0x03a1b400 +static int dpaa_phy_init (struct net_device *net_dev) {__ETHTOOL_DECLARE_LINK_MODE_MASK (mask) = {0 , };
@@ -2471,9 +2474,14 @@ static int dpaa_phy_init(struct net_devireturn -ENODEV ; } -/* Remove any features not supported by the controller */ -ethtool_convert_legacy_u32_to_link_mode (mask, mac_dev->if_support); -linkmode_and (phy_dev->supported, phy_dev->supported, mask); +/* Unless the PHY is capable of rate adaptation */ +if (mac_dev->phy_if !=PHY_INTERFACE_MODE_XGMII || + ((phy_dev->drv->phy_id &GENMASK (31 ,10 )) !=PHY_VEND_AQUANTIA )) { +/* remove any features not supported by the controller */ +ethtool_convert_legacy_u32_to_link_mode (mask, + mac_dev->if_support); +linkmode_and (phy_dev->supported, phy_dev->supported, mask); + }phy_support_asym_pause (phy_dev);
Greg Kroah-Hartman
maintainerPATCH 317/367 devlink: report 0 after hitting end in region read
In reply to Greg Kroah-HartmanFrom: Jacob Keller <[email protected]>
[ Upstream commit d5b90e99e1d51b7b5d2b74fbc4c2db236a510913 ]
commit fdd41ec21e15 ("devlink: Return right error code in case of errors for region read") modified the region read code to report errors properly in unexpected cases.
In the case where the start_offset and ret_offset match, it unilaterally converted this into an error. This causes an issue for the "dump" version of the command. In this case, the devlink region dump will always report an invalid argument:
000000000000ffd0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 000000000000ffe0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff devlink answers: Invalid argument000000000000fff0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
This occurs because the expected flow for the dump is to return 0 after there is no further data.
The simplest fix would be to stop converting the error code to -EINVAL if start_offset == ret_offset. However, avoid unnecessary work by checking for when start_offset is larger than the region size and returning 0 upfront.
--- net/core/devlink.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/core/devlink.c +6 -0
@@ -3986,6 +3986,12 @@ static int devlink_nl_cmd_region_read_du goto out_unlock; } +/* return 0 if there is no further data to read */ +if (start_offset >= region->size) { + err =0 ; + goto out_unlock; + } + hdr =genlmsg_put (skb,NETLINK_CB (cb->skb).portid, cb->nlh->nlmsg_seq, &devlink_nl_family,NLM_F_ACK |NLM_F_MULTI ,DEVLINK_CMD_REGION_READ );
Greg Kroah-Hartman
maintainerPATCH 313/367 bpf: Fix trampoline usage in preempt
In reply to Greg Kroah-HartmanFrom: Alexei Starovoitov <[email protected]>
commit 05d57f1793fb250c85028c9952c3720010baa853 upstream.
Though the second half of trampoline page is unused a task could be preempted in the middle of the first half of trampoline and two updates to trampoline would change the code from underneath the preempted task. Hence wait for tasks to voluntarily schedule or go to userspace. Add similar wait before freeing the trampoline.
--- kernel/bpf/trampoline.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/bpf/trampoline.c +10 -0
@@ -150,6 +150,14 @@ static int bpf_trampoline_update(structif (fexit_cnt) flags =BPF_TRAMP_F_CALL_ORIG |BPF_TRAMP_F_SKIP_FRAME ; +/* Though the second half of trampoline page is unused a task could be +* preempted in the middle of the first half of trampoline and two +* updates to trampoline would change the code from underneath the +* preempted task. Hence wait for tasks to voluntarily schedule or go +* to userspace. +*/ +synchronize_rcu_tasks (); + err = arch_prepare_bpf_trampoline(new_image, &tr->func.model, flags, fentry, fentry_cnt, fexit, fexit_cnt,
@@ -240,6 +248,8 @@ void bpf_trampoline_put(struct bpf_tramp goto out;if (WARN_ON_ONCE (!hlist_empty (&tr->progs_hlist[BPF_TRAMP_FEXIT ]))) goto out; +/* wait for tasks to get out of trampoline before freeing it */ +synchronize_rcu_tasks ();bpf_jit_free_exec (tr->image);hlist_del (&tr->hlist);kfree (tr);
Greg Kroah-Hartman
maintainerPATCH 312/367 mfd: ab8500: Fix ab8500-clk typo
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
commit 702204c22c53f94b2e25a3bdcda759cce7b26305 upstream.
Commit f4d41ad84433 ("mfd: ab8500: Example using new OF_MFD_CELL MACRO") has a typo error renaming "ab8500-clk" to "abx500-clk"
with the result att ALSA SoC audio broke as the clock
driver was not probing anymore. Fixed it up.
--- drivers/mfd/ab8500-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/ab8500-core.c +2 -2
@@ -631,8 +631,8 @@ static const struct mfd_cell ab8500_devs NULL, NULL, 0, 0, "stericsson,ab8500-ext-regulator"),OF_MFD_CELL ("ab8500-regulator" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-regulator" ), -OF_MFD_CELL ("abx500-clk" , -NULL ,NULL ,0 ,0 ,"stericsson,abx500-clk" ), +OF_MFD_CELL ("ab8500-clk" , +NULL ,NULL ,0 ,0 ,"stericsson,ab8500-clk" ),OF_MFD_CELL ("ab8500-gpadc" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-gpadc" ), OF_MFD_CELL("ab8500-rtc",
Greg Kroah-Hartman
maintainerPATCH 314/367 libbpf: Extract and generalize CPU mask parsing logic
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
commit 6803ee25f0ead1e836808acb14396bb9a9849113 upstream.
This logic is re-used for parsing a set of online CPUs. Having it as an isolated piece of code working with input string makes it conveninent to test this logic as well. While refactoring, also improve the robustness of original implementation.
--- tools/lib/bpf/libbpf.c | 127 ++++++++++++++++++++++++++-------------- tools/lib/bpf/libbpf_internal.h | 2 2 files changed, 87 insertions(+), 42 deletions(-)
tools/lib/bpf/libbpf.c +85 -42
@@ -6542,61 +6542,104 @@ void bpf_program__bpil_offs_to_addr(stru } } -int libbpf_num_possible_cpus (void ) +int parse_cpu_mask_str (const char *s,bool **mask,int *mask_sz) { -static const char *fcpu ="/sys/devices/system/cpu/possible" ; -int len =0 , n =0 , il =0 , ir =0 ; -unsigned int start =0 , end =0 ; -int tmp_cpus =0 ; -static int cpus; -char buf[128 ]; -int error =0 ; -int fd =-1 ; +int err =0 , n, len, start, end =-1 ; +bool *tmp; - tmp_cpus =READ_ONCE (cpus); -if (tmp_cpus >0 ) -return tmp_cpus; + *mask =NULL ; + *mask_sz =0 ; + +/* Each sub string separated by ',' has format \d+-\d+ or \d+ */ +while (*s) { +if (*s ==',' || *s =='\n' ) { + s++; +continue ; + } + n =sscanf (s,"%d%n-%d%n" , &start, &len, &end, &len); +if (n <=0 || n >2 ) { +pr_warn ("Failed to get CPU range %s: %d\n" , s, n); + err = -EINVAL ; + goto cleanup; + }else if (n ==1 ) { + end = start; + } +if (start <0 || start > end) { +pr_warn ("Invalid CPU range [%d,%d] in %s\n" , + start, end, s); + err = -EINVAL ; + goto cleanup; + } + tmp =realloc (*mask, end +1 ); +if (!tmp) { + err = -ENOMEM ; + goto cleanup; + } + *mask = tmp; +memset (tmp + *mask_sz,0 , start - *mask_sz); +memset (tmp + start,1 , end - start +1 ); + *mask_sz = end +1 ; + s += len; + } +if (!*mask_sz) { +pr_warn ("Empty CPU range\n" ); +return -EINVAL ; + } +return 0 ; +cleanup: +free (*mask); + *mask =NULL ; +return err; +} + +int parse_cpu_mask_file (const char *fcpu,bool **mask,int *mask_sz) +{ +int fd, err =0 , len; +char buf[128 ]; fd =open (fcpu,O_RDONLY );if (fd <0 ) { - error = errno; -pr_warn ("Failed to open file %s: %s\n" , fcpu,strerror (error)); -return -error; + err = -errno; +pr_warn ("Failed to open cpu mask file %s: %d\n" , fcpu, err); +return err; } len =read (fd, buf,sizeof (buf));close (fd);if (len <=0 ) { - error = len ? errno :EINVAL ; -pr_warn ("Failed to read # of possible cpus from %s: %s\n" , - fcpu,strerror (error)); -return -error; - } -if (len ==sizeof (buf)) { -pr_warn ("File %s size overflow\n" , fcpu); -return -EOVERFLOW ; + err = len ? -errno : -EINVAL ; +pr_warn ("Failed to read cpu mask from %s: %d\n" , fcpu, err); +return err; + } +if (len >=sizeof (buf)) { +pr_warn ("CPU mask is too big in file %s\n" , fcpu); +return -E2BIG ; } buf[len] ='\0' ; -for (ir =0 , tmp_cpus =0 ; ir <= len; ir++) { -/* Each sub string separated by ',' has format \d+-\d+ or \d+ */ -if (buf[ir] ==',' || buf[ir] =='\0' ) { - buf[ir] ='\0' ; - n =sscanf (&buf[il],"%u-%u" , &start, &end); -if (n <=0 ) { -pr_warn ("Failed to get # CPUs from %s\n" , - &buf[il]); -return -EINVAL ; - }else if (n ==1 ) { - end = start; - } - tmp_cpus += end - start +1 ; - il = ir +1 ; - } - } -if (tmp_cpus <=0 ) { -pr_warn ("Invalid #CPUs %d from %s\n" , tmp_cpus, fcpu); -return -EINVAL ; +return parse_cpu_mask_str (buf, mask, mask_sz); +} + +int libbpf_num_possible_cpus (void ) +{ +static const char *fcpu ="/sys/devices/system/cpu/possible" ; +static int cpus; +int err, n, i, tmp_cpus; +bool *mask; + + tmp_cpus =READ_ONCE (cpus); +if (tmp_cpus >0 ) +return tmp_cpus; + + err =parse_cpu_mask_file (fcpu, &mask, &n); +if (err) +return err; + + tmp_cpus =0 ; +for (i =0 ; i < n; i++) { +if (mask[i]) + tmp_cpus++; } +free (mask);WRITE_ONCE (cpus, tmp_cpus);return tmp_cpus;
tools/lib/bpf/libbpf_internal.h +2 -0
@@ -95,6 +95,8 @@ static inline bool libbpf_validate_opts(#define OPTS_GET (opts, field, fallback_value) \ (OPTS_HAS(opts, field) ? (opts)->field : fallback_value) +int parse_cpu_mask_str (const char *s,bool **mask,int *mask_sz); +int parse_cpu_mask_file (const char *fcpu,bool **mask,int *mask_sz);int libbpf__load_raw_btf (const char *raw_types,size_t types_len,const char *str_sec,size_t str_len);
Greg Kroah-Hartman
maintainerPATCH 311/367 mfd: bd70528: Fix hour register mask
In reply to Greg Kroah-HartmanFrom: Matti Vaittinen <[email protected]>
commit 6c883472e1c11cb05561b6dd0c28bb037c2bf2de upstream.
When RTC is used in 24H mode (and it is by this driver) the maximum hour value is 24 in BCD. This occupies bits [5:0] - which means correct mask for HOUR register is 0x3f not 0x1f. Fix the mask
--- include/linux/mfd/rohm-bd70528.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mfd/rohm-bd70528.h +1 -1
@@ -317,7 +317,7 @@ enum {#define BD70528_MASK_RTC_MINUTE 0x7f#define BD70528_MASK_RTC_HOUR_24H 0x80#define BD70528_MASK_RTC_HOUR_PM 0x20 -#define BD70528_MASK_RTC_HOUR 0x1f +#define BD70528_MASK_RTC_HOUR 0x3f#define BD70528_MASK_RTC_DAY 0x3f#define BD70528_MASK_RTC_WEEK 0x07#define BD70528_MASK_RTC_MONTH 0x1f
Greg Kroah-Hartman
maintainerPATCH 310/367 mfd: rn5t618: Mark ADC control register volatile
In reply to Greg Kroah-HartmanFrom: Andreas Kemnade <[email protected]>
commit 2f3dc25c0118de03a00ddc88b61f7216854f534d upstream.
There is a bit which gets cleared after conversion.
--- drivers/mfd/rn5t618.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/rn5t618.c +1 -0
@@ -26,6 +26,7 @@ static bool rn5t618_volatile_reg(structcase RN5T618_WATCHDOGCNT :case RN5T618_DCIRQ : case RN5T618_ILIMDATAH ... RN5T618_AIN0DATAL: +case RN5T618_ADCCNT3 : case RN5T618_IR_ADC1 ... RN5T618_IR_ADC3:case RN5T618_IR_GPR :case RN5T618_IR_GPF :
Greg Kroah-Hartman
maintainerPATCH 291/367 ppp: Adjust indentation into ppp_async_input
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 08cbc75f96029d3092664213a844a5e25523aa35 upstream.
Clang warns:
../drivers/net/ppp/ppp_async.c:877:6: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
ap->rpkt = skb;
^
../drivers/net/ppp/ppp_async.c:875:5: note: previous statement is here
if (!skb)
^1 warning generated.
This warning occurs because there is a space before the tab on this line. Clean up this entire block's indentation so that it is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/net/ppp/ppp_async.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/ppp/ppp_async.c +9 -9
@@ -874,15 +874,15 @@ ppp_async_input(struct asyncppp *ap, con skb =dev_alloc_skb (ap->mru +PPP_HDRLEN +2 );if (!skb) goto nomem; - ap->rpkt = skb; - } -if (skb->len ==0 ) { -/* Try to get the payload 4-byte aligned. -* This should match the -* PPP_ALLSTATIONS/PPP_UI/compressed tests in -* process_input_packet, but we do not have -* enough chars here to test buf[1] and buf[2]. -*/ + ap->rpkt = skb; + } +if (skb->len ==0 ) { +/* Try to get the payload 4-byte aligned. +* This should match the +* PPP_ALLSTATIONS/PPP_UI/compressed tests in +* process_input_packet, but we do not have +* enough chars here to test buf[1] and buf[2]. +*/ if (buf[0 ] !=PPP_ALLSTATIONS )skb_reserve (skb,2 + (buf[0 ] &1 )); }
Greg Kroah-Hartman
maintainerPATCH 309/367 mfd: da9062: Fix watchdog compatible string
In reply to Greg Kroah-HartmanFrom: Marco Felsch <[email protected]>
commit 1112ba02ff1190ca9c15a912f9269e54b46d2d82 upstream.
The watchdog driver compatible is "dlg,da9062-watchdog" and not "dlg,da9062-wdt". Therefore the mfd-core can't populate the of_node and fwnode. As result the watchdog driver can't parse the devicetree.
--- drivers/mfd/da9062-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/da9062-core.c +1 -1
@@ -248,7 +248,7 @@ static const struct mfd_cell da9062_devs .name = "da9062-watchdog", .num_resources = ARRAY_SIZE(da9062_wdt_resources), .resources = da9062_wdt_resources, - .of_compatible = "dlg,da9062-wdt", + .of_compatible = "dlg,da9062-watchdog", }, { .name = "da9062-thermal",
Greg Kroah-Hartman
maintainerPATCH 305/367 ubifs: Fix memory leak from c->sup_node
In reply to Greg Kroah-HartmanFrom: Quanyang Wang <[email protected]>
commit ff90bdfb206e49c8b418811efbdd0c77380fa8c2 upstream.
The c->sup_node is allocated in function ubifs_read_sb_node but is not freed. This will cause memory leak as below:
unreferenced object 0xbc9ce000 (size 4096):
comm "mount", pid 500, jiffies 4294952946 (age 315.820s) hex dump (first 32 bytes):
31 18 10 06 06 7b f1 11 02 00 00 00 00 00 00 00 1....{..........
00 10 00 00 06 00 00 00 00 00 00 00 08 00 00 00 ................
backtrace:
[<d1c503cd>] ubifs_read_superblock+0x48/0xebc
[<a20e14bd>] ubifs_mount+0x974/0x1420
[<8589ecc3>] legacy_get_tree+0x2c/0x50
[<5f1fb889>] vfs_get_tree+0x28/0xfc
[<bbfc7939>] do_mount+0x4f8/0x748
[<4151f538>] ksys_mount+0x78/0xa0
[<d59910a9>] ret_fast_syscall+0x0/0x54
[<1cc40005>] 0x7ea02790Free it in ubifs_umount and in the error path of mount_ubifs.
--- fs/ubifs/super.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ubifs/super.c +2 -0
@@ -1599,6 +1599,7 @@ out_free:vfree (c->ileb_buf);vfree (c->sbuf);kfree (c->bottom_up_buf); +kfree (c->sup_node);ubifs_debugging_exit (c);return err; }
@@ -1641,6 +1642,7 @@ static void ubifs_umount(struct ubifs_invfree (c->ileb_buf);vfree (c->sbuf);kfree (c->bottom_up_buf); +kfree (c->sup_node);ubifs_debugging_exit (c); }
Greg Kroah-Hartman
maintainerPATCH 308/367 ASoC: Intel: skl_hda_dsp_common: Fix global-out-of-bounds bug
In reply to Greg Kroah-HartmanFrom: Cezary Rojewski <[email protected]>
commit 15adb20f64c302b31e10ad50f22bb224052ce1df upstream.
Definitions for idisp snd_soc_dai_links within skl_hda_dsp_common are missing platform component. Add it to address following bug reported by KASAN:
[ 10.538502] BUG: KASAN: global-out-of-bounds in skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538509] Write of size 8 at addr ffffffffc0606840 by task systemd-udevd/299 (...) [ 10.538519] Call Trace: [ 10.538524] dump_stack+0x62/0x95 [ 10.538528] print_address_description+0x2f5/0x3b0 [ 10.538532] ? skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538535] __kasan_report+0x134/0x191 [ 10.538538] ? skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538542] ? skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538544] kasan_report+0x12/0x20 [ 10.538546] __asan_store8+0x57/0x90 [ 10.538550] skl_hda_audio_probe+0x13a/0x2b0 [snd_soc_skl_hda_dsp] [ 10.538553] platform_drv_probe+0x51/0xb0 [ 10.538556] really_probe+0x311/0x600 [ 10.538559] driver_probe_device+0x87/0x1b0 [ 10.538562] device_driver_attach+0x8f/0xa0 [ 10.538565] ? device_driver_attach+0xa0/0xa0 [ 10.538567] __driver_attach+0x102/0x1a0 [ 10.538569] ? device_driver_attach+0xa0/0xa0 [ 10.538572] bus_for_each_dev+0xe8/0x160 [ 10.538574] ? subsys_dev_iter_exit+0x10/0x10 [ 10.538577] ? preempt_count_sub+0x18/0xc0 [ 10.538580] ? _raw_write_unlock+0x1f/0x40 [ 10.538582] driver_attach+0x2b/0x30 [ 10.538585] bus_add_driver+0x251/0x340 [ 10.538588] driver_register+0xd3/0x1c0 [ 10.538590] __platform_driver_register+0x6c/0x80 [ 10.538592] ? 0xffffffffc03e8000 [ 10.538595] skl_hda_audio_init+0x1c/0x1000 [snd_soc_skl_hda_dsp] [ 10.538598] do_one_initcall+0xd0/0x36a [ 10.538600] ? trace_event_raw_event_initcall_finish+0x160/0x160 [ 10.538602] ? kasan_unpoison_shadow+0x36/0x50 [ 10.538605] ? __kasan_kmalloc+0xcc/0xe0 [ 10.538607] ? kasan_unpoison_shadow+0x36/0x50 [ 10.538609] ? kasan_poison_shadow+0x2f/0x40 [ 10.538612] ? __asan_register_globals+0x65/0x80 [ 10.538615] do_init_module+0xf9/0x36f [ 10.538619] load_module+0x398e/0x4590 [ 10.538625] ? module_frob_arch_sections+0x20/0x20 [ 10.538628] ? __kasan_check_write+0x14/0x20 [ 10.538630] ? kernel_read+0x9a/0xc0 [ 10.538632] ? __kasan_check_write+0x14/0x20 [ 10.538634] ? kernel_read_file+0x1d3/0x3c0 [ 10.538638] ? cap_capable+0xca/0x110 [ 10.538642] __do_sys_finit_module+0x190/0x1d0 [ 10.538644] ? __do_sys_finit_module+0x190/0x1d0 [ 10.538646] ? __x64_sys_init_module+0x50/0x50 [ 10.538649] ? expand_files+0x380/0x380 [ 10.538652] ? __kasan_check_write+0x14/0x20 [ 10.538654] ? fput_many+0x20/0xc0 [ 10.538658] __x64_sys_finit_module+0x43/0x50 [ 10.538660] do_syscall_64+0xce/0x700 [ 10.538662] ? syscall_return_slowpath+0x230/0x230 [ 10.538665] ? __do_page_fault+0x51e/0x640 [ 10.538668] ? __kasan_check_read+0x11/0x20 [ 10.538670] ? prepare_exit_to_usermode+0xc7/0x200 [ 10.538673] entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- sound/soc/intel/boards/skl_hda_dsp_common.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
sound/soc/intel/boards/skl_hda_dsp_common.c +12 -9
@@ -41,16 +41,19 @@ int skl_hda_hdmi_add_pcm(struct snd_soc_return 0 ; } -SND_SOC_DAILINK_DEFS (idisp1, -DAILINK_COMP_ARRAY (COMP_CPU ("iDisp1 Pin" )), +SND_SOC_DAILINK_DEF (idisp1_cpu, +DAILINK_COMP_ARRAY (COMP_CPU ("iDisp1 Pin" ))); +SND_SOC_DAILINK_DEF (idisp1_codec,DAILINK_COMP_ARRAY (COMP_CODEC ("ehdaudio0D2" ,"intel-hdmi-hifi1" ))); -SND_SOC_DAILINK_DEFS (idisp2, -DAILINK_COMP_ARRAY (COMP_CPU ("iDisp2 Pin" )), +SND_SOC_DAILINK_DEF (idisp2_cpu, +DAILINK_COMP_ARRAY (COMP_CPU ("iDisp2 Pin" ))); +SND_SOC_DAILINK_DEF (idisp2_codec,DAILINK_COMP_ARRAY (COMP_CODEC ("ehdaudio0D2" ,"intel-hdmi-hifi2" ))); -SND_SOC_DAILINK_DEFS (idisp3, -DAILINK_COMP_ARRAY (COMP_CPU ("iDisp3 Pin" )), +SND_SOC_DAILINK_DEF (idisp3_cpu, +DAILINK_COMP_ARRAY (COMP_CPU ("iDisp3 Pin" ))); +SND_SOC_DAILINK_DEF (idisp3_codec,DAILINK_COMP_ARRAY (COMP_CODEC ("ehdaudio0D2" ,"intel-hdmi-hifi3" ))); SND_SOC_DAILINK_DEF(analog_cpu,
@@ -83,21 +86,21 @@ struct snd_soc_dai_link skl_hda_be_dai_l .id = 1, .dpcm_playback = 1, .no_pcm = 1, - SND_SOC_DAILINK_REG(idisp1), + SND_SOC_DAILINK_REG(idisp1_cpu, idisp1_codec, platform), }, { .name = "iDisp2", .id = 2, .dpcm_playback = 1, .no_pcm =1 , - SND_SOC_DAILINK_REG(idisp2), + SND_SOC_DAILINK_REG(idisp2_cpu, idisp2_codec, platform), }, { .name ="iDisp3" , .id = 3, .dpcm_playback = 1, .no_pcm = 1, - SND_SOC_DAILINK_REG(idisp3), + SND_SOC_DAILINK_REG(idisp3_cpu, idisp3_codec, platform), }, { .name = "Analog Playback and Capture",
Greg Kroah-Hartman
maintainerPATCH 302/367 virtio_balloon: Fix memory leaks on errors in virtballoon_probe()
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
commit 1ad6f58ea9364b0a5d8ae06249653ac9304a8578 upstream.
We forget to put the inode and unmount the kernfs used for compaction.
--- drivers/virtio/virtio_balloon.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/virtio/virtio_balloon.c +9 -4
@@ -901,8 +901,7 @@ static int virtballoon_probe(struct virt vb->vb_dev_info.inode =alloc_anon_inode (balloon_mnt->mnt_sb);if (IS_ERR (vb->vb_dev_info.inode)) { err =PTR_ERR (vb->vb_dev_info.inode); -kern_unmount (balloon_mnt); - goto out_del_vqs; + goto out_kern_unmount; } vb->vb_dev_info.inode->i_mapping->a_ops = &balloon_aops;#endif
@@ -913,13 +912,13 @@ static int virtballoon_probe(struct virt*/ if (virtqueue_get_vring_size (vb->free_page_vq) <2 ) { err = -ENOSPC ; - goto out_del_vqs; + goto out_iput; } vb->balloon_wq =alloc_workqueue ("balloon-wq" ,WQ_FREEZABLE |WQ_CPU_INTENSIVE ,0 );if (!vb->balloon_wq) { err = -ENOMEM ; - goto out_del_vqs; + goto out_iput; }INIT_WORK (&vb->report_free_page_work, report_free_page_func); vb->cmd_id_received_cache =VIRTIO_BALLOON_CMD_ID_STOP ;
@@ -953,6 +952,12 @@ static int virtballoon_probe(struct virt out_del_balloon_wq:if (virtio_has_feature (vdev,VIRTIO_BALLOON_F_FREE_PAGE_HINT ))destroy_workqueue (vb->balloon_wq); +out_iput: +#ifdef CONFIG_BALLOON_COMPACTION +iput (vb->vb_dev_info.inode); +out_kern_unmount: +kern_unmount (balloon_mnt); +#endif out_del_vqs: vdev->config->del_vqs (vdev); out_free_vb:
Greg Kroah-Hartman
maintainerPATCH 304/367 ubi: Fix an error pointer dereference in error handling code
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 5d3805af279c93ef49a64701f35254676d709622 upstream.
If "seen_pebs = init_seen(ubi);" fails then "seen_pebs" is an error pointer and we try to kfree() it which results in an Oops.
This patch re-arranges the error handling so now it only frees things which have been allocated successfully.
--- drivers/mtd/ubi/fastmap.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/mtd/ubi/fastmap.c +12 -9
@@ -1137,7 +1137,7 @@ static int ubi_write_fastmap(struct ubi_struct rb_node *tmp_rb;int ret, i, j, free_peb_count, used_peb_count, vol_count;int scrub_peb_count, erase_peb_count; -unsigned long *seen_pebs =NULL ; +unsigned long *seen_pebs; fm_raw = ubi->fm_buf;memset (ubi->fm_buf,0 , ubi->fm_size);
@@ -1151,7 +1151,7 @@ static int ubi_write_fastmap(struct ubi_ dvbuf =new_fm_vbuf (ubi,UBI_FM_DATA_VOLUME_ID );if (!dvbuf) { ret = -ENOMEM ; - goto out_kfree; + goto out_free_avbuf; } avhdr =ubi_get_vid_hdr (avbuf);
@@ -1160,7 +1160,7 @@ static int ubi_write_fastmap(struct ubi_ seen_pebs =init_seen (ubi);if (IS_ERR (seen_pebs)) { ret =PTR_ERR (seen_pebs); - goto out_kfree; + goto out_free_dvbuf; }spin_lock (&ubi->volumes_lock);
@@ -1328,7 +1328,7 @@ static int ubi_write_fastmap(struct ubi_ ret =ubi_io_write_vid_hdr (ubi, new_fm->e[0 ]->pnum, avbuf);if (ret) {ubi_err (ubi,"unable to write vid_hdr to fastmap SB!" ); - goto out_kfree; + goto out_free_seen; }for (i =0 ; i < new_fm->used_blocks; i++) {
@@ -1350,7 +1350,7 @@ static int ubi_write_fastmap(struct ubi_if (ret) {ubi_err (ubi,"unable to write vid_hdr to PEB %i!" , new_fm->e[i]->pnum); - goto out_kfree; + goto out_free_seen; } }
@@ -1360,7 +1360,7 @@ static int ubi_write_fastmap(struct ubi_if (ret) {ubi_err (ubi,"unable to write fastmap to PEB %i!" , new_fm->e[i]->pnum); - goto out_kfree; + goto out_free_seen; } }
@@ -1370,10 +1370,13 @@ static int ubi_write_fastmap(struct ubi_ ret =self_check_seen (ubi, seen_pebs);dbg_bld ("fastmap written!" ); -out_kfree: -ubi_free_vid_buf (avbuf); -ubi_free_vid_buf (dvbuf); +out_free_seen:free_seen (seen_pebs); +out_free_dvbuf: +ubi_free_vid_buf (dvbuf); +out_free_avbuf: +ubi_free_vid_buf (avbuf); + out:return ret; }
Greg Kroah-Hartman
maintainerPATCH 303/367 ubi: fastmap: Fix inverted logic in seen selfcheck
In reply to Greg Kroah-HartmanFrom: Sascha Hauer <[email protected]>
commit ef5aafb6e4e9942a28cd300bdcda21ce6cbaf045 upstream.
set_seen() sets the bit corresponding to the PEB number in the bitmap, so when self_check_seen() wants to find PEBs that haven't been seen we have to print the PEBs that have their bit cleared, not the ones which have it set.
--- drivers/mtd/ubi/fastmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubi/fastmap.c +1 -1
@@ -64,7 +64,7 @@ static int self_check_seen(struct ubi_dereturn 0 ;for (pnum =0 ; pnum < ubi->peb_count; pnum++) { -if (test_bit (pnum, seen) && ubi->lookuptbl[pnum]) { +if (!test_bit (pnum, seen) && ubi->lookuptbl[pnum]) {ubi_err (ubi,"self-check failed for PEB %d, fastmap didn't see it" , pnum); ret = -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 301/367 virtio-balloon: Fix memory leak when unloading while hinting is in progress
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
commit 6c22dc61c76b7e7d355f1697ba0ecf26d1334ba6 upstream.
When unloading the driver while hinting is in progress, we will not release the free page blocks back to MM, resulting in a memory leak.
--- drivers/virtio/virtio_balloon.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/virtio/virtio_balloon.c +4 -0
@@ -968,6 +968,10 @@ static void remove_common(struct virtio_leak_balloon (vb, vb->num_pages);update_balloon_size (vb); +/* There might be free pages that are being reported: release them. */ +if (virtio_has_feature (vb->vdev,VIRTIO_BALLOON_F_FREE_PAGE_HINT )) +return_free_pages_to_mm (vb,ULONG_MAX ); +/* Now we reset the device so we can clean up the queues. */ vb->vdev->config->reset (vb->vdev);
Greg Kroah-Hartman
maintainerPATCH 245/367 KVM: x86: use CPUID to locate host page table reserved bits
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 7adacf5eb2d2048045d9fd8fdab861fd9e7e2e96 upstream.
The comment in kvm_get_shadow_phys_bits refers to MKTME, but the same is actually true of SME and SEV. Just use CPUID[0x8000_0008].EAX[7:0] unconditionally if available, it is simplest and works even if memory is not encrypted.
--- arch/x86/kvm/mmu/mmu.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
arch/x86/kvm/mmu/mmu.c +12 -8
@@ -538,16 +538,20 @@ EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes)static u8 kvm_get_shadow_phys_bits (void ) {/* -* boot_cpu_data.x86_phys_bits is reduced when MKTME is detected -* in CPU detection code, but MKTME treats those reduced bits as -* 'keyID' thus they are not reserved bits. Therefore for MKTME -* we should still return physical address bits reported by CPUID. +* boot_cpu_data.x86_phys_bits is reduced when MKTME or SME are detected +* in CPU detection code, but the processor treats those reduced bits as +* 'keyID' thus they are not reserved bits. Therefore KVM needs to look at +* the physical address bits reported by CPUID. */ -if (!boot_cpu_has (X86_FEATURE_TME ) || -WARN_ON_ONCE (boot_cpu_data.extended_cpuid_level <0x80000008 )) -return boot_cpu_data.x86_phys_bits; +if (likely (boot_cpu_data.extended_cpuid_level >=0x80000008 )) +return cpuid_eax (0x80000008 ) &0xff ; -return cpuid_eax (0x80000008 ) &0xff ; +/* +* Quite weird to have VMX or SVM but not MAXPHYADDR; probably a VM with +* custom CPUID. Proceed with whatever the kernel found since these features +* aren't virtualizable (SME/SEV also require CPUIDs higher than 0x80000008). +*/ +return boot_cpu_data.x86_phys_bits; }static void kvm_mmu_reset_all_pte_masks (void )
Greg Kroah-Hartman
maintainerPATCH 290/367 NFC: pn544: Adjust indentation in pn544_hci_check_presence
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 5080832627b65e3772a35d1dced68c64e2b24442 upstream.
Clang warns
../drivers/nfc/pn544/pn544.c:696:4: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
return nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE, ^../drivers/nfc/pn544/pn544.c:692:3: note: previous statement is here
if (target->nfcid1_len != 4 && target->nfcid1_len != 7 &&
^1 warning generated.
This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/nfc/pn544/pn544.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/pn544/pn544.c +1 -1
@@ -693,7 +693,7 @@ static int pn544_hci_check_presence(stru target->nfcid1_len != 10)return -EOPNOTSUPP ; -return nfc_hci_send_cmd (hdev,NFC_HCI_RF_READER_A_GATE , +return nfc_hci_send_cmd (hdev,NFC_HCI_RF_READER_A_GATE ,PN544_RF_READER_CMD_ACTIVATE_NEXT , target->nfcid1, target->nfcid1_len,NULL ); } else if (target->supported_protocols & (NFC_PROTO_JEWEL_MASK |
Greg Kroah-Hartman
maintainerPATCH 253/367 KVM: x86: Free wbinvd_dirty_mask if vCPU creation fails
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 16be9ddea268ad841457a59109963fff8c9de38d upstream.
Free the vCPU's wbinvd_dirty_mask if vCPU creation fails after kvm_arch_vcpu_init(), e.g. when installing the vCPU's file descriptor. Do the freeing by calling kvm_arch_vcpu_free() instead of open coding the freeing. This adds a likely superfluous, but ultimately harmless, call to kvmclock_reset(), which only clears vcpu->arch.pv_time_enabled. Using kvm_arch_vcpu_free() allows for additional cleanup in the future.
--- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -9208,7 +9208,7 @@ void kvm_arch_vcpu_destroy(struct kvm_vckvm_mmu_unload (vcpu);vcpu_put (vcpu); - kvm_x86_ops->vcpu_free (vcpu); +kvm_arch_vcpu_free (vcpu); }void kvm_vcpu_reset (struct kvm_vcpu *vcpu,bool init_event)
Greg Kroah-Hartman
maintainerPATCH 251/367 KVM: VMX: Add non-canonical check on writes to RTIT address MSRs
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit fe6ed369fca98e99df55c932b85782a5687526b5 upstream.
Reject writes to RTIT address MSRs if the data being written is a non-canonical address as the MSRs are subject to canonical checks, e.g. KVM will trigger an unchecked #GP when loading the values to hardware during pt_guest_enter().
--- arch/x86/kvm/vmx/vmx.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kvm/vmx/vmx.c +2 -0
@@ -2146,6 +2146,8 @@ static int vmx_set_msr(struct kvm_vcpu * (index >= 2 * intel_pt_validate_cap(vmx->pt_desc.caps, PT_CAP_num_address_ranges)))return 1 ; +if (is_noncanonical_address (data, vcpu)) +return 1 ;if (index %2 ) vmx->pt_desc.guest.addr_b[index /2 ] = data;else
Greg Kroah-Hartman
maintainerPATCH 287/367 ext2: Adjust indentation in ext2_fill_super
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit d9e9866803f7b6c3fdd35d345e97fb0b2908bbbc upstream.
Clang warns:
../fs/ext2/super.c:1076:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
^
../fs/ext2/super.c:1074:2: note: previous statement is here
if (EXT2_BLOCKS_PER_GROUP(sb) == 0)
^1 warning generated.
This warning occurs because there is a space before the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- fs/ext2/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ext2/super.c +3 -3
@@ -1073,9 +1073,9 @@ static int ext2_fill_super(struct super_if (EXT2_BLOCKS_PER_GROUP (sb) ==0 ) goto cantfind_ext2; - sbi->s_groups_count = ((le32_to_cpu (es->s_blocks_count) - -le32_to_cpu (es->s_first_data_block) -1 ) - /EXT2_BLOCKS_PER_GROUP (sb)) +1 ; + sbi->s_groups_count = ((le32_to_cpu (es->s_blocks_count) - +le32_to_cpu (es->s_first_data_block) -1 ) + /EXT2_BLOCKS_PER_GROUP (sb)) +1 ; db_count = (sbi->s_groups_count +EXT2_DESC_PER_BLOCK (sb) -1 ) /EXT2_DESC_PER_BLOCK (sb); sbi->s_group_desc = kmalloc_array (db_count,
Greg Kroah-Hartman
maintainerPATCH 285/367 mtd: spi-nor: Split mt25qu512a (n25q512a) entry into two
In reply to Greg Kroah-HartmanFrom: Vignesh Raghavendra <[email protected]>
commit bd8a6e31b87b39a03ab11820776363640440dbe0 upstream.
mt25q family is different from n25q family of devices, even though manf ID and device IDs are same. mt25q flash has bit 6 set in 5th byte of READ ID response which can be used to distinguish it from n25q variant. mt25q flashes support stateless 4 Byte addressing opcodes where as n25q flashes don't. Therefore, have two separate entries for mt25qu512a and n25q512a.
--- drivers/mtd/spi-nor/spi-nor.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mtd/spi-nor/spi-nor.c +5 -4
@@ -2461,15 +2461,16 @@ static const struct flash_info spi_nor_i { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "n25q256ax1", INFO(0x20bb19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) }, { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, + { "mt25qu512a", INFO6(0x20bb20, 0x104400, 64 * 1024, 1024, +SECT_4K |USE_FSR |SPI_NOR_DUAL_READ | + SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | + SPI_NOR_QUAD_READ) }, { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, { "n25q00a", INFO(0x20bb21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, { "mt25ql02g", INFO(0x20ba22, 0, 64 * 1024, 4096,SECT_4K |USE_FSR |SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, - { "mt25qu512a (n25q512a)", INFO(0x20bb20, 0, 64 * 1024, 1024, -SECT_4K |USE_FSR |SPI_NOR_DUAL_READ | -SPI_NOR_QUAD_READ | - SPI_NOR_4B_OPCODES) }, { "mt25qu02g", INFO(0x20bb22, 0, 64 * 1024, 4096, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, /* Micron */
Greg Kroah-Hartman
maintainerPATCH 286/367 phy: qualcomm: Adjust indentation in read_poll_timeout
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit a89806c998ee123bb9c0f18526e55afd12c0c0ab upstream.
Clang warns:
../drivers/phy/qualcomm/phy-qcom-apq8064-sata.c:83:4: warning:
misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
usleep_range(DELAY_INTERVAL_US, DELAY_INTERVAL_US + 50);
^../drivers/phy/qualcomm/phy-qcom-apq8064-sata.c:80:3: note: previous statement is here
if (readl_relaxed(addr) & mask)
^
1 warning generated.
This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/phy/qualcomm/phy-qcom-apq8064-sata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-apq8064-sata.c +1 -1
@@ -80,7 +80,7 @@ static int read_poll_timeout(void __iomeif (readl_relaxed (addr) & mask)return 0 ; -usleep_range (DELAY_INTERVAL_US ,DELAY_INTERVAL_US +50 ); +usleep_range (DELAY_INTERVAL_US ,DELAY_INTERVAL_US +50 ); }while (!time_after (jiffies, timeout));return (readl_relaxed (addr) & mask) ?0 : -ETIMEDOUT ;
Greg Kroah-Hartman
maintainerPATCH 283/367 scsi: ufs: Recheck bkops level if bkops is disabled
In reply to Greg Kroah-HartmanFrom: Asutosh Das <[email protected]>
commit 24366c2afbb0539fb14eff330d4e3a5db5c0a3ef upstream.
bkops level should be rechecked upon receiving an exception. Currently the level is being cached and never updated.
Update bkops each time the level is checked. Also do not use the cached bkops level value if it is disabled and then enabled.
--- drivers/scsi/ufs/ufshcd.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/ufs/ufshcd.c +3 -0
@@ -5053,6 +5053,7 @@ static int ufshcd_disable_auto_bkops(str hba->auto_bkops_enabled = false;trace_ufshcd_auto_bkops_state (dev_name (hba->dev),"Disabled" ); + hba->is_urgent_bkops_lvl_checked = false; out:return err; }
@@ -5077,6 +5078,7 @@ static void ufshcd_force_reset_auto_bkop hba->ee_ctrl_mask &= ~MASK_EE_URGENT_BKOPS ;ufshcd_disable_auto_bkops (hba); } + hba->is_urgent_bkops_lvl_checked = false; }static inline int ufshcd_get_bkops_status (struct ufs_hba *hba,u32 *status)
@@ -5123,6 +5125,7 @@ static int ufshcd_bkops_ctrl(struct ufs_ err =ufshcd_enable_auto_bkops (hba); else err =ufshcd_disable_auto_bkops (hba); + hba->urgent_bkops_lvl = curr_status; out:return err; }
Greg Kroah-Hartman
maintainerPATCH 282/367 scsi: qla4xxx: Adjust indentation in qla4xxx_mem_free
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit aa8679736a82386551eb9f3ea0e6ebe2c0e99104 upstream.
Clang warns:
../drivers/scsi/qla4xxx/ql4_os.c:4148:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
if (ha->fw_dump)
^
../drivers/scsi/qla4xxx/ql4_os.c:4144:2: note: previous statement is
here
if (ha->queues)
^1 warning generated.
This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/scsi/qla4xxx/ql4_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla4xxx/ql4_os.c +1 -1
@@ -4145,7 +4145,7 @@ static void qla4xxx_mem_free(struct scsidma_free_coherent (&ha->pdev->dev, ha->queues_len, ha->queues, ha->queues_dma); -if (ha->fw_dump) +if (ha->fw_dump)vfree (ha->fw_dump); ha->queues_len =0 ;
Greg Kroah-Hartman
maintainerPATCH 280/367 scsi: qla2xxx: Fix the endianness of the qla82xx_get_fw_size() return type
In reply to Greg Kroah-HartmanFrom: Bart Van Assche <[email protected]>
commit 3f5f7335e5e234e340b48ecb24c2aba98a61f934 upstream.
Since qla82xx_get_fw_size() returns a number in CPU-endian format, change its return type from __le32 into u32. This patch does not change any functionality.
--- drivers/scsi/qla2xxx/qla_nx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/qla2xxx/qla_nx.c +3 -4
@@ -1612,8 +1612,7 @@ qla82xx_get_bootld_offset(struct qla_hw_return (u8 *)&ha->hablob->fw->data[offset]; } -static __le32 -qla82xx_get_fw_size (struct qla_hw_data *ha) +static u32 qla82xx_get_fw_size (struct qla_hw_data *ha) {struct qla82xx_uri_data_desc *uri_desc =NULL ;
@@ -1624,7 +1623,7 @@ qla82xx_get_fw_size(struct qla_hw_data *return cpu_to_le32 (uri_desc->size); } -return cpu_to_le32 (*(u32 *)&ha->hablob->fw->data[FW_SIZE_OFFSET ]); +return get_unaligned_le32 (&ha->hablob->fw->data[FW_SIZE_OFFSET ]); } static u8 *
@@ -1816,7 +1815,7 @@ qla82xx_fw_load_from_blob(struct qla_hw_ } flashaddr =FLASH_ADDR_START ; - size = (__force u32 )qla82xx_get_fw_size (ha) /8 ; + size =qla82xx_get_fw_size (ha) /8 ; ptr64 = (u64 *)qla82xx_get_fw_offs (ha);for (i =0 ; i < size; i++) {
Greg Kroah-Hartman
maintainerPATCH 279/367 ASoC: meson: axg-fifo: fix fifo threshold setup
In reply to Greg Kroah-HartmanFrom: Jerome Brunet <[email protected]>
commit 864cee90d4bd870e5d5e5a0b1a6f055f4f951350 upstream.
On TODDR sm1, the fifo threshold register field is slightly different compared to the other SoCs. This leads to the fifo A being flushed to memory every 8kB. If the period is smaller than that, several periods are pushed to memory and notified at once. This is not ideal.
Fix the register field update. With this, the fifos are flushed every 128B. We could still do better, like adapt the threshold depending on the period size, but at least it consistent across the different SoC/fifos
--- sound/soc/meson/axg-fifo.c | 27 +++++++++++++++++++++++++-- sound/soc/meson/axg-fifo.h | 6 ++++-- sound/soc/meson/axg-frddr.c | 24 ++++++++++++------------ sound/soc/meson/axg-toddr.c | 21 +++++++++------------ 4 files changed, 50 insertions(+), 28 deletions(-)
sound/soc/meson/axg-fifo.c +25 -2
@@ -113,10 +113,12 @@ int axg_fifo_pcm_hw_params(struct snd_so {struct snd_pcm_runtime *runtime = ss->runtime;struct axg_fifo *fifo =axg_fifo_data (ss); +unsigned int burst_num, period, threshold;dma_addr_t end_ptr; -unsigned int burst_num;int ret; + period =params_period_bytes (params); + ret =snd_pcm_lib_malloc_pages (ss,params_buffer_bytes (params));if (ret <0 )return ret;
@@ -127,9 +129,25 @@ int axg_fifo_pcm_hw_params(struct snd_soregmap_write (fifo->map,FIFO_FINISH_ADDR , end_ptr);/* Setup interrupt periodicity */ - burst_num =params_period_bytes (params) /AXG_FIFO_BURST ; + burst_num = period /AXG_FIFO_BURST ;regmap_write (fifo->map,FIFO_INT_ADDR , burst_num); +/* +* Start the fifo request on the smallest of the following: +* - Half the fifo size +* - Half the period size +*/ + threshold =min (period /2 , + (unsigned int )AXG_FIFO_MIN_DEPTH /2 ); + +/* +* With the threshold in bytes, register value is: +* V = (threshold / burst) - 1 +*/ + threshold /=AXG_FIFO_BURST ; +regmap_field_write (fifo->field_threshold, + threshold ? threshold -1 :0 ); +/* Enable block count irq */ regmap_update_bits(fifo->map, FIFO_CTRL0, CTRL0_INT_EN(FIFO_INT_COUNT_REPEAT),
@@ -352,6 +370,11 @@ int axg_fifo_probe(struct platform_devicreturn fifo->irq; } + fifo->field_threshold = +devm_regmap_field_alloc (dev, fifo->map, data->field_threshold); +if (IS_ERR (fifo->field_threshold)) +return PTR_ERR (fifo->field_threshold); +return devm_snd_soc_register_component (dev, data->component_drv, data->dai_drv,1 ); }
sound/soc/meson/axg-fifo.h +4 -2
@@ -9,7 +9,9 @@struct clk ;struct platform_device ; +struct reg_field ;struct regmap ; +struct regmap_field ;struct reset_control ;struct snd_soc_component_driver ;
@@ -50,8 +52,6 @@ struct snd_soc_pcm_runtime;#define CTRL1_STATUS2_SEL_MASK GENMASK(11, 8)#define CTRL1_STATUS2_SEL (x) ((x) << 8)#define STATUS2_SEL_DDR_READ 0 -#define CTRL1_THRESHOLD_MASK GENMASK(23, 16) -#define CTRL1_THRESHOLD (x) ((x) << 16)#define CTRL1_FRDDR_DEPTH_MASK GENMASK(31, 24)#define CTRL1_FRDDR_DEPTH (x) ((x) << 24)#define FIFO_START_ADDR 0x08
@@ -67,12 +67,14 @@ struct axg_fifo {struct regmap *map;struct clk *pclk;struct reset_control *arb; +struct regmap_field *field_threshold;int irq; };struct axg_fifo_match_data {const struct snd_soc_component_driver *component_drv;struct snd_soc_dai_driver *dai_drv; +struct reg_field field_threshold; }; int axg_fifo_pcm_open(struct snd_soc_component *component,
sound/soc/meson/axg-frddr.c +12 -12
@@ -50,7 +50,7 @@ static int axg_frddr_dai_startup(struct struct snd_soc_dai *dai) {struct axg_fifo *fifo =snd_soc_dai_get_drvdata (dai); -unsigned int fifo_depth, fifo_threshold; +unsigned int fifo_depth;int ret;/* Enable pclk to access registers and clock the fifo ip */
@@ -68,11 +68,8 @@ static int axg_frddr_dai_startup(struct* Depth and threshold are zero based. */ fifo_depth =AXG_FIFO_MIN_CNT -1 ; - fifo_threshold = (AXG_FIFO_MIN_CNT /2 ) -1 ; -regmap_update_bits (fifo->map,FIFO_CTRL1 , -CTRL1_FRDDR_DEPTH_MASK |CTRL1_THRESHOLD_MASK , -CTRL1_FRDDR_DEPTH (fifo_depth) | -CTRL1_THRESHOLD (fifo_threshold)); +regmap_update_bits (fifo->map,FIFO_CTRL1 ,CTRL1_FRDDR_DEPTH_MASK , +CTRL1_FRDDR_DEPTH (fifo_depth));return 0 ; }
@@ -159,8 +156,9 @@ static const struct snd_soc_component_dr };static const struct axg_fifo_match_data axg_frddr_match_data = { - .component_drv = &axg_frddr_component_drv, - .dai_drv = &axg_frddr_dai_drv + .field_threshold =REG_FIELD (FIFO_CTRL1 ,16 ,23 ), + .component_drv = &axg_frddr_component_drv, + .dai_drv = &axg_frddr_dai_drv };static const struct snd_soc_dai_ops g12a_frddr_ops = {
@@ -283,8 +281,9 @@ static const struct snd_soc_component_dr };static const struct axg_fifo_match_data g12a_frddr_match_data = { - .component_drv = &g12a_frddr_component_drv, - .dai_drv = &g12a_frddr_dai_drv + .field_threshold =REG_FIELD (FIFO_CTRL1 ,16 ,23 ), + .component_drv = &g12a_frddr_component_drv, + .dai_drv = &g12a_frddr_dai_drv };/* On SM1, the output selection in on CTRL2 */
@@ -353,8 +352,9 @@ static const struct snd_soc_component_dr };static const struct axg_fifo_match_data sm1_frddr_match_data = { - .component_drv = &sm1_frddr_component_drv, - .dai_drv = &g12a_frddr_dai_drv + .field_threshold =REG_FIELD (FIFO_CTRL1 ,16 ,23 ), + .component_drv = &sm1_frddr_component_drv, + .dai_drv = &g12a_frddr_dai_drv };static const struct of_device_id axg_frddr_of_match[] = {
sound/soc/meson/axg-toddr.c +9 -12
@@ -89,7 +89,6 @@ static int axg_toddr_dai_startup(struct struct snd_soc_dai *dai) {struct axg_fifo *fifo =snd_soc_dai_get_drvdata (dai); -unsigned int fifo_threshold;int ret;/* Enable pclk to access registers and clock the fifo ip */
@@ -107,11 +106,6 @@ static int axg_toddr_dai_startup(struct/* Apply single buffer mode to the interface */ regmap_update_bits (fifo->map,FIFO_CTRL0 ,CTRL0_TODDR_PP_MODE ,0 ); -/* TODDR does not have a configurable fifo depth */ - fifo_threshold =AXG_FIFO_MIN_CNT -1 ; -regmap_update_bits (fifo->map,FIFO_CTRL1 ,CTRL1_THRESHOLD_MASK , -CTRL1_THRESHOLD (fifo_threshold)); -return 0 ; }
@@ -191,8 +185,9 @@ static const struct snd_soc_component_dr };static const struct axg_fifo_match_data axg_toddr_match_data = { - .component_drv = &axg_toddr_component_drv, - .dai_drv = &axg_toddr_dai_drv + .field_threshold =REG_FIELD (FIFO_CTRL1 ,16 ,23 ), + .component_drv = &axg_toddr_component_drv, + .dai_drv = &axg_toddr_dai_drv };static const struct snd_soc_dai_ops g12a_toddr_ops = {
@@ -230,8 +225,9 @@ static const struct snd_soc_component_dr };static const struct axg_fifo_match_data g12a_toddr_match_data = { - .component_drv = &g12a_toddr_component_drv, - .dai_drv = &g12a_toddr_dai_drv + .field_threshold =REG_FIELD (FIFO_CTRL1 ,16 ,23 ), + .component_drv = &g12a_toddr_component_drv, + .dai_drv = &g12a_toddr_dai_drv };static const char *const sm1_toddr_sel_texts[] = {
@@ -300,8 +296,9 @@ static const struct snd_soc_component_dr };static const struct axg_fifo_match_data sm1_toddr_match_data = { - .component_drv = &sm1_toddr_component_drv, - .dai_drv = &g12a_toddr_dai_drv + .field_threshold =REG_FIELD (FIFO_CTRL1 ,12 ,23 ), + .component_drv = &sm1_toddr_component_drv, + .dai_drv = &g12a_toddr_dai_drv };static const struct of_device_id axg_toddr_of_match[] = {
Greg Kroah-Hartman
maintainerPATCH 278/367 percpu: Separate decrypted varaibles anytime encryption can be enabled
In reply to Greg Kroah-HartmanFrom: Erdem Aktas <[email protected]>
commit 264b0d2bee148073c117e7bbbde5be7125a53be1 upstream.
CONFIG_VIRTUALIZATION may not be enabled for memory encrypted guests. If disabled, decrypted per-CPU variables may end up sharing the same page with variables that should be left encrypted.
Always separate per-CPU variables that should be decrypted into their own page anytime memory encryption can be enabled in the guest rather than rely on any other config option that may not be enabled.
--- include/linux/percpu-defs.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/percpu-defs.h +1 -2
@@ -175,8 +175,7 @@* Declaration/definition used for per-CPU variables that should be accessed * as decrypted when memory encryption is enabled in the guest. */ -#if defined(CONFIG_VIRTUALIZATION ) && defined(CONFIG_AMD_MEM_ENCRYPT ) - +#ifdef CONFIG_AMD_MEM_ENCRYPT #define DECLARE_PER_CPU_DECRYPTED (type, name) \ DECLARE_PER_CPU_SECTION(type, name, "..decrypted")
Greg Kroah-Hartman
maintainerPATCH 277/367 broken ping to ipv6 linklocal addresses on debian buster
In reply to Greg Kroah-HartmanFrom: Casey Schaufler <[email protected]>
commit 87fbfffcc89b92a4281b0aa53bd06af714087889 upstream.
I am seeing ping failures to IPv6 linklocal addresses with Debian buster. Easiest example to reproduce is:
$ ping -c1 -w1 ff02::1%eth1 connect: Invalid argument
$ ping -c1 -w1 ff02::1%eth1 PING ff02::01%eth1(ff02::1%eth1) 56 data bytes 64 bytes from fe80::e0:f9ff:fe0c:37%eth1: icmp_seq=1 ttl=64 time=0.059 ms
git bisect traced the failure to
commit b9ef5513c99b ("smack: Check address length before reading address family")
Arguably ping is being stupid since the buster version is not setting the address family properly (ping on stretch for example does):
$ strace -e connect ping6 -c1 -w1 ff02::1%eth1
connect(5, {sa_family=AF_UNSPEC,
sa_data="\4\1\0\0\0\0\377\2\0\0\0\0\0\0\0\0\0\0\0\0\0\1\3\0\0\0"}, 28)
= -1 EINVAL (Invalid argument)but the command works fine on kernels prior to this commit, so this is breakage which goes against the Linux paradigm of "don't break userspace"
security/smack/smack_lsm.c | 41 +++++++++++++++++++----------------------
security/smack/smack_lsm.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-)
security/smack/smack_lsm.c +19 -22
@@ -2831,42 +2831,39 @@ static int smack_socket_connect(struct s int addrlen) {int rc =0 ; -#if IS_ENABLED (CONFIG_IPV6 ) -struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap; -#endif -#ifdef SMACK_IPV6_SECMARK_LABELING -struct smack_known *rsp; -struct socket_smack *ssp; -#endif if (sock->sk ==NULL )return 0 ; - +if (sock->sk->sk_family !=PF_INET && + (!IS_ENABLED (CONFIG_IPV6 ) || sock->sk->sk_family !=PF_INET6 )) +return 0 ; + if (addrlen < offsetofend(struct sockaddr, sa_family)) +return 0 ; +if (IS_ENABLED (CONFIG_IPV6 ) && sap->sa_family ==AF_INET6 ) { +struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap;#ifdef SMACK_IPV6_SECMARK_LABELING - ssp = sock->sk->sk_security; +struct smack_known *rsp;#endif -switch (sock->sk->sk_family) { -case PF_INET : -if (addrlen <sizeof (struct sockaddr_in ) || - sap->sa_family !=AF_INET ) -return -EINVAL ; - rc =smack_netlabel_send (sock->sk, (struct sockaddr_in *)sap); -break ; -case PF_INET6 : -if (addrlen <SIN6_LEN_RFC2133 || sap->sa_family !=AF_INET6 ) -return -EINVAL ; +if (addrlen <SIN6_LEN_RFC2133 ) +return 0 ;#ifdef SMACK_IPV6_SECMARK_LABELING rsp =smack_ipv6host_label (sip); -if (rsp !=NULL ) +if (rsp !=NULL ) { +struct socket_smack *ssp = sock->sk->sk_security; + rc =smk_ipv6_check (ssp->smk_out, rsp, sip, -SMK_CONNECTING ); +SMK_CONNECTING ); + }#endif #ifdef SMACK_IPV6_PORT_LABELING rc =smk_ipv6_port_check (sock->sk, sip,SMK_CONNECTING );#endif -break ; +return rc; } +if (sap->sa_family !=AF_INET || addrlen <sizeof (struct sockaddr_in )) +return 0 ; + rc =smack_netlabel_send (sock->sk, (struct sockaddr_in *)sap);return rc; }
Greg Kroah-Hartman
maintainerPATCH 276/367 fix up iter on short count in fuse_direct_io()
In reply to Greg Kroah-HartmanFrom: Miklos Szeredi <[email protected]>
commit f658adeea45e430a24c7a157c3d5448925ac2038 upstream.
fuse_direct_io() can end up advancing the iterator by more than the amount of data read or written. This case is handled by the generic code if going through ->direct_IO(), but not in the FOPEN_DIRECT_IO case.
Fix by reverting the extra bytes from the iterator in case of error or a short count.
To test: install lxcfs, then the following testcase
int fd = open("/var/lib/lxcfs/proc/uptime", O_RDONLY); sendfile(1, fd, NULL, 16777216);
sendfile(1, fd, NULL, 16777216);
will spew WARN_ON() in iov_iter_pipe().
--- fs/fuse/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/fuse/file.c +4 -1
@@ -1465,6 +1465,7 @@ ssize_t fuse_direct_io(struct fuse_io_pr } ia =NULL ;if (nres <0 ) { +iov_iter_revert (iter, nbytes); err = nres;break ; }
@@ -1473,8 +1474,10 @@ ssize_t fuse_direct_io(struct fuse_io_pr count -= nres; res += nres; pos += nres; -if (nres != nbytes) +if (nres != nbytes) { +iov_iter_revert (iter, nbytes - nres);break ; + }if (count) { max_pages =iov_iter_npages (iter, fc->max_pages); ia =fuse_io_alloc (io, max_pages);
Greg Kroah-Hartman
maintainerPATCH 273/367 drm/amdgpu/smu_v11_0: Correct behavior of restoring default tables (v2)
In reply to Greg Kroah-HartmanFrom: Matt Coffin <[email protected]>
commit 93c5f1f66c6ad4a3b180c1644f74e1b3b4be7864 upstream.
Previously, the syfs functionality for restoring the default powerplay table was sourcing it's information from the currently-staged powerplay table.
This patch adds a step to cache the first overdrive table that we see on boot, so that it can be used later to "restore" the powerplay table
v2: sqaush my original with Matt's fix
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 7 ++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 6 +++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 28 +++++++------------------ 4 files changed, 22 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
@@ -263,6 +263,7 @@ struct smu_table_contextuint8_t thermal_controller_type;void *overdrive_table; +void *boot_overdrive_table; };struct smu_dpm_context {
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +7 -0
@@ -2020,6 +2020,13 @@ static int navi10_od_edit_dpm_table(strureturn ret; od_table->UclkFmax = input[1 ];break ; +case PP_OD_RESTORE_DEFAULT_TABLE : +if (!(table_context->overdrive_table && table_context->boot_overdrive_table)) { +pr_err ("Overdrive table was not initialized!\n" ); +return -EINVAL ; + } +memcpy (table_context->overdrive_table, table_context->boot_overdrive_table,sizeof (OverDriveTable_t)); +break ;case PP_OD_COMMIT_DPM_TABLE :navi10_dump_od_table (od_table); ret =smu_update_table (smu,SMU_TABLE_OVERDRIVE ,0 , (void *)od_table, true);
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +6 -0
@@ -1807,6 +1807,12 @@ int smu_v11_0_set_default_od_settings(stpr_err ("Failed to export overdrive table!\n" );return ret; } +if (!table_context->boot_overdrive_table) { + table_context->boot_overdrive_table =kmemdup (table_context->overdrive_table, overdrive_table_size,GFP_KERNEL ); +if (!table_context->boot_overdrive_table) { +return -ENOMEM ; + } + } } ret =smu_update_table (smu,SMU_TABLE_OVERDRIVE ,0 , table_context->overdrive_table, true);if (ret) {
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +8 -20
@@ -1702,22 +1702,11 @@ static int vega20_set_default_od_settingstruct smu_table_context *table_context = &smu->smu_table;int ret; -if (initialize) { -if (table_context->overdrive_table) -return -EINVAL ; - - table_context->overdrive_table =kzalloc (sizeof (OverDriveTable_t),GFP_KERNEL ); - -if (!table_context->overdrive_table) -return -ENOMEM ; - - ret =smu_update_table (smu,SMU_TABLE_OVERDRIVE ,0 , - table_context->overdrive_table, false); -if (ret) { -pr_err ("Failed to export over drive table!\n" ); -return ret; - } + ret =smu_v11_0_set_default_od_settings (smu, initialize,sizeof (OverDriveTable_t)); +if (ret) +return ret; +if (initialize) { ret =vega20_set_default_od8_setttings (smu);if (ret)return ret;
@@ -2774,12 +2763,11 @@ static int vega20_odn_edit_dpm_table(strbreak ;case PP_OD_RESTORE_DEFAULT_TABLE : - ret =smu_update_table (smu,SMU_TABLE_OVERDRIVE ,0 , table_context->overdrive_table, false); -if (ret) { -pr_err ("Failed to export over drive table!\n" ); -return ret; +if (!(table_context->overdrive_table && table_context->boot_overdrive_table)) { +pr_err ("Overdrive table was not initialized!\n" ); +return -EINVAL ; } - +memcpy (table_context->overdrive_table, table_context->boot_overdrive_table,sizeof (OverDriveTable_t));break ;case PP_OD_COMMIT_DPM_TABLE :
Greg Kroah-Hartman
maintainerPATCH 274/367 virtio-balloon: initialize all vq callbacks
In reply to Greg Kroah-HartmanFrom: Daniel Verkamp <[email protected]>
commit 5790b53390e18fdd21e70776e46d058c05eda2f2 upstream.
Ensure that elements of the callbacks array that correspond to unavailable features are set to NULL; previously, they would be left uninitialized.
Since the corresponding names array elements were explicitly set to NULL, the uninitialized callback pointers would not actually be dereferenced; however, the uninitialized callbacks elements would still be read in vp_find_vqs_msix() and used to calculate the number of MSI-X vectors required.
--- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
@@ -475,7 +475,9 @@ static int init_vqs(struct virtio_balloo names[VIRTIO_BALLOON_VQ_INFLATE ] ="inflate" ; callbacks[VIRTIO_BALLOON_VQ_DEFLATE ] = balloon_ack; names[VIRTIO_BALLOON_VQ_DEFLATE ] ="deflate" ; + callbacks[VIRTIO_BALLOON_VQ_STATS ] =NULL ; names[VIRTIO_BALLOON_VQ_STATS ] =NULL ; + callbacks[VIRTIO_BALLOON_VQ_FREE_PAGE ] =NULL ; names[VIRTIO_BALLOON_VQ_FREE_PAGE ] =NULL ;if (virtio_has_feature (vb->vdev,VIRTIO_BALLOON_F_STATS_VQ )) {
Greg Kroah-Hartman
maintainerPATCH 269/367 drm/amd/powerplay: fix navi10 system intermittent reboot issue V2
In reply to Greg Kroah-HartmanFrom: Evan Quan <[email protected]>
commit 1cf8c930b378016846c88ef0f1444248033326ec upstream.
This workaround is needed only for Navi10 12 Gbps SKUs.
V2: added SMU firmware version guard
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 18 ++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 drivers/gpu/drm/amd/powerplay/inc/smu_types.h | 2 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0_ppsmc.h | 5 + drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 58 ++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/smu_internal.h | 3 + 6 files changed, 86 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +18 -0
@@ -21,6 +21,7 @@*/ #include <linux/firmware.h> +#include <linux/pci.h> #include "pp_debug.h" #include "amdgpu.h"
@@ -1125,6 +1126,23 @@ static int smu_smc_table_hw_init(struct ret =smu_get_power_limit (smu, &smu->default_power_limit, false, false);if (ret)return ret; + +if (adev->asic_type ==CHIP_NAVI10 ) { +if ((adev->pdev->device ==0x731f && (adev->pdev->revision ==0xc2 || + adev->pdev->revision ==0xc3 || + adev->pdev->revision ==0xca || + adev->pdev->revision ==0xcb )) || + (adev->pdev->device ==0x66af && (adev->pdev->revision ==0xf3 || + adev->pdev->revision ==0xf4 || + adev->pdev->revision ==0xf5 || + adev->pdev->revision ==0xf6 ))) { + ret =smu_disable_umc_cdr_12gbps_workaround (smu); +if (ret) { +pr_err ("Workaround failed to disable UMC CDR feature on 12Gbps SKU!\n" ); +return ret; + } + } + } }/*
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
@@ -550,6 +550,7 @@ struct pptable_funcs {int (*set_soft_freq_limited_range)(struct smu_context *smu,enum smu_clk_type clk_type,uint32_t min,uint32_t max);int (*override_pcie_parameters)(struct smu_context *smu);uint32_t (*get_pptable_power_limit)(struct smu_context *smu); +int (*disable_umc_cdr_12gbps_workaround)(struct smu_context *smu); };int smu_load_microcode (struct smu_context *smu);
drivers/gpu/drm/amd/powerplay/inc/smu_types.h +2 -0
@@ -170,6 +170,8 @@__SMU_DUMMY_MAP (SetSoftMinJpeg), \__SMU_DUMMY_MAP (SetHardMinFclkByFreq), \__SMU_DUMMY_MAP (DFCstateControl), \ +__SMU_DUMMY_MAP (DAL_DISABLE_DUMMY_PSTATE_CHANGE ), \ +__SMU_DUMMY_MAP (DAL_ENABLE_DUMMY_PSTATE_CHANGE ), \ #undef __SMU_DUMMY_MAP#define __SMU_DUMMY_MAP (type) SMU_MSG_##type
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0_ppsmc.h +4 -1
@@ -120,7 +120,10 @@#define PPSMC_MSG_GetVoltageByDpmOverdrive 0x45#define PPSMC_MSG_BacoAudioD3PME 0x48 -#define PPSMC_Message_Count 0x49 +#define PPSMC_MSG_DALDisableDummyPstateChange 0x49 +#define PPSMC_MSG_DALEnableDummyPstateChange 0x4A + +#define PPSMC_Message_Count 0x4Btypedef uint32_t PPSMC_Result ;typedef uint32_t PPSMC_Msg ;
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +58 -0
76 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/smu_internal.h +3 -0
@@ -201,4 +201,7 @@ int smu_send_smc_msg(struct smu_context#define smu_update_pcie_parameters (smu, pcie_gen_cap, pcie_width_cap) \ ((smu)->ppt_funcs->update_pcie_parameters ? (smu)->ppt_funcs->update_pcie_parameters((smu), (pcie_gen_cap), (pcie_width_cap)) : 0) +#define smu_disable_umc_cdr_12gbps_workaround (smu) \ + ((smu)->ppt_funcs->disable_umc_cdr_12gbps_workaround ? (smu)->ppt_funcs->disable_umc_cdr_12gbps_workaround((smu)) : 0) +#endif
Greg Kroah-Hartman
maintainerPATCH 270/367 drm/amd/dm/mst: Ignore payload update failures
In reply to Greg Kroah-HartmanFrom: Lyude Paul <[email protected]>
commit 58fe03d6dec908a1bec07eea7e94907af5c07eec upstream.
Disabling a display on MST can potentially happen after the entire MST topology has been removed, which means that we can't communicate with the topology at all in this scenario. Likewise, this also means that we can't properly update payloads on the topology and as such, it's a good idea to ignore payload update failures when disabling displays. Currently, amdgpu makes the mistake of halting the payload update process when any payload update failures occur, resulting in leaving DC's local copies of the payload tables out of date.
This ends up causing problems with hotplugging MST topologies, and causes modesets on the second hotplug to fail like so:
[drm] Failed to updateMST allocation table forpipe idx:1
------------[ cut here ]------------ WARNING: CPU: 5 PID: 1511 at drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:2677 update_mst_stream_alloc_table+0x11e/0x130 [amdgpu] Modules linked in: cdc_ether usbnet fuse xt_conntrack nf_conntrack
nf_defrag_ipv6 libcrc32c nf_defrag_ipv4 ipt_REJECT nf_reject_ipv4 nft_counter nft_compat nf_tables nfnetlink tun bridge stp llc sunrpc vfat fat wmi_bmof uvcvideo snd_hda_codec_realtek snd_hda_codec_generic snd_hda_codec_hdmi videobuf2_vmalloc snd_hda_intel videobuf2_memops videobuf2_v4l2 snd_intel_dspcfg videobuf2_common crct10dif_pclmul snd_hda_codec videodev crc32_pclmul snd_hwdep snd_hda_core ghash_clmulni_intel snd_seq mc joydev pcspkr snd_seq_device snd_pcm sp5100_tco k10temp i2c_piix4 snd_timer thinkpad_acpi ledtrig_audio snd wmi soundcore video i2c_scmi acpi_cpufreq ip_tables amdgpu(O) rtsx_pci_sdmmc amd_iommu_v2 gpu_sched mmc_core i2c_algo_bit ttm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops cec drm crc32c_intel serio_raw hid_multitouch r8152 mii nvme r8169 nvme_core rtsx_pci pinctrl_amd
CPU: 5 PID: 1511 Comm: gnome-shell Tainted: G O 5.5.0-rc7Lyude-Test+ #4 Hardware name: LENOVO FA495SIT26/FA495SIT26, BIOS R12ET22W(0.22 ) 01/31/2019 RIP: 0010:update_mst_stream_alloc_table+0x11e/0x130 [amdgpu] Code: 28 00 00 00 75 2b 48 8d 65 e0 5b 41 5c 41 5d 41 5e 5d c3 0f b6 06 49 89 1c 24 41 88 44 24 08 0f b6 46 01 41 88 44 24 09 eb 93 <0f> 0b e9 2f ff ff ff e8 a6 82 a3 c2 66 0f 1f 44 00 00 0f 1f 44 00 RSP: 0018:ffffac428127f5b0 EFLAGS: 00010202 RAX: 0000000000000002 RBX: ffff8d1e166eee80 RCX: 0000000000000000 RDX: ffffac428127f668 RSI: ffff8d1e166eee80 RDI: ffffac428127f610 RBP: ffffac428127f640 R08: ffffffffc03d94a8 R09: 0000000000000000 R10: ffff8d1e24b02000 R11: ffffac428127f5b0 R12: ffff8d1e1b83d000 R13: ffff8d1e1bea0b08 R14: 0000000000000002 R15: 0000000000000002 FS: 00007fab23ffcd80(0000) GS:ffff8d1e28b40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f151f1711e8 CR3: 00000005997c0000 CR4: 00000000003406e0 Call Trace: ? mutex_lock+0xe/0x30 dc_link_allocate_mst_payload+0x9a/0x210 [amdgpu] ? dm_read_reg_func+0x39/0xb0 [amdgpu] ? core_link_enable_stream+0x656/0x730 [amdgpu] core_link_enable_stream+0x656/0x730 [amdgpu] dce110_apply_ctx_to_hw+0x58e/0x5d0 [amdgpu] ? dcn10_verify_allow_pstate_change_high+0x1d/0x280 [amdgpu] ? dcn10_wait_for_mpcc_disconnect+0x3c/0x130 [amdgpu] dc_commit_state+0x292/0x770 [amdgpu] ? add_timer+0x101/0x1f0 ? ttm_bo_put+0x1a1/0x2f0 [ttm] amdgpu_dm_atomic_commit_tail+0xb59/0x1ff0 [amdgpu] ? amdgpu_move_blit.constprop.0+0xb8/0x1f0 [amdgpu] ? amdgpu_bo_move+0x16d/0x2b0 [amdgpu] ? ttm_bo_handle_move_mem+0x118/0x570 [ttm] ? ttm_bo_validate+0x134/0x150 [ttm] ? dm_plane_helper_prepare_fb+0x1b9/0x2a0 [amdgpu] ? _cond_resched+0x15/0x30 ? wait_for_completion_timeout+0x38/0x160 ? _cond_resched+0x15/0x30 ? wait_for_completion_interruptible+0x33/0x190 commit_tail+0x94/0x130 [drm_kms_helper] drm_atomic_helper_commit+0x113/0x140 [drm_kms_helper] drm_atomic_helper_set_config+0x70/0xb0 [drm_kms_helper] drm_mode_setcrtc+0x194/0x6a0 [drm] ? _cond_resched+0x15/0x30 ? mutex_lock+0xe/0x30 ? drm_mode_getcrtc+0x180/0x180 [drm] drm_ioctl_kernel+0xaa/0xf0 [drm] drm_ioctl+0x208/0x390 [drm] ? drm_mode_getcrtc+0x180/0x180 [drm] amdgpu_drm_ioctl+0x49/0x80 [amdgpu] do_vfs_ioctl+0x458/0x6d0 ksys_ioctl+0x5e/0x90 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x55/0x1b0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fab2121f87b Code: 0f 1e fa 48 8b 05 0d 96 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff
ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d dd 95 2c 00 f7 d8 64 89 01 48
RSP: 002b:00007ffd045f9068 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffd045f90a0 RCX: 00007fab2121f87b
RDX: 00007ffd045f90a0 RSI: 00000000c06864a2 RDI: 000000000000000b
RBP: 00007ffd045f90a0 R08: 0000000000000000 R09: 000055dbd2985d10
R10: 000055dbd2196280 R11: 0000000000000246 R12: 00000000c06864a2
R13: 000000000000000b R14: 0000000000000000 R15: 000055dbd2196280
---[ end trace 6ea888c24d2059cd ]---
Note as well, I have only been able to reproduce this on setups with 2 MST displays.
Changes since v1:
* Don't return false when part 1 or part 2 of updating the payloads fails, we don't want to abort at any step of the process even if things fail
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +4 -9
@@ -246,7 +246,8 @@ bool dm_helpers_dp_mst_write_payload_alldrm_dp_mst_reset_vcpi_slots (mst_mgr, mst_port); } - ret =drm_dp_update_payload_part1 (mst_mgr); +/* It's OK for this to fail */ +drm_dp_update_payload_part1 (mst_mgr);/* mst_mgr->->payloads are VC payload notify MST branch using DPCD or * AUX message. The sequence is slot 1-63 allocated sequence for each
@@ -255,9 +256,6 @@ bool dm_helpers_dp_mst_write_payload_allget_payload_table (aconnector, proposed_table); -if (ret) -return false; -return true; }
@@ -315,7 +313,6 @@ bool dm_helpers_dp_mst_send_payload_allostruct amdgpu_dm_connector *aconnector;struct drm_dp_mst_topology_mgr *mst_mgr;struct drm_dp_mst_port *mst_port; -int ret; aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
@@ -329,10 +326,8 @@ bool dm_helpers_dp_mst_send_payload_alloif (!mst_mgr->mst_state)return false; - ret =drm_dp_update_payload_part2 (mst_mgr); - -if (ret) -return false; +/* It's OK for this to fail */ +drm_dp_update_payload_part2 (mst_mgr);if (!enable)drm_dp_mst_deallocate_vcpi (mst_mgr, mst_port);
Greg Kroah-Hartman
maintainerPATCH 265/367 clk: tegra: Mark fuse clock as critical
In reply to Greg Kroah-HartmanFrom: Stephen Warren <[email protected]>
commit bf83b96f87ae2abb1e535306ea53608e8de5dfbb upstream.
For a little over a year, U-Boot on Tegra124 has configured the flow controller to perform automatic RAM re-repair on off->on power transitions of the CPU rail[1]. This is mandatory for correct operation of Tegra124. However, RAM re-repair relies on certain clocks, which the kernel must enable and leave running. The fuse clock is one of those clocks. Mark this clock as critical so that LP1 power mode (system suspend) operates correctly.
[1] 3cc7942a4ae5 ARM: tegra: implement RAM repair
--- drivers/clk/tegra/clk-tegra-periph.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/clk/tegra/clk-tegra-periph.c +5 -1
@@ -777,7 +777,11 @@ static struct tegra_periph_init_data gatGATE ("ahbdma" ,"hclk" ,33 ,0 , tegra_clk_ahbdma,0 ),GATE ("apbdma" ,"pclk" ,34 ,0 , tegra_clk_apbdma,0 ),GATE ("kbc" ,"clk_32k" ,36 ,TEGRA_PERIPH_ON_APB |TEGRA_PERIPH_NO_RESET , tegra_clk_kbc,0 ), -GATE ("fuse" ,"clk_m" ,39 ,TEGRA_PERIPH_ON_APB , tegra_clk_fuse,0 ), +/* +* Critical for RAM re-repair operation, which must occur on resume +* from LP1 system suspend and as part of CCPLEX cluster switching. +*/ +GATE ("fuse" ,"clk_m" ,39 ,TEGRA_PERIPH_ON_APB , tegra_clk_fuse,CLK_IS_CRITICAL ),GATE ("fuse_burn" ,"clk_m" ,39 ,TEGRA_PERIPH_ON_APB , tegra_clk_fuse_burn,0 ),GATE ("kfuse" ,"clk_m" ,40 ,TEGRA_PERIPH_ON_APB , tegra_clk_kfuse,0 ), GATE("apbif", "clk_m", 107, TEGRA_PERIPH_ON_APB, tegra_clk_apbif, 0),
Greg Kroah-Hartman
maintainerPATCH 247/367 x86/KVM: Make sure KVM_VCPU_FLUSH_TLB flag is not missed
In reply to Greg Kroah-HartmanFrom: Boris Ostrovsky <[email protected]>
commit b043138246a41064527cf019a3d51d9f015e9796 upstream.
There is a potential race in record_steal_time() between setting host-local vcpu->arch.st.steal.preempted to zero (i.e. clearing KVM_VCPU_PREEMPTED) and propagating this value to the guest with kvm_write_guest_cached(). Between those two events the guest may still see KVM_VCPU_PREEMPTED in its copy of kvm_steal_time, set KVM_VCPU_FLUSH_TLB and assume that hypervisor will do the right thing. Which it won't.
Instad of copying, we should map kvm_steal_time and that will guarantee atomicity of accesses to @preempted.
This is part of CVE-2019-3016.
--- arch/x86/kvm/x86.c | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-)
arch/x86/kvm/x86.c +30 -21
@@ -2588,45 +2588,47 @@ static void kvm_vcpu_flush_tlb(struct kvstatic void record_steal_time (struct kvm_vcpu *vcpu) { +struct kvm_host_map map; +struct kvm_steal_time *st; +if (!(vcpu->arch.st.msr_val &KVM_MSR_ENABLED ))return ; -if (unlikely (kvm_read_guest_cached (vcpu->kvm, &vcpu->arch.st.stime, - &vcpu->arch.st.steal,sizeof (struct kvm_steal_time )))) +/* -EAGAIN is returned in atomic context so we can just return. */ +if (kvm_map_gfn (vcpu, vcpu->arch.st.msr_val >>PAGE_SHIFT , + &map, &vcpu->arch.st.cache, false))return ; + st = map.hva + +offset_in_page (vcpu->arch.st.msr_val &KVM_STEAL_VALID_BITS ); +/* * Doing a TLB flush here, on the guest's behalf, can avoid * expensive IPIs. */ trace_kvm_pv_tlb_flush (vcpu->vcpu_id, - vcpu->arch.st.steal.preempted &KVM_VCPU_FLUSH_TLB ); -if (xchg (&vcpu->arch.st.steal.preempted,0 ) &KVM_VCPU_FLUSH_TLB ) + st->preempted &KVM_VCPU_FLUSH_TLB ); +if (xchg (&st->preempted,0 ) &KVM_VCPU_FLUSH_TLB )kvm_vcpu_flush_tlb (vcpu, false); -if (vcpu->arch.st.steal.version &1 ) - vcpu->arch.st.steal.version +=1 ;/* first time write, random junk */ + vcpu->arch.st.steal.preempted =0 ; - vcpu->arch.st.steal.version +=1 ; +if (st->version &1 ) + st->version +=1 ;/* first time write, random junk */ -kvm_write_guest_cached (vcpu->kvm, &vcpu->arch.st.stime, - &vcpu->arch.st.steal,sizeof (struct kvm_steal_time )); + st->version +=1 ;smp_wmb (); - vcpu->arch.st.steal.steal += current->sched_info.run_delay - + st->steal += current->sched_info.run_delay - vcpu->arch.st.last_steal; vcpu->arch.st.last_steal = current->sched_info.run_delay; -kvm_write_guest_cached (vcpu->kvm, &vcpu->arch.st.stime, - &vcpu->arch.st.steal,sizeof (struct kvm_steal_time )); -smp_wmb (); - vcpu->arch.st.steal.version +=1 ; + st->version +=1 ; -kvm_write_guest_cached (vcpu->kvm, &vcpu->arch.st.stime, - &vcpu->arch.st.steal,sizeof (struct kvm_steal_time )); +kvm_unmap_gfn (vcpu, &map, &vcpu->arch.st.cache, true, false); }int kvm_set_msr_common (struct kvm_vcpu *vcpu,struct msr_data *msr_info)
@@ -3511,18 +3513,25 @@ void kvm_arch_vcpu_load(struct kvm_vcpustatic void kvm_steal_time_set_preempted (struct kvm_vcpu *vcpu) { +struct kvm_host_map map; +struct kvm_steal_time *st; +if (!(vcpu->arch.st.msr_val &KVM_MSR_ENABLED ))return ;if (vcpu->arch.st.steal.preempted)return ; - vcpu->arch.st.steal.preempted =KVM_VCPU_PREEMPTED ; +if (kvm_map_gfn (vcpu, vcpu->arch.st.msr_val >>PAGE_SHIFT , &map, + &vcpu->arch.st.cache, true)) +return ; + + st = map.hva + +offset_in_page (vcpu->arch.st.msr_val &KVM_STEAL_VALID_BITS ); + + st->preempted = vcpu->arch.st.steal.preempted =KVM_VCPU_PREEMPTED ; -kvm_write_guest_offset_cached (vcpu->kvm, &vcpu->arch.st.stime, - &vcpu->arch.st.steal.preempted, - offsetof(struct kvm_steal_time , preempted), -sizeof (vcpu->arch.st.steal.preempted)); +kvm_unmap_gfn (vcpu, &map, &vcpu->arch.st.cache, true, true); }void kvm_arch_vcpu_put (struct kvm_vcpu *vcpu)
Greg Kroah-Hartman
maintainerPATCH 263/367 arm64: dts: qcom: qcs404-evb: Set vdd_apc regulator in high power mode
In reply to Greg Kroah-HartmanFrom: Niklas Cassel <[email protected]>
commit eac8ce86cb90ba96cb4bcbf2549d7a8b6938aa30 upstream.
vdd_apc is the regulator that supplies the main CPU cluster.
At sudden CPU load changes, we have noticed invalid page faults on addresses with all bits shifted, as well as on addresses with individual bits flipped.
By putting the vdd_apc regulator in high power mode, the voltage drops during sudden load changes will be less severe, and we have not been able to reproduce the invalid page faults with the regulator in this mode.
--- arch/arm64/boot/dts/qcom/qcs404-evb.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/qcs404-evb.dtsi +1 -0
@@ -73,6 +73,7 @@ regulator-always-on; regulator-boot-on; regulator-name = "vdd_apc"; + regulator-initial-mode = <1>; regulator-min-microvolt = <1048000>; regulator-max-microvolt = <1384000>; };
Greg Kroah-Hartman
maintainerPATCH 262/367 mm/page_alloc.c: fix uninitialized memmaps on a partially populated last section
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
commit e822969cab48b786b64246aad1a3ba2a774f5d23 upstream.
Patch series "mm: fix max_pfn not falling on section boundary", v2.
Playing with different memory sizes for a x86-64 guest, I discovered that some memmaps (highest section if max_mem does not fall on the section boundary) are marked as being valid and online, but contain garbage. We have to properly initialize these memmaps.
Looking at /proc/kpageflags and friends, I found some more issues, partially related to this.
This patch (of 3):
If max_pfn is not aligned to a section boundary, we can easily run into BUGs. This can e.g., be triggered on x86-64 under QEMU by specifying a memory size that is not a multiple of 128MB (e.g., 4097MB, but also 4160MB). I was told that on real HW, we can easily have this scenario (esp., one of the main reasons sub-section hotadd of devmem was added).
The issue is, that we have a valid memmap (pfn_valid()) for the whole section, and the whole section will be marked "online". pfn_to_online_page() will succeed, but the memmap contains garbage.
E.g., doing a "./page-types -r -a 0x144001" when QEMU was started with "-m 4160M" - (see tools/vm/page-types.c):
[ 200.476376] BUG: unable to handle page fault for address: fffffffffffffffe [ 200.477500] #PF: supervisor read access in kernel mode [ 200.478334] #PF: error_code(0x0000) - not-present page [ 200.479076] PGD 59614067 P4D 59614067 PUD 59616067 PMD 0 [ 200.479557] Oops: 0000 [#4] SMP NOPTI [ 200.479875] CPU: 0 PID: 603 Comm: page-types Tainted: G D W 5.5.0-rc1-next-20191209 #93 [ 200.480646] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu4 [ 200.481648] RIP: 0010:stable_page_flags+0x4d/0x410 [ 200.482061] Code: f3 ff 41 89 c0 48 b8 00 00 00 00 01 00 00 00 45 84 c0 0f 85 cd 02 00 00 48 8b 53 08 48 8b 2b 48f [ 200.483644] RSP: 0018:ffffb139401cbe60 EFLAGS: 00010202 [ 200.484091] RAX: fffffffffffffffe RBX: fffffbeec5100040 RCX: 0000000000000000 [ 200.484697] RDX: 0000000000000001 RSI: ffffffff9535c7cd RDI: 0000000000000246 [ 200.485313] RBP: ffffffffffffffff R08: 0000000000000000 R09: 0000000000000000 [ 200.485917] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000144001 [ 200.486523] R13: 00007ffd6ba55f48 R14: 00007ffd6ba55f40 R15: ffffb139401cbf08 [ 200.487130] FS: 00007f68df717580(0000) GS:ffff9ec77fa00000(0000) knlGS:0000000000000000 [ 200.487804] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 200.488295] CR2: fffffffffffffffe CR3: 0000000135d48000 CR4: 00000000000006f0 [ 200.488897] Call Trace: [ 200.489115] kpageflags_read+0xe9/0x140 [ 200.489447] proc_reg_read+0x3c/0x60 [ 200.489755] vfs_read+0xc2/0x170 [ 200.490037] ksys_pread64+0x65/0xa0 [ 200.490352] do_syscall_64+0x5c/0xa0 [ 200.490665] entry_SYSCALL_64_after_hwframe+0x49/0xbe
But it can be triggered much easier via "cat /proc/kpageflags > /dev/null" after cold/hot plugging a DIMM to such a system:
[root@localhost ~]# cat /proc/kpageflags > /dev/null
[ 111.517275] BUG: unable to handle page fault for address: fffffffffffffffe [ 111.517907] #PF: supervisor read access in kernel mode [ 111.518333] #PF: error_code(0x0000) - not-present page [ 111.518771] PGD a240e067 P4D a240e067 PUD a2410067 PMD 0
This patch fixes that by at least zero-ing out that memmap (so e.g., page_to_pfn() will not crash). Commit 907ec5fca3dc ("mm: zero remaining unavailable struct pages") tried to fix a similar issue, but forgot to consider this special case.
After this patch, there are still problems to solve. E.g., not all of these pages falling into a memory hole will actually get initialized later and set PageReserved - they are only zeroed out - but at least the immediate crashes are gone. A follow-up patch will take care of this.
--- mm/page_alloc.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
mm/page_alloc.c +12 -2
@@ -6921,7 +6921,8 @@ static u64 zero_pfn_range(unsigned long* This function also addresses a similar issue where struct pages are left * uninitialized because the physical address range is not covered by * memblock.memory or memblock.reserved. That could happen when memblock -* layout is manually configured via memmap=. +* layout is manually configured via memmap=, or when the highest physical +* address (max_pfn) does not end on a section boundary. */ void __init zero_resv_unavail (void ) {
@@ -6939,7 +6940,16 @@ void __init zero_resv_unavail(void) pgcnt +=zero_pfn_range (PFN_DOWN (next),PFN_UP (start)); next = end; } - pgcnt +=zero_pfn_range (PFN_DOWN (next), max_pfn); + +/* +* Early sections always have a fully populated memmap for the whole +* section - see pfn_valid(). If the last section has holes at the +* end and that section is marked "online", the memmap will be +* considered initialized. Make sure that memmap has a well defined +* state. +*/ + pgcnt +=zero_pfn_range (PFN_DOWN (next), +round_up (max_pfn,PAGES_PER_SECTION ));/* * Struct pages that do not have backing memory. This could be because
Greg Kroah-Hartman
maintainerPATCH 259/367 KVM: x86: reorganize pvclock_gtod_data members
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 917f9475c0a8ab8958db7f22a5d495b9a1d51be6 upstream.
We will need a copy of tk->offs_boot in the next patch. Store it and cleanup the struct: instead of storing tk->tkr_xxx.base with the tk->offs_boot included, store the raw value in struct pvclock_clock and sum it indo_monotonic_raw and do_realtime. tk->tkr_xxx.xtime_nsec also moves
to struct pvclock_clock.
While at it, fix a (usually harmless) typo in do_monotonic_raw, which was using gtod->clock.shift instead of gtod->raw_clock.shift.
--- arch/x86/kvm/x86.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-)
arch/x86/kvm/x86.c +12 -17
@@ -1580,6 +1580,8 @@ struct pvclock_clock {u64 mask;u32 mult;u32 shift; +u64 base_cycles; +u64 offset; };struct pvclock_gtod_data {
@@ -1588,11 +1590,8 @@ struct pvclock_gtod_data {struct pvclock_clock clock;/* extract of a clocksource struct */ struct pvclock_clock raw_clock;/* extract of a clocksource struct */ -u64 boot_ns_raw; -u64 boot_ns; -u64 nsec_base; +ktime_t offs_boot;u64 wall_time_sec; -u64 monotonic_raw_nsec; };static struct pvclock_gtod_data pvclock_gtod_data;
@@ -1600,10 +1599,6 @@ static struct pvclock_gtod_data pvclock_static void update_pvclock_gtod (struct timekeeper *tk) {struct pvclock_gtod_data *vdata = &pvclock_gtod_data; -u64 boot_ns, boot_ns_raw; - - boot_ns =ktime_to_ns (ktime_add (tk->tkr_mono.base, tk->offs_boot)); - boot_ns_raw =ktime_to_ns (ktime_add (tk->tkr_raw.base, tk->offs_boot));write_seqcount_begin (&vdata->seq);
@@ -1613,20 +1608,20 @@ static void update_pvclock_gtod(struct t vdata->clock.mask = tk->tkr_mono.mask; vdata->clock.mult = tk->tkr_mono.mult; vdata->clock.shift = tk->tkr_mono.shift; + vdata->clock.base_cycles = tk->tkr_mono.xtime_nsec; + vdata->clock.offset = tk->tkr_mono.base; vdata->raw_clock.vclock_mode = tk->tkr_raw.clock->archdata.vclock_mode; vdata->raw_clock.cycle_last = tk->tkr_raw.cycle_last; vdata->raw_clock.mask = tk->tkr_raw.mask; vdata->raw_clock.mult = tk->tkr_raw.mult; vdata->raw_clock.shift = tk->tkr_raw.shift; - - vdata->boot_ns = boot_ns; - vdata->nsec_base = tk->tkr_mono.xtime_nsec; + vdata->raw_clock.base_cycles = tk->tkr_raw.xtime_nsec; + vdata->raw_clock.offset = tk->tkr_raw.base; vdata->wall_time_sec = tk->xtime_sec; - vdata->boot_ns_raw = boot_ns_raw; - vdata->monotonic_raw_nsec = tk->tkr_raw.xtime_nsec; + vdata->offs_boot = tk->offs_boot;write_seqcount_end (&vdata->seq); }
@@ -2096,10 +2091,10 @@ static int do_monotonic_raw(s64 *t, u64do { seq =read_seqcount_begin (>od->seq); - ns = gtod->monotonic_raw_nsec; + ns = gtod->raw_clock.base_cycles; ns +=vgettsc (>od->raw_clock, tsc_timestamp, &mode); - ns >>= gtod->clock.shift; - ns += gtod->boot_ns_raw; + ns >>= gtod->raw_clock.shift; + ns +=ktime_to_ns (ktime_add (gtod->raw_clock.offset, gtod->offs_boot)); }while (unlikely (read_seqcount_retry (>od->seq, seq))); *t = ns;
@@ -2116,7 +2111,7 @@ static int do_realtime(struct timespec64do { seq =read_seqcount_begin (>od->seq); ts->tv_sec = gtod->wall_time_sec; - ns = gtod->nsec_base; + ns = gtod->clock.base_cycles; ns +=vgettsc (>od->clock, tsc_timestamp, &mode); ns >>= gtod->clock.shift; }while (unlikely (read_seqcount_retry (>od->seq, seq)));
Greg Kroah-Hartman
maintainerPATCH 260/367 KVM: x86: use raw clock values consistently
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 8171cd68806bd2fc28ef688e32fb2a3b3deb04e5 upstream.
Commit 53fafdbb8b21f ("KVM: x86: switch KVMCLOCK base to monotonic raw clock") changed kvmclock to use tkr_raw instead of tkr_mono. However, the default kvmclock_offset for the VM was still based on the monotonic clock and, if the raw clock drifted enough from the monotonic clock, this could cause a negative system_time to be written to the guest's struct pvclock. RHEL5 does not like it and (if it boots fast enough to observe a negative time value) it hangs.
There is another thing to be careful about: getboottime64 returns the host boot time with tkr_mono frequency, and subtracting the tkr_raw-based kvmclock value will cause the wallclock to be off if tkr_raw drifts from tkr_mono. To avoid this, compute the wallclock delta from the current time instead of being clever and using getboottime64.
--- arch/x86/kvm/x86.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-)
arch/x86/kvm/x86.c +23 -15
@@ -1625,6 +1625,18 @@ static void update_pvclock_gtod(struct t write_seqcount_end(&vdata->seq); } + +static s64 get_kvmclock_base_ns (void ) +{ +/* Count up from boot time, but with the frequency of the raw clock. */ +return ktime_to_ns (ktime_add (ktime_get_raw (), pvclock_gtod_data.offs_boot)); +} +#else +static s64 get_kvmclock_base_ns (void ) +{ +/* Master clock not used, so we can just use CLOCK_BOOTTIME. */ +return ktime_get_boottime_ns (); +}#endif void kvm_set_pending_timer (struct kvm_vcpu *vcpu)
@@ -1638,7 +1650,7 @@ static void kvm_write_wall_clock(structint version;int r;struct pvclock_wall_clock wc; -struct timespec64 boot; +u64 wall_nsec;if (!wall_clock)return ;
@@ -1658,17 +1670,12 @@ static void kvm_write_wall_clock(struct/* * The guest calculates current wall clock time by adding * system time (updated by kvm_guest_time_update below) to the -* wall clock specified here. guest system time equals host -* system time for us, thus we must fill in host boot time here. +* wall clock specified here. We do the reverse here. */ -getboottime64 (&boot); + wall_nsec =ktime_get_real_ns () -get_kvmclock_ns (kvm); -if (kvm->arch.kvmclock_offset) { -struct timespec64 ts =ns_to_timespec64 (kvm->arch.kvmclock_offset); - boot =timespec64_sub (boot, ts); - } - wc.sec = (u32 )boot.tv_sec;/* overflow in 2106 guest time */ - wc.nsec = boot.tv_nsec; + wc.nsec =do_div (wall_nsec,1000000000 ); + wc.sec = (u32 )wall_nsec;/* overflow in 2106 guest time */ wc.version = version;kvm_write_guest (kvm, wall_clock, &wc,sizeof (wc));
@@ -1916,7 +1923,7 @@ void kvm_write_tsc(struct kvm_vcpu *vcpuraw_spin_lock_irqsave (&kvm->arch.tsc_write_lock, flags); offset =kvm_compute_tsc_offset (vcpu, data); - ns =ktime_get_boottime_ns (); + ns =get_kvmclock_base_ns (); elapsed = ns - kvm->arch.last_tsc_nsec;if (vcpu->arch.virtual_tsc_khz) {
@@ -2254,7 +2261,7 @@ u64 get_kvmclock_ns(struct kvm *kvm)spin_lock (&ka->pvclock_gtod_sync_lock);if (!ka->use_master_clock) {spin_unlock (&ka->pvclock_gtod_sync_lock); -return ktime_get_boottime_ns () + ka->kvmclock_offset; +return get_kvmclock_base_ns () + ka->kvmclock_offset; } hv_clock.tsc_timestamp = ka->master_cycle_now;
@@ -2270,7 +2277,7 @@ u64 get_kvmclock_ns(struct kvm *kvm) &hv_clock.tsc_to_system_mul); ret =__pvclock_read_cycles (&hv_clock,rdtsc ()); }else - ret =ktime_get_boottime_ns () + ka->kvmclock_offset; + ret =get_kvmclock_base_ns () + ka->kvmclock_offset;put_cpu ();
@@ -2369,7 +2376,7 @@ static int kvm_guest_time_update(struct }if (!use_master_clock) { host_tsc =rdtsc (); - kernel_ns =ktime_get_boottime_ns (); + kernel_ns =get_kvmclock_base_ns (); } tsc_timestamp =kvm_read_l1_tsc (v, host_tsc);
@@ -2409,6 +2416,7 @@ static int kvm_guest_time_update(struct vcpu->hv_clock.tsc_timestamp = tsc_timestamp; vcpu->hv_clock.system_time = kernel_ns + v->kvm->arch.kvmclock_offset; vcpu->last_guest_tsc = tsc_timestamp; +WARN_ON (vcpu->hv_clock.system_time <0 );/* If the host uses TSC clocksource, then it is stable */ pvclock_flags =0 ;
@@ -9580,7 +9588,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unmutex_init (&kvm->arch.apic_map_lock);spin_lock_init (&kvm->arch.pvclock_gtod_sync_lock); - kvm->arch.kvmclock_offset = -ktime_get_boottime_ns (); + kvm->arch.kvmclock_offset = -get_kvmclock_base_ns ();pvclock_update_vm_gtod_copy (kvm); kvm->arch.guest_can_read_msr_platform_info = true;
Greg Kroah-Hartman
maintainerPATCH 257/367 KVM: x86: Revert "KVM: X86: Fix fpu state crash in kvm guest"
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 2620fe268e80d667a94553cd37a94ccaa2cb8c83 upstream.
Reload the current thread's FPU state, which contains the guest's FPU state, to the CPU registers if necessary during vcpu_enter_guest(). TIF_NEED_FPU_LOAD can be set any time control is transferred out of KVM, e.g. if I/O is triggered during a KVM call to get_user_pages() or if a softirq occurs while KVM is scheduled in.
Moving the handling of TIF_NEED_FPU_LOAD from vcpu_enter_guest() to kvm_arch_vcpu_load(), effectively kvm_sched_in(), papered over a bug where kvm_put_guest_fpu() failed to account for TIF_NEED_FPU_LOAD. The easiest way to the kvm_put_guest_fpu() bug was to run with involuntary preemption enable, thus handling TIF_NEED_FPU_LOAD during kvm_sched_in() made the bug go away. But, removing the handling in vcpu_enter_guest() exposed KVM to the rare case of a softirq triggering kernel_fpu_begin() between vcpu_load() and vcpu_enter_guest().
Now that kvm_{load,put}_guest_fpu() correctly handle TIF_NEED_FPU_LOAD, revert the commit to both restore the vcpu_enter_guest() behavior and eliminate the superfluous switch_fpu_return() in kvm_arch_vcpu_load().
Note, leaving the handling in kvm_arch_vcpu_load() isn't wrong per se, but it is unnecessary, and most critically, makes it extremely difficult to find bugs such as the kvm_put_guest_fpu() issue due to shrinking the window where a softirq can corrupt state.
A sample trace triggered by warning if TIF_NEED_FPU_LOAD is set while vcpu state is loaded:
<IRQ> gcmaes_crypt_by_sg.constprop.12+0x26e/0x660 ? 0xffffffffc024547d ? __qdisc_run+0x83/0x510 ? __dev_queue_xmit+0x45e/0x990 ? ip_finish_output2+0x1a8/0x570 ? fib4_rule_action+0x61/0x70 ? fib4_rule_action+0x70/0x70 ? fib_rules_lookup+0x13f/0x1c0 ? helper_rfc4106_decrypt+0x82/0xa0 ? crypto_aead_decrypt+0x40/0x70 ? crypto_aead_decrypt+0x40/0x70 ? crypto_aead_decrypt+0x40/0x70 ? esp_output_tail+0x8f4/0xa5a [esp4] ? skb_ext_add+0xd3/0x170 ? xfrm_input+0x7a6/0x12c0 ? xfrm4_rcv_encap+0xae/0xd0 ? xfrm4_transport_finish+0x200/0x200 ? udp_queue_rcv_one_skb+0x1ba/0x460 ? udp_unicast_rcv_skb.isra.63+0x72/0x90 ? __udp4_lib_rcv+0x51b/0xb00 ? ip_protocol_deliver_rcu+0xd2/0x1c0 ? ip_local_deliver_finish+0x44/0x50 ? ip_local_deliver+0xe0/0xf0 ? ip_protocol_deliver_rcu+0x1c0/0x1c0 ? ip_rcv+0xbc/0xd0 ? ip_rcv_finish_core.isra.19+0x380/0x380 ? __netif_receive_skb_one_core+0x7e/0x90 ? netif_receive_skb_internal+0x3d/0xb0 ? napi_gro_receive+0xed/0x150 ? 0xffffffffc0243c77 ? net_rx_action+0x149/0x3b0 ? __do_softirq+0xe4/0x2f8 ? handle_irq_event_percpu+0x6a/0x80 ? irq_exit+0xe6/0xf0 ? do_IRQ+0x7f/0xd0 ? common_interrupt+0xf/0xf </IRQ> ? irq_entries_start+0x20/0x660 ? vmx_get_interrupt_shadow+0x2f0/0x710 [kvm_intel] ? kvm_set_msr_common+0xfc7/0x2380 [kvm] ? recalibrate_cpu_khz+0x10/0x10 ? ktime_get+0x3a/0xa0 ? kvm_arch_vcpu_ioctl_run+0x107/0x560 [kvm] ? kvm_init+0x6bf/0xd00 [kvm] ? __seccomp_filter+0x7a/0x680 ? do_vfs_ioctl+0xa4/0x630 ? security_file_ioctl+0x32/0x50 ? ksys_ioctl+0x60/0x90 ? __x64_sys_ioctl+0x16/0x20 ? do_syscall_64+0x5f/0x1a0 ? entry_SYSCALL_64_after_hwframe+0x44/0xa9 ---[ end trace 9564a1ccad733a90 ]---
This reverts commit e751732486eb3f159089a64d1901992b1357e7cc.
--- arch/x86/kvm/x86.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
arch/x86/kvm/x86.c +3 -6
@@ -3496,10 +3496,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu kvm_x86_ops->vcpu_load (vcpu, cpu); -fpregs_assert_state_consistent (); -if (test_thread_flag (TIF_NEED_FPU_LOAD )) -switch_fpu_return (); -/* Apply any externally detected TSC adjustments (due to suspend) */ if (unlikely (vcpu->arch.tsc_offset_adjustment)) {adjust_tsc_offset_host (vcpu, vcpu->arch.tsc_offset_adjustment);
@@ -8244,8 +8240,9 @@ static int vcpu_enter_guest(struct kvm_vtrace_kvm_entry (vcpu->vcpu_id);guest_enter_irqoff (); -/* The preempt notifier should have taken care of the FPU already. */ -WARN_ON_ONCE (test_thread_flag (TIF_NEED_FPU_LOAD )); +fpregs_assert_state_consistent (); +if (test_thread_flag (TIF_NEED_FPU_LOAD )) +switch_fpu_return ();if (unlikely (vcpu->arch.switch_db_regs)) {set_debugreg (0 ,7 );
Greg Kroah-Hartman
maintainerPATCH 258/367 KVM: s390: do not clobber registers during guest reset/store status
In reply to Greg Kroah-HartmanFrom: Christian Borntraeger <[email protected]>
commit 55680890ea78be0df5e1384989f1be835043c084 upstream.
The initial CPU reset clobbers the userspace fpc and the store status ioctl clobbers the guest acrs + fpr. As these calls are only done via ioctl (and not via vcpu_run), no CPU context is loaded, so we can (and must) act directly on the sync regs, not on the thread context.
--- arch/s390/kvm/kvm-s390.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/s390/kvm/kvm-s390.c +2 -4
@@ -2860,9 +2860,7 @@ static void kvm_s390_vcpu_initial_reset( vcpu->arch.sie_block->gcr[14 ] =CR14_UNUSED_32 |CR14_UNUSED_33 |CR14_EXTERNAL_DAMAGE_SUBMASK ; -/* make sure the new fpc will be lazily loaded */ -save_fpu_regs (); - current->thread.fpu.fpc =0 ; + vcpu->run->s.regs.fpc =0 ; vcpu->arch.sie_block->gbea =1 ; vcpu->arch.sie_block->pp =0 ; vcpu->arch.sie_block->fpf &= ~FPF_BPBC ;
@@ -4351,7 +4349,7 @@ long kvm_arch_vcpu_ioctl(struct file *fiswitch (ioctl) {case KVM_S390_STORE_STATUS : idx =srcu_read_lock (&vcpu->kvm->srcu); - r =kvm_s390_vcpu_store_status (vcpu, arg); + r =kvm_s390_store_status_unloaded (vcpu, arg);srcu_read_unlock (&vcpu->kvm->srcu, idx);break ;case KVM_S390_SET_INITIAL_PSW : {
Greg Kroah-Hartman
maintainerPATCH 256/367 KVM: x86: Ensure guests FPU state is loaded when accessing for emulation
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit a7baead7e312f5a05381d68585fb6dc68e19e90f upstream.
Lock the FPU regs and reload the current thread's FPU state, which holds the guest's FPU state, to the CPU registers if necessary prior to accessing guest FPU state as part of emulation. kernel_fpu_begin() can be called from softirq context, therefore KVM must ensure softirqs are disabled (locking the FPU regs disables softirqs) when touching CPU FPU state.
Note, for all intents and purposes this reverts commit 6ab0b9feb82a7 ("x86,kvm: remove KVM emulator get_fpu / put_fpu"), but at the time it was applied, removing get/put_fpu() was correct. The re-introduction of {get,put}_fpu() is necessitated by the deferring of FPU state load.
--- arch/x86/kvm/emulate.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
arch/x86/kvm/emulate.c +39 -0
@@ -22,6 +22,7 @@#include "kvm_cache_regs.h" #include <asm/kvm_emulate.h> #include <linux/stringify.h> +#include <asm/fpu/api.h> #include <asm/debugreg.h> #include <asm/nospec-branch.h>
@@ -1075,8 +1076,23 @@ static void fetch_register_operand(struc } } +static void emulator_get_fpu (void ) +{ +fpregs_lock (); + +fpregs_assert_state_consistent (); +if (test_thread_flag (TIF_NEED_FPU_LOAD )) +switch_fpu_return (); +} + +static void emulator_put_fpu (void ) +{ +fpregs_unlock (); +} +static void read_sse_reg (struct x86_emulate_ctxt *ctxt,sse128_t *data,int reg) { +emulator_get_fpu ();switch (reg) {case 0 : asm("movdqa %%xmm0, %0" :"=m" (*data));break ;case 1 : asm("movdqa %%xmm1, %0" :"=m" (*data));break ;
@@ -1098,11 +1114,13 @@ static void read_sse_reg(struct x86_emul#endif default :BUG (); } +emulator_put_fpu (); }static void write_sse_reg (struct x86_emulate_ctxt *ctxt,sse128_t *data,int reg) { +emulator_get_fpu ();switch (reg) {case 0 : asm("movdqa %0, %%xmm0" : :"m" (*data));break ;case 1 : asm("movdqa %0, %%xmm1" : :"m" (*data));break ;
@@ -1124,10 +1142,12 @@ static void write_sse_reg(struct x86_emu#endif default :BUG (); } +emulator_put_fpu (); }static void read_mmx_reg (struct x86_emulate_ctxt *ctxt,u64 *data,int reg) { +emulator_get_fpu ();switch (reg) {case 0 : asm("movq %%mm0, %0" :"=m" (*data));break ;case 1 : asm("movq %%mm1, %0" :"=m" (*data));break ;
@@ -1139,10 +1159,12 @@ static void read_mmx_reg(struct x86_emulcase 7 : asm("movq %%mm7, %0" :"=m" (*data));break ;default :BUG (); } +emulator_put_fpu (); }static void write_mmx_reg (struct x86_emulate_ctxt *ctxt,u64 *data,int reg) { +emulator_get_fpu ();switch (reg) {case 0 : asm("movq %0, %%mm0" : :"m" (*data));break ;case 1 : asm("movq %0, %%mm1" : :"m" (*data));break ;
@@ -1154,6 +1176,7 @@ static void write_mmx_reg(struct x86_emucase 7 : asm("movq %0, %%mm7" : :"m" (*data));break ;default :BUG (); } +emulator_put_fpu (); }static int em_fninit (struct x86_emulate_ctxt *ctxt)
@@ -1161,7 +1184,9 @@ static int em_fninit(struct x86_emulate_if (ctxt->ops->get_cr (ctxt,0 ) & (X86_CR0_TS |X86_CR0_EM ))return emulate_nm (ctxt); +emulator_get_fpu (); asmvolatile ("fninit" ); +emulator_put_fpu ();return X86EMUL_CONTINUE ; }
@@ -1172,7 +1197,9 @@ static int em_fnstcw(struct x86_emulate_if (ctxt->ops->get_cr (ctxt,0 ) & (X86_CR0_TS |X86_CR0_EM ))return emulate_nm (ctxt); +emulator_get_fpu (); asmvolatile ("fnstcw %0" :"+m" (fcw)); +emulator_put_fpu (); ctxt->dst.val = fcw;
@@ -1186,7 +1213,9 @@ static int em_fnstsw(struct x86_emulate_if (ctxt->ops->get_cr (ctxt,0 ) & (X86_CR0_TS |X86_CR0_EM ))return emulate_nm (ctxt); +emulator_get_fpu (); asmvolatile ("fnstsw %0" :"+m" (fsw)); +emulator_put_fpu (); ctxt->dst.val = fsw;
@@ -4092,8 +4121,12 @@ static int em_fxsave(struct x86_emulate_if (rc !=X86EMUL_CONTINUE )return rc; +emulator_get_fpu (); + rc = asm_safe("fxsave %[fx]", , [fx] "+m"(fx_state)); +emulator_put_fpu (); +if (rc !=X86EMUL_CONTINUE )return rc;
@@ -4136,6 +4169,8 @@ static int em_fxrstor(struct x86_emulateif (rc !=X86EMUL_CONTINUE )return rc; +emulator_get_fpu (); +if (size <__fxstate_size (16 )) { rc =fxregs_fixup (&fx_state, size);if (rc !=X86EMUL_CONTINUE )
@@ -4151,6 +4186,8 @@ static int em_fxrstor(struct x86_emulate rc = asm_safe("fxrstor %[fx]", : [fx] "m"(fx_state)); out: +emulator_put_fpu (); +return rc; }
@@ -5465,7 +5502,9 @@ static int flush_pending_x87_faults(stru {int rc; +emulator_get_fpu (); rc =asm_safe ("fwait" ); +emulator_put_fpu ();if (unlikely (rc !=X86EMUL_CONTINUE ))return emulate_exception (ctxt,MF_VECTOR ,0 , false);
Greg Kroah-Hartman
maintainerPATCH 246/367 x86/kvm: Introduce kvm_(un)map_gfn()
In reply to Greg Kroah-HartmanFrom: Boris Ostrovsky <[email protected]>
commit 1eff70a9abd46f175defafd29bc17ad456f398a7 upstream.
kvm_vcpu_(un)map operates on gfns from any current address space. In certain cases we want to make sure we are not mapping SMRAM and for that we can use kvm_(un)map_gfn() that we are introducing in this patch.
This is part of CVE-2019-3016.
--- include/linux/kvm_host.h | 2 ++ virt/kvm/kvm_main.c | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-)
include/linux/kvm_host.h +2 -0
@@ -775,8 +775,10 @@ struct kvm_memory_slot *kvm_vcpu_gfn_to_kvm_pfn_t kvm_vcpu_gfn_to_pfn_atomic (struct kvm_vcpu *vcpu,gfn_t gfn);kvm_pfn_t kvm_vcpu_gfn_to_pfn (struct kvm_vcpu *vcpu,gfn_t gfn);int kvm_vcpu_map (struct kvm_vcpu *vcpu,gpa_t gpa,struct kvm_host_map *map); +int kvm_map_gfn (struct kvm_vcpu *vcpu,gfn_t gfn,struct kvm_host_map *map);struct page *kvm_vcpu_gfn_to_page (struct kvm_vcpu *vcpu,gfn_t gfn);void kvm_vcpu_unmap (struct kvm_vcpu *vcpu,struct kvm_host_map *map,bool dirty); +int kvm_unmap_gfn (struct kvm_vcpu *vcpu,struct kvm_host_map *map,bool dirty);unsigned long kvm_vcpu_gfn_to_hva (struct kvm_vcpu *vcpu,gfn_t gfn);unsigned long kvm_vcpu_gfn_to_hva_prot (struct kvm_vcpu *vcpu,gfn_t gfn,bool *writable); int kvm_vcpu_read_guest_page(struct kvm_vcpu *vcpu, gfn_t gfn, void *data, int offset,
virt/kvm/kvm_main.c +24 -5
@@ -1821,12 +1821,13 @@ struct page *gfn_to_page(struct kvm *kvm }EXPORT_SYMBOL_GPL (gfn_to_page); -static int __kvm_map_gfn (struct kvm_memory_slot *slot,gfn_t gfn, +static int __kvm_map_gfn (struct kvm_memslots *slots,gfn_t gfn,struct kvm_host_map *map) {kvm_pfn_t pfn;void *hva =NULL ;struct page *page =KVM_UNMAPPED_PAGE ; +struct kvm_memory_slot *slot =__gfn_to_memslot (slots, gfn);if (!map)return -EINVAL ;
@@ -1855,14 +1856,20 @@ static int __kvm_map_gfn(struct kvm_memoreturn 0 ; } +int kvm_map_gfn (struct kvm_vcpu *vcpu,gfn_t gfn,struct kvm_host_map *map) +{ +return __kvm_map_gfn (kvm_memslots (vcpu->kvm), gfn, map); +} +EXPORT_SYMBOL_GPL (kvm_map_gfn); +int kvm_vcpu_map (struct kvm_vcpu *vcpu,gfn_t gfn,struct kvm_host_map *map) { -return __kvm_map_gfn (kvm_vcpu_gfn_to_memslot (vcpu, gfn), gfn, map); +return __kvm_map_gfn (kvm_vcpu_memslots (vcpu), gfn, map); }EXPORT_SYMBOL_GPL (kvm_vcpu_map); -void kvm_vcpu_unmap (struct kvm_vcpu *vcpu,struct kvm_host_map *map, -bool dirty) +static void __kvm_unmap_gfn (struct kvm_memory_slot *memslot, +struct kvm_host_map *map,bool dirty) {if (!map)return ;
@@ -1878,7 +1885,7 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcp#endif if (dirty) { -kvm_vcpu_mark_page_dirty (vcpu, map->gfn); +mark_page_dirty_in_slot (memslot, map->gfn);kvm_release_pfn_dirty (map->pfn); }else {kvm_release_pfn_clean (map->pfn);
@@ -1887,6 +1894,18 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcp map->hva =NULL ; map->page =NULL ; } + +int kvm_unmap_gfn (struct kvm_vcpu *vcpu,struct kvm_host_map *map,bool dirty) +{ +__kvm_unmap_gfn (gfn_to_memslot (vcpu->kvm, map->gfn), map, dirty); +return 0 ; +} +EXPORT_SYMBOL_GPL (kvm_unmap_gfn); + +void kvm_vcpu_unmap (struct kvm_vcpu *vcpu,struct kvm_host_map *map,bool dirty) +{ +__kvm_unmap_gfn (kvm_vcpu_gfn_to_memslot (vcpu, map->gfn), map, dirty); +}EXPORT_SYMBOL_GPL (kvm_vcpu_unmap);struct page *kvm_vcpu_gfn_to_page (struct kvm_vcpu *vcpu,gfn_t gfn)
Greg Kroah-Hartman
maintainerPATCH 211/367 gfs2: fix O_SYNC write handling
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
commit 6e5e41e2dc4e4413296d5a4af54ac92d7cd52317 upstream.
In gfs2_file_write_iter, for direct writes, the error checking in the buffered write fallback case is incomplete. This can cause inode write errors to go undetected. Fix and clean up gfs2_file_write_iter along the way.
Based on a proposed fix by Christoph Hellwig <[email protected]>.
--- fs/gfs2/file.c | 51 +++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 30 deletions(-)
fs/gfs2/file.c +21 -30
@@ -847,7 +847,7 @@ static ssize_t gfs2_file_write_iter(strustruct file *file = iocb->ki_filp;struct inode *inode =file_inode (file);struct gfs2_inode *ip =GFS2_I (inode); -ssize_t written =0 , ret; +ssize_t ret; ret =gfs2_rsqa_alloc (ip);if (ret)
@@ -879,55 +879,46 @@ static ssize_t gfs2_file_write_iter(struif (iocb->ki_flags &IOCB_DIRECT ) {struct address_space *mapping = file->f_mapping; -loff_t pos, endbyte; -ssize_t buffered; +ssize_t buffered, ret2; - written =gfs2_file_direct_write (iocb, from); -if (written <0 || !iov_iter_count (from)) + ret =gfs2_file_direct_write (iocb, from); +if (ret <0 || !iov_iter_count (from)) goto out_unlock; + iocb->ki_flags |=IOCB_DSYNC ; current->backing_dev_info =inode_to_bdi (inode); - ret =iomap_file_buffered_write (iocb, from, &gfs2_iomap_ops); + buffered =iomap_file_buffered_write (iocb, from, &gfs2_iomap_ops); current->backing_dev_info =NULL ; -if (unlikely (ret <0 )) +if (unlikely (buffered <=0 )) goto out_unlock; - buffered = ret;/* * We need to ensure that the page cache pages are written to * disk and invalidated to preserve the expected O_DIRECT -* semantics. +* semantics. If the writeback or invalidate fails, only report +* the direct I/O range as we don't know if the buffered pages +* made it to disk. */ - pos = iocb->ki_pos; - endbyte = pos + buffered -1 ; - ret =filemap_write_and_wait_range (mapping, pos, endbyte); -if (!ret) { - iocb->ki_pos += buffered; - written += buffered; -invalidate_mapping_pages (mapping, - pos >>PAGE_SHIFT , - endbyte >>PAGE_SHIFT ); - }else { -/* -* We don't know how much we wrote, so just return -* the number of bytes which were direct-written -*/ - } + iocb->ki_pos += buffered; + ret2 =generic_write_sync (iocb, buffered); +invalidate_mapping_pages (mapping, + (iocb->ki_pos - buffered) >>PAGE_SHIFT , + (iocb->ki_pos -1 ) >>PAGE_SHIFT ); +if (!ret || ret2 >0 ) + ret += ret2; }else { current->backing_dev_info =inode_to_bdi (inode); ret =iomap_file_buffered_write (iocb, from, &gfs2_iomap_ops); current->backing_dev_info =NULL ; -if (likely (ret >0 )) +if (likely (ret >0 )) { iocb->ki_pos += ret; + ret =generic_write_sync (iocb, ret); + } } out_unlock:inode_unlock (inode); -if (likely (ret >0 )) { -/* Handle various SYNC-type writes */ - ret =generic_write_sync (iocb, ret); - } -return written ? written : ret; +return ret; } static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
Greg Kroah-Hartman
maintainerPATCH 202/367 btrfs: flush write bio if we loop in extent_write_cache_pages
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 42ffb0bf584ae5b6b38f72259af1e0ee417ac77f upstream.
There exists a deadlock with range_cyclic that has existed forever. If we loop around with a bio already built we could deadlock with a writer who has the page locked that we're attempting to write but is waiting on a page in our bio to be written out. The task traces are as follows
PID: 1329874 TASK: ffff889ebcdf3800 CPU: 33 COMMAND: "kworker/u113:5"
#0 [ffffc900297bb658] __schedule at ffffffff81a4c33f
#1 [ffffc900297bb6e0] schedule at ffffffff81a4c6e3
#2 [ffffc900297bb6f8] io_schedule at ffffffff81a4ca42
#3 [ffffc900297bb708] __lock_page at ffffffff811f145b
#4 [ffffc900297bb798] __process_pages_contig at ffffffff814bc502 #5 [ffffc900297bb8c8] lock_delalloc_pages at ffffffff814bc684 #6 [ffffc900297bb900] find_lock_delalloc_range at ffffffff814be9ff #7 [ffffc900297bb9a0] writepage_delalloc at ffffffff814bebd0 #8 [ffffc900297bba18] __extent_writepage at ffffffff814bfbf2 #9 [ffffc900297bba98] extent_write_cache_pages at ffffffff814bffbd
PID: 2167901 TASK: ffff889dc6a59c00 CPU: 14 COMMAND:
"aio-dio-invalid"
#0 [ffffc9003b50bb18] __schedule at ffffffff81a4c33f #1 [ffffc9003b50bba0] schedule at ffffffff81a4c6e3 #2 [ffffc9003b50bbb8] io_schedule at ffffffff81a4ca42 #3 [ffffc9003b50bbc8] wait_on_page_bit at ffffffff811f24d6 #4 [ffffc9003b50bc60] prepare_pages at ffffffff814b05a7 #5 [ffffc9003b50bcd8] btrfs_buffered_write at ffffffff814b1359 #6 [ffffc9003b50bdb0] btrfs_file_write_iter at ffffffff814b5933 #7 [ffffc9003b50be38] new_sync_write at ffffffff8128f6a8 #8 [ffffc9003b50bec8] vfs_write at ffffffff81292b9d #9 [ffffc9003b50bf00] ksys_pwrite64 at ffffffff81293032
I used drgn to find the respective pages we were stuck on
page_entry.page 0xffffea00fbfc7500 index 8148 bit 15 pid 2167901 page_entry.page 0xffffea00f9bb7400 index 7680 bit 0 pid 1329874
As you can see the kworker is waiting for bit 0 (PG_locked) on index 7680, and aio-dio-invalid is waiting for bit 15 (PG_writeback) on index 8148. aio-dio-invalid has 7680, and the kworker epd looks like the following
crash> struct extent_page_data ffffc900297bbbb0
struct extent_page_data {
bio = 0xffff889f747ed830,
tree = 0xffff889eed6ba448,
extent_locked = 0,
sync_io = 0
}Probably worth mentioning as well that it waits for writeback of the page to complete while holding a lock on it (at prepare_pages()).
Using drgn I walked the bio pages looking for page 0xffffea00fbfc7500 which is the one we're waiting for writeback on
bio = Object(prog, 'struct bio', address=0xffff889f747ed830) for i in range(0, bio.bi_vcnt.value_()):
bv = bio.bi_io_vec[i]
if bv.bv_page.value_() == 0xffffea00fbfc7500:
print("FOUND IT")which validated what I suspected.
The fix for this is simple, flush the epd before we loop back around to the beginning of the file during writeout.
--- fs/btrfs/extent_io.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/btrfs/extent_io.c +10 -1
@@ -4188,7 +4188,16 @@ retry:*/ scanned =1 ; index =0 ; - goto retry; + +/* +* If we're looping we could run into a page that is locked by a +* writer and that writer could be waiting on writeback for a +* page in our current bio, and thus deadlock, so flush the +* write bio here. +*/ + ret =flush_write_bio (epd); +if (!ret) + goto retry; }if (wbc->range_cyclic || (wbc->nr_to_write >0 && range_whole))
Greg Kroah-Hartman
maintainerPATCH 210/367 gfs2: move setting current->backing_dev_info
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
commit 4c0e8dda608a51855225c611b5c6b442f95fbc56 upstream.
Set current->backing_dev_info just around the buffered write calls to prepare for the next fix.
--- fs/gfs2/file.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
fs/gfs2/file.c +10 -11
@@ -867,18 +867,15 @@ static ssize_t gfs2_file_write_iter(struinode_lock (inode); ret =generic_write_checks (iocb, from);if (ret <=0 ) - goto out; - -/* We can write back this queue in page reclaim */ - current->backing_dev_info =inode_to_bdi (inode); + goto out_unlock; ret =file_remove_privs (file);if (ret) - goto out2; + goto out_unlock; ret =file_update_time (file);if (ret) - goto out2; + goto out_unlock;if (iocb->ki_flags &IOCB_DIRECT ) {struct address_space *mapping = file->f_mapping;
@@ -887,11 +884,13 @@ static ssize_t gfs2_file_write_iter(stru written =gfs2_file_direct_write (iocb, from);if (written <0 || !iov_iter_count (from)) - goto out2; + goto out_unlock; + current->backing_dev_info =inode_to_bdi (inode); ret =iomap_file_buffered_write (iocb, from, &gfs2_iomap_ops); + current->backing_dev_info =NULL ;if (unlikely (ret <0 )) - goto out2; + goto out_unlock; buffered = ret;/*
@@ -915,14 +914,14 @@ static ssize_t gfs2_file_write_iter(stru*/ } }else { + current->backing_dev_info =inode_to_bdi (inode); ret =iomap_file_buffered_write (iocb, from, &gfs2_iomap_ops); + current->backing_dev_info =NULL ;if (likely (ret >0 )) iocb->ki_pos += ret; } -out2: - current->backing_dev_info =NULL ; -out: +out_unlock:inode_unlock (inode);if (likely (ret >0 )) {/* Handle various SYNC-type writes */
Greg Kroah-Hartman
maintainerPATCH 209/367 gfs2: fix gfs2_find_jhead that returns uninitialized jhead with seq 0
In reply to Greg Kroah-HartmanFrom: Abhi Das <[email protected]>
commit 7582026f6f3588ecebd281965c8a71aff6fb6158 upstream.
When the first log header in a journal happens to have a sequence number of 0, a bug in gfs2_find_jhead() causes it to prematurely exit, and return an uninitialized jhead with seq 0. This can cause failures in the caller. For instance, a mount fails in one test case.
The correct behavior is for it to continue searching through the journal to find the correct journal head with the highest sequence number.
--- fs/gfs2/lops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/lops.c +1 -1
@@ -422,7 +422,7 @@ static bool gfs2_jhead_pg_srch(struct gffor (offset =0 ; offset <PAGE_SIZE ; offset += sdp->sd_sb.sb_bsize) {if (!__get_log_header (sdp, kaddr + offset,0 , &lh)) { -if (lh.lh_sequence > head->lh_sequence) +if (lh.lh_sequence >= head->lh_sequence) *head = lh;else { ret = true;
Greg Kroah-Hartman
maintainerPATCH 243/367 KVM: x86/mmu: Apply max PA check for MMIO sptes to 32-bit KVM
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit e30a7d623dccdb3f880fbcad980b0cb589a1da45 upstream.
Remove the bogus 64-bit only condition from the check that disables MMIO spte optimization when the system supports the max PA, i.e. doesn't have any reserved PA bits. 32-bit KVM always uses PAE paging for the shadow MMU, and per Intel's SDM:
PAE paging translates 32-bit linear addresses to 52-bit physical addresses.
The kernel's restrictions on max physical addresses are limits on how much memory the kernel can reasonably use, not what physical addresses are supported by hardware.
--- arch/x86/kvm/mmu/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmu/mmu.c +1 -1
@@ -6249,7 +6249,7 @@ static void kvm_set_mmio_spte_mask(void)* If reserved bit is not supported, clear the present bit to disable * mmio page fault. */ -if (IS_ENABLED (CONFIG_X86_64 ) && shadow_phys_bits ==52 ) +if (shadow_phys_bits ==52 ) mask &= ~1ull ;kvm_mmu_set_mmio_spte_mask (mask, mask,ACC_WRITE_MASK |ACC_USER_MASK );
Greg Kroah-Hartman
maintainerPATCH 242/367 kvm/svm: PKU not currently supported
In reply to Greg Kroah-HartmanFrom: John Allen <[email protected]>
commit a47970ed74a535b1accb4bc73643fd5a93993c3e upstream.
Current SVM implementation does not have support for handling PKU. Guests running on a host with future AMD cpus that support the feature will read garbage from the PKRU register and will hit segmentation faults on boot as memory is getting marked as protected that should not be. Ensure that cpuid from SVM does not advertise the feature.
--- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/cpuid.c | 4 +++- arch/x86/kvm/svm.c | 6 ++++++ arch/x86/kvm/vmx/capabilities.h | 5 +++++ arch/x86/kvm/vmx/vmx.c | 1 + 5 files changed, 16 insertions(+), 1 deletion(-)
arch/x86/include/asm/kvm_host.h +1 -0
@@ -1145,6 +1145,7 @@ struct kvm_x86_ops {bool (*xsaves_supported)(void );bool (*umip_emulated)(void );bool (*pt_supported)(void ); +bool (*pku_supported)(void );int (*check_nested_events)(struct kvm_vcpu *vcpu,bool external_intr);void (*request_immediate_exit)(struct kvm_vcpu *vcpu);
arch/x86/kvm/cpuid.c +3 -1
@@ -352,6 +352,7 @@ static inline void do_cpuid_7_mask(strucunsigned f_umip = kvm_x86_ops->umip_emulated () ?F (UMIP ) :0 ;unsigned f_intel_pt = kvm_x86_ops->pt_supported () ?F (INTEL_PT ) :0 ;unsigned f_la57; +unsigned f_pku = kvm_x86_ops->pku_supported () ?F (PKU ) :0 ;/* cpuid 7.0.ebx */ const u32 kvm_cpuid_7_0_ebx_x86_features =
@@ -363,7 +364,7 @@ static inline void do_cpuid_7_mask(struc/* cpuid 7.0.ecx*/ const u32 kvm_cpuid_7_0_ecx_x86_features = -F (AVX512VBMI ) |F (LA57 ) |F (PKU ) |0 /*OSPKE*/ |F (RDPID ) | +F (AVX512VBMI ) |F (LA57 ) |0 /*PKU*/ |0 /*OSPKE*/ |F (RDPID ) |F (AVX512_VPOPCNTDQ ) |F (UMIP ) |F (AVX512_VBMI2 ) |F (GFNI ) |F (VAES ) |F (VPCLMULQDQ ) |F (AVX512_VNNI ) |F (AVX512_BITALG ) |F (CLDEMOTE ) |F (MOVDIRI ) |F (MOVDIR64B ) |0 /*WAITPKG*/ ;
@@ -392,6 +393,7 @@ static inline void do_cpuid_7_mask(struc/* Set LA57 based on hardware capability. */ entry->ecx |= f_la57; entry->ecx |= f_umip; + entry->ecx |= f_pku;/* PKU is not yet implemented for shadow paging. */ if (!tdp_enabled || !boot_cpu_has (X86_FEATURE_OSPKE )) entry->ecx &= ~F (PKU );
arch/x86/kvm/svm.c +6 -0
@@ -6001,6 +6001,11 @@ static bool svm_has_wbinvd_exit(void)return true; } +static bool svm_pku_supported (void ) +{ +return false; +} +#define PRE_EX (exit) { .exit_code = (exit), \ .stage = X86_ICPT_PRE_EXCEPT, }#define POST_EX (exit) { .exit_code = (exit), \
@@ -7341,6 +7346,7 @@ static struct kvm_x86_ops svm_x86_ops __ .xsaves_supported = svm_xsaves_supported, .umip_emulated = svm_umip_emulated, .pt_supported = svm_pt_supported, + .pku_supported = svm_pku_supported, .set_supported_cpuid = svm_set_supported_cpuid,
arch/x86/kvm/vmx/capabilities.h +5 -0
@@ -145,6 +145,11 @@ static inline bool vmx_umip_emulated(voiSECONDARY_EXEC_DESC ; } +static inline bool vmx_pku_supported (void ) +{ +return boot_cpu_has (X86_FEATURE_PKU ); +} +static inline bool cpu_has_vmx_rdtscp (void ) { return vmcs_config.cpu_based_2nd_exec_ctrl &
arch/x86/kvm/vmx/vmx.c +1 -0
@@ -7870,6 +7870,7 @@ static struct kvm_x86_ops vmx_x86_ops __ .xsaves_supported = vmx_xsaves_supported, .umip_emulated = vmx_umip_emulated, .pt_supported = vmx_pt_supported, + .pku_supported = vmx_pku_supported, .request_immediate_exit = vmx_request_immediate_exit,
Greg Kroah-Hartman
maintainerPATCH 206/367 iwlwifi: dont throw error when trying to remove IGTK
In reply to Greg Kroah-HartmanFrom: Luca Coelho <[email protected]>
commit 197288d5ba8a5289f22d3aeb4fca3824bfd9b4af upstream.
The IGTK keys are only removed by mac80211 after it has already removed the AP station. This causes the driver to throw an error because mac80211 is trying to remove the IGTK when the station doesn't exist anymore.
The firmware is aware that the station has been removed and can deal with it the next time we try to add an IGTK for a station, so we shouldn't try to remove the key if the station ID is IWL_MVM_INVALID_STA. Do this by removing the check for mvm_sta before calling iwl_mvm_send_sta_igtk() and check return from that function gracefully if the station ID is invalid.
--- drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/sta.c +7 -3
@@ -3320,6 +3320,10 @@ static int iwl_mvm_send_sta_igtk(struct igtk_cmd.sta_id =cpu_to_le32 (sta_id);if (remove_key) { +/* This is a valid situation for IGTK */ +if (sta_id ==IWL_MVM_INVALID_STA ) +return 0 ; + igtk_cmd.ctrl_flags |=cpu_to_le32 (STA_KEY_NOT_VALID ); }else {struct ieee80211_key_seq seq;
@@ -3574,9 +3578,9 @@ int iwl_mvm_remove_sta_key(struct iwl_mvIWL_DEBUG_WEP (mvm,"mvm remove dynamic key: idx=%d sta=%d\n" , keyconf->keyidx, sta_id); -if (mvm_sta && (keyconf->cipher ==WLAN_CIPHER_SUITE_AES_CMAC || - keyconf->cipher ==WLAN_CIPHER_SUITE_BIP_GMAC_128 || - keyconf->cipher ==WLAN_CIPHER_SUITE_BIP_GMAC_256 )) +if (keyconf->cipher ==WLAN_CIPHER_SUITE_AES_CMAC || + keyconf->cipher ==WLAN_CIPHER_SUITE_BIP_GMAC_128 || + keyconf->cipher ==WLAN_CIPHER_SUITE_BIP_GMAC_256 )return iwl_mvm_send_sta_igtk (mvm, keyconf, sta_id, true);if (!__test_and_clear_bit (keyconf->hw_key_idx, mvm->fw_key_table)) {
Greg Kroah-Hartman
maintainerPATCH 240/367 KVM: PPC: Book3S HV: Uninit vCPU if vcore creation fails
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 1a978d9d3e72ddfa40ac60d26301b154247ee0bc upstream.
Call kvm_vcpu_uninit() if vcore creation fails to avoid leaking any resources allocated by kvm_vcpu_init(), i.e. the vcpu->run page.
--- arch/powerpc/kvm/book3s_hv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kvm/book3s_hv.c +3 -1
@@ -2368,7 +2368,7 @@ static struct kvm_vcpu *kvmppc_core_vcpumutex_unlock (&kvm->lock);if (!vcore) - goto free_vcpu; + goto uninit_vcpu;spin_lock (&vcore->lock); ++vcore->num_threads;
@@ -2385,6 +2385,8 @@ static struct kvm_vcpu *kvmppc_core_vcpureturn vcpu; +uninit_vcpu: +kvm_vcpu_uninit (vcpu); free_vcpu:kmem_cache_free (kvm_vcpu_cache, vcpu); out:
Greg Kroah-Hartman
maintainerPATCH 239/367 KVM: x86: Fix potential put_fpu() w/o load_fpu() on MPX platform
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit f958bd2314d117f8c29f4821401bc1925bc2e5ef upstream.
Unlike most state managed by XSAVE, MPX is initialized to zero on INIT. Because INITs are usually recognized in the context of a VCPU_RUN call, kvm_vcpu_reset() puts the guest's FPU so that the FPU state is resident in memory, zeros the MPX state, and reloads FPU state to hardware. But, in the unlikely event that an INIT is recognized during kvm_arch_vcpu_ioctl_get_mpstate() via kvm_apic_accept_events(), kvm_vcpu_reset() will call kvm_put_guest_fpu() without a preceding kvm_load_guest_fpu() and corrupt the guest's FPU state (and possibly userspace's FPU state as well).
Given that MPX is being removed from the kernel[*], fix the bug with the simple-but-ugly approach of loading the guest's FPU during KVM_GET_MP_STATE.
[*] See commit f240652b6032b ("x86/mpx: Remove MPX APIs").
--- arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/x86.c +4 -0
@@ -8724,6 +8724,8 @@ int kvm_arch_vcpu_ioctl_get_mpstate(stru struct kvm_mp_state *mp_state) {vcpu_load (vcpu); +if (kvm_mpx_supported ()) +kvm_load_guest_fpu (vcpu);kvm_apic_accept_events (vcpu); if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED &&
@@ -8732,6 +8734,8 @@ int kvm_arch_vcpu_ioctl_get_mpstate(struelse mp_state->mp_state = vcpu->arch.mp_state; +if (kvm_mpx_supported ()) +kvm_put_guest_fpu (vcpu);vcpu_put (vcpu);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 238/367 KVM: x86: Protect MSR-based index computations in fixed_msr_to_seg_unit() from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 25a5edea71b7c154b6a0b8cec14c711cafa31d26 upstream.
This fixes a Spectre-v1/L1TF vulnerability in fixed_msr_to_seg_unit(). This function contains index computations based on the (attacker-controlled) MSR number.
--- arch/x86/kvm/mtrr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/kvm/mtrr.c +6 -2
@@ -192,11 +192,15 @@ static bool fixed_msr_to_seg_unit(u32 msbreak ; case MSR_MTRRfix16K_80000 ... MSR_MTRRfix16K_A0000: *seg =1 ; - *unit = msr - MSR_MTRRfix16K_80000; + *unit =array_index_nospec ( + msr - MSR_MTRRfix16K_80000, + MSR_MTRRfix16K_A0000 - MSR_MTRRfix16K_80000 +1 );break ; case MSR_MTRRfix4K_C0000 ... MSR_MTRRfix4K_F8000: *seg =2 ; - *unit = msr - MSR_MTRRfix4K_C0000; + *unit =array_index_nospec ( + msr - MSR_MTRRfix4K_C0000, + MSR_MTRRfix4K_F8000 - MSR_MTRRfix4K_C0000 +1 );break ;default :return false;
Greg Kroah-Hartman
maintainerPATCH 237/367 KVM: x86: Protect x86_decode_insn from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 3c9053a2cae7ba2ba73766a34cea41baa70f57f7 upstream.
This fixes a Spectre-v1/L1TF vulnerability in x86_decode_insn(). kvm_emulate_instruction() (an ancestor of x86_decode_insn()) is an exported symbol, so KVM should treat it conservatively from a security perspective.
--- arch/x86/kvm/emulate.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/x86/kvm/emulate.c +8 -3
@@ -5315,10 +5315,15 @@ done_prefixes: }break ;case Escape: -if (ctxt->modrm >0xbf ) - opcode = opcode.u.esc->high[ctxt->modrm -0xc0 ]; -else +if (ctxt->modrm >0xbf ) { +size_t size =ARRAY_SIZE (opcode.u.esc->high); +u32 index =array_index_nospec ( + ctxt->modrm -0xc0 , size); + + opcode = opcode.u.esc->high[index]; + }else { opcode = opcode.u.esc->op[(ctxt->modrm >>3 ) &7 ]; + }break ;case InstrDual:if ((ctxt->modrm >>6 ) ==3 )
Greg Kroah-Hartman
maintainerPATCH 236/367 KVM: x86: Protect MSR-based index computations from Spectre-v1/L1TF attacks in x86.c
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 6ec4c5eee1750d5d17951c4e1960d953376a0dda upstream.
This fixes a Spectre-v1/L1TF vulnerability in set_msr_mce() and get_msr_mce().
Both functions contain index computations based on the (attacker-controlled) MSR number.
--- arch/x86/kvm/x86.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +8 -2
@@ -2489,7 +2489,10 @@ static int set_msr_mce(struct kvm_vcpu *default :if (msr >=MSR_IA32_MC0_CTL && msr <MSR_IA32_MCx_CTL (bank_num)) { -u32 offset = msr -MSR_IA32_MC0_CTL ; +u32 offset =array_index_nospec ( + msr -MSR_IA32_MC0_CTL , +MSR_IA32_MCx_CTL (bank_num) -MSR_IA32_MC0_CTL ); +/* only 0 or all 1s can be written to IA32_MCi_CTL * some Linux kernels though clear bit 10 in bank 4 to * workaround a BIOS/GART TBL issue on AMD K8s, ignore
@@ -2930,7 +2933,10 @@ static int get_msr_mce(struct kvm_vcpu *default :if (msr >=MSR_IA32_MC0_CTL && msr <MSR_IA32_MCx_CTL (bank_num)) { -u32 offset = msr -MSR_IA32_MC0_CTL ; +u32 offset =array_index_nospec ( + msr -MSR_IA32_MC0_CTL , +MSR_IA32_MCx_CTL (bank_num) -MSR_IA32_MC0_CTL ); + data = vcpu->arch.mce_banks[offset];break ; }
Greg Kroah-Hartman
maintainerPATCH 234/367 KVM: x86: Protect MSR-based index computations in pmu.h from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 13c5183a4e643cc2b03a22d0e582c8e17bb7457d upstream.
This fixes a Spectre-v1/L1TF vulnerability in the get_gp_pmc() and get_fixed_pmc() functions.
They both contain index computations based on the (attacker-controlled) MSR number.
--- arch/x86/kvm/pmu.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
arch/x86/kvm/pmu.h +14 -4
@@ -2,6 +2,8 @@#ifndef __KVM_X86_PMU_H#define __KVM_X86_PMU_H +#include <linux/nospec.h> +#define vcpu_to_pmu (vcpu) (&(vcpu)->arch.pmu)#define pmu_to_vcpu (pmu) (container_of((pmu), struct kvm_vcpu, arch.pmu))#define pmc_to_pmu (pmc) (&(pmc)->vcpu->arch.pmu)
@@ -102,8 +104,12 @@ static inline bool kvm_valid_perf_globalstatic inline struct kvm_pmc *get_gp_pmc (struct kvm_pmu *pmu,u32 msr,u32 base) { -if (msr >= base && msr < base + pmu->nr_arch_gp_counters) -return &pmu->gp_counters[msr - base]; +if (msr >= base && msr < base + pmu->nr_arch_gp_counters) { +u32 index =array_index_nospec (msr - base, + pmu->nr_arch_gp_counters); + +return &pmu->gp_counters[index]; + }return NULL ; }
@@ -113,8 +119,12 @@ static inline struct kvm_pmc *get_fixed_ {int base =MSR_CORE_PERF_FIXED_CTR0 ; -if (msr >= base && msr < base + pmu->nr_arch_fixed_counters) -return &pmu->fixed_counters[msr - base]; +if (msr >= base && msr < base + pmu->nr_arch_fixed_counters) { +u32 index =array_index_nospec (msr - base, + pmu->nr_arch_fixed_counters); + +return &pmu->fixed_counters[index]; + }return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 235/367 KVM: x86: Protect ioapic_read_indirect() from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 8c86405f606ca8508b8d9280680166ca26723695 upstream.
This fixes a Spectre-v1/L1TF vulnerability in ioapic_read_indirect(). This function contains index computations based on the (attacker-controlled) IOREGSEL register.
--- arch/x86/kvm/ioapic.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/x86/kvm/ioapic.c +8 -6
@@ -36,6 +36,7 @@#include <linux/io.h> #include <linux/slab.h> #include <linux/export.h> +#include <linux/nospec.h> #include <asm/processor.h> #include <asm/page.h> #include <asm/current.h>
@@ -68,13 +69,14 @@ static unsigned long ioapic_read_indirecdefault : {u32 redir_index = (ioapic->ioregsel -0x10 ) >>1 ; -u64 redir_content; +u64 redir_content = ~0ULL ; -if (redir_index <IOAPIC_NUM_PINS ) - redir_content = - ioapic->redirtbl[redir_index].bits; -else - redir_content = ~0ULL ; +if (redir_index <IOAPIC_NUM_PINS ) { +u32 index =array_index_nospec ( + redir_index,IOAPIC_NUM_PINS ); + + redir_content = ioapic->redirtbl[index].bits; + } result = (ioapic->ioregsel &0x1 ) ? (redir_content >> 32) & 0xffffffff :
Greg Kroah-Hartman
maintainerPATCH 233/367 KVM: x86: Protect ioapic_write_indirect() from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 670564559ca35b439c8d8861fc399451ddf95137 upstream.
This fixes a Spectre-v1/L1TF vulnerability in ioapic_write_indirect(). This function contains index computations based on the (attacker-controlled) IOREGSEL register.
This patch depends on patch
"KVM: x86: Protect ioapic_read_indirect() from Spectre-v1/L1TF attacks".
--- arch/x86/kvm/ioapic.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kvm/ioapic.c +1 -0
@@ -292,6 +292,7 @@ static void ioapic_write_indirect(structif (index >=IOAPIC_NUM_PINS )return ; + index =array_index_nospec (index,IOAPIC_NUM_PINS ); e = &ioapic->redirtbl[index]; mask_before = e->fields.mask;/* Preserve read-only fields */
Greg Kroah-Hartman
maintainerPATCH 232/367 KVM: x86: Protect kvm_hv_msr_[get|set]_crash_data() from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 8618793750071d66028584a83ed0b4fa7eb4f607 upstream.
This fixes Spectre-v1/L1TF vulnerabilities in kvm_hv_msr_get_crash_data() and kvm_hv_msr_set_crash_data().
These functions contain index computations that use the (attacker-controlled) MSR number.
--- arch/x86/kvm/hyperv.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/kvm/hyperv.c +6 -4
@@ -809,11 +809,12 @@ static int kvm_hv_msr_get_crash_data(str u32 index, u64 *pdata) { struct kvm_hv *hv = &vcpu->kvm->arch.hyperv; +size_t size =ARRAY_SIZE (hv->hv_crash_param); -if (WARN_ON_ONCE (index >=ARRAY_SIZE (hv->hv_crash_param))) +if (WARN_ON_ONCE (index >= size))return -EINVAL ; - *pdata = hv->hv_crash_param[index]; + *pdata = hv->hv_crash_param[array_index_nospec (index, size)];return 0 ; }
@@ -852,11 +853,12 @@ static int kvm_hv_msr_set_crash_data(str u32 index, u64 data) {struct kvm_hv *hv = &vcpu->kvm->arch.hyperv; +size_t size =ARRAY_SIZE (hv->hv_crash_param); -if (WARN_ON_ONCE (index >=ARRAY_SIZE (hv->hv_crash_param))) +if (WARN_ON_ONCE (index >= size))return -EINVAL ; - hv->hv_crash_param[index] = data; + hv->hv_crash_param[array_index_nospec (index, size)] = data;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 229/367 KVM: x86: Protect pmu_intel.c from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 66061740f1a487f4ed54fde75e724709f805da53 upstream.
This fixes Spectre-v1/L1TF vulnerabilities in intel_find_fixed_event() and intel_rdpmc_ecx_to_pmc().kvm_rdpmc() (ancestor of intel_find_fixed_event()) and reprogram_fixed_counter() (ancestor of intel_rdpmc_ecx_to_pmc()) are exported symbols so KVM should treat them conservatively from a security perspective.
--- arch/x86/kvm/vmx/pmu_intel.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
arch/x86/kvm/vmx/pmu_intel.c +16 -8
@@ -86,10 +86,14 @@ static unsigned intel_find_arch_event(ststatic unsigned intel_find_fixed_event (int idx) { -if (idx >=ARRAY_SIZE (fixed_pmc_events)) +u32 event; +size_t size =ARRAY_SIZE (fixed_pmc_events); + +if (idx >= size)return PERF_COUNT_HW_MAX ; -return intel_arch_events[fixed_pmc_events[idx]].event_type; + event = fixed_pmc_events[array_index_nospec (idx, size)]; +return intel_arch_events[event].event_type; }/* check if a PMC is enabled by comparing it with globl_ctrl bits. */
@@ -130,16 +134,20 @@ static struct kvm_pmc *intel_rdpmc_ecx_tstruct kvm_pmu *pmu =vcpu_to_pmu (vcpu);bool fixed = idx & (1u <<30 );struct kvm_pmc *counters; +unsigned int num_counters; idx &= ~(3u <<30 ); -if (!fixed && idx >= pmu->nr_arch_gp_counters) -return NULL ; -if (fixed && idx >= pmu->nr_arch_fixed_counters) +if (fixed) { + counters = pmu->fixed_counters; + num_counters = pmu->nr_arch_fixed_counters; + }else { + counters = pmu->gp_counters; + num_counters = pmu->nr_arch_gp_counters; + } +if (idx >= num_counters)return NULL ; - counters = fixed ? pmu->fixed_counters : pmu->gp_counters; *mask &= pmu->counter_bitmask[fixed ?KVM_PMC_FIXED :KVM_PMC_GP ]; - -return &counters[idx]; +return &counters[array_index_nospec (idx, num_counters)]; }static bool intel_is_valid_msr (struct kvm_vcpu *vcpu,u32 msr)
Greg Kroah-Hartman
maintainerPATCH 224/367 io_uring: spin for sq thread to idle on shutdown
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit df069d80c8e38c19531c392322e9a16617475c44 upstream.
As part of io_uring shutdown, we cancel work that is pending and won't necessarily complete on its own. That includes requests like poll commands and timeouts.
If we're using SQPOLL for kernel side submission and we shutdown the ring immediately after queueing such work, we can race with the sqthread doing the submission. This means we may miss cancelling some work, which results in the io_uring shutdown hanging forever.
--- fs/io_uring.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
fs/io_uring.c +12 -1
@@ -3902,7 +3902,8 @@ static int io_sq_thread(void *data)* reap events and wake us up. */ if (inflight || - (!time_after (jiffies, timeout) && ret != -EBUSY )) { + (!time_after (jiffies, timeout) && ret != -EBUSY && + !percpu_ref_is_dying (&ctx->refs))) {cond_resched ();continue ; }
@@ -4983,6 +4984,16 @@ static void io_ring_ctx_wait_and_kill(stpercpu_ref_kill (&ctx->refs);mutex_unlock (&ctx->uring_lock); +/* +* Wait for sq thread to idle, if we have one. It won't spin on new +* work after we've killed the ctx ref above. This is important to do +* before we cancel existing commands, as the thread could otherwise +* be queueing new work post that. If that's work we need to cancel, +* it could cause shutdown to hang. +*/ +while (ctx->sqo_thread && !wq_has_sleeper (&ctx->sqo_wait)) +cpu_relax (); +io_kill_timeouts (ctx);io_poll_remove_all (ctx);
Greg Kroah-Hartman
maintainerPATCH 223/367 io_uring: dont map read/write iovec potentially twice
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 5d204bcfa09330972ad3428a8f81c23f371d3e6d upstream.
If we have a read/write that is deferred, we already setup the async IO context for that request, and mapped it. When we later try and execute the request and we get -EAGAIN, we don't want to attempt to re-map it. If we do, we end up with garbage in the iovec, which typically leads to an -EFAULT or -EINVAL completion.
--- fs/io_uring.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/io_uring.c +5 -3
@@ -1789,10 +1789,12 @@ static int io_setup_async_rw(struct io_kif (req->opcode ==IORING_OP_READ_FIXED || req->opcode ==IORING_OP_WRITE_FIXED )return 0 ; -if (!req->io &&io_alloc_async_ctx (req)) -return -ENOMEM ; +if (!req->io) { +if (io_alloc_async_ctx (req)) +return -ENOMEM ; -io_req_map_rw (req, io_size, iovec, fast_iov, iter); +io_req_map_rw (req, io_size, iovec, fast_iov, iter); + } req->work.func = io_rw_async;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 222/367 bcache: add readahead cache policy options via sysfs interface
In reply to Greg Kroah-HartmanFrom: Coly Li <[email protected]>
commit 038ba8cc1bffc51250add4a9b9249d4331576d8f upstream.
In year 2007 high performance SSD was still expensive, in order to save more space for real workload or meta data, the readahead I/Os for non-meta data was bypassed and not cached on SSD.
In now days, SSD price drops a lot and people can find larger size SSD with more comfortable price. It is unncessary to alway bypass normal readahead I/Os to save SSD space for now.
This patch adds options for readahead data cache policies via sysfs file /sys/block/bcache<N>/readahead_cache_policy, the options are,
- "all": cache all readahead data I/Os.
- "meta-only": only cache meta data, and bypass other regular I/Os.
If users want to make bcache continue to only cache readahead request for metadata and bypass regular data readahead, please set "meta-only" to this sysfs file. By default, bcache will back to cache all read- ahead requests now.
--- drivers/md/bcache/bcache.h | 3 +++ drivers/md/bcache/request.c | 17 ++++++++++++----- drivers/md/bcache/sysfs.c | 22 ++++++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-)
drivers/md/bcache/bcache.h +3 -0
@@ -329,6 +329,9 @@ struct cached_dev {*/ atomic_t has_dirty; +#define BCH_CACHE_READA_ALL 0 +#define BCH_CACHE_READA_META_ONLY 1 +unsigned int cache_readahead_policy;struct bch_ratelimit writeback_rate;struct delayed_work writeback_rate_update;
drivers/md/bcache/request.c +12 -5
@@ -379,13 +379,20 @@ static bool check_should_bypass(struct c goto skip;/* -* Flag for bypass if the IO is for read-ahead or background, -* unless the read-ahead request is for metadata +* If the bio is for read-ahead or background IO, bypass it or +* not depends on the following situations, +* - If the IO is for meta data, always cache it and no bypass +* - If the IO is not meta data, check dc->cache_reada_policy, +* BCH_CACHE_READA_ALL: cache it and not bypass +* BCH_CACHE_READA_META_ONLY: not cache it and bypass +* That is, read-ahead request for metadata always get cached * (eg, for gfs2 or xfs). */ -if (bio->bi_opf & (REQ_RAHEAD |REQ_BACKGROUND ) && - !(bio->bi_opf & (REQ_META |REQ_PRIO ))) - goto skip; +if ((bio->bi_opf & (REQ_RAHEAD |REQ_BACKGROUND ))) { +if (!(bio->bi_opf & (REQ_META |REQ_PRIO )) && + (dc->cache_readahead_policy !=BCH_CACHE_READA_ALL )) + goto skip; + }if (bio->bi_iter.bi_sector & (c->sb.block_size -1 ) ||bio_sectors (bio) & (c->sb.block_size -1 )) {
drivers/md/bcache/sysfs.c +22 -0
@@ -27,6 +27,12 @@ static const char * const bch_cache_modeNULL }; +static const char *const bch_reada_cache_policies[] = { +"all" , +"meta-only" , +NULL +}; +/* Default is 0 ("auto") */ static const char *const bch_stop_on_failure_modes[] = {"auto" ,
@@ -100,6 +106,7 @@ rw_attribute(congested_write_threshold_urw_attribute (sequential_cutoff);rw_attribute (data_csum);rw_attribute (cache_mode); +rw_attribute (readahead_cache_policy);rw_attribute (stop_when_cache_set_failed);rw_attribute (writeback_metadata);rw_attribute (writeback_running);
@@ -168,6 +175,11 @@ SHOW(__bch_cached_dev) bch_cache_modes, BDEV_CACHE_MODE(&dc->sb)); +if (attr == &sysfs_readahead_cache_policy) +return bch_snprint_string_list (buf,PAGE_SIZE , + bch_reada_cache_policies, + dc->cache_readahead_policy); +if (attr == &sysfs_stop_when_cache_set_failed) return bch_snprint_string_list(buf, PAGE_SIZE, bch_stop_on_failure_modes,
@@ -353,6 +365,15 @@ STORE(__cached_dev) } } +if (attr == &sysfs_readahead_cache_policy) { + v =__sysfs_match_string (bch_reada_cache_policies,-1 , buf); +if (v <0 ) +return v; + +if ((unsigned int ) v != dc->cache_readahead_policy) + dc->cache_readahead_policy = v; + } +if (attr == &sysfs_stop_when_cache_set_failed) { v =__sysfs_match_string (bch_stop_on_failure_modes,-1 , buf);if (v <0 )
@@ -467,6 +488,7 @@ static struct attribute *bch_cached_dev_ &sysfs_data_csum, #endif &sysfs_cache_mode, + &sysfs_readahead_cache_policy, &sysfs_stop_when_cache_set_failed, &sysfs_writeback_metadata, &sysfs_writeback_running,
Greg Kroah-Hartman
maintainerPATCH 219/367 xen/balloon: Support xend-based toolstack take two
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit eda4eabf86fd6806eaabc23fb90dd056fdac037b upstream.
Commit 3aa6c19d2f38be ("xen/balloon: Support xend-based toolstack") tried to fix a regression with running on rather ancient Xen versions. Unfortunately the fix was based on the assumption that xend would just use another Xenstore node, but in reality only some downstream versions of xend are doing that. The upstream xend does not write that Xenstore node at all, so the problem must be fixed in another way.
The easiest way to achieve that is to fall back to the behavior before commit 96edd61dcf4436 ("xen/balloon: don't online new memory initially") in case the static memory maximum can't be read.
This is achieved by setting static_max to the current number of memory pages known by the system resulting in target_diff becoming zero.
--- drivers/xen/xen-balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/xen-balloon.c +1 -1
@@ -94,7 +94,7 @@ static void watch_target(struct xenbus_w "%llu", &static_max) == 1)) static_max >>=PAGE_SHIFT -10 ; else - static_max = new_target; + static_max = balloon_stats.current_pages; target_diff = (xen_pv_domain () ||xen_initial_domain ()) ?0 : static_max - balloon_stats.target_pages;
Greg Kroah-Hartman
maintainerPATCH 220/367 xen/gntdev: Do not use mm notifiers with autotranslating guests
In reply to Greg Kroah-HartmanFrom: Boris Ostrovsky <[email protected]>
commit 9293724192a73f49c722e9685d45649c6df67dfe upstream.
Commit d3eeb1d77c5d ("xen/gntdev: use mmu_interval_notifier_insert") missed a test for use_ptemod when calling mmu_interval_read_begin(). Fix that.
--- drivers/xen/gntdev.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/xen/gntdev.c +12 -12
@@ -1006,19 +1006,19 @@ static int gntdev_mmap(struct file *flip }mutex_unlock (&priv->lock); -/* -* gntdev takes the address of the PTE in find_grant_ptes() and passes -* it to the hypervisor in gntdev_map_grant_pages(). The purpose of -* the notifier is to prevent the hypervisor pointer to the PTE from -* going stale. -* -* Since this vma's mappings can't be touched without the mmap_sem, -* and we are holding it now, there is no need for the notifier_range -* locking pattern. -*/ -mmu_interval_read_begin (&map->notifier); -if (use_ptemod) { +/* +* gntdev takes the address of the PTE in find_grant_ptes() and +* passes it to the hypervisor in gntdev_map_grant_pages(). The +* purpose of the notifier is to prevent the hypervisor pointer +* to the PTE from going stale. +* +* Since this vma's mappings can't be touched without the +* mmap_sem, and we are holding it now, there is no need for +* the notifier_range locking pattern. +*/ +mmu_interval_read_begin (&map->notifier); + map->pages_vm_start = vma->vm_start; err = apply_to_page_range(vma->vm_mm, vma->vm_start, vma->vm_end - vma->vm_start,
Greg Kroah-Hartman
maintainerPATCH 215/367 drm/rect: Avoid division by zero
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 433480c1afd44f3e1e664b85063d98cefeefa0ed upstream.
Check for zero width/height destination rectangle in drm_rect_clip_scaled() to avoid a division by zero.
Testcase: igt/kms_selftest/drm_rect_clip_scaled_div_by_zero
--- drivers/gpu/drm/drm_rect.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_rect.c +6 -1
@@ -54,7 +54,12 @@ EXPORT_SYMBOL(drm_rect_intersect);static u32 clip_scaled (u32 src,u32 dst,u32 clip) { -u64 tmp =mul_u32_u32 (src, dst - clip); +u64 tmp; + +if (dst ==0 ) +return 0 ; + + tmp =mul_u32_u32 (src, dst - clip);/* * Round toward 1.0 when clipping so that we don't accidentally
Greg Kroah-Hartman
maintainerPATCH 216/367 media: iguanair: fix endpoint sanity check
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 1b257870a78b0a9ce98fdfb052c58542022ffb5b upstream.
Make sure to use the current alternate setting, which need not be the first one by index, when verifying the endpoint descriptors and initialising the URBs.
Failing to do so could cause the driver to misbehave or trigger a WARN() in usb_submit_urb() that kernels with panic_on_warn set would choke on.
--- drivers/media/rc/iguanair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/iguanair.c +1 -1
@@ -413,7 +413,7 @@ static int iguanair_probe(struct usb_intint ret, pipein, pipeout;struct usb_host_interface *idesc; - idesc = intf->altsetting; + idesc = intf->cur_altsetting;if (idesc->desc.bNumEndpoints <2 )return -ENODEV ;
Greg Kroah-Hartman
maintainerPATCH 212/367 drm: atmel-hlcdc: use double rate for pixel clock only if supported
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
commit 07acf4bafe81dd37eff3fbcfbbdbc48084bc202b upstream.
Doubled system clock should be used as pixel cock source only if this is supported. This is emphasized by the value of atmel_hlcdc_crtc::dc::desc::fixed_clksrc.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +3 -3
@@ -95,14 +95,14 @@ static void atmel_hlcdc_crtc_mode_set_no (adj->crtc_hdisplay -1 ) | ((adj->crtc_vdisplay - 1) << 16)); + prate =clk_get_rate (crtc->dc->hlcdc->sys_clk); + mode_rate = adj->crtc_clock *1000 ;if (!crtc->dc->desc->fixed_clksrc) { + prate *=2 ; cfg |=ATMEL_HLCDC_CLKSEL ; mask |=ATMEL_HLCDC_CLKSEL ; } - prate =2 *clk_get_rate (crtc->dc->hlcdc->sys_clk); - mode_rate = adj->crtc_clock *1000 ; - div =DIV_ROUND_UP (prate, mode_rate);if (div <2 ) { div =2 ;
Greg Kroah-Hartman
maintainerPATCH 203/367 btrfs: Correctly handle empty trees in find_first_clear_extent_bit
In reply to Greg Kroah-HartmanFrom: Nikolay Borisov <[email protected]>
commit 5750c37523a2c8cbb450b9ef31e21c2ba876b05e upstream.
Raviu reported that running his regular fs_trim segfaulted with the following backtrace:
[ 237.525947] assertion failed: prev, in ../fs/btrfs/extent_io.c:1595 [ 237.525984] ------------[ cut here ]------------ [ 237.525985] kernel BUG at ../fs/btrfs/ctree.h:3117! [ 237.525992] invalid opcode: 0000 [#1] SMP PTI [ 237.525998] CPU: 4 PID: 4423 Comm: fstrim Tainted: G U OE 5.4.14-8-vanilla #1 [ 237.526001] Hardware name: ASUSTeK COMPUTER INC. [ 237.526044] RIP: 0010:assfail.constprop.58+0x18/0x1a [btrfs] [ 237.526079] Call Trace: [ 237.526120] find_first_clear_extent_bit+0x13d/0x150 [btrfs] [ 237.526148] btrfs_trim_fs+0x211/0x3f0 [btrfs] [ 237.526184] btrfs_ioctl_fitrim+0x103/0x170 [btrfs] [ 237.526219] btrfs_ioctl+0x129a/0x2ed0 [btrfs] [ 237.526227] ? filemap_map_pages+0x190/0x3d0 [ 237.526232] ? do_filp_open+0xaf/0x110 [ 237.526238] ? _copy_to_user+0x22/0x30 [ 237.526242] ? cp_new_stat+0x150/0x180 [ 237.526247] ? do_vfs_ioctl+0xa4/0x640 [ 237.526278] ? btrfs_ioctl_get_supported_features+0x30/0x30 [btrfs] [ 237.526283] do_vfs_ioctl+0xa4/0x640 [ 237.526288] ? __do_sys_newfstat+0x3c/0x60 [ 237.526292] ksys_ioctl+0x70/0x80 [ 237.526297] __x64_sys_ioctl+0x16/0x20 [ 237.526303] do_syscall_64+0x5a/0x1c0 [ 237.526310] entry_SYSCALL_64_after_hwframe+0x49/0xbe
That was due to btrfs_fs_device::aloc_tree being empty. Initially I thought this wasn't possible and as a percaution have put the assert in find_first_clear_extent_bit. Turns out this is indeed possible and could happen when a file system with SINGLE data/metadata profile has a 2nd device added. Until balance is run or a new chunk is allocated on this device it will be completely empty.
In this case find_first_clear_extent_bit should return the full range [0, -1ULL] and let the caller handle this i.e for trim the end will be capped at the size of actual device.
--- fs/btrfs/extent_io.c | 32 ++++++++++++++++++-------------- fs/btrfs/tests/extent-io-tests.c | 9 +++++++++ 2 files changed, 27 insertions(+), 14 deletions(-)
fs/btrfs/extent_io.c +18 -14
@@ -1593,21 +1593,25 @@ void find_first_clear_extent_bit(struct/* Find first extent with bits cleared */ while (1 ) { node =__etree_search (tree, start, &next, &prev,NULL ,NULL ); -if (!node) { +if (!node && !next && !prev) { +/* +* Tree is completely empty, send full range and let +* caller deal with it +*/ + *start_ret =0 ; + *end_ret =-1 ; + goto out; + }else if (!node && !next) { +/* +* We are past the last allocated chunk, set start at +* the end of the last extent. +*/ + state = rb_entry(prev, struct extent_state, rb_node); + *start_ret = state->end +1 ; + *end_ret =-1 ; + goto out; + }else if (!node) { node = next; -if (!node) { -/* -* We are past the last allocated chunk, -* set start at the end of the last extent. The -* device alloc tree should never be empty so -* prev is always set. -*/ -ASSERT (prev); - state = rb_entry(prev, struct extent_state, rb_node); - *start_ret = state->end +1 ; - *end_ret =-1 ; - goto out; - } }/* * At this point 'node' either contains 'start' or start is
fs/btrfs/tests/extent-io-tests.c +9 -0
@@ -441,8 +441,17 @@ static int test_find_first_clear_extent_int ret = -EINVAL ;test_msg ("running find_first_clear_extent_bit test" ); +extent_io_tree_init (NULL , &tree,IO_TREE_SELFTEST ,NULL ); +/* Test correct handling of empty tree */ +find_first_clear_extent_bit (&tree,0 , &start, &end,CHUNK_TRIMMED ); +if (start !=0 || end !=-1 ) { +test_err ( +"error getting a range from completely empty tree: start %llu end %llu" , + start, end); + goto out; + }/* * Set 1M-4M alloc/discard and 32M-64M thus leaving a hole between * 4M-32M
Greg Kroah-Hartman
maintainerPATCH 158/367 libbpf: Fix readelf output parsing for Fedora
In reply to Greg Kroah-HartmanFrom: Thadeu Lima de Souza Cascardo <[email protected]>
commit aa915931ac3e53ccf371308e6750da510e3591dd upstream.
Fedora binutils has been patched to show "other info" for a symbol at the end of the line. This was done in order to support unmaintained scripts that would break with the extra info. [1]
[1] https://src.fedoraproject.org/rpms/binutils/c/b8265c46f7ddae23a792ee8306fbaaeacba83bf8
This in turn has been done to fix the build of ruby, because of checksec.
[2] Thanks Michael Ellerman for the pointer.
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1479302
As libbpf Makefile is not unmaintained, we can simply deal with either output format, by just removing the "other info" field, as it always comes inside brackets.
--- tools/lib/bpf/Makefile | 2 ++ 1 file changed, 2 insertions(+)
tools/lib/bpf/Makefile +2 -0
@@ -148,6 +148,7 @@ TAGS_PROG := $(if $(shell which etags 2> GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN_SHARED) | \ cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \ + sed 's/\[.*\]//' | \ awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}' | \ sort -u | wc -l) VERSIONED_SYM_COUNT = $(shell readelf -s --wide $(OUTPUT)libbpf.so | \
@@ -214,6 +215,7 @@ check_abi: $(OUTPUT)libbpf.so "versioned in $(VERSION_SCRIPT)." >&2; \ readelf -s --wide $(BPF_IN_SHARED) | \ cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \ + sed 's/\[.*\]//' | \ awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'| \ sort -u > $(OUTPUT)libbpf_global_syms.tmp; \ readelf -s --wide $(OUTPUT)libbpf.so | \
Greg Kroah-Hartman
maintainerPATCH 164/367 libbpf: Add missing newline in opts validation macro
In reply to Greg Kroah-HartmanFrom: Toke Høiland-Jørgensen <[email protected]>
commit 12dd14b230b3c742b80272ecb8a83cdf824625ca upstream.
The error log output in the opts validation macro was missing a newline.
--- tools/lib/bpf/libbpf_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf_internal.h +1 -1
@@ -76,7 +76,7 @@ static inline bool libbpf_validate_opts(for (i = opts_sz; i < user_sz; i++) {if (opts[i]) { -pr_warn ("%s has non-zero extra bytes" , +pr_warn ("%s has non-zero extra bytes\n" , type_name);return false; }
Greg Kroah-Hartman
maintainerPATCH 163/367 bpf, devmap: Pass lockdep expression to RCU lists
In reply to Greg Kroah-HartmanFrom: Amol Grover <[email protected]>
commit 485ec2ea9cf556e9c120e07961b7b459d776a115 upstream.
head is traversed using hlist_for_each_entry_rcu outside an RCU read-side critical section but under the protection of dtab->index_lock.
Hence, add corresponding lockdep expression to silence false-positive lockdep warnings, and harden RCU lists.
--- kernel/bpf/devmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/bpf/devmap.c +2 -1
@@ -293,7 +293,8 @@ struct bpf_dtab_netdev *__dev_map_hash_lstruct hlist_head *head =dev_map_index_hash (dtab, key);struct bpf_dtab_netdev *dev; -hlist_for_each_entry_rcu (dev, head, index_hlist) +hlist_for_each_entry_rcu (dev, head, index_hlist, +lockdep_is_held (&dtab->index_lock))if (dev->idx == key)return dev;
Greg Kroah-Hartman
maintainerPATCH 165/367 libbpf: Fix realloc usage in bpf_core_find_cands
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
commit 35b9211c0a2427e8f39e534f442f43804fc8d5ca upstream.
Fix bug requesting invalid size of reallocated array when constructing CO-RE relocation candidate list. This can cause problems if there are many potential candidates and a very fine-grained memory allocator bucket sizes are used.
--- tools/lib/bpf/libbpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +3 -1
@@ -2744,7 +2744,9 @@ static struct ids_vec *bpf_core_find_canif (strncmp (local_name, targ_name, local_essent_len) ==0 ) {pr_debug ("[%d] %s: found candidate [%d] %s\n" , local_type_id, local_name, i, targ_name); - new_ids =realloc (cand_ids->data, cand_ids->len +1 ); + new_ids =reallocarray (cand_ids->data, + cand_ids->len +1 , +sizeof (*cand_ids->data));if (!new_ids) { err = -ENOMEM ; goto err_out;
Greg Kroah-Hartman
maintainerPATCH 201/367 Btrfs: fix race between adding and putting tree mod seq elements and nodes
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 7227ff4de55d931bbdc156c8ef0ce4f100c78a5b upstream.
There is a race between adding and removing elements to the tree mod log list and rbtree that can lead to use-after-free problems.
Consider the following example that explains how/why the problems happens:
1) Task A has mod log element with sequence number 200. It currently is the only element in the mod log list;
2) Task A calls btrfs_put_tree_mod_seq() because it no longer needs to access the tree mod log. When it enters the function, it initializes 'min_seq' to (u64)-1. Then it acquires the lock 'tree_mod_seq_lock' before checking if there are other elements in the mod seq list. Since the list it empty, 'min_seq' remains set to (u64)-1. Then it unlocks the lock 'tree_mod_seq_lock';
3) Before task A acquires the lock 'tree_mod_log_lock', task B adds itself to the mod seq list through btrfs_get_tree_mod_seq() and gets a sequence number of 201;
4) Some other task, name it task C, modifies a btree and because there elements in the mod seq list, it adds a tree mod elem to the tree mod log rbtree. That node added to the mod log rbtree is assigned a sequence number of 202;
5) Task B, which is doing fiemap and resolving indirect back references, calls btrfs get_old_root(), with 'time_seq' == 201, which in turn calls tree_mod_log_search() - the search returns the mod log node from the rbtree with sequence number 202, created by task C;
6) Task A now acquires the lock 'tree_mod_log_lock', starts iterating the mod log rbtree and finds the node with sequence number 202. Since 202 is less than the previously computed 'min_seq', (u64)-1, it removes the node and frees it;
7) Task B still has a pointer to the node with sequence number 202, and it dereferences the pointer itself and through the call to __tree_mod_log_rewind(), resulting in a use-after-free problem.
This issue can be triggered sporadically with the test case generic/561 from fstests, and it happens more frequently with a higher number of duperemove processes. When it happens to me, it either freezes the VM or it produces a trace like the following before crashing:
[ 1245.321140] general protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC PTI [ 1245.321200] CPU: 1 PID: 26997 Comm: pool Not tainted 5.5.0-rc6-btrfs-next-52 #1 [ 1245.321235] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-0-ga698c8995f-prebuilt.qemu.org 04/01/2014 [ 1245.321287] RIP: 0010:rb_next+0x16/0x50 [ 1245.321307] Code: .... [ 1245.321372] RSP: 0018:ffffa151c4d039b0 EFLAGS: 00010202 [ 1245.321388] RAX: 6b6b6b6b6b6b6b6b RBX: ffff8ae221363c80 RCX: 6b6b6b6b6b6b6b6b [ 1245.321409] RDX: 0000000000000001 RSI: 0000000000000000 RDI: ffff8ae221363c80 [ 1245.321439] RBP: ffff8ae20fcc4688 R08: 0000000000000002 R09: 0000000000000000 [ 1245.321475] R10: ffff8ae20b120910 R11: 00000000243f8bb1 R12: 0000000000000038 [ 1245.321506] R13: ffff8ae221363c80 R14: 000000000000075f R15: ffff8ae223f762b8 [ 1245.321539] FS: 00007fdee1ec7700(0000) GS:ffff8ae236c80000(0000) knlGS:0000000000000000 [ 1245.321591] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1245.321614] CR2: 00007fded4030c48 CR3: 000000021da16003 CR4: 00000000003606e0 [ 1245.321642] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1245.321668] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 1245.321706] Call Trace: [ 1245.321798] __tree_mod_log_rewind+0xbf/0x280 [btrfs] [ 1245.321841] btrfs_search_old_slot+0x105/0xd00 [btrfs] [ 1245.321877] resolve_indirect_refs+0x1eb/0xc60 [btrfs] [ 1245.321912] find_parent_nodes+0x3dc/0x11b0 [btrfs] [ 1245.321947] btrfs_check_shared+0x115/0x1c0 [btrfs] [ 1245.321980] ? extent_fiemap+0x59d/0x6d0 [btrfs] [ 1245.322029] extent_fiemap+0x59d/0x6d0 [btrfs] [ 1245.322066] do_vfs_ioctl+0x45a/0x750 [ 1245.322081] ksys_ioctl+0x70/0x80 [ 1245.322092] ? trace_hardirqs_off_thunk+0x1a/0x1c [ 1245.322113] __x64_sys_ioctl+0x16/0x20 [ 1245.322126] do_syscall_64+0x5c/0x280 [ 1245.322139] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 1245.322155] RIP: 0033:0x7fdee3942dd7 [ 1245.322177] Code: .... [ 1245.322258] RSP: 002b:00007fdee1ec6c88 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ 1245.322294] RAX: ffffffffffffffda RBX: 00007fded40210d8 RCX: 00007fdee3942dd7 [ 1245.322314] RDX: 00007fded40210d8 RSI: 00000000c020660b RDI: 0000000000000004 [ 1245.322337] RBP: 0000562aa89e7510 R08: 0000000000000000 R09: 00007fdee1ec6d44 [ 1245.322369] R10: 0000000000000073 R11: 0000000000000246 R12: 00007fdee1ec6d48 [ 1245.322390] R13: 00007fdee1ec6d40 R14: 00007fded40210d0 R15: 00007fdee1ec6d50 [ 1245.322423] Modules linked in: .... [ 1245.323443] ---[ end trace 01de1e9ec5dff3cd ]---
Fix this by ensuring that btrfs_put_tree_mod_seq() computes the minimum sequence number and iterates the rbtree while holding the lock 'tree_mod_log_lock' in write mode. Also get rid of the 'tree_mod_seq_lock' lock, since it is now redundant.
--- fs/btrfs/ctree.c | 8 ++------ fs/btrfs/ctree.h | 6 ++---- fs/btrfs/delayed-ref.c | 8 ++++---- fs/btrfs/disk-io.c | 1 - fs/btrfs/tests/btrfs-tests.c | 1 - 5 files changed, 8 insertions(+), 16 deletions(-)
fs/btrfs/ctree.c +2 -6
@@ -326,12 +326,10 @@ u64 btrfs_get_tree_mod_seq(struct btrfs_ struct seq_list *elem) {write_lock (&fs_info->tree_mod_log_lock); -spin_lock (&fs_info->tree_mod_seq_lock);if (!elem->seq) { elem->seq =btrfs_inc_tree_mod_seq (fs_info);list_add_tail (&elem->list, &fs_info->tree_mod_seq_list); } -spin_unlock (&fs_info->tree_mod_seq_lock);write_unlock (&fs_info->tree_mod_log_lock);return elem->seq;
@@ -351,7 +349,7 @@ void btrfs_put_tree_mod_seq(struct btrfsif (!seq_putting)return ; -spin_lock (&fs_info->tree_mod_seq_lock); +write_lock (&fs_info->tree_mod_log_lock);list_del (&elem->list); elem->seq =0 ;
@@ -362,19 +360,17 @@ void btrfs_put_tree_mod_seq(struct btrfs* blocker with lower sequence number exists, we * cannot remove anything from the log */ -spin_unlock (&fs_info->tree_mod_seq_lock); +write_unlock (&fs_info->tree_mod_log_lock);return ; } min_seq = cur_elem->seq; } } -spin_unlock (&fs_info->tree_mod_seq_lock);/* * anything that's lower than the lowest existing (read: blocked) * sequence number can be removed from the tree. */ -write_lock (&fs_info->tree_mod_log_lock); tm_root = &fs_info->tree_mod_log;for (node =rb_first (tm_root); node; node = next) { next =rb_next (node);
fs/btrfs/ctree.h +2 -4
@@ -673,14 +673,12 @@ struct btrfs_fs_info {atomic_t nr_delayed_iputs;wait_queue_head_t delayed_iputs_wait; -/* this protects tree_mod_seq_list */ -spinlock_t tree_mod_seq_lock;atomic64_t tree_mod_seq; -struct list_head tree_mod_seq_list; -/* this protects tree_mod_log */ +/* this protects tree_mod_log and tree_mod_seq_list */ rwlock_t tree_mod_log_lock;struct rb_root tree_mod_log; +struct list_head tree_mod_seq_list;atomic_t async_delalloc_pages;
fs/btrfs/delayed-ref.c +4 -4
@@ -492,7 +492,7 @@ void btrfs_merge_delayed_refs(struct btrif (head->is_data)return ; -spin_lock (&fs_info->tree_mod_seq_lock); +read_lock (&fs_info->tree_mod_log_lock);if (!list_empty (&fs_info->tree_mod_seq_list)) {struct seq_list *elem;
@@ -500,7 +500,7 @@ void btrfs_merge_delayed_refs(struct btr struct seq_list, list); seq = elem->seq; } -spin_unlock (&fs_info->tree_mod_seq_lock); +read_unlock (&fs_info->tree_mod_log_lock); again: for (node = rb_first_cached(&head->ref_tree); node;
@@ -518,7 +518,7 @@ int btrfs_check_delayed_seq(struct btrfsstruct seq_list *elem;int ret =0 ; -spin_lock (&fs_info->tree_mod_seq_lock); +read_lock (&fs_info->tree_mod_log_lock);if (!list_empty (&fs_info->tree_mod_seq_list)) { elem =list_first_entry (&fs_info->tree_mod_seq_list, struct seq_list, list);
@@ -531,7 +531,7 @@ int btrfs_check_delayed_seq(struct btrfs } } -spin_unlock (&fs_info->tree_mod_seq_lock); +read_unlock (&fs_info->tree_mod_log_lock);return ret; }
fs/btrfs/disk-io.c +0 -1
@@ -2691,7 +2691,6 @@ int __cold open_ctree(struct super_blockspin_lock_init (&fs_info->fs_roots_radix_lock);spin_lock_init (&fs_info->delayed_iput_lock);spin_lock_init (&fs_info->defrag_inodes_lock); -spin_lock_init (&fs_info->tree_mod_seq_lock);spin_lock_init (&fs_info->super_lock);spin_lock_init (&fs_info->buffer_lock);spin_lock_init (&fs_info->unused_bgs_lock);
fs/btrfs/tests/btrfs-tests.c +0 -1
@@ -121,7 +121,6 @@ struct btrfs_fs_info *btrfs_alloc_dummy_spin_lock_init (&fs_info->qgroup_lock);spin_lock_init (&fs_info->super_lock);spin_lock_init (&fs_info->fs_roots_radix_lock); -spin_lock_init (&fs_info->tree_mod_seq_lock);mutex_init (&fs_info->qgroup_ioctl_lock);mutex_init (&fs_info->qgroup_rescan_lock);rwlock_init (&fs_info->tree_mod_log_lock);
Greg Kroah-Hartman
maintainerPATCH 199/367 btrfs: drop log root for dropped roots
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 889bfa39086e86b52fcfaa04d72c95eaeb12f9a5 upstream.
If we fsync on a subvolume and create a log root for that volume, and then later delete that subvolume we'll never clean up its log root. Fix this by making switch_commit_roots free the log for any dropped roots we encounter. The extra churn is because we need a btrfs_trans_handle, not the btrfs_transaction.
--- fs/btrfs/transaction.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
fs/btrfs/transaction.c +12 -10
@@ -147,13 +147,14 @@ void btrfs_put_transaction(struct btrfs_ } } -static noinline void switch_commit_roots(struct btrfs_transaction *trans) +static noinline void switch_commit_roots(struct btrfs_trans_handle *trans) { +struct btrfs_transaction *cur_trans = trans->transaction;struct btrfs_fs_info *fs_info = trans->fs_info;struct btrfs_root *root, *tmp;down_write (&fs_info->commit_root_sem); -list_for_each_entry_safe (root, tmp, &trans->switch_commits, +list_for_each_entry_safe (root, tmp, &cur_trans->switch_commits, dirty_list) {list_del_init (&root->dirty_list);free_extent_buffer (root->commit_root);
@@ -165,16 +166,17 @@ static noinline void switch_commit_roots }/* We can free old roots now. */ -spin_lock (&trans->dropped_roots_lock); -while (!list_empty (&trans->dropped_roots)) { - root =list_first_entry (&trans->dropped_roots, +spin_lock (&cur_trans->dropped_roots_lock); +while (!list_empty (&cur_trans->dropped_roots)) { + root =list_first_entry (&cur_trans->dropped_roots, struct btrfs_root, root_list);list_del_init (&root->root_list); -spin_unlock (&trans->dropped_roots_lock); +spin_unlock (&cur_trans->dropped_roots_lock); +btrfs_free_log (trans, root);btrfs_drop_and_free_fs_root (fs_info, root); -spin_lock (&trans->dropped_roots_lock); +spin_lock (&cur_trans->dropped_roots_lock); } -spin_unlock (&trans->dropped_roots_lock); +spin_unlock (&cur_trans->dropped_roots_lock);up_write (&fs_info->commit_root_sem); }
@@ -1421,7 +1423,7 @@ static int qgroup_account_snapshot(struc ret =commit_cowonly_roots (trans);if (ret) goto out; -switch_commit_roots (trans->transaction); +switch_commit_roots (trans); ret =btrfs_write_and_wait_transaction (trans);if (ret) btrfs_handle_fs_error(fs_info, ret,
@@ -2309,7 +2311,7 @@ int btrfs_commit_transaction(struct btrflist_add_tail (&fs_info->chunk_root->dirty_list, &cur_trans->switch_commits); -switch_commit_roots (cur_trans); +switch_commit_roots (trans);ASSERT (list_empty (&cur_trans->dirty_bgs));ASSERT (list_empty (&cur_trans->io_bgs));
Greg Kroah-Hartman
maintainerPATCH 162/367 flow_dissector: Fix to use new variables for port ranges in bpf hook
In reply to Greg Kroah-HartmanFrom: Yoshiki Komachi <[email protected]>
commit 59fb9b62fb6c929a756563152a89f39b07cf8893 upstream.
This patch applies new flag (FLOW_DISSECTOR_KEY_PORTS_RANGE) and field (tp_range) to BPF flow dissector to generate appropriate flow keys when classified by specified port ranges.
--- net/core/flow_dissector.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/core/flow_dissector.c +9 -2
@@ -834,10 +834,10 @@ static void __skb_flow_bpf_to_target(construct flow_dissector *flow_dissector, void *target_container) { + struct flow_dissector_key_ports *key_ports = NULL;struct flow_dissector_key_control *key_control;struct flow_dissector_key_basic *key_basic;struct flow_dissector_key_addrs *key_addrs; -struct flow_dissector_key_ports *key_ports;struct flow_dissector_key_tags *key_tags; key_control = skb_flow_dissector_target(flow_dissector,
@@ -876,10 +876,17 @@ static void __skb_flow_bpf_to_target(con key_control->addr_type =FLOW_DISSECTOR_KEY_IPV6_ADDRS ; } -if (dissector_uses_key (flow_dissector,FLOW_DISSECTOR_KEY_PORTS )) { +if (dissector_uses_key (flow_dissector,FLOW_DISSECTOR_KEY_PORTS )) key_ports =skb_flow_dissector_target (flow_dissector,FLOW_DISSECTOR_KEY_PORTS , target_container); +else if (dissector_uses_key (flow_dissector, +FLOW_DISSECTOR_KEY_PORTS_RANGE )) + key_ports =skb_flow_dissector_target (flow_dissector, +FLOW_DISSECTOR_KEY_PORTS_RANGE , + target_container); + +if (key_ports) { key_ports->src = flow_keys->sport; key_ports->dst = flow_keys->dport; }
Greg Kroah-Hartman
maintainerPATCH 197/367 Btrfs: fix infinite loop during fsync after rename operations
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit b5e4ff9d465da1233a2d9a47ebce487c70d8f4ab upstream.
Recently fsstress (from fstests) sporadically started to trigger an infinite loop during fsync operations. This turned out to be because support for the rename exchange and whiteout operations was added to fsstress in fstests. These operations, unlike any others in fsstress, cause file names to be reused, whence triggering this issue. However it's not necessary to use rename exchange and rename whiteout operations trigger this issue, simple rename operations and file creations are enough to trigger the issue.
The issue boils down to when we are logging inodes that conflict (that had the name of any inode we need to log during the fsync operation), we keep logging them even if they were already logged before, and after that we check if there's any other inode that conflicts with them and then add it again to the list of inodes to log. Skipping already logged inodes fixes the issue.
Consider the following example:
$ mkfs.btrfs -f /dev/sdb $ mount /dev/sdb /mnt
$ mkdir /mnt/testdir # inode 257
$ touch /mnt/testdir/zz # inode 258 $ ln /mnt/testdir/zz /mnt/testdir/zz_link
$ touch /mnt/testdir/a # inode 259
$ sync
# The following 3 renames achieve the same result as a rename exchange
# operation (<rename_exchange> /mnt/testdir/zz_link to /mnt/testdir/a).
$ mv /mnt/testdir/a /mnt/testdir/a/tmp $ mv /mnt/testdir/zz_link /mnt/testdir/a $ mv /mnt/testdir/a/tmp /mnt/testdir/zz_link
# The following rename and file creation give the same result as a
# rename whiteout operation (<rename_whiteout> zz to a2).
$ mv /mnt/testdir/zz /mnt/testdir/a2 $ touch /mnt/testdir/zz # inode 260
$ xfs_io -c fsync /mnt/testdir/zz
--> results in the infinite loopThe following steps happen:
1) When logging inode 260, we find that its reference named "zz" was used by inode 258 in the previous transaction (through the commit root), so inode 258 is added to the list of conflicting indoes that need to be logged;
2) After logging inode 258, we find that its reference named "a" was used by inode 259 in the previous transaction, and therefore we add inode 259 to the list of conflicting inodes to be logged;
3) After logging inode 259, we find that its reference named "zz_link" was used by inode 258 in the previous transaction - we add inode 258 to the list of conflicting inodes to log, again - we had already logged it before at step 3. After logging it again, we find again that inode 259 conflicts with him, and we add again 259 to the list, etc - we end up repeating all the previous steps.
So fix this by skipping logging of conflicting inodes that were already logged.
--- fs/btrfs/tree-log.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
fs/btrfs/tree-log.c +44 -0
@@ -4836,6 +4836,50 @@ static int log_conflicting_inodes(structcontinue ; }/* +* If the inode was already logged skip it - otherwise we can +* hit an infinite loop. Example: +* +* From the commit root (previous transaction) we have the +* following inodes: +* +* inode 257 a directory +* inode 258 with references "zz" and "zz_link" on inode 257 +* inode 259 with reference "a" on inode 257 +* +* And in the current (uncommitted) transaction we have: +* +* inode 257 a directory, unchanged +* inode 258 with references "a" and "a2" on inode 257 +* inode 259 with reference "zz_link" on inode 257 +* inode 261 with reference "zz" on inode 257 +* +* When logging inode 261 the following infinite loop could +* happen if we don't skip already logged inodes: +* +* - we detect inode 258 as a conflicting inode, with inode 261 +* on reference "zz", and log it; +* +* - we detect inode 259 as a conflicting inode, with inode 258 +* on reference "a", and log it; +* +* - we detect inode 258 as a conflicting inode, with inode 259 +* on reference "zz_link", and log it - again! After this we +* repeat the above steps forever. +*/ +spin_lock (&BTRFS_I (inode)->lock); +/* +* Check the inode's logged_trans only instead of +* btrfs_inode_in_log(). This is because the last_log_commit of +* the inode is not updated when we only log that it exists and +* and it has the full sync bit set (see btrfs_log_inode()). +*/ +if (BTRFS_I (inode)->logged_trans == trans->transid) { +spin_unlock (&BTRFS_I (inode)->lock); +btrfs_add_delayed_iput (inode); +continue ; + } +spin_unlock (&BTRFS_I (inode)->lock); +/* * We are safe logging the other inode without acquiring its * lock as long as we log with the LOG_INODE_EXISTS mode. We * are safe against concurrent renames of the other inode as
Greg Kroah-Hartman
maintainerPATCH 195/367 Btrfs: fix missing hole after hole punching and fsync when using NO_HOLES
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 0e56315ca147b3e60c7bf240233a301d3c7fb508 upstream.
When using the NO_HOLES feature, if we punch a hole into a file and then fsync it, there are cases where a subsequent fsync will miss the fact that a hole was punched, resulting in the holes not existing after replaying the log tree.
Essentially these cases all imply that, tree-log.c:copy_items(), is not invoked for the leafs that delimit holes, because nothing changed those leafs in the current transaction. And it's precisely copy_items() where we currenly detect and log holes, which works as long as the holes are between file extent items in the input leaf or between the beginning of input leaf and the previous leaf or between the last item in the leaf and the next leaf.
First example where we miss a hole:
*) The extent items of the inode span multiple leafs;
*) The punched hole covers a range that affects only the extent items of
the first leaf;
*) The fsync operation is done in full mode (BTRFS_INODE_NEEDS_FULL_SYNC
is set in the inode's runtime flags).
That results in the hole not existing after replaying the log tree.
For example, if the fs/subvolume tree has the following layout for a particular inode:
Leaf N, generation 10:
[ ... INODE_ITEM INODE_REF EXTENT_ITEM (0 64K) EXTENT_ITEM (64K 128K) ]
Leaf N + 1, generation 10:
[ EXTENT_ITEM (128K 64K) ... ]
If at transaction 11 we punch a hole coverting the range [0, 128K[, we end up dropping the two extent items from leaf N, but we don't touch the other leaf, so we end up in the following state:
Leaf N, generation 11:
[ ... INODE_ITEM INODE_REF ]
Leaf N + 1, generation 10:
[ EXTENT_ITEM (128K 64K) ... ]
A full fsync after punching the hole will only process leaf N because it was modified in the current transaction, but not leaf N + 1, since it was not modified in the current transaction (generation 10 and not 11). As a result the fsync will not log any holes, because it didn't process any leaf with extent items.
Second example where we will miss a hole:
*) An inode as its items spanning 5 (or more) leafs;
*) A hole is punched and it covers only the extents items of the 3rd
leaf. This resulsts in deleting the entire leaf and not touching any of the other leafs.
So the only leaf that is modified in the current transaction, when punching the hole, is the first leaf, which contains the inode item. During the full fsync, the only leaf that is passed to copy_items() is that first leaf, and that's not enough for the hole detection code in copy_items() to determine there's a hole between the last file extent item in the 2nd leaf and the first file extent item in the 3rd leaf (which was the 4th leaf before punching the hole).
Fix this by scanning all leafs and punch holes as necessary when doing a full fsync (less common than a non-full fsync) when the NO_HOLES feature is enabled. The lack of explicit file extent items to mark holes makes it necessary to scan existing extents to determine if holes exist.
A test case for fstests follows soon.
--- fs/btrfs/tree-log.c | 388 +++++++++++++--------------------------------------- 1 file changed, 100 insertions(+), 288 deletions(-)
fs/btrfs/tree-log.c +100 -288
@@ -3935,7 +3935,7 @@ static int log_csums(struct btrfs_trans_ static noinline int copy_items(struct btrfs_trans_handle *trans,struct btrfs_inode *inode,struct btrfs_path *dst_path, -struct btrfs_path *src_path,u64 *last_extent, +struct btrfs_path *src_path,int start_slot,int nr,int inode_only,u64 logged_isize) {
@@ -3946,7 +3946,6 @@ static noinline int copy_items(struct btstruct btrfs_file_extent_item *extent;struct btrfs_inode_item *inode_item;struct extent_buffer *src = src_path->nodes[0 ]; -struct btrfs_key first_key, last_key, key;int ret;struct btrfs_key *ins_keys;u32 *ins_sizes;
@@ -3954,9 +3953,6 @@ static noinline int copy_items(struct btint i;struct list_head ordered_sums;int skip_csum = inode->flags &BTRFS_INODE_NODATASUM ; -bool has_extents = false; -bool need_find_last_extent = true; -bool done = false;INIT_LIST_HEAD (&ordered_sums);
@@ -3965,8 +3961,6 @@ static noinline int copy_items(struct btif (!ins_data)return -ENOMEM ; - first_key.objectid = (u64)-1 ; - ins_sizes = (u32 *)ins_data; ins_keys = (struct btrfs_key *)(ins_data + nr *sizeof (u32));
@@ -3987,9 +3981,6 @@ static noinline int copy_items(struct bt src_offset =btrfs_item_ptr_offset (src, start_slot + i); -if (i == nr -1 ) - last_key = ins_keys[i]; -if (ins_keys[i].type ==BTRFS_INODE_ITEM_KEY ) { inode_item = btrfs_item_ptr(dst_path->nodes[0], dst_path->slots[0],
@@ -4003,20 +3994,6 @@ static noinline int copy_items(struct bt src_offset, ins_sizes[i]); } -/* -* We set need_find_last_extent here in case we know we were -* processing other items and then walk into the first extent in -* the inode. If we don't hit an extent then nothing changes, -* we'll do the last search the next time around. -*/ -if (ins_keys[i].type ==BTRFS_EXTENT_DATA_KEY ) { - has_extents = true; -if (first_key.objectid == (u64)-1 ) - first_key = ins_keys[i]; - }else { - need_find_last_extent = false; - } -/* take a reference on file data extents so that truncates * or deletes of this inode don't have to relog the inode * again
@@ -4082,167 +4059,6 @@ static noinline int copy_items(struct btkfree (sums); } -if (!has_extents) -return ret; - -if (need_find_last_extent && *last_extent == first_key.offset) { -/* -* We don't have any leafs between our current one and the one -* we processed before that can have file extent items for our -* inode (and have a generation number smaller than our current -* transaction id). -*/ - need_find_last_extent = false; - } - -/* -* Because we use btrfs_search_forward we could skip leaves that were -* not modified and then assume *last_extent is valid when it really -* isn't. So back up to the previous leaf and read the end of the last -* extent before we go and fill in holes. -*/ -if (need_find_last_extent) { -u64 len; - - ret =btrfs_prev_leaf (inode->root, src_path); -if (ret <0 ) -return ret; -if (ret) - goto fill_holes; -if (src_path->slots[0 ]) - src_path->slots[0 ]--; - src = src_path->nodes[0 ]; -btrfs_item_key_to_cpu (src, &key, src_path->slots[0 ]); -if (key.objectid !=btrfs_ino (inode) || - key.type !=BTRFS_EXTENT_DATA_KEY ) - goto fill_holes; - extent =btrfs_item_ptr (src, src_path->slots[0 ], - struct btrfs_file_extent_item); -if (btrfs_file_extent_type (src, extent) == -BTRFS_FILE_EXTENT_INLINE ) { - len =btrfs_file_extent_ram_bytes (src, extent); - *last_extent =ALIGN (key.offset + len, - fs_info->sectorsize); - }else { - len =btrfs_file_extent_num_bytes (src, extent); - *last_extent = key.offset + len; - } - } -fill_holes: -/* So we did prev_leaf, now we need to move to the next leaf, but a few -* things could have happened -* -* 1) A merge could have happened, so we could currently be on a leaf -* that holds what we were copying in the first place. -* 2) A split could have happened, and now not all of the items we want -* are on the same leaf. -* -* So we need to adjust how we search for holes, we need to drop the -* path and re-search for the first extent key we found, and then walk -* forward until we hit the last one we copied. -*/ -if (need_find_last_extent) { -/* btrfs_prev_leaf could return 1 without releasing the path */ -btrfs_release_path (src_path); - ret =btrfs_search_slot (NULL , inode->root, &first_key, - src_path,0 ,0 ); -if (ret <0 ) -return ret; -ASSERT (ret ==0 ); - src = src_path->nodes[0 ]; - i = src_path->slots[0 ]; - }else { - i = start_slot; - } - -/* -* Ok so here we need to go through and fill in any holes we may have -* to make sure that holes are punched for those areas in case they had -* extents previously. -*/ -while (!done) { -u64 offset, len; -u64 extent_end; - -if (i >=btrfs_header_nritems (src_path->nodes[0 ])) { - ret =btrfs_next_leaf (inode->root, src_path); -if (ret <0 ) -return ret; -ASSERT (ret ==0 ); - src = src_path->nodes[0 ]; - i =0 ; - need_find_last_extent = true; - } - -btrfs_item_key_to_cpu (src, &key, i); -if (!btrfs_comp_cpu_keys (&key, &last_key)) - done = true; -if (key.objectid !=btrfs_ino (inode) || - key.type !=BTRFS_EXTENT_DATA_KEY ) { - i++; -continue ; - } - extent = btrfs_item_ptr(src, i, struct btrfs_file_extent_item); -if (btrfs_file_extent_type (src, extent) == -BTRFS_FILE_EXTENT_INLINE ) { - len =btrfs_file_extent_ram_bytes (src, extent); - extent_end =ALIGN (key.offset + len, - fs_info->sectorsize); - }else { - len =btrfs_file_extent_num_bytes (src, extent); - extent_end = key.offset + len; - } - i++; - -if (*last_extent == key.offset) { - *last_extent = extent_end; -continue ; - } - offset = *last_extent; - len = key.offset - *last_extent; - ret =btrfs_insert_file_extent (trans, log,btrfs_ino (inode), - offset,0 ,0 , len,0 , len,0 ,0 ,0 ); -if (ret) -break ; - *last_extent = extent_end; - } - -/* -* Check if there is a hole between the last extent found in our leaf -* and the first extent in the next leaf. If there is one, we need to -* log an explicit hole so that at replay time we can punch the hole. -*/ -if (ret ==0 && - key.objectid ==btrfs_ino (inode) && - key.type ==BTRFS_EXTENT_DATA_KEY && - i ==btrfs_header_nritems (src_path->nodes[0 ])) { - ret =btrfs_next_leaf (inode->root, src_path); - need_find_last_extent = true; -if (ret >0 ) { - ret =0 ; - }else if (ret ==0 ) { -btrfs_item_key_to_cpu (src_path->nodes[0 ], &key, - src_path->slots[0 ]); -if (key.objectid ==btrfs_ino (inode) && - key.type ==BTRFS_EXTENT_DATA_KEY && - *last_extent < key.offset) { -const u64 len = key.offset - *last_extent; - - ret =btrfs_insert_file_extent (trans, log, -btrfs_ino (inode), - *last_extent,0 , -0 , len,0 , len, -0 ,0 ,0 ); - *last_extent += len; - } - } - } -/* -* Need to let the callers know we dropped the path so they should -* re-search. -*/ -if (!ret && need_find_last_extent) - ret =1 ;return ret; }
@@ -4407,7 +4223,7 @@ static int btrfs_log_prealloc_extents(stconst u64 i_size =i_size_read (&inode->vfs_inode);const u64 ino =btrfs_ino (inode);struct btrfs_path *dst_path =NULL ; -u64 last_extent = (u64)-1 ; +bool dropped_extents = false;int ins_nr =0 ;int start_slot;int ret;
@@ -4429,8 +4245,7 @@ static int btrfs_log_prealloc_extents(stif (slot >=btrfs_header_nritems (leaf)) {if (ins_nr >0 ) { ret =copy_items (trans, inode, dst_path, path, - &last_extent, start_slot, - ins_nr,1 ,0 ); + start_slot, ins_nr,1 ,0 );if (ret <0 ) goto out; ins_nr =0 ;
@@ -4454,8 +4269,7 @@ static int btrfs_log_prealloc_extents(st path->slots[0 ]++;continue ; } -if (last_extent == (u64)-1 ) { - last_extent = key.offset; +if (!dropped_extents) {/* * Avoid logging extent items logged in past fsync calls * and leading to duplicate keys in the log tree.
@@ -4469,6 +4283,7 @@ static int btrfs_log_prealloc_extents(st }while (ret == -EAGAIN );if (ret) goto out; + dropped_extents = true; }if (ins_nr ==0 ) start_slot = slot;
@@ -4483,7 +4298,7 @@ static int btrfs_log_prealloc_extents(st } }if (ins_nr >0 ) { - ret =copy_items (trans, inode, dst_path, path, &last_extent, + ret =copy_items (trans, inode, dst_path, path, start_slot, ins_nr,1 ,0 );if (ret >0 ) ret =0 ;
@@ -4670,13 +4485,8 @@ static int btrfs_log_all_xattrs(struct bif (slot >= nritems) {if (ins_nr >0 ) { -u64 last_extent =0 ; - ret =copy_items (trans, inode, dst_path, path, - &last_extent, start_slot, - ins_nr,1 ,0 ); -/* can't be 1, extent items aren't processed */ -ASSERT (ret <=0 ); + start_slot, ins_nr,1 ,0 );if (ret <0 )return ret; ins_nr =0 ;
@@ -4700,13 +4510,8 @@ static int btrfs_log_all_xattrs(struct bcond_resched (); }if (ins_nr >0 ) { -u64 last_extent =0 ; - ret =copy_items (trans, inode, dst_path, path, - &last_extent, start_slot, - ins_nr,1 ,0 ); -/* can't be 1, extent items aren't processed */ -ASSERT (ret <=0 ); + start_slot, ins_nr,1 ,0 );if (ret <0 )return ret; }
@@ -4715,100 +4520,119 @@ static int btrfs_log_all_xattrs(struct b }/* -* If the no holes feature is enabled we need to make sure any hole between the -* last extent and the i_size of our inode is explicitly marked in the log. This -* is to make sure that doing something like: -* -* 1) create file with 128Kb of data -* 2) truncate file to 64Kb -* 3) truncate file to 256Kb -* 4) fsync file -* 5) <crash/power failure> -* 6) mount fs and trigger log replay -* -* Will give us a file with a size of 256Kb, the first 64Kb of data match what -* the file had in its first 64Kb of data at step 1 and the last 192Kb of the -* file correspond to a hole. The presence of explicit holes in a log tree is -* what guarantees that log replay will remove/adjust file extent items in the -* fs/subvol tree. -* -* Here we do not need to care about holes between extents, that is already done -* by copy_items(). We also only need to do this in the full sync path, where we -* lookup for extents from the fs/subvol tree only. In the fast path case, we -* lookup the list of modified extent maps and if any represents a hole, we -* insert a corresponding extent representing a hole in the log tree. +* When using the NO_HOLES feature if we punched a hole that causes the +* deletion of entire leafs or all the extent items of the first leaf (the one +* that contains the inode item and references) we may end up not processing +* any extents, because there are no leafs with a generation matching the +* current transaction that have extent items for our inode. So we need to find +* if any holes exist and then log them. We also need to log holes after any +* truncate operation that changes the inode's size. */ -static int btrfs_log_trailing_hole (struct btrfs_trans_handle *trans, -struct btrfs_root *root, -struct btrfs_inode *inode, -struct btrfs_path *path) +static int btrfs_log_holes (struct btrfs_trans_handle *trans, +struct btrfs_root *root, +struct btrfs_inode *inode, +struct btrfs_path *path) {struct btrfs_fs_info *fs_info = root->fs_info; -int ret;struct btrfs_key key; -u64 hole_start; -u64 hole_size; -struct extent_buffer *leaf; -struct btrfs_root *log = root->log_root;const u64 ino =btrfs_ino (inode);const u64 i_size =i_size_read (&inode->vfs_inode); +u64 prev_extent_end =0 ; +int ret; -if (!btrfs_fs_incompat (fs_info,NO_HOLES )) +if (!btrfs_fs_incompat (fs_info,NO_HOLES ) || i_size ==0 )return 0 ; key.objectid = ino; key.type =BTRFS_EXTENT_DATA_KEY ; - key.offset = (u64)-1 ; + key.offset =0 ; ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 ); -ASSERT (ret !=0 );if (ret <0 )return ret; -ASSERT (path->slots[0 ] >0 ); - path->slots[0 ]--; - leaf = path->nodes[0 ]; -btrfs_item_key_to_cpu (leaf, &key, path->slots[0 ]); - -if (key.objectid != ino || key.type !=BTRFS_EXTENT_DATA_KEY ) { -/* inode does not have any extents */ - hole_start =0 ; - hole_size = i_size; - }else { +while (true) {struct btrfs_file_extent_item *extent; +struct extent_buffer *leaf = path->nodes[0 ];u64 len; -/* -* If there's an extent beyond i_size, an explicit hole was -* already inserted by copy_items(). -*/ -if (key.offset >= i_size) -return 0 ; +if (path->slots[0 ] >=btrfs_header_nritems (path->nodes[0 ])) { + ret =btrfs_next_leaf (root, path); +if (ret <0 ) +return ret; +if (ret >0 ) { + ret =0 ; +break ; + } + leaf = path->nodes[0 ]; + } + +btrfs_item_key_to_cpu (leaf, &key, path->slots[0 ]); +if (key.objectid != ino || key.type !=BTRFS_EXTENT_DATA_KEY ) +break ; + +/* We have a hole, log it. */ +if (prev_extent_end < key.offset) { +const u64 hole_len = key.offset - prev_extent_end; + +/* +* Release the path to avoid deadlocks with other code +* paths that search the root while holding locks on +* leafs from the log root. +*/ +btrfs_release_path (path); + ret =btrfs_insert_file_extent (trans, root->log_root, + ino, prev_extent_end,0 , +0 , hole_len,0 , hole_len, +0 ,0 ,0 ); +if (ret <0 ) +return ret; + +/* +* Search for the same key again in the root. Since it's +* an extent item and we are holding the inode lock, the +* key must still exist. If it doesn't just emit warning +* and return an error to fall back to a transaction +* commit. +*/ + ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 ); +if (ret <0 ) +return ret; +if (WARN_ON (ret >0 )) +return -ENOENT ; + leaf = path->nodes[0 ]; + } extent =btrfs_item_ptr (leaf, path->slots[0 ], struct btrfs_file_extent_item); -if (btrfs_file_extent_type (leaf, extent) == -BTRFS_FILE_EXTENT_INLINE ) -return 0 ; +BTRFS_FILE_EXTENT_INLINE ) { + len =btrfs_file_extent_ram_bytes (leaf, extent); + prev_extent_end =ALIGN (key.offset + len, + fs_info->sectorsize); + }else { + len =btrfs_file_extent_num_bytes (leaf, extent); + prev_extent_end = key.offset + len; + } - len =btrfs_file_extent_num_bytes (leaf, extent); -/* Last extent goes beyond i_size, no need to log a hole. */ -if (key.offset + len > i_size) -return 0 ; - hole_start = key.offset + len; - hole_size = i_size - hole_start; + path->slots[0 ]++; +cond_resched (); } -btrfs_release_path (path); -/* Last extent ends at i_size. */ -if (hole_size ==0 ) -return 0 ; +if (prev_extent_end < i_size) { +u64 hole_len; - hole_size =ALIGN (hole_size, fs_info->sectorsize); - ret =btrfs_insert_file_extent (trans, log, ino, hole_start,0 ,0 , - hole_size,0 , hole_size,0 ,0 ,0 ); -return ret; +btrfs_release_path (path); + hole_len =ALIGN (i_size - prev_extent_end, fs_info->sectorsize); + ret =btrfs_insert_file_extent (trans, root->log_root, + ino, prev_extent_end,0 ,0 , + hole_len,0 , hole_len, +0 ,0 ,0 ); +if (ret <0 ) +return ret; + } + +return 0 ; }/*
@@ -5110,7 +4934,6 @@ static int btrfs_log_inode(struct btrfs_struct btrfs_key min_key;struct btrfs_key max_key;struct btrfs_root *log = root->log_root; -u64 last_extent =0 ;int err =0 ;int ret;int nritems;
@@ -5288,7 +5111,7 @@ again: ins_start_slot = path->slots[0 ]; } ret =copy_items (trans, inode, dst_path, path, - &last_extent, ins_start_slot, + ins_start_slot, ins_nr, inode_only, logged_isize);if (ret <0 ) {
@@ -5311,17 +5134,13 @@ again:if (ins_nr ==0 ) goto next_slot; ret =copy_items (trans, inode, dst_path, path, - &last_extent, ins_start_slot, + ins_start_slot, ins_nr, inode_only, logged_isize);if (ret <0 ) { err = ret; goto out_unlock; } ins_nr =0 ; -if (ret) { -btrfs_release_path (path); -continue ; - } goto next_slot; }
@@ -5334,18 +5153,13 @@ again: goto next_slot; } - ret =copy_items (trans, inode, dst_path, path, &last_extent, + ret =copy_items (trans, inode, dst_path, path, ins_start_slot, ins_nr, inode_only, logged_isize);if (ret <0 ) { err = ret; goto out_unlock; } -if (ret) { - ins_nr =0 ; -btrfs_release_path (path); -continue ; - } ins_nr =1 ; ins_start_slot = path->slots[0 ]; next_slot:
@@ -5359,13 +5173,12 @@ next_slot: }if (ins_nr) { ret =copy_items (trans, inode, dst_path, path, - &last_extent, ins_start_slot, + ins_start_slot, ins_nr, inode_only, logged_isize);if (ret <0 ) { err = ret; goto out_unlock; } - ret =0 ; ins_nr =0 ; }btrfs_release_path (path);
@@ -5380,14 +5193,13 @@ next_key: } }if (ins_nr) { - ret =copy_items (trans, inode, dst_path, path, &last_extent, + ret =copy_items (trans, inode, dst_path, path, ins_start_slot, ins_nr, inode_only, logged_isize);if (ret <0 ) { err = ret; goto out_unlock; } - ret =0 ; ins_nr =0 ; }
@@ -5400,7 +5212,7 @@ next_key:if (max_key.type >=BTRFS_EXTENT_DATA_KEY && !fast_search) {btrfs_release_path (path);btrfs_release_path (dst_path); - err =btrfs_log_trailing_hole (trans, root, inode, path); + err =btrfs_log_holes (trans, root, inode, path);if (err) goto out_unlock; }
Greg Kroah-Hartman
maintainerPATCH 194/367 ext4: fix race conditions in ->d_compare() and ->d_hash()
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit ec772f01307a2c06ebf6cdd221e6b518a71ddae7 upstream.
Since ->d_compare() and ->d_hash() can be called in RCU-walk mode, ->d_parent and ->d_inode can be concurrently modified, and in particular, ->d_inode may be changed to NULL. For ext4_d_hash() this resulted in a reproducible NULL dereference if a lookup is done in a directory being deleted, e.g. with:
int main()
{
if (fork()) {
for (;;) {
mkdir("subdir", 0700);
rmdir("subdir");
}
} else {
for (;;)
access("subdir/file", 0);
}
}... or by running the 't_encrypted_d_revalidate' program from xfstests. Both repros work in any directory on a filesystem with the encoding feature, even if the directory doesn't actually have the casefold flag.
I couldn't reproduce a crash in ext4_d_compare(), but it appears that a similar crash is possible there.
Fix these bugs by reading ->d_parent and ->d_inode using READ_ONCE() and falling back to the case sensitive behavior if the inode is NULL.
--- fs/ext4/dir.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/ext4/dir.c +6 -3
@@ -672,9 +672,11 @@ static int ext4_d_compare(const struct d const char *str, const struct qstr *name) { struct qstr qstr = {.name = str, .len = len }; -struct inode *inode = dentry->d_parent->d_inode; +const struct dentry *parent =READ_ONCE (dentry->d_parent); +const struct inode *inode =READ_ONCE (parent->d_inode); -if (!IS_CASEFOLDED (inode) || !EXT4_SB (inode->i_sb)->s_encoding) { +if (!inode || !IS_CASEFOLDED (inode) || + !EXT4_SB (inode->i_sb)->s_encoding) {if (len != name->len)return -1 ;return memcmp (str, name->name, len);
@@ -687,10 +689,11 @@ static int ext4_d_hash(const struct dent {const struct ext4_sb_info *sbi =EXT4_SB (dentry->d_sb);const struct unicode_map *um = sbi->s_encoding; +const struct inode *inode =READ_ONCE (dentry->d_inode);unsigned char *norm;int len, ret =0 ; -if (!IS_CASEFOLDED (dentry->d_inode) || !um) +if (!inode || !IS_CASEFOLDED (inode) || !um)return 0 ; norm =kmalloc (PATH_MAX ,GFP_ATOMIC );
Greg Kroah-Hartman
maintainerPATCH 181/367 crypto: arm64/ghash-neon - bump priority to 150
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit 5441c6507bc84166e9227e9370a56c57ba13794a upstream.
The SIMD based GHASH implementation for arm64 is typically much faster than the generic one, and doesn't use any lookup tables, so it is clearly preferred when available. So bump the priority to reflect that.
--- arch/arm64/crypto/ghash-ce-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/crypto/ghash-ce-glue.c +1 -1
@@ -259,7 +259,7 @@ static int ghash_setkey(struct crypto_shstatic struct shash_alg ghash_alg[] = {{ .base.cra_name ="ghash" , .base.cra_driver_name ="ghash-neon" , - .base.cra_priority =100 , + .base.cra_priority =150 , .base.cra_blocksize =GHASH_BLOCK_SIZE , .base.cra_ctxsize =sizeof (struct ghash_key ), .base.cra_module =THIS_MODULE ,
Greg Kroah-Hartman
maintainerPATCH 182/367 crypto: pcrypt - Do not clear MAY_SLEEP flag in original request
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
commit e8d998264bffade3cfe0536559f712ab9058d654 upstream.
We should not be modifying the original request's MAY_SLEEP flag upon completion. It makes no sense to do so anyway.
--- crypto/pcrypt.c | 1 - 1 file changed, 1 deletion(-)
crypto/pcrypt.c +0 -1
@@ -71,7 +71,6 @@ static void pcrypt_aead_done(struct crypstruct padata_priv *padata =pcrypt_request_padata (preq); padata->info = err; - req->base.flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP ;padata_do_serial (padata); }
Greg Kroah-Hartman
maintainerPATCH 160/367 libbpf: Dont attach perf_buffer to offline/missing CPUs
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
commit 783b8f01f5942a786998f5577bd9ff3992f22a1a upstream.
It's quite common on some systems to have more CPUs enlisted as "possible", than there are (and could ever be) present/online CPUs. In such cases, perf_buffer creationg will fail due to inability to create perf event on missing CPU with error like this:
libbpf: failed to open perf buffer event on cpu #16: No such device
This patch fixes the logic of perf_buffer__new() to ignore CPUs that are missing or currently offline. In rare cases where user explicitly listed specific CPUs to connect to, behavior is unchanged: libbpf will try to open perf event buffer on specified CPU(s) anyways.
--- tools/lib/bpf/libbpf.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)
tools/lib/bpf/libbpf.c +25 -7
@@ -5945,7 +5945,7 @@ struct perf_buffer {size_t mmap_size;struct perf_cpu_buf **cpu_bufs;struct epoll_event *events; -int cpu_cnt; +int cpu_cnt;/* number of allocated CPU buffers */ int epoll_fd;/* perf event FD */ int map_fd;/* BPF_MAP_TYPE_PERF_EVENT_ARRAY BPF map FD */ };
@@ -6079,11 +6079,13 @@ perf_buffer__new_raw(int map_fd, size_tstatic struct perf_buffer *__perf_buffer__new (int map_fd,size_t page_cnt,struct perf_buffer_params *p) { +const char *online_cpus_file ="/sys/devices/system/cpu/online" ;struct bpf_map_info map = {};char msg[STRERR_BUFSIZE ];struct perf_buffer *pb; +bool *online =NULL ;__u32 map_info_len; -int err, i; +int err, i, j, n;if (page_cnt & (page_cnt -1 )) { pr_warn("page count should be power of two, but is %zu\n",
@@ -6152,20 +6154,32 @@ static struct perf_buffer *__perf_buffer goto error; } -for (i =0 ; i < pb->cpu_cnt; i++) { + err =parse_cpu_mask_file (online_cpus_file, &online, &n); +if (err) { +pr_warn ("failed to get online CPU mask: %d\n" , err); + goto error; + } + +for (i =0 , j =0 ; i < pb->cpu_cnt; i++) {struct perf_cpu_buf *cpu_buf;int cpu, map_key; cpu = p->cpu_cnt >0 ? p->cpus[i] : i; map_key = p->cpu_cnt >0 ? p->map_keys[i] : i; +/* in case user didn't explicitly requested particular CPUs to +* be attached to, skip offline/not present CPUs +*/ +if (p->cpu_cnt <=0 && (cpu >= n || !online[cpu])) +continue ; + cpu_buf =perf_buffer__open_cpu_buf (pb, p->attr, cpu, map_key);if (IS_ERR (cpu_buf)) { err =PTR_ERR (cpu_buf); goto error; } - pb->cpu_bufs[i] = cpu_buf; + pb->cpu_bufs[j] = cpu_buf; err =bpf_map_update_elem (pb->map_fd, &map_key, &cpu_buf->fd,0 );
@@ -6177,21 +6191,25 @@ static struct perf_buffer *__perf_buffer goto error; } - pb->events[i].events =EPOLLIN ; - pb->events[i].data.ptr = cpu_buf; + pb->events[j].events =EPOLLIN ; + pb->events[j].data.ptr = cpu_buf;if (epoll_ctl (pb->epoll_fd,EPOLL_CTL_ADD , cpu_buf->fd, - &pb->events[i]) <0 ) { + &pb->events[j]) <0 ) { err = -errno;pr_warn ("failed to epoll_ctl cpu #%d perf FD %d: %s\n" , cpu, cpu_buf->fd,libbpf_strerror_r (err, msg,sizeof (msg))); goto error; } + j++; } + pb->cpu_cnt = j; +free (online);return pb; error: +free (online);if (pb)perf_buffer__free (pb);return ERR_PTR (err);
Greg Kroah-Hartman
maintainerPATCH 179/367 crypto: hisilicon - Use the offset fields in sqe to avoid need to split scatterlists
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 484a897ffa3005f16cd9a31efd747bcf8155826f upstream.
We can configure sgl offset fields in ZIP sqe to let ZIP engine read/write sgl data with skipped data. Hence no need to splite the sgl.
--- drivers/crypto/hisilicon/Kconfig | 1 drivers/crypto/hisilicon/zip/zip.h | 4 + drivers/crypto/hisilicon/zip/zip_crypto.c | 92 +++++++----------------------- 3 files changed, 27 insertions(+), 70 deletions(-)
drivers/crypto/hisilicon/Kconfig +0 -1
@@ -44,7 +44,6 @@ config CRYPTO_DEV_HISI_ZIP depends on ARM64 || (COMPILE_TEST && 64BIT) depends on !CPU_BIG_ENDIAN || COMPILE_TEST select CRYPTO_DEV_HISI_QM - select SG_SPLIT help Support for HiSilicon ZIP Driver
drivers/crypto/hisilicon/zip/zip.h +4 -0
@@ -11,6 +11,10 @@/* hisi_zip_sqe dw3 */ #define HZIP_BD_STATUS_M GENMASK(7, 0) +/* hisi_zip_sqe dw7 */ +#define HZIP_IN_SGE_DATA_OFFSET_M GENMASK(23, 0) +/* hisi_zip_sqe dw8 */ +#define HZIP_OUT_SGE_DATA_OFFSET_M GENMASK(23, 0)/* hisi_zip_sqe dw9 */ #define HZIP_REQ_TYPE_M GENMASK(7, 0)#define HZIP_ALG_TYPE_ZLIB 0x02
drivers/crypto/hisilicon/zip/zip_crypto.c +23 -69
178 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 180/367 crypto: ccp - set max RSA modulus size for v3 platform devices as well
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit 11548f5a5747813ff84bed6f2ea01100053b0d8d upstream.
AMD Seattle incorporates a non-PCI version of the v3 CCP crypto accelerator, and this version was left behind when the maximum RSA modulus size was parameterized in order to support v5 hardware which supports larger moduli than v3 hardware does. Due to this oversight, RSA acceleration no longer works at all on these systems.
Fix this by setting the .rsamax property to the appropriate value for v3 platform hardware.
--- drivers/crypto/ccp/ccp-dev-v3.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/ccp/ccp-dev-v3.c +1 -0
@@ -586,6 +586,7 @@ const struct ccp_vdata ccpv3_platform = .setup = NULL, .perform = &ccp3_actions, .offset = 0, + .rsamax = CCP_RSA_MAX_WIDTH, };const struct ccp_vdata ccpv3 = {
Greg Kroah-Hartman
maintainerPATCH 176/367 crypto: sun8i-ce - fix removal of module
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit 93d24ac4b26770f8e5118a731cd9314f3808bd10 upstream.
Removing the driver cause an oops due to the fact we clean an extra channel.
Let's give the right index to the cleaning function.
--- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-core.c +2 -2
@@ -624,7 +624,7 @@ error_alg: error_irq:sun8i_ce_pm_exit (ce); error_pm: -sun8i_ce_free_chanlist (ce,MAXFLOW ); +sun8i_ce_free_chanlist (ce,MAXFLOW -1 );return err; }
@@ -638,7 +638,7 @@ static int sun8i_ce_remove(struct platfodebugfs_remove_recursive (ce->dbgfs_dir);#endif -sun8i_ce_free_chanlist (ce,MAXFLOW ); +sun8i_ce_free_chanlist (ce,MAXFLOW -1 );sun8i_ce_pm_exit (ce);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 177/367 crypto: api - fix unexpectedly getting generic implementation
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
commit 2bbb3375d967155bccc86a5887d4a6e29c56b683 upstream.
When CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y, the first lookup of an algorithm that needs to be instantiated using a template will always get the generic implementation, even when an accelerated one is available.
This happens because the extra self-tests for the accelerated implementation allocate the generic implementation for comparison purposes, and then crypto_alg_tested() for the generic implementation "fulfills" the original request (i.e. sets crypto_larval::adult).
This patch fixes this by only fulfilling the original request if we are currently the best outstanding larval as judged by the priority. If we're not the best then we will ask all waiters on that larval request to retry the lookup.
Note that this patch introduces a behaviour change when the module providing the new algorithm is unregistered during the process. Previously we would have failed with ENOENT, after the patch we will instead redo the lookup.
--- crypto/algapi.c | 24 +++++++++++++++++++++--- crypto/api.c | 4 +++- 2 files changed, 24 insertions(+), 4 deletions(-)
crypto/algapi.c +21 -3
@@ -257,6 +257,7 @@ void crypto_alg_tested(const char *name,struct crypto_alg *alg;struct crypto_alg *q;LIST_HEAD (list); +bool best;down_write (&crypto_alg_sem);list_for_each_entry (q, &crypto_alg_list, cra_list) {
@@ -280,6 +281,21 @@ found: alg->cra_flags |=CRYPTO_ALG_TESTED ; +/* Only satisfy larval waiters if we are the best. */ + best = true; +list_for_each_entry (q, &crypto_alg_list, cra_list) { +if (crypto_is_moribund (q) || !crypto_is_larval (q)) +continue ; + +if (strcmp (alg->cra_name, q->cra_name)) +continue ; + +if (q->cra_priority > alg->cra_priority) { + best = false; +break ; + } + } +list_for_each_entry (q, &crypto_alg_list, cra_list) {if (q == alg)continue ;
@@ -303,10 +319,12 @@ found:continue ;if ((q->cra_flags ^ alg->cra_flags) & larval->mask)continue ; -if (!crypto_mod_get (alg)) -continue ; - larval->adult = alg; +if (best &&crypto_mod_get (alg)) + larval->adult = alg; +else + larval->adult =ERR_PTR (-EAGAIN ); +continue ; }
crypto/api.c +3 -1
@@ -97,7 +97,7 @@ static void crypto_larval_destroy(structstruct crypto_larval *larval = (void *)alg;BUG_ON (!crypto_is_larval (alg)); -if (larval->adult) +if (!IS_ERR_OR_NULL (larval->adult))crypto_mod_put (larval->adult);kfree (larval); }
@@ -178,6 +178,8 @@ static struct crypto_alg *crypto_larval_ alg =ERR_PTR (-ETIMEDOUT ); else if (!alg) alg =ERR_PTR (-ENOENT ); + else if (IS_ERR(alg)) + ; else if (crypto_is_test_larval(larval) && !(alg->cra_flags & CRYPTO_ALG_TESTED)) alg =ERR_PTR (-EAGAIN );
Greg Kroah-Hartman
maintainerPATCH 172/367 selftests: bpf: Use a temporary file in test_sockmap
In reply to Greg Kroah-HartmanFrom: Lorenz Bauer <[email protected]>
commit c31dbb1e41d1857b403f9bf58c87f5898519a0bc upstream.
Use a proper temporary file for sendpage tests. This means that running the tests doesn't clutter the working directory, and allows running the test on read-only filesystems.
--- tools/testing/selftests/bpf/test_sockmap.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
tools/testing/selftests/bpf/test_sockmap.c +5 -10
@@ -331,7 +331,7 @@ static int msg_loop_sendpage(int fd, intFILE *file;int i, fp; - file =fopen (".sendpage_tst.tmp" ,"w+" ); + file =tmpfile ();if (!file) {perror ("create file for sendpage" );return 1 ;
@@ -340,13 +340,8 @@ static int msg_loop_sendpage(int fd, intfwrite (&k,sizeof (char ),1 , file);fflush (file);fseek (file,0 ,SEEK_SET ); -fclose (file); - fp =open (".sendpage_tst.tmp" ,O_RDONLY ); -if (fp <0 ) { -perror ("reopen file for sendpage" ); -return 1 ; - } + fp =fileno (file);clock_gettime (CLOCK_MONOTONIC , &s->start);for (i =0 ; i < cnt; i++) {
@@ -354,11 +349,11 @@ static int msg_loop_sendpage(int fd, intif (!drop && sent <0 ) {perror ("send loop error" ); -close (fp); +fclose (file);return sent; }else if (drop && sent >=0 ) {printf ("sendpage loop error expected: %i\n" , sent); -close (fp); +fclose (file);return -EIO ; }
@@ -366,7 +361,7 @@ static int msg_loop_sendpage(int fd, int s->bytes_sent += sent; }clock_gettime (CLOCK_MONOTONIC , &s->end); -close (fp); +fclose (file);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 170/367 selftests/bpf: Fix test_attach_probe
In reply to Greg Kroah-HartmanFrom: Alexei Starovoitov <[email protected]>
commit 580205dd4fe800b1e95be8b6df9e2991f975a8ad upstream.
Fix two issues in test_attach_probe:
1. it was not able to parse /proc/self/maps beyond the first line, since %s means parse string until white space.
2. offset has to be accounted for otherwise uprobed address is incorrect.
--- tools/testing/selftests/bpf/prog_tests/attach_probe.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/attach_probe.c +4 -3
@@ -20,7 +20,7 @@ extern char NAME##_data[]; \ extern int NAME##_size;ssize_t get_base_addr () { -size_t start; +size_t start, offset;char buf[256 ];FILE *f;
@@ -28,10 +28,11 @@ ssize_t get_base_addr() {if (!f)return -errno; -while (fscanf (f,"%zx-%*x %s %*s\n" , &start, buf) ==2 ) { +while (fscanf (f,"%zx-%*x %s %zx %*[^\n]\n" , + &start, buf, &offset) ==3 ) {if (strcmp (buf,"r-xp" ) ==0 ) {fclose (f); -return start; +return start - offset; } }
Greg Kroah-Hartman
maintainerPATCH 168/367 samples/bpf: Xdp_redirect_cpu fix missing tracepoint attach
In reply to Greg Kroah-HartmanFrom: Jesper Dangaard Brouer <[email protected]>
commit f9e6bfdbaf0cf304d72c70a05d81acac01a04f48 upstream.
When sample xdp_redirect_cpu was converted to use libbpf, the tracepoints used by this sample were not getting attached automatically like with bpf_load.c. The BPF-maps was still getting loaded, thus nobody notice that the tracepoints were not updating these maps.
This fix doesn't use the new skeleton code, as this bug was introduced in v5.1 and stable might want to backport this. E.g. Red Hat QA uses this sample as part of their testing.
--- samples/bpf/xdp_redirect_cpu_user.c | 59 +++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-)
samples/bpf/xdp_redirect_cpu_user.c +55 -4
@@ -16,6 +16,10 @@ static const char *__doc__ =#include <getopt.h> #include <net/if.h> #include <time.h> +#include <linux/limits.h> + +#define __must_check +#include <linux/err.h> #include <arpa/inet.h> #include <linux/if_link.h>
@@ -46,6 +50,10 @@ static int cpus_count_map_fd;static int cpus_iterator_map_fd;static int exception_cnt_map_fd; +#define NUM_TP 5 +struct bpf_link *tp_links[NUM_TP ] = {0 }; +static int tp_cnt =0 ; +/* Exit return codes */ #define EXIT_OK 0#define EXIT_FAIL 1
@@ -88,6 +96,10 @@ static void int_exit(int sig)printf ("program on interface changed, not removing\n" ); } } +/* Detach tracepoints */ +while (tp_cnt) +bpf_link__destroy (tp_links[--tp_cnt]); +exit (EXIT_OK ); }
@@ -588,23 +600,61 @@ static void stats_poll(int interval, boofree_stats_record (prev); } +static struct bpf_link *attach_tp (struct bpf_object *obj, +const char *tp_category, +const char * tp_name) +{ +struct bpf_program *prog; +struct bpf_link *link; +char sec_name[PATH_MAX ]; +int len; + + len =snprintf (sec_name,PATH_MAX ,"tracepoint/%s/%s" , + tp_category, tp_name); +if (len <0 ) +exit (EXIT_FAIL ); + + prog =bpf_object__find_program_by_title (obj, sec_name); +if (!prog) { +fprintf (stderr,"ERR: finding progsec: %s\n" , sec_name); +exit (EXIT_FAIL_BPF ); + } + + link =bpf_program__attach_tracepoint (prog, tp_category, tp_name); +if (IS_ERR (link)) +exit (EXIT_FAIL_BPF ); + +return link; +} + +static void init_tracepoints (struct bpf_object *obj) { + tp_links[tp_cnt++] =attach_tp (obj,"xdp" ,"xdp_redirect_err" ); + tp_links[tp_cnt++] =attach_tp (obj,"xdp" ,"xdp_redirect_map_err" ); + tp_links[tp_cnt++] =attach_tp (obj,"xdp" ,"xdp_exception" ); + tp_links[tp_cnt++] =attach_tp (obj,"xdp" ,"xdp_cpumap_enqueue" ); + tp_links[tp_cnt++] =attach_tp (obj,"xdp" ,"xdp_cpumap_kthread" ); +} +static int init_map_fds (struct bpf_object *obj) { - cpu_map_fd =bpf_object__find_map_fd_by_name (obj,"cpu_map" ); - rx_cnt_map_fd =bpf_object__find_map_fd_by_name (obj,"rx_cnt" ); +/* Maps updated by tracepoints */ redirect_err_cnt_map_fd =bpf_object__find_map_fd_by_name (obj,"redirect_err_cnt" ); + exception_cnt_map_fd = +bpf_object__find_map_fd_by_name (obj,"exception_cnt" ); cpumap_enqueue_cnt_map_fd =bpf_object__find_map_fd_by_name (obj,"cpumap_enqueue_cnt" ); cpumap_kthread_cnt_map_fd =bpf_object__find_map_fd_by_name (obj,"cpumap_kthread_cnt" ); + +/* Maps used by XDP */ + rx_cnt_map_fd =bpf_object__find_map_fd_by_name (obj,"rx_cnt" ); + cpu_map_fd =bpf_object__find_map_fd_by_name (obj,"cpu_map" ); cpus_available_map_fd =bpf_object__find_map_fd_by_name (obj,"cpus_available" ); cpus_count_map_fd =bpf_object__find_map_fd_by_name (obj,"cpus_count" ); cpus_iterator_map_fd =bpf_object__find_map_fd_by_name (obj,"cpus_iterator" ); - exception_cnt_map_fd = -bpf_object__find_map_fd_by_name (obj,"exception_cnt" ); if (cpu_map_fd < 0 || rx_cnt_map_fd < 0 || redirect_err_cnt_map_fd < 0 || cpumap_enqueue_cnt_map_fd < 0 ||
@@ -662,6 +712,7 @@ int main(int argc, char **argv) strerror(errno));return EXIT_FAIL ; } +init_tracepoints (obj);if (init_map_fds (obj) <0 ) {fprintf (stderr,"bpf_object__find_map_fd_by_name failed\n" );return EXIT_FAIL ;
Greg Kroah-Hartman
maintainerPATCH 123/367 erofs: fix out-of-bound read for shifted uncompressed block
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
commit 4d2024370d877f9ac8b98694bcff666da6a5d333 upstream.
rq->out[1] should be valid before accessing. Otherwise, in very rare cases, out-of-bound dirty onstack rq->out[1] can equal to *in and lead to unintended memmove behavior.
--- fs/erofs/decompressor.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
fs/erofs/decompressor.c +10 -12
@@ -306,24 +306,22 @@ static int z_erofs_shifted_transform(con } src =kmap_atomic (*rq->in); -if (!rq->out[0 ]) { - dst =NULL ; - }else { +if (rq->out[0 ]) { dst =kmap_atomic (rq->out[0 ]);memcpy (dst + rq->pageofs_out, src, righthalf); +kunmap_atomic (dst); } -if (rq->out[1 ] == *rq->in) { -memmove (src, src + righthalf, rq->pageofs_out); - }else if (nrpages_out ==2 ) { -if (dst) -kunmap_atomic (dst); +if (nrpages_out ==2 ) {DBG_BUGON (!rq->out[1 ]); - dst =kmap_atomic (rq->out[1 ]); -memcpy (dst, src + righthalf, rq->pageofs_out); +if (rq->out[1 ] == *rq->in) { +memmove (src, src + righthalf, rq->pageofs_out); + }else { + dst =kmap_atomic (rq->out[1 ]); +memcpy (dst, src + righthalf, rq->pageofs_out); +kunmap_atomic (dst); + } } -if (dst) -kunmap_atomic (dst);kunmap_atomic (src);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 122/367 scripts/find-unused-docs: Fix massive false positives
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
commit 1630146db2111412e7524d05d812ff8f2c75977e upstream.
scripts/find-unused-docs.sh invokes scripts/kernel-doc to find out if a source file contains kerneldoc or not.
However, as it passes the no longer supported "-text" option to scripts/kernel-doc, the latter prints out its help text, causing all files to be considered containing kerneldoc.
Get rid of these false positives by removing the no longer supported "-text" option from the scripts/kernel-doc invocation.
--- scripts/find-unused-docs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/find-unused-docs.sh +1 -1
@@ -54,7 +54,7 @@ for file in `find $1 -name '*.c'`; do if [[ ${FILES_INCLUDED[$file]+_} ]]; then continue; fi - str=$(scripts/kernel-doc -text -export "$file" 2>/dev/null) + str=$(scripts/kernel-doc -export "$file" 2>/dev/null) if [[ -n "$str" ]]; then echo "$file" fi
Greg Kroah-Hartman
maintainerPATCH 156/367 btrfs: Handle another split brain scenario with metadata uuid feature
In reply to Greg Kroah-HartmanFrom: Nikolay Borisov <[email protected]>
commit 05840710149c7d1a78ea85a2db5723f706e97d8f upstream.
There is one more cases which isn't handled by the original metadata uuid work. Namely, when a filesystem has METADATA_UUID incompat bit and the user decides to change the FSID to the original one e.g. have metadata_uuid and fsid match. In case of power failure while this operation is in progress we could end up in a situation where some of the disks have the incompat bit removed and the other half have both METADATA_UUID_INCOMPAT and FSID_CHANGING_IN_PROGRESS flags.
This patch handles the case where a disk that has successfully changed its FSID such that it equals METADATA_UUID is scanned first. Subsequently when a disk with both METADATA_UUID_INCOMPAT/FSID_CHANGING_IN_PROGRESS flags is scanned find_fsid_changed won't be able to find an appropriate btrfs_fs_devices. This is done by extending find_fsid_changed to correctly find btrfs_fs_devices whose metadata_uuid/fsid are the same and they match the metadata_uuid of the currently scanned device.
--- fs/btrfs/volumes.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
fs/btrfs/volumes.c +14 -3
@@ -697,17 +697,28 @@ static struct btrfs_fs_devices *find_fsi/* * Handles the case where scanned device is part of an fs that had * multiple successful changes of FSID but curently device didn't -* observe it. Meaning our fsid will be different than theirs. +* observe it. Meaning our fsid will be different than theirs. We need +* to handle two subcases : +* 1 - The fs still continues to have different METADATA/FSID uuids. +* 2 - The fs is switched back to its original FSID (METADATA/FSID +* are equal). */ list_for_each_entry (fs_devices, &fs_uuids, fs_list) { +/* Changed UUIDs */ if (memcmp (fs_devices->metadata_uuid, fs_devices->fsid,BTRFS_FSID_SIZE ) !=0 &&memcmp (fs_devices->metadata_uuid, disk_super->metadata_uuid,BTRFS_FSID_SIZE ) ==0 &&memcmp (fs_devices->fsid, disk_super->fsid, -BTRFS_FSID_SIZE ) !=0 ) { +BTRFS_FSID_SIZE ) !=0 ) +return fs_devices; + +/* Unchanged UUIDs */ +if (memcmp (fs_devices->metadata_uuid, fs_devices->fsid, +BTRFS_FSID_SIZE ) ==0 && +memcmp (fs_devices->fsid, disk_super->metadata_uuid, +BTRFS_FSID_SIZE ) ==0 )return fs_devices; - } }return NULL ;