5.15.121-rc1 review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 443/532 nvme-pci: fix DMA direction of unmapping integrity data
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit b8f6446b6853768cb99e7c201bddce69ca60c15e ]
DMA direction should be taken in dma_unmap_page() for unmapping integrity data.
Fix this DMA direction, and reported in Guangwu's test.
--- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/pci.c +1 -1
@@ -965,7 +965,7 @@ static void nvme_pci_complete_rq(struct request *req)struct nvme_iod *iod =blk_mq_rq_to_pdu (req);dma_unmap_page (dev->dev, iod->meta_dma, -rq_integrity_vec (req)->bv_len,rq_data_dir (req)); +rq_integrity_vec (req)->bv_len,rq_dma_dir (req)); }if (blk_rq_nr_phys_segments (req))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 444/532 fs/ntfs3: Check fields while reading
In reply to Greg Kroah-HartmanFrom: Konstantin Komarov <[email protected]>
commit 0e8235d28f3a0e9eda9f02ff67ee566d5f42b66b upstream.
Added new functions index_hdr_check and index_buf_check. Now we check all stuff for correctness while reading from disk. Also fixed bug with stale nfs data.
--- fs/ntfs3/index.c | 84 ++++++++++++++++++++++++++++++++++++---- fs/ntfs3/inode.c | 18 ++++---- fs/ntfs3/ntfs_fs.h | 4 - fs/ntfs3/run.c | 7 ++- fs/ntfs3/xattr.c | 109 ++++++++++++++++++++++++++++++++++------------------- 5 files changed, 164 insertions(+), 58 deletions(-)
fs/ntfs3/index.c +76 -8
@@ -605,11 +605,58 @@ static const struct NTFS_DE *hdr_insert_return e; } +/* +* index_hdr_check +* +* return true if INDEX_HDR is valid +*/ +static bool index_hdr_check (const struct INDEX_HDR *hdr,u32 bytes) +{ +u32 end =le32_to_cpu (hdr->used); +u32 tot =le32_to_cpu (hdr->total); +u32 off =le32_to_cpu (hdr->de_off); + +if (!IS_ALIGNED (off,8 ) || tot > bytes || end > tot || + off +sizeof (struct NTFS_DE ) > end) { +/* incorrect index buffer. */ +return false; + } + +return true; +} + +/* +* index_buf_check +* +* return true if INDEX_BUFFER seems is valid +*/ +static bool index_buf_check (const struct INDEX_BUFFER *ib,u32 bytes, +const CLST *vbn) +{ +const struct NTFS_RECORD_HEADER *rhdr = &ib->rhdr; +u16 fo =le16_to_cpu (rhdr->fix_off); +u16 fn =le16_to_cpu (rhdr->fix_num); + +if (bytes <= offsetof(struct INDEX_BUFFER , ihdr) || + rhdr->sign !=NTFS_INDX_SIGNATURE || + fo <sizeof (struct INDEX_BUFFER ) +/* Check index buffer vbn. */ + || (vbn && *vbn !=le64_to_cpu (ib->vbn)) || (fo %sizeof (short )) || + fo + fn *sizeof (short ) >= bytes || + fn != ((bytes >>SECTOR_SHIFT ) +1 )) { +/* incorrect index buffer. */ +return false; + } + +return index_hdr_check (&ib->ihdr, + bytes - offsetof(struct INDEX_BUFFER , ihdr)); +} +void fnd_clear (struct ntfs_fnd *fnd) {int i; -for (i =0 ; i < fnd->level; i++) { +for (i = fnd->level -1 ; i >=0 ; i--) {struct indx_node *n = fnd->nodes[i];if (!n)
@@ -828,9 +875,16 @@ int indx_init(struct ntfs_index *indx, su32 t32;const struct INDEX_ROOT *root =resident_data (attr); + t32 =le32_to_cpu (attr->res.data_size); +if (t32 <= offsetof(struct INDEX_ROOT , ihdr) || + !index_hdr_check (&root->ihdr, + t32 - offsetof(struct INDEX_ROOT , ihdr))) { + goto out; + } +/* Check root fields. */ if (!root->index_block_clst) -return -EINVAL ; + goto out; indx->type = type; indx->idx2vbn_bits =__ffs (root->index_block_clst);
@@ -842,19 +896,19 @@ int indx_init(struct ntfs_index *indx, sif (t32 < sbi->cluster_size) {/* Index record is smaller than a cluster, use 512 blocks. */ if (t32 != root->index_block_clst *SECTOR_SIZE ) -return -EINVAL ; + goto out;/* Check alignment to a cluster. */ if ((sbi->cluster_size >>SECTOR_SHIFT ) & (root->index_block_clst -1 )) { -return -EINVAL ; + goto out; } indx->vbn2vbo_bits =SECTOR_SHIFT ; }else {/* Index record must be a multiple of cluster size. */ if (t32 != root->index_block_clst << sbi->cluster_bits) -return -EINVAL ; + goto out; indx->vbn2vbo_bits = sbi->cluster_bits; }
@@ -862,7 +916,14 @@ int indx_init(struct ntfs_index *indx, sinit_rwsem (&indx->run_lock); indx->cmp =get_cmp_func (root); -return indx->cmp ?0 : -EINVAL ; +if (!indx->cmp) + goto out; + +return 0 ; + +out: +ntfs_set_state (sbi,NTFS_DIRTY_DIRTY ); +return -EINVAL ; } static struct indx_node *indx_new(struct ntfs_index *indx,
@@ -1029,6 +1090,13 @@ int indx_read(struct ntfs_index *indx, s goto out; ok: +if (!index_buf_check (ib, bytes, &vbn)) { +ntfs_inode_err (&ni->vfs_inode,"directory corrupted" ); +ntfs_set_state (ni->mi.sbi,NTFS_DIRTY_ERROR ); + err = -EINVAL ; + goto out; + } +if (err == -E_NTFS_FIXUP ) {ntfs_write_bh (ni->mi.sbi, &ib->rhdr, &in->nb,0 ); err =0 ;
@@ -1623,9 +1691,9 @@ static int indx_insert_into_root(structif (err) {/* Restore root. */ -if (mi_resize_attr (mi, attr, -ds_root)) +if (mi_resize_attr (mi, attr, -ds_root)) {memcpy (attr, a_root, asize); -else { + }else {/* Bug? */ ntfs_set_state (sbi,NTFS_DIRTY_ERROR ); }
fs/ntfs3/inode.c +10 -8
@@ -81,7 +81,7 @@ static struct inode *ntfs_read_mft(struc le16_to_cpu(ref->seq), le16_to_cpu(rec->seq)); goto out; }else if (!is_rec_inuse (rec)) { - err = -EINVAL ; + err = -ESTALE ;ntfs_err (sb,"Inode r=%x is not in use!" , (u32 )ino); goto out; }
@@ -92,8 +92,10 @@ static struct inode *ntfs_read_mft(struc goto out; } -if (!is_rec_base (rec)) - goto Ok; +if (!is_rec_base (rec)) { + err = -EINVAL ; + goto out; + }/* Record should contain $I30 root. */ is_dir = rec->flags &RECORD_FLAG_DIR ;
@@ -472,7 +474,6 @@ end_enum: inode->i_flags |=S_NOSEC ; } -Ok:if (ino ==MFT_REC_MFT && !sb->s_root) sbi->mft.ni =NULL ;
@@ -526,6 +527,9 @@ struct inode *ntfs_iget5(struct super_blmake_bad_inode (inode); } +if (IS_ERR (inode) && name) +ntfs_set_state (sb->s_fs_info,NTFS_DIRTY_ERROR ); +return inode; }
@@ -1647,10 +1651,8 @@ out6:ntfs_remove_reparse (sbi,IO_REPARSE_TAG_SYMLINK , &new_de->ref); out5: -if (S_ISDIR (mode) ||run_is_empty (&ni->file.run)) - goto out4; - -run_deallocate (sbi, &ni->file.run, false); +if (!S_ISDIR (mode)) +run_deallocate (sbi, &ni->file.run, false); out4:clear_rec_inuse (rec);
fs/ntfs3/ntfs_fs.h +2 -2
@@ -789,12 +789,12 @@ int run_pack(const struct runs_tree *run u32 run_buf_size, CLST *packed_vcns);int run_unpack (struct runs_tree *run,struct ntfs_sb_info *sbi,CLST ino,CLST svcn,CLST evcn,CLST vcn,const u8 *run_buf, -u32 run_buf_size); +int run_buf_size);#ifdef NTFS3_CHECK_FREE_CLST int run_unpack_ex (struct runs_tree *run,struct ntfs_sb_info *sbi,CLST ino,CLST svcn,CLST evcn,CLST vcn,const u8 *run_buf, -u32 run_buf_size); +int run_buf_size);#else #define run_unpack_ex run_unpack#endif
fs/ntfs3/run.c +5 -2
@@ -872,12 +872,15 @@ error:*/ int run_unpack (struct runs_tree *run,struct ntfs_sb_info *sbi,CLST ino,CLST svcn,CLST evcn,CLST vcn,const u8 *run_buf, -u32 run_buf_size) +int run_buf_size) {u64 prev_lcn, vcn64, lcn, next_vcn;const u8 *run_last, *run_0;bool is_mft = ino ==MFT_REC_MFT ; +if (run_buf_size <0 ) +return -EINVAL ; +/* Check for empty. */ if (evcn +1 == svcn)return 0 ;
@@ -999,7 +1002,7 @@ int run_unpack(struct runs_tree *run, st*/ int run_unpack_ex (struct runs_tree *run,struct ntfs_sb_info *sbi,CLST ino,CLST svcn,CLST evcn,CLST vcn,const u8 *run_buf, -u32 run_buf_size) +int run_buf_size) {int ret, err;CLST next_vcn, lcn, len;
fs/ntfs3/xattr.c +71 -38
204 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 445/532 f2fs: fix to avoid NULL pointer dereference f2fs_write_end_io()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
commit d8189834d4348ae608083e1f1f53792cfcc2a9bc upstream.
butt3rflyh4ck reports a bug as below:
When a thread always calls F2FS_IOC_RESIZE_FS to resize fs, if resize fs is failed, f2fs kernel thread would invoke callback function to update f2fs io info, it would call f2fs_write_end_io and may trigger null-ptr-deref in NODE_MAPPING.
general protection fault, probably for non-canonical address KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037] RIP: 0010:NODE_MAPPING fs/f2fs/f2fs.h:1972 [inline] RIP: 0010:f2fs_write_end_io+0x727/0x1050 fs/f2fs/data.c:370 <TASK> bio_endio+0x5af/0x6c0 block/bio.c:1608 req_bio_endio block/blk-mq.c:761 [inline] blk_update_request+0x5cc/0x1690 block/blk-mq.c:906 blk_mq_end_request+0x59/0x4c0 block/blk-mq.c:1023 lo_complete_rq+0x1c6/0x280 drivers/block/loop.c:370 blk_complete_reqs+0xad/0xe0 block/blk-mq.c:1101 __do_softirq+0x1d4/0x8ef kernel/softirq.c:571 run_ksoftirqd kernel/softirq.c:939 [inline] run_ksoftirqd+0x31/0x60 kernel/softirq.c:931 smpboot_thread_fn+0x659/0x9e0 kernel/smpboot.c:164 kthread+0x33e/0x440 kernel/kthread.c:379 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
The root cause is below race case can cause leaving dirty metadata in f2fs after filesystem is remount as ro:
Thread A Thread B
- f2fs_ioc_resize_fs
- f2fs_readonly --- return false
- f2fs_resize_fs
- f2fs_remount
- write_checkpoint
- set f2fs as ro
- free_segment_range
- update meta_inode's data
Then, if f2fs_put_super() fails to write_checkpoint due to readonly status, and meta_inode's dirty data will be writebacked after node_inode is put, finally, f2fs_write_end_io will access NULL pointer on sbi->node_inode.
Thread A IRQ context
- f2fs_put_super
- write_checkpoint fails
- iput(node_inode)
- node_inode = NULL
- iput(meta_inode)
- write_inode_now
- f2fs_write_meta_page
- f2fs_write_end_io
- NODE_MAPPING(sbi)
: access NULL pointer on node_inode
--- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 2 +- fs/f2fs/gc.c | 21 ++++++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-)
fs/f2fs/f2fs.h +1 -1
@@ -3660,7 +3660,7 @@ block_t f2fs_start_bidx_of_node(unsignedint f2fs_gc (struct f2fs_sb_info *sbi,bool sync,bool background,bool force,unsigned int segno);void f2fs_build_gc_manager (struct f2fs_sb_info *sbi); -int f2fs_resize_fs (struct f2fs_sb_info *sbi,__u64 block_count); +int f2fs_resize_fs (struct file *filp,__u64 block_count);int __init f2fs_create_garbage_collection_cache (void );void f2fs_destroy_garbage_collection_cache (void );
fs/f2fs/file.c +1 -1
@@ -3251,7 +3251,7 @@ static int f2fs_ioc_resize_fs(struct fil sizeof(block_count)))return -EFAULT ; -return f2fs_resize_fs (sbi, block_count); +return f2fs_resize_fs (filp, block_count); }static int f2fs_ioc_enable_verity (struct file *filp,unsigned long arg)
fs/f2fs/gc.c +18 -3
@@ -1992,8 +1992,9 @@ static void update_fs_metadata(struct f2 } } -int f2fs_resize_fs (struct f2fs_sb_info *sbi,__u64 block_count) +int f2fs_resize_fs (struct file *filp,__u64 block_count) { +struct f2fs_sb_info *sbi =F2FS_I_SB (file_inode (filp));__u64 old_block_count, shrunk_blocks;struct cp_control cpc = {CP_RESIZE ,0 ,0 ,0 };unsigned int secs;
@@ -2031,12 +2032,18 @@ int f2fs_resize_fs(struct f2fs_sb_info *return -EINVAL ; } + err =mnt_want_write_file (filp); +if (err) +return err; + shrunk_blocks = old_block_count - block_count; secs =div_u64 (shrunk_blocks,BLKS_PER_SEC (sbi));/* stop other GC */ -if (!down_write_trylock (&sbi->gc_lock)) -return -EAGAIN ; +if (!down_write_trylock (&sbi->gc_lock)) { + err = -EAGAIN ; + goto out_drop_write; + }/* stop CP to protect MAIN_SEC in free_segment_range */ f2fs_lock_op (sbi);
@@ -2056,10 +2063,18 @@ int f2fs_resize_fs(struct f2fs_sb_info * out_unlock:f2fs_unlock_op (sbi);up_write (&sbi->gc_lock); +out_drop_write: +mnt_drop_write_file (filp);if (err)return err;freeze_super (sbi->sb); + +if (f2fs_readonly (sbi->sb)) { +thaw_super (sbi->sb); +return -EROFS ; + } +down_write (&sbi->gc_lock);down_write (&sbi->cp_global_sem);
Greg Kroah-Hartman
maintainerPATCH 446/532 pinctrl: amd: Fix mistake in handling clearing pins at startup
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit a855724dc08b8cb0c13ab1e065a4922f1e5a7552 upstream.
commit 4e5a04be88fe ("pinctrl: amd: disable and mask interrupts on probe") had a mistake in loop iteration 63 that it would clear offset 0xFC instead of 0x100. Offset 0xFC is actually WAKE_INT_MASTER_REG. This was clearing bits 13 and 15 from the register which significantly changed the expected handling for some platforms for GPIO0.
--- drivers/pinctrl/pinctrl-amd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/pinctrl-amd.c +2 -2
@@ -883,9 +883,9 @@ static void amd_gpio_irq_init(struct amdraw_spin_lock_irqsave (&gpio_dev->lock, flags); - pin_reg =readl (gpio_dev->base + i *4 ); + pin_reg =readl (gpio_dev->base + pin *4 ); pin_reg &= ~mask; -writel (pin_reg, gpio_dev->base + i *4 ); +writel (pin_reg, gpio_dev->base + pin *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); }
Greg Kroah-Hartman
maintainerPATCH 447/532 pinctrl: amd: Detect internal GPIO0 debounce handling
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit 968ab9261627fa305307e3935ca1a32fcddd36cb upstream.
commit 4e5a04be88fe ("pinctrl: amd: disable and mask interrupts on probe") had a mistake in loop iteration 63 that it would clear offset 0xFC instead of 0x100. Offset 0xFC is actually WAKE_INT_MASTER_REG. This was clearing bits 13 and 15 from the register which significantly changed the expected handling for some platforms for GPIO0.
commit b26cd9325be4 ("pinctrl: amd: Disable and mask interrupts on resume") actually fixed this bug, but lead to regressions on Lenovo Z13 and some other systems. This is because there was no handling in the driver for bit 15 debounce behavior.
Quoting a public BKDG:
``` EnWinBlueBtn. Read-write. Reset: 0. 0=GPIO0 detect debounced power button; Power button override is 4 seconds. 1=GPIO0 detect debounced power button in S3/S5/S0i3, and detect "pressed less than 2 seconds" and "pressed 2~10 seconds" in S0; Power button override is 10 seconds ```
Cross referencing the same master register in Windows it's obvious that Windows doesn't use debounce values in this configuration. So align the Linux driver to do this as well. This fixes wake on lid when WAKE_INT_MASTER_REG is properly programmed.
--- drivers/pinctrl/pinctrl-amd.c | 7 +++++++ drivers/pinctrl/pinctrl-amd.h | 1 + 2 files changed, 8 insertions(+)
drivers/pinctrl/pinctrl-amd.c +7 -0
@@ -126,6 +126,12 @@ static int amd_gpio_set_debounce(structstruct amd_gpio *gpio_dev =gpiochip_get_data (gc);raw_spin_lock_irqsave (&gpio_dev->lock, flags); + +/* Use special handling for Pin0 debounce */ + pin_reg =readl (gpio_dev->base +WAKE_INT_MASTER_REG ); +if (pin_reg &INTERNAL_GPIO0_DEBOUNCE ) + debounce =0 ; + pin_reg =readl (gpio_dev->base + offset *4 );if (debounce) {
@@ -223,6 +229,7 @@ static void amd_gpio_dbg_show(struct seqchar debounce_value[40 ];char *debounce_enable; +seq_printf (s,"WAKE_INT_MASTER_REG: 0x%08x\n" ,readl (gpio_dev->base +WAKE_INT_MASTER_REG ));for (bank =0 ; bank < gpio_dev->hwbank_num; bank++) {seq_printf (s,"GPIO bank%d\t" , bank);
drivers/pinctrl/pinctrl-amd.h +1 -0
@@ -17,6 +17,7 @@#define AMD_GPIO_PINS_BANK3 32#define WAKE_INT_MASTER_REG 0xfc +#define INTERNAL_GPIO0_DEBOUNCE (1 << 15)#define EOI_MASK (1 << 29)#define WAKE_INT_STATUS_REG0 0x2f8
Greg Kroah-Hartman
maintainerPATCH 448/532 pinctrl: amd: Detect and mask spurious interrupts
In reply to Greg Kroah-HartmanFrom: Kornel Dulęba <[email protected]>
commit 0cf9e48ff22e15f3f0882991f33d23ccc5ae1d01 upstream.
Leverage gpiochip_line_is_irq to check whether a pin has an irq associated with it. The previous check ("irq == 0") didn't make much sense. The irq variable refers to the pinctrl irq, and has nothing do to with an individual pin.
On some systems, during suspend/resume cycle, the firmware leaves an interrupt enabled on a pin that is not used by the kernel. Without this patch that caused an interrupt storm.
--- drivers/pinctrl/pinctrl-amd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pinctrl/pinctrl-amd.c +6 -6
@@ -653,21 +653,21 @@ static bool do_amd_gpio_irq_handler(int* We must read the pin register again, in case the * value was changed while executing * generic_handle_domain_irq() above. -* If we didn't find a mapping for the interrupt, -* disable it in order to avoid a system hang caused -* by an interrupt storm. +* If the line is not an irq, disable it in order to +* avoid a system hang caused by an interrupt storm. */ raw_spin_lock_irqsave (&gpio_dev->lock, flags); regval =readl (regs + i); -if (irq ==0 ) { - regval &= ~BIT (INTERRUPT_ENABLE_OFF ); +if (!gpiochip_line_is_irq (gc, irqnr + i)) { + regval &= ~BIT (INTERRUPT_MASK_OFF );dev_dbg (&gpio_dev->pdev->dev,"Disabling spurious GPIO IRQ %d\n" , irqnr + i); + }else { + ret = true; }writel (regval, regs + i);raw_spin_unlock_irqrestore (&gpio_dev->lock, flags); - ret = true; } }/* did not cause wake on resume context for shared IRQ */
Greg Kroah-Hartman
maintainerPATCH 449/532 pinctrl: amd: Only use special debounce behavior for GPIO 0
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit 0d5ace1a07f7e846d0f6d972af60d05515599d0b upstream.
It's uncommon to use debounce on any other pin, but technically we should only set debounce to 0 when working off GPIO0.
--- drivers/pinctrl/pinctrl-amd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/pinctrl/pinctrl-amd.c +5 -3
@@ -128,9 +128,11 @@ static int amd_gpio_set_debounce(structraw_spin_lock_irqsave (&gpio_dev->lock, flags);/* Use special handling for Pin0 debounce */ - pin_reg =readl (gpio_dev->base +WAKE_INT_MASTER_REG ); -if (pin_reg &INTERNAL_GPIO0_DEBOUNCE ) - debounce =0 ; +if (offset ==0 ) { + pin_reg =readl (gpio_dev->base +WAKE_INT_MASTER_REG ); +if (pin_reg &INTERNAL_GPIO0_DEBOUNCE ) + debounce =0 ; + } pin_reg =readl (gpio_dev->base + offset *4 );
Greg Kroah-Hartman
maintainerPATCH 450/532 tpm: tpm_vtpm_proxy: fix a race condition in /dev/vtpmx creation
In reply to Greg Kroah-HartmanFrom: Jarkko Sakkinen <[email protected]>
commit f4032d615f90970d6c3ac1d9c0bce3351eb4445c upstream.
/dev/vtpmx is made visible before 'workqueue' is initialized, which can lead to a memory corruption in the worst case scenario.
Address this by initializing 'workqueue' as the very first step of the driver initialization.
--- drivers/char/tpm/tpm_vtpm_proxy.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-)
drivers/char/tpm/tpm_vtpm_proxy.c +7 -23
@@ -683,37 +683,21 @@ static struct miscdevice vtpmx_miscdev = .fops = &vtpmx_fops, }; -static int vtpmx_init (void ) -{ -return misc_register (&vtpmx_miscdev); -} - -static void vtpmx_cleanup (void ) -{ -misc_deregister (&vtpmx_miscdev); -} -static int __init vtpm_module_init (void ) {int rc; - rc =vtpmx_init (); -if (rc) { -pr_err ("couldn't create vtpmx device\n" ); -return rc; - } - workqueue =create_workqueue ("tpm-vtpm" );if (!workqueue) {pr_err ("couldn't create workqueue\n" ); - rc = -ENOMEM ; - goto err_vtpmx_cleanup; +return -ENOMEM ; } -return 0 ; - -err_vtpmx_cleanup: -vtpmx_cleanup (); + rc =misc_register (&vtpmx_miscdev); +if (rc) { +pr_err ("couldn't create vtpmx device\n" ); +destroy_workqueue (workqueue); + }return rc; }
@@ -721,7 +705,7 @@ err_vtpmx_cleanup: static void __exit vtpm_module_exit(void) {destroy_workqueue (workqueue); -vtpmx_cleanup (); +misc_deregister (&vtpmx_miscdev); }module_init (vtpm_module_init);
Greg Kroah-Hartman
maintainerPATCH 451/532 mtd: rawnand: meson: fix unaligned DMA buffers handling
In reply to Greg Kroah-HartmanFrom: Arseniy Krasnov <[email protected]>
commit 98480a181a08ceeede417e5b28f6d0429d8ae156 upstream.
Meson NAND controller requires 8 bytes alignment for DMA addresses, otherwise it "aligns" passed address by itself thus accessing invalid location in the provided buffer. This patch makes unaligned buffers to be reallocated to become valid.
--- drivers/mtd/nand/raw/meson_nand.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mtd/nand/raw/meson_nand.c +4 -0
@@ -72,6 +72,7 @@#define GENCMDIADDRH (aih, addr) ((aih) | (((addr) >> 16) & 0xffff))#define DMA_DIR (dir) ((dir) ? NFC_CMD_N2M : NFC_CMD_M2N) +#define DMA_ADDR_ALIGN 8#define ECC_CHECK_RETURN_FF (-1)
@@ -838,6 +839,9 @@ static int meson_nfc_read_oob(struct nanstatic bool meson_nfc_is_buffer_dma_safe (const void *buffer) { +if ((uintptr_t )buffer %DMA_ADDR_ALIGN ) +return false; +if (virt_addr_valid (buffer) && (!object_is_on_stack (buffer)))return true;return false;
Greg Kroah-Hartman
maintainerPATCH 452/532 net: bcmgenet: Ensure MDIO unregistration has clocks enabled
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
commit 1b5ea7ffb7a3bdfffb4b7f40ce0d20a3372ee405 upstream.
With support for Ethernet PHY LEDs having been added, while unregistering a MDIO bus and its child device liks PHYs there may be "late" accesses to the MDIO bus. One typical use case is setting the PHY LEDs brightness to OFF for instance.
We need to ensure that the MDIO bus controller remains entirely functional since it runs off the main GENET adapter clock.
--- drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmmii.c +2 -0
@@ -627,5 +627,7 @@ void bcmgenet_mii_exit(struct net_deviceif (of_phy_is_fixed_link (dn))of_phy_deregister_fixed_link (dn);of_node_put (priv->phy_dn); +clk_prepare_enable (priv->clk);platform_device_unregister (priv->mii_pdev); +clk_disable_unprepare (priv->clk); }
Greg Kroah-Hartman
maintainerPATCH 453/532 mm/damon/ops-common: atomically test and clear young on ptes and pmds
In reply to Greg Kroah-HartmanFrom: Ryan Roberts <[email protected]>
commit c11d34fa139e4b0fb4249a30f37b178353533fa1 upstream.
It is racy to non-atomically read a pte, then clear the young bit, then write it back as this could discard dirty information. Further, it is bad practice to directly set a pte entry within a table. Instead clearing young must go through the arch-provided helper, ptep_test_and_clear_young() to ensure it is modified atomically and to give the arch code visibility and allow it to check (and potentially modify) the operation.
--- mm/damon/vaddr.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
mm/damon/vaddr.c +8 -12
@@ -393,7 +393,7 @@ static struct page *damon_get_page(unsigreturn page; } -static void damon_ptep_mkold (pte_t *pte,struct mm_struct *mm, +static void damon_ptep_mkold (pte_t *pte,struct vm_area_struct *vma,unsigned long addr) {bool referenced = false;
@@ -402,13 +402,11 @@ static void damon_ptep_mkold(pte_t *pte,if (!page)return ; -if (pte_young (*pte)) { +if (ptep_test_and_clear_young (vma, addr, pte)) referenced = true; - *pte =pte_mkold (*pte); - }#ifdef CONFIG_MMU_NOTIFIER -if (mmu_notifier_clear_young (mm, addr, addr +PAGE_SIZE )) +if (mmu_notifier_clear_young (vma->vm_mm, addr, addr +PAGE_SIZE )) referenced = true;#endif /* CONFIG_MMU_NOTIFIER */
@@ -419,7 +417,7 @@ static void damon_ptep_mkold(pte_t *pte,put_page (page); } -static void damon_pmdp_mkold (pmd_t *pmd,struct mm_struct *mm, +static void damon_pmdp_mkold (pmd_t *pmd,struct vm_area_struct *vma,unsigned long addr) {#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -429,13 +427,11 @@ static void damon_pmdp_mkold(pmd_t *pmd,if (!page)return ; -if (pmd_young (*pmd)) { +if (pmdp_test_and_clear_young (vma, addr, pmd)) referenced = true; - *pmd =pmd_mkold (*pmd); - }#ifdef CONFIG_MMU_NOTIFIER -if (mmu_notifier_clear_young (mm, addr, +if (mmu_notifier_clear_young (vma->vm_mm, addr, addr + ((1UL ) <<HPAGE_PMD_SHIFT ))) referenced = true;#endif /* CONFIG_MMU_NOTIFIER */
@@ -462,7 +458,7 @@ static int damon_mkold_pmd_entry(pmd_t * }if (pmd_huge (*pmd)) { -damon_pmdp_mkold (pmd, walk->mm, addr); +damon_pmdp_mkold (pmd, walk->vma, addr);spin_unlock (ptl);return 0 ; }
@@ -474,7 +470,7 @@ static int damon_mkold_pmd_entry(pmd_t * pte =pte_offset_map_lock (walk->mm, pmd, addr, &ptl);if (!pte_present (*pte)) goto out; -damon_ptep_mkold (pte, walk->mm, addr); +damon_ptep_mkold (pte, walk->vma, addr); out:pte_unmap_unlock (pte, ptl);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 454/532 powerpc: Fail build if using recordmcount with binutils v2.37
In reply to Greg Kroah-HartmanFrom: Naveen N Rao <[email protected]>
commit 25ea739ea1d4d3de41acc4f4eb2d1a97eee0eb75 upstream.
binutils v2.37 drops unused section symbols, which prevents recordmcount from capturing mcount locations in sections that have no non-weak symbols. This results in a build failure with a message such as:
Cannot find symbol for section 12: .text.perf_callchain_kernel. kernel/events/callchain.o: failed
The change to binutils was reverted for v2.38, so this behavior is specific to binutils v2.37:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c09c8b42021180eee9495bd50d8b35e683d3901b
Objtool is able to cope with such sections, so this issue is specific to recordmcount.
Fail the build and print a warning if binutils v2.37 is detected and if we are using recordmcount.
--- arch/powerpc/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/powerpc/Makefile +8 -0
@@ -444,3 +444,11 @@ checkbin: echo -n '*** Please use a different binutils version.' ; \ false ; \ fi + @if test "x${CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT}" = "xy" -a \ + "x${CONFIG_LD_IS_BFD}" = "xy" -a \ + "${CONFIG_LD_VERSION}" = "23700" ; then \ + echo -n '*** binutils 2.37 drops unused section symbols, which recordmcount ' ; \ + echo 'is unable to handle.' ; \ + echo '*** Please use a different binutils version.' ; \ + false ; \ + fi
Greg Kroah-Hartman
maintainerPATCH 455/532 misc: fastrpc: Create fastrpc scalar with correct buffer count
In reply to Greg Kroah-HartmanFrom: Ekansh Gupta <[email protected]>
commit 0b4e32df3e09406b835d8230b9331273f2805058 upstream.
A process can spawn a PD on DSP with some attributes that can be associated with the PD during spawn and run. The invocation corresponding to the create request with attributes has total 4 buffers at the DSP side implementation. If this number is not correct, the invocation is expected to fail on DSP. Added change to use correct number of buffer count for creating fastrpc scalar.
Message-ID: <[email protected]>
--- drivers/misc/fastrpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/fastrpc.c +1 -1
@@ -1108,7 +1108,7 @@ static int fastrpc_init_create_process(s sc =FASTRPC_SCALARS (FASTRPC_RMID_INIT_CREATE ,4 ,0 );if (init.attrs) - sc =FASTRPC_SCALARS (FASTRPC_RMID_INIT_CREATE_ATTR ,6 ,0 ); + sc =FASTRPC_SCALARS (FASTRPC_RMID_INIT_CREATE_ATTR ,4 ,0 ); err =fastrpc_internal_invoke (fl, true,FASTRPC_INIT_HANDLE , sc, args);
Greg Kroah-Hartman
maintainerPATCH 456/532 powerpc/security: Fix Speculation_Store_Bypass reporting on Power10
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 5bcedc5931e7bd6928a2d8207078d4cb476b3b55 upstream.
Nageswara reported that /proc/self/status was showing "vulnerable" for the Speculation_Store_Bypass feature on Power10, eg:
$ grep Speculation_Store_Bypass: /proc/self/status Speculation_Store_Bypass: vulnerable
But at the same time the sysfs files, and lscpu, were showing "Not affected".
This turns out to simply be a bug in the reporting of the Speculation_Store_Bypass, aka. PR_SPEC_STORE_BYPASS, case.
When SEC_FTR_STF_BARRIER was added, so that firmware could communicate the vulnerability was not present, the code in ssb_prctl_get() was not updated to check the new flag.
So add the check for SEC_FTR_STF_BARRIER being disabled. Rather than adding the new check to the existing if block and expanding the comment to cover both cases, rewrite the three cases to be separate so they can be commented separately for clarity.
--- arch/powerpc/kernel/security.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
arch/powerpc/kernel/security.c +18 -17
@@ -363,26 +363,27 @@ ssize_t cpu_show_spec_store_bypass(strucstatic int ssb_prctl_get (struct task_struct *task) { +/* +* The STF_BARRIER feature is on by default, so if it's off that means +* firmware has explicitly said the CPU is not vulnerable via either +* the hypercall or device tree. +*/ +if (!security_ftr_enabled (SEC_FTR_STF_BARRIER )) +return PR_SPEC_NOT_AFFECTED ; + +/* +* If the system's CPU has no known barrier (see setup_stf_barrier()) +* then assume that the CPU is not vulnerable. +*/ if (stf_enabled_flush_types ==STF_BARRIER_NONE ) -/* -* We don't have an explicit signal from firmware that we're -* vulnerable or not, we only have certain CPU revisions that -* are known to be vulnerable. -* -* We assume that if we're on another CPU, where the barrier is -* NONE, then we are not vulnerable. -*/ return PR_SPEC_NOT_AFFECTED ; -else -/* -* If we do have a barrier type then we are vulnerable. The -* barrier is not a global or per-process mitigation, so the -* only value we can report here is PR_SPEC_ENABLE, which -* appears as "vulnerable" in /proc. -*/ -return PR_SPEC_ENABLE ; -return -EINVAL ; +/* +* Otherwise the CPU is vulnerable. The barrier is not a global or +* per-process mitigation, so the only value that can be reported here +* is PR_SPEC_ENABLE, which appears as "vulnerable" in /proc. +*/ +return PR_SPEC_ENABLE ; }int arch_prctl_spec_ctrl_get (struct task_struct *task,unsigned long which)
Greg Kroah-Hartman
maintainerPATCH 457/532 arm64: errata: Add detection for TRBE overwrite in FILL mode
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
commit b9d216fcef4298de76519e2baeed69ba482467bd upstream
Arm Neoverse-N2 and the Cortex-A710 cores are affected by a CPU erratum where the TRBE will overwrite the trace buffer in FILL mode. The TRBE doesn't stop (as expected in FILL mode) when it reaches the limit and wraps to the base to continue writing upto 3 cache lines. This will overwrite any trace that was written previously.
Add the Neoverse-N2 erratum(#2139208) and Cortex-A710 erratum (#2119858) to the detection logic.
This will be used by the TRBE driver in later patches to work around the issue. The detection has been kept with the core arm64 errata framework list to make sure :
- We don't duplicate the framework in TRBE driver
- The errata detection is advertised like the rest of the CPU errata.
Note that the Kconfig entries are not fully active until the TRBE driver implements the work around.
--- Documentation/arm64/silicon-errata.rst | 4 +++ arch/arm64/Kconfig | 41 +++++++++++++++++++++++++++++++++ arch/arm64/kernel/cpu_errata.c | 26 ++++++++++++++++++++ arch/arm64/tools/cpucaps | 1 4 files changed, 72 insertions(+)
Documentation/arm64/silicon-errata.rst +4 -0
@@ -102,12 +102,16 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A510 | #2457168 | ARM64_ERRATUM_2457168 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A710 | #2119858 | ARM64_ERRATUM_2119858 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Neoverse-N1 | #1188873,1418040| ARM64_ERRATUM_1418040 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Neoverse-N1 | #1349291 | N/A | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Neoverse-N1 | #1542419 | ARM64_ERRATUM_1542419 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Neoverse-N2 | #2139208 | ARM64_ERRATUM_2139208 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | MMU-500 | #841119,826419 | N/A | +----------------+-----------------+-----------------+-----------------------------+ +----------------+-----------------+-----------------+-----------------------------+
arch/arm64/Kconfig +41 -0
47 lines not on this page · raw message
arch/arm64/kernel/cpu_errata.c +26 -0
@@ -363,6 +363,18 @@ static struct midr_range broken_aarch32_ };#endif +#ifdef CONFIG_ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE +static const struct midr_range trbe_overwrite_fill_mode_cpus[] = { +#ifdef CONFIG_ARM64_ERRATUM_2139208 +MIDR_ALL_VERSIONS (MIDR_NEOVERSE_N2 ), +#endif +#ifdef CONFIG_ARM64_ERRATUM_2119858 +MIDR_ALL_VERSIONS (MIDR_CORTEX_A710 ), +#endif + {}, +}; +#endif /* CONFIG_ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE */ + const struct arm64_cpu_capabilities arm64_errata[] = {#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE {
@@ -564,6 +576,7 @@ const struct arm64_cpu_capabilities arm6 ERRATA_MIDR_ALL_VERSIONS(MIDR_NVIDIA_CARMEL), },#endif +#ifdef CONFIG_ARM64_ERRATUM_2457168 { .desc = "ARM erratum 2457168",
@@ -581,6 +594,19 @@ const struct arm64_cpu_capabilities arm6 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, },#endif +#ifdef CONFIG_ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE + { +/* +* The erratum work around is handled within the TRBE +* driver and can be applied per-cpu. So, we can allow +* a late CPU to come online with this erratum. +*/ + .desc = "ARM erratum 2119858 or 2139208", + .capability = ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE, + .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, + CAP_MIDR_RANGE_LIST(trbe_overwrite_fill_mode_cpus), + }, +#endif { } };
arch/arm64/tools/cpucaps +1 -0
@@ -56,6 +56,7 @@ WORKAROUND_1508412 WORKAROUND_1542419 WORKAROUND_1742098 WORKAROUND_2457168 +WORKAROUND_TRBE_OVERWRITE_FILL_MODE WORKAROUND_CAVIUM_23154 WORKAROUND_CAVIUM_27456 WORKAROUND_CAVIUM_30115
Greg Kroah-Hartman
maintainerPATCH 458/532 erofs: fix compact 4B support for 16k block size
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
commit 001b8ccd0650727e54ec16ef72bf1b8eeab7168e upstream.
In compact 4B, two adjacent lclusters are packed together as a unit to form on-disk indexes for effective random access, as below:
(amortized = 4, vcnt = 2)
_____________________________________________
|___@_____ encoded bits __________|_ blkaddr _|
0 . amortized * vcnt = 8
. .
. . amortized * vcnt - 4 = 4
. .
.____________________________.
|_type (2 bits)_|_clusterofs_|Therefore, encoded bits for each pack are 32 bits (4 bytes). IOWs, since each lcluster can get 16 bits for its type and clusterofs, the maximum supported lclustersize for compact 4B format is 16k (14 bits).
Fix this to enable compact 4B format for 16k lclusters (blocks), which is tested on an arm64 server with 16k page size.
--- fs/erofs/zmap.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
fs/erofs/zmap.c +1 -5
@@ -253,7 +253,7 @@ static int unpack_compacted_index(structu8 *in, type;bool big_pcluster; -if (1 << amortizedshift ==4 ) +if (1 << amortizedshift ==4 && lclusterbits <=14 ) vcnt =2 ;else if (1 << amortizedshift ==2 && lclusterbits ==12 ) vcnt =16 ;
@@ -351,7 +351,6 @@ static int compacted_load_cluster_from_d {struct inode *const inode = m->inode;struct erofs_inode *const vi =EROFS_I (inode); -const unsigned int lclusterbits = vi->z_logical_clusterbits;const erofs_off_t ebase =ALIGN (iloc (EROFS_I_SB (inode), vi->nid) + vi->inode_isize + vi->xattr_isize,8 ) +sizeof (struct z_erofs_map_header );
@@ -361,9 +360,6 @@ static int compacted_load_cluster_from_derofs_off_t pos;int err; -if (lclusterbits !=12 ) -return -EOPNOTSUPP ; -if (lcn >= totalidx)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 459/532 MIPS: Loongson: Fix cpu_probe_loongson() again
In reply to Greg Kroah-HartmanFrom: Huacai Chen <[email protected]>
commit 65fee014dc41a774bcd94896f3fb380bc39d8dda upstream.
Commit 7db5e9e9e5e6c10d7d ("MIPS: loongson64: fix FTLB configuration") move decode_configs() from the beginning of cpu_probe_loongson() to the end in order to fix FTLB configuration. However, it breaks the CPUCFG decoding because decode_configs() use "c->options = xxxx" rather than "c->options |= xxxx", all information get from CPUCFG by decode_cpucfg() is lost.
This causes error when creating a KVM guest on Loongson-3A4000:
Exception Code: 4 not handled @ PC: 0000000087ad5981, inst: 0xcb7a1898 BadVaddr: 0x0 Status: 0x0
Fix this by moving the c->cputype setting to the beginning and moving decode_configs() after that.
--- arch/mips/kernel/cpu-probe.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
arch/mips/kernel/cpu-probe.c +3 -6
@@ -1734,7 +1734,10 @@ static inline void decode_cpucfg(structstatic inline void cpu_probe_loongson (struct cpuinfo_mips *c,unsigned int cpu) { + c->cputype =CPU_LOONGSON64 ; +/* All Loongson processors covered here define ExcCode 16 as GSExc. */ +decode_configs (c); c->options |=MIPS_CPU_GSEXCEX ;switch (c->processor_id &PRID_IMP_MASK ) {
@@ -1744,7 +1747,6 @@ static inline void cpu_probe_loongson(stcase PRID_REV_LOONGSON2K_R1_1 :case PRID_REV_LOONGSON2K_R1_2 :case PRID_REV_LOONGSON2K_R1_3 : - c->cputype =CPU_LOONGSON64 ; __cpu_name[cpu] ="Loongson-2K" ;set_elf_platform (cpu,"gs264e" );set_isa (c,MIPS_CPU_ISA_M64R2 );
@@ -1757,14 +1759,12 @@ static inline void cpu_probe_loongson(stswitch (c->processor_id &PRID_REV_MASK ) {case PRID_REV_LOONGSON3A_R2_0 :case PRID_REV_LOONGSON3A_R2_1 : - c->cputype =CPU_LOONGSON64 ; __cpu_name[cpu] ="ICT Loongson-3" ;set_elf_platform (cpu,"loongson3a" );set_isa (c,MIPS_CPU_ISA_M64R2 );break ;case PRID_REV_LOONGSON3A_R3_0 :case PRID_REV_LOONGSON3A_R3_1 : - c->cputype =CPU_LOONGSON64 ; __cpu_name[cpu] ="ICT Loongson-3" ;set_elf_platform (cpu,"loongson3a" );set_isa (c,MIPS_CPU_ISA_M64R2 );
@@ -1784,7 +1784,6 @@ static inline void cpu_probe_loongson(st c->ases &= ~MIPS_ASE_VZ ;/* VZ of Loongson-3A2000/3000 is incomplete */ break ;case PRID_IMP_LOONGSON_64G : - c->cputype =CPU_LOONGSON64 ; __cpu_name[cpu] ="ICT Loongson-3" ;set_elf_platform (cpu,"loongson3a" );set_isa (c,MIPS_CPU_ISA_M64R2 );
@@ -1794,8 +1793,6 @@ static inline void cpu_probe_loongson(stpanic ("Unknown Loongson Processor ID!" ); break; } - -decode_configs (c); }#else static inline void cpu_probe_loongson (struct cpuinfo_mips *c,unsigned int cpu) { }
Greg Kroah-Hartman
maintainerPATCH 460/532 MIPS: KVM: Fix NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Huacai Chen <[email protected]>
commit e4de2057698636c0ee709e545d19b169d2069fa3 upstream.
After commit 45c7e8af4a5e3f0bea4ac209 ("MIPS: Remove KVM_TE support") we get a NULL pointer dereference when creating a KVM guest:
[ 146.243409] Starting KVM with MIPS VZ extensions [ 149.849151] CPU 3 Unable to handle kernel paging request at virtual address 0000000000000300, epc == ffffffffc06356ec, ra == ffffffffc063568c [ 149.849177] Oops[#1]: [ 149.849182] CPU: 3 PID: 2265 Comm: qemu-system-mip Not tainted 6.4.0-rc3+ #1671 [ 149.849188] Hardware name: THTF CX TL630 Series/THTF-LS3A4000-7A1000-ML4A, BIOS KL4.1F.TF.D.166.201225.R 12/25/2020 [ 149.849192] $ 0 : 0000000000000000 000000007400cce0 0000000000400004 ffffffff8119c740 [ 149.849209] $ 4 : 000000007400cce1 000000007400cce1 0000000000000000 0000000000000000 [ 149.849221] $ 8 : 000000240058bb36 ffffffff81421ac0 0000000000000000 0000000000400dc0 [ 149.849233] $12 : 9800000102a07cc8 ffffffff80e40e38 0000000000000001 0000000000400dc0 [ 149.849245] $16 : 0000000000000000 9800000106cd0000 9800000106cd0000 9800000100cce000 [ 149.849257] $20 : ffffffffc0632b28 ffffffffc05b31b0 9800000100ccca00 0000000000400000 [ 149.849269] $24 : 9800000106cd09ce ffffffff802f69d0 [ 149.849281] $28 : 9800000102a04000 9800000102a07cd0 98000001106a8000 ffffffffc063568c [ 149.849293] Hi : 00000335b2111e66 [ 149.849295] Lo : 6668d90061ae0ae9 [ 149.849298] epc : ffffffffc06356ec kvm_vz_vcpu_setup+0xc4/0x328 [kvm] [ 149.849324] ra : ffffffffc063568c kvm_vz_vcpu_setup+0x64/0x328 [kvm] [ 149.849336] Status: 7400cce3 KX SX UX KERNEL EXL IE [ 149.849351] Cause : 1000000c (ExcCode 03) [ 149.849354] BadVA : 0000000000000300 [ 149.849357] PrId : 0014c004 (ICT Loongson-3) [ 149.849360] Modules linked in: kvm nfnetlink_queue nfnetlink_log nfnetlink fuse sha256_generic libsha256 cfg80211 rfkill binfmt_misc vfat fat snd_hda_codec_hdmi input_leds led_class snd_hda_intel snd_intel_dspcfg snd_hda_codec snd_hda_core snd_pcm snd_timer snd serio_raw xhci_pci radeon drm_suballoc_helper drm_display_helper xhci_hcd ip_tables x_tables [ 149.849432] Process qemu-system-mip (pid: 2265, threadinfo=00000000ae2982d2, task=0000000038e09ad4, tls=000000ffeba16030) [ 149.849439] Stack : 9800000000000003 9800000100ccca00 9800000100ccc000 ffffffffc062cef4 [ 149.849453] 9800000102a07d18 c89b63a7ab338e00 0000000000000000 ffffffff811a0000 [ 149.849465] 0000000000000000 9800000106cd0000 ffffffff80e59938 98000001106a8920 [ 149.849476] ffffffff80e57f30 ffffffffc062854c ffffffff811a0000 9800000102bf4240 [ 149.849488] ffffffffc05b0000 ffffffff80e3a798 000000ff78000000 000000ff78000010 [ 149.849500] 0000000000000255 98000001021f7de0 98000001023f0078 ffffffff81434000 [ 149.849511] 0000000000000000 0000000000000000 9800000102ae0000 980000025e92ae28 [ 149.849523] 0000000000000000 c89b63a7ab338e00 0000000000000001 ffffffff8119dce0 [ 149.849535] 000000ff78000010 ffffffff804f3d3c 9800000102a07eb0 0000000000000255 [ 149.849546] 0000000000000000 ffffffff8049460c 000000ff78000010 0000000000000255 [ 149.849558] ... [ 149.849565] Call Trace: [ 149.849567] [<ffffffffc06356ec>] kvm_vz_vcpu_setup+0xc4/0x328 [kvm] [ 149.849586] [<ffffffffc062cef4>] kvm_arch_vcpu_create+0x184/0x228 [kvm] [ 149.849605] [<ffffffffc062854c>] kvm_vm_ioctl+0x64c/0xf28 [kvm] [ 149.849623] [<ffffffff805209c0>] sys_ioctl+0xc8/0x118 [ 149.849631] [<ffffffff80219eb0>] syscall_common+0x34/0x58
The root cause is the deletion of kvm_mips_commpage_init() leaves vcpu ->arch.cop0 NULL. So fix it by making cop0 from a pointer to an embedded object.
--- arch/mips/include/asm/kvm_host.h | 6 +++--- arch/mips/kvm/emulate.c | 22 +++++++++++----------- arch/mips/kvm/mips.c | 16 ++++++++-------- arch/mips/kvm/trace.h | 8 ++++---- arch/mips/kvm/vz.c | 20 ++++++++++---------- 5 files changed, 36 insertions(+), 36 deletions(-)
arch/mips/include/asm/kvm_host.h +3 -3
@@ -318,7 +318,7 @@ struct kvm_vcpu_arch {unsigned int aux_inuse;/* COP0 State */ -struct mips_coproc *cop0; +struct mips_coproc cop0;/* Resume PC after MMIO completion */ unsigned long io_pc;
@@ -699,7 +699,7 @@ static inline bool kvm_mips_guest_can_hastatic inline bool kvm_mips_guest_has_fpu (struct kvm_vcpu_arch *vcpu) {return kvm_mips_guest_can_have_fpu (vcpu) && -kvm_read_c0_guest_config1 (vcpu->cop0) &MIPS_CONF1_FP ; +kvm_read_c0_guest_config1 (&vcpu->cop0) &MIPS_CONF1_FP ; }static inline bool kvm_mips_guest_can_have_msa (struct kvm_vcpu_arch *vcpu)
@@ -711,7 +711,7 @@ static inline bool kvm_mips_guest_can_hastatic inline bool kvm_mips_guest_has_msa (struct kvm_vcpu_arch *vcpu) {return kvm_mips_guest_can_have_msa (vcpu) && -kvm_read_c0_guest_config3 (vcpu->cop0) &MIPS_CONF3_MSA ; +kvm_read_c0_guest_config3 (&vcpu->cop0) &MIPS_CONF3_MSA ; }struct kvm_mips_callbacks {
arch/mips/kvm/emulate.c +11 -11
@@ -312,7 +312,7 @@ int kvm_get_badinstrp(u32 *opc, struct k*/ int kvm_mips_count_disabled (struct kvm_vcpu *vcpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;return (vcpu->arch.count_ctl &KVM_REG_MIPS_COUNT_CTL_DC ) || (kvm_read_c0_guest_cause (cop0) &CAUSEF_DC );
@@ -384,7 +384,7 @@ static inline ktime_t kvm_mips_count_tim*/ static u32 kvm_mips_read_count_running (struct kvm_vcpu *vcpu,ktime_t now) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;ktime_t expires, threshold;u32 count, compare;int running;
@@ -444,7 +444,7 @@ static u32 kvm_mips_read_count_running(s*/ u32 kvm_mips_read_count (struct kvm_vcpu *vcpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;/* If count disabled just read static copy of count */ if (kvm_mips_count_disabled (vcpu))
@@ -502,7 +502,7 @@ ktime_t kvm_mips_freeze_hrtimer(struct kstatic void kvm_mips_resume_hrtimer (struct kvm_vcpu *vcpu,ktime_t now,u32 count) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;u32 compare;u64 delta;ktime_t expire;
@@ -603,7 +603,7 @@ resume:*/ void kvm_mips_write_count (struct kvm_vcpu *vcpu,u32 count) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;ktime_t now;/* Calculate bias */
@@ -649,7 +649,7 @@ void kvm_mips_init_count(struct kvm_vcpu*/ int kvm_mips_set_count_hz (struct kvm_vcpu *vcpu,s64 count_hz) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;int dc;ktime_t now;u32 count;
@@ -696,7 +696,7 @@ int kvm_mips_set_count_hz(struct kvm_vcp*/ void kvm_mips_write_compare (struct kvm_vcpu *vcpu,u32 compare,bool ack) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;int dc;u32 old_compare =kvm_read_c0_guest_compare (cop0);s32 delta = compare - old_compare;
@@ -779,7 +779,7 @@ void kvm_mips_write_compare(struct kvm_v*/ static ktime_t kvm_mips_count_disable (struct kvm_vcpu *vcpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;u32 count;ktime_t now;
@@ -806,7 +806,7 @@ static ktime_t kvm_mips_count_disable(st*/ void kvm_mips_count_disable_cause (struct kvm_vcpu *vcpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;kvm_set_c0_guest_cause (cop0,CAUSEF_DC );if (!(vcpu->arch.count_ctl &KVM_REG_MIPS_COUNT_CTL_DC ))
@@ -826,7 +826,7 @@ void kvm_mips_count_disable_cause(struct*/ void kvm_mips_count_enable_cause (struct kvm_vcpu *vcpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;u32 count;kvm_clear_c0_guest_cause (cop0,CAUSEF_DC );
@@ -852,7 +852,7 @@ void kvm_mips_count_enable_cause(struct*/ int kvm_mips_set_count_ctl (struct kvm_vcpu *vcpu,s64 count_ctl) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;s64 changed = count_ctl ^ vcpu->arch.count_ctl;s64 delta;ktime_t expire, now;
arch/mips/kvm/mips.c +8 -8
@@ -652,7 +652,7 @@ static int kvm_mips_copy_reg_indices(strstatic int kvm_mips_get_reg (struct kvm_vcpu *vcpu,const struct kvm_one_reg *reg) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;struct mips_fpu_struct *fpu = &vcpu->arch.fpu;int ret;s64 v;
@@ -764,7 +764,7 @@ static int kvm_mips_get_reg(struct kvm_vstatic int kvm_mips_set_reg (struct kvm_vcpu *vcpu,const struct kvm_one_reg *reg) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;struct mips_fpu_struct *fpu = &vcpu->arch.fpu;s64 v;s64 vs[2 ];
@@ -1104,7 +1104,7 @@ int kvm_vm_ioctl_check_extension(structint kvm_cpu_has_pending_timer (struct kvm_vcpu *vcpu) {return kvm_mips_pending_timer (vcpu) || -kvm_read_c0_guest_cause (vcpu->arch.cop0) &C_TI ; +kvm_read_c0_guest_cause (&vcpu->arch.cop0) &C_TI ; }int kvm_arch_vcpu_dump_regs (struct kvm_vcpu *vcpu)
@@ -1128,7 +1128,7 @@ int kvm_arch_vcpu_dump_regs(struct kvm_vkvm_debug ("\thi: 0x%08lx\n" , vcpu->arch.hi);kvm_debug ("\tlo: 0x%08lx\n" , vcpu->arch.lo); - cop0 = vcpu->arch.cop0; + cop0 = &vcpu->arch.cop0;kvm_debug ("\tStatus: 0x%08x, Cause: 0x%08x\n" ,kvm_read_c0_guest_status (cop0),kvm_read_c0_guest_cause (cop0));
@@ -1250,7 +1250,7 @@ int kvm_mips_handle_exit(struct kvm_vcpucase EXCCODE_TLBS :kvm_debug ("TLB ST fault: cause %#x, status %#x, PC: %p, BadVaddr: %#lx\n" , - cause,kvm_read_c0_guest_status (vcpu->arch.cop0), opc, + cause,kvm_read_c0_guest_status (&vcpu->arch.cop0), opc, badvaddr); ++vcpu->stat.tlbmiss_st_exits;
@@ -1322,7 +1322,7 @@ int kvm_mips_handle_exit(struct kvm_vcpukvm_get_badinstr (opc, vcpu, &inst);kvm_err ("Exception Code: %d, not yet handled, @ PC: %p, inst: 0x%08x BadVaddr: %#lx Status: %#x\n" , exccode, opc, inst, badvaddr, -kvm_read_c0_guest_status (vcpu->arch.cop0)); +kvm_read_c0_guest_status (&vcpu->arch.cop0));kvm_arch_vcpu_dump_regs (vcpu); run->exit_reason =KVM_EXIT_INTERNAL_ERROR ; ret =RESUME_HOST ;
@@ -1384,7 +1384,7 @@ int kvm_mips_handle_exit(struct kvm_vcpu/* Enable FPU for guest and restore context */ void kvm_own_fpu (struct kvm_vcpu *vcpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;unsigned int sr, cfg5;preempt_disable ();
@@ -1428,7 +1428,7 @@ void kvm_own_fpu(struct kvm_vcpu *vcpu)/* Enable MSA for guest and restore context */ void kvm_own_msa (struct kvm_vcpu *vcpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;unsigned int sr, cfg5;preempt_disable ();
arch/mips/kvm/trace.h +4 -4
@@ -322,11 +322,11 @@ TRACE_EVENT_FN(kvm_guest_mode_change, ),TP_fast_assign ( - __entry->epc = kvm_read_c0_guest_epc(vcpu->arch.cop0); + __entry->epc = kvm_read_c0_guest_epc(&vcpu->arch.cop0); __entry->pc = vcpu->arch.pc; - __entry->badvaddr =kvm_read_c0_guest_badvaddr (vcpu->arch.cop0); - __entry->status =kvm_read_c0_guest_status (vcpu->arch.cop0); - __entry->cause =kvm_read_c0_guest_cause (vcpu->arch.cop0); + __entry->badvaddr =kvm_read_c0_guest_badvaddr (&vcpu->arch.cop0); + __entry->status =kvm_read_c0_guest_status (&vcpu->arch.cop0); + __entry->cause =kvm_read_c0_guest_cause (&vcpu->arch.cop0); ), TP_printk("EPC: 0x%08lx PC: 0x%08lx Status: 0x%08x Cause: 0x%08x BadVAddr: 0x%08lx",
arch/mips/kvm/vz.c +10 -10
@@ -422,7 +422,7 @@ static void _kvm_vz_restore_htimer(struc*/ static void kvm_vz_restore_timer (struct kvm_vcpu *vcpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;u32 cause, compare; compare =kvm_read_sw_gc0_compare (cop0);
@@ -517,7 +517,7 @@ static void _kvm_vz_save_htimer(struct k*/ static void kvm_vz_save_timer (struct kvm_vcpu *vcpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;u32 gctl0, compare, cause; gctl0 =read_c0_guestctl0 ();
@@ -863,7 +863,7 @@ static unsigned long mips_process_maar(ustatic void kvm_write_maari (struct kvm_vcpu *vcpu,unsigned long val) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0; val &=MIPS_MAARI_INDEX ;if (val ==MIPS_MAARI_INDEX )
@@ -876,7 +876,7 @@ static enum emulation_result kvm_vz_gpsi u32 *opc, u32 cause, struct kvm_vcpu *vcpu) { - struct mips_coproc *cop0 = vcpu->arch.cop0; + struct mips_coproc *cop0 = &vcpu->arch.cop0;enum emulation_result er =EMULATE_DONE ;u32 rt, rd, sel;unsigned long curr_pc;
@@ -1905,7 +1905,7 @@ static int kvm_vz_get_one_reg(struct kvmconst struct kvm_one_reg *reg, s64 *v) { - struct mips_coproc *cop0 = vcpu->arch.cop0; + struct mips_coproc *cop0 = &vcpu->arch.cop0;unsigned int idx;switch (reg->id) {
@@ -2075,7 +2075,7 @@ static int kvm_vz_get_one_reg(struct kvmcase KVM_REG_MIPS_CP0_MAARI :if (!cpu_guest_has_maar || cpu_guest_has_dyn_maar)return -EINVAL ; - *v =kvm_read_sw_gc0_maari (vcpu->arch.cop0); + *v =kvm_read_sw_gc0_maari (&vcpu->arch.cop0);break ;#ifdef CONFIG_64BIT case KVM_REG_MIPS_CP0_XCONTEXT :
@@ -2129,7 +2129,7 @@ static int kvm_vz_set_one_reg(struct kvm const struct kvm_one_reg *reg, s64 v) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;unsigned int idx;int ret =0 ;unsigned int cur, change;
@@ -2556,7 +2556,7 @@ static void kvm_vz_vcpu_load_tlb(structstatic int kvm_vz_vcpu_load (struct kvm_vcpu *vcpu,int cpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;bool migrated, all;/*
@@ -2698,7 +2698,7 @@ static int kvm_vz_vcpu_load(struct kvm_vstatic int kvm_vz_vcpu_put (struct kvm_vcpu *vcpu,int cpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;if (current->flags &PF_VCPU )kvm_vz_vcpu_save_wired (vcpu);
@@ -3070,7 +3070,7 @@ static void kvm_vz_vcpu_uninit(struct kvstatic int kvm_vz_vcpu_setup (struct kvm_vcpu *vcpu) { -struct mips_coproc *cop0 = vcpu->arch.cop0; +struct mips_coproc *cop0 = &vcpu->arch.cop0;unsigned long count_hz =100 *1000 *1000 ;/* default to 100 MHz */ /*
Greg Kroah-Hartman
maintainerPATCH 461/532 ext4: Fix reusing stale buffer heads from last failed mounting
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 26fb5290240dc31cae99b8b4dd2af7f46dfcba6b upstream.
Following process makes ext4 load stale buffer heads from last failed mounting in a new mounting operation:mount_bdev
ext4_fill_super
| ext4_load_and_init_journal
| ext4_load_journal
| jbd2_journal_load
| load_superblock
| journal_get_superblock
| set_buffer_verified(bh) // buffer head is verified
| jbd2_journal_recover // failed caused by EIO
| goto failed_mount3a // skip 'sb->s_root' initialization
deactivate_locked_super
kill_block_super
generic_shutdown_super
if (sb->s_root)
// false, skip ext4_put_super->invalidate_bdev->
// invalidate_mapping_pages->mapping_evict_folio->
// filemap_release_folio->try_to_free_buffers, which
// cannot drop buffer head.
blkdev_put
blkdev_put_whole
if (atomic_dec_and_test(&bdev->bd_openers))
// false, systemd-udev happens to open the device. Then
// blkdev_flush_mapping->kill_bdev->truncate_inode_pages->
// truncate_inode_folio->truncate_cleanup_folio->
// folio_invalidate->block_invalidate_folio->
// filemap_release_folio->try_to_free_buffers will be skipped,
// dropping buffer head is missed again.Second mount:ext4_fill_super
ext4_load_and_init_journal
ext4_load_journal
ext4_get_journal
jbd2_journal_init_inode
journal_init_common
bh = getblk_unmovable
bh = __find_get_block // Found stale bh in last failed mounting
journal->j_sb_buffer = bh
jbd2_journal_load
load_superblock
journal_get_superblock
if (buffer_verified(bh))
// true, skip journal->j_format_version = 2, value is 0
jbd2_journal_recover
do_one_pass
next_log_block += count_tags(journal, bh)
// According to journal_tag_bytes(), 'tag_bytes' calculating is
// affected by jbd2_has_feature_csum3(), jbd2_has_feature_csum3()
// returns false because 'j->j_format_version >= 2' is not true,
// then we get wrong next_log_block. The do_one_pass may exit
// early whenoccuring non JBD2_MAGIC_NUMBER in 'next_log_block'.The filesystem is corrupted here, journal is partially replayed, and new journal sequence number actually is already used by last mounting.
The invalidate_bdev() can drop all buffer heads even racing with bare reading block device(eg. systemd-udev), so we can fix it by invalidating bdev in error handling path in __ext4_fill_super().
Fetch a reproducer in [Link].
--- fs/ext4/super.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
fs/ext4/super.c +7 -6
@@ -1097,6 +1097,12 @@ static void ext4_blkdev_remove(struct exstruct block_device *bdev; bdev = sbi->s_journal_bdev;if (bdev) { +/* +* Invalidate the journal device's buffers. We don't want them +* floating about in memory - the physical journal device may +* hotswapped, and it breaks the `ro-after' testing code. +*/ +invalidate_bdev (bdev);ext4_blkdev_put (bdev); sbi->s_journal_bdev =NULL ; }
@@ -1239,13 +1245,7 @@ static void ext4_put_super(struct super_sync_blockdev (sb->s_bdev);invalidate_bdev (sb->s_bdev);if (sbi->s_journal_bdev && sbi->s_journal_bdev != sb->s_bdev) { -/* -* Invalidate the journal device's buffers. We don't want them -* floating about in memory - the physical journal device may -* hotswapped, and it breaks the `ro-after' testing code. -*/ sync_blockdev (sbi->s_journal_bdev); -invalidate_bdev (sbi->s_journal_bdev);ext4_blkdev_remove (sbi); }
@@ -5100,6 +5100,7 @@ failed_mount:brelse (bh);ext4_blkdev_remove (sbi); out_fail: +invalidate_bdev (sb->s_bdev); sb->s_fs_info =NULL ;kfree (sbi->s_blockgroup_lock); out_free_base:
Greg Kroah-Hartman
maintainerPATCH 462/532 ext4: fix wrong unit use in ext4_mb_clear_bb
In reply to Greg Kroah-HartmanFrom: Kemeng Shi <[email protected]>
commit 247c3d214c23dfeeeb892e91a82ac1188bdaec9f upstream.
Function ext4_issue_discard need count in cluster. Pass count_clusters instead of count to fix the mismatch.
--- fs/ext4/mballoc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/mballoc.c +2 -2
@@ -6086,8 +6086,8 @@ do_more:* them with group lock_held */ if (test_opt (sb,DISCARD )) { - err =ext4_issue_discard (sb, block_group, bit, count, -NULL ); + err =ext4_issue_discard (sb, block_group, bit, + count_clusters,NULL );if (err && err != -EOPNOTSUPP )ext4_msg (sb,KERN_WARNING ,"discard request in" " group:%u block:%d count:%lu failed"
Greg Kroah-Hartman
maintainerPATCH 463/532 ext4: get block from bh in ext4_free_blocks for fast commit replay
In reply to Greg Kroah-HartmanFrom: Kemeng Shi <[email protected]>
commit 11b6890be0084ad4df0e06d89a9fdcc948472c65 upstream.
ext4_free_blocks will retrieve block from bh if block parameter is zero. Retrieve block before ext4_free_blocks_simple to avoid potentially passing wrong block to ext4_free_blocks_simple.
--- fs/ext4/mballoc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
fs/ext4/mballoc.c +7 -6
@@ -6171,12 +6171,6 @@ void ext4_free_blocks(handle_t *handle, sbi =EXT4_SB (sb); -if (sbi->s_mount_state &EXT4_FC_REPLAY ) { -ext4_free_blocks_simple (inode, block, count); -return ; - } - -might_sleep ();if (bh) {if (block)BUG_ON (block != bh->b_blocknr);
@@ -6184,6 +6178,13 @@ void ext4_free_blocks(handle_t *handle, block = bh->b_blocknr; } +if (sbi->s_mount_state &EXT4_FC_REPLAY ) { +ext4_free_blocks_simple (inode, block, count); +return ; + } + +might_sleep (); +if (!(flags &EXT4_FREE_BLOCKS_VALIDATED ) && !ext4_inode_block_valid (inode, block, count)) { ext4_error(sb, "Freeing blocks not in datazone - "
Greg Kroah-Hartman
maintainerPATCH 464/532 ext4: fix wrong unit use in ext4_mb_new_blocks
In reply to Greg Kroah-HartmanFrom: Kemeng Shi <[email protected]>
commit 2ec6d0a5ea72689a79e6f725fd8b443a788ae279 upstream.
Function ext4_free_blocks_simple needs count in cluster. Function ext4_free_blocks accepts count in block. Convert count to cluster to fix the mismatch.
--- fs/ext4/mballoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/mballoc.c +1 -1
@@ -6179,7 +6179,7 @@ void ext4_free_blocks(handle_t *handle, }if (sbi->s_mount_state &EXT4_FC_REPLAY ) { -ext4_free_blocks_simple (inode, block, count); +ext4_free_blocks_simple (inode, block,EXT4_NUM_B2C (sbi, count));return ; }
Greg Kroah-Hartman
maintainerPATCH 465/532 ext4: fix to check return value of freeze_bdev() in ext4_shutdown()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
commit c4d13222afd8a64bf11bc7ec68645496ee8b54b9 upstream.
freeze_bdev() can fail due to a lot of reasons, it needs to check its reason before later process.
--- fs/ext4/ioctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ext4/ioctl.c +4 -1
@@ -559,6 +559,7 @@ static int ext4_shutdown(struct super_bl {struct ext4_sb_info *sbi =EXT4_SB (sb);__u32 flags; +int ret;if (!capable (CAP_SYS_ADMIN ))return -EPERM ;
@@ -577,7 +578,9 @@ static int ext4_shutdown(struct super_blswitch (flags) {case EXT4_GOING_FLAGS_DEFAULT : -freeze_bdev (sb->s_bdev); + ret =freeze_bdev (sb->s_bdev); +if (ret) +return ret;set_bit (EXT4_FLAGS_SHUTDOWN , &sbi->s_ext4_flags);thaw_bdev (sb->s_bdev);break ;
Greg Kroah-Hartman
maintainerPATCH 466/532 ext4: turn quotas off if mount failed after enabling quotas
In reply to Greg Kroah-HartmanFrom: Baokun Li <[email protected]>
commit d13f99632748462c32fc95d729f5e754bab06064 upstream.
Yi found during a review of the patch "ext4: don't BUG on inconsistent journal feature" that when ext4_mark_recovery_complete() returns an error value, the error handling path does not turn off the enabled quotas, which triggers the following kmemleak:
================================================================
unreferenced object 0xffff8cf68678e7c0 (size 64):
comm "mount", pid 746, jiffies 4294871231 (age 11.540s) hex dump (first 32 bytes):
00 90 ef 82 f6 8c ff ff 00 00 00 00 41 01 00 00 ............A... c7 00 00 00 bd 00 00 00 0a 00 00 00 48 00 00 00 ............H... backtrace:
[<00000000c561ef24>] __kmem_cache_alloc_node+0x4d4/0x880 [<00000000d4e621d7>] kmalloc_trace+0x39/0x140 [<00000000837eee74>] v2_read_file_info+0x18a/0x3a0 [<0000000088f6c877>] dquot_load_quota_sb+0x2ed/0x770 [<00000000340a4782>] dquot_load_quota_inode+0xc6/0x1c0 [<0000000089a18bd5>] ext4_enable_quotas+0x17e/0x3a0 [ext4] [<000000003a0268fa>] __ext4_fill_super+0x3448/0x3910 [ext4] [<00000000b0f2a8a8>] ext4_fill_super+0x13d/0x340 [ext4] [<000000004a9489c4>] get_tree_bdev+0x1dc/0x370 [<000000006e723bf1>] ext4_get_tree+0x1d/0x30 [ext4] [<00000000c7cb663d>] vfs_get_tree+0x31/0x160 [<00000000320e1bed>] do_new_mount+0x1d5/0x480 [<00000000c074654c>] path_mount+0x22e/0xbe0 [<0000000003e97a8e>] do_mount+0x95/0xc0 [<000000002f3d3736>] __x64_sys_mount+0xc4/0x160 [<0000000027d2140c>] do_syscall_64+0x3f/0x90 ================================================================
To solve this problem, we add a "failed_mount10" tag, and call ext4_quota_off_umount() in this tag to release the enabled qoutas.
--- fs/ext4/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ext4/super.c +4 -2
@@ -4977,7 +4977,7 @@ no_journal:ext4_msg (sb,KERN_INFO ,"recovery complete" ); err =ext4_mark_recovery_complete (sb, es);if (err) - goto failed_mount9; + goto failed_mount10; }if (EXT4_SB (sb)->s_journal) {if (test_opt (sb,DATA_FLAGS ) ==EXT4_MOUNT_JOURNAL_DATA )
@@ -5023,7 +5023,9 @@ cantfind_ext4:ext4_msg (sb,KERN_ERR ,"VFS: Can't find ext4 filesystem" ); goto failed_mount; -failed_mount9: +failed_mount10: +ext4_quota_off_umount (sb); +failed_mount9:__maybe_unused ext4_release_orphan_info (sb); failed_mount8:ext4_unregister_sysfs (sb);
Greg Kroah-Hartman
maintainerPATCH 467/532 ext4: only update i_reserved_data_blocks on successful block allocation
In reply to Greg Kroah-HartmanFrom: Baokun Li <[email protected]>
commit de25d6e9610a8b30cce9bbb19b50615d02ebca02 upstream.
In our fault injection test, we create an ext4 file, migrate it to non-extent based file, then punch a hole and finally trigger a WARN_ON in the ext4_da_update_reserve_space():
EXT4-fs warning (device sda): ext4_da_update_reserve_space:369:
ino 14, used 11 with only 10 reserved data blocks
When writing back a non-extent based file, if we enable delalloc, the number of reserved blocks will be subtracted from the number of blocks mapped by ext4_ind_map_blocks(), and the extent status tree will be updated. We update the extent status tree by first removing the old extent_status and then inserting the new extent_status. If the block range we remove happens to be in an extent, then we need to allocate another extent_status with ext4_es_alloc_extent().
use old to remove to add new
|----------|------------|------------|
old extent_status
The problem is that the allocation of a new extent_status failed due to a fault injection, and __es_shrink() did not get free memory, resulting in a return of -ENOMEM. Then do_writepages() retries after receiving -ENOMEM, we map to the same extent again, and the number of reserved blocks is again subtracted from the number of blocks in that extent. Since the blocks in the same extent are subtracted twice, we end up triggering WARN_ON at ext4_da_update_reserve_space() because used > ei->i_reserved_data_blocks.
For non-extent based file, we update the number of reserved blocks after ext4_ind_map_blocks() is executed, which causes a problem that when we call ext4_ind_map_blocks() to create a block, it doesn't always create a block, but we always reduce the number of reserved blocks. So we move the logic for updating reserved blocks to ext4_ind_map_blocks() to ensure that the number of reserved blocks is updated only after we do succeed in allocating some new blocks.
--- fs/ext4/indirect.c | 8 ++++++++ fs/ext4/inode.c | 10 ---------- 2 files changed, 8 insertions(+), 10 deletions(-)
fs/ext4/indirect.c +8 -0
@@ -651,6 +651,14 @@ int ext4_ind_map_blocks(handle_t *handleext4_update_inode_fsync_trans (handle, inode,1 ); count = ar.len; + +/* +* Update reserved blocks/metadata blocks after successful block +* allocation which had been deferred till now. +*/ +if (flags &EXT4_GET_BLOCKS_DELALLOC_RESERVE ) +ext4_da_update_reserve_space (inode, count,1 ); + got_it: map->m_flags |=EXT4_MAP_MAPPED ; map->m_pblk =le32_to_cpu (chain[depth-1 ].key);
fs/ext4/inode.c +0 -10
@@ -654,16 +654,6 @@ found:*/ ext4_clear_inode_state (inode,EXT4_STATE_EXT_MIGRATE ); } - -/* -* Update reserved blocks/metadata blocks after successful -* block allocation which had been deferred till now. We don't -* support fallocate for non extent files. So we can update -* reserve space here. -*/ -if ((retval >0 ) && - (flags &EXT4_GET_BLOCKS_DELALLOC_RESERVE )) -ext4_da_update_reserve_space (inode, retval,1 ); }if (retval >0 ) {
Greg Kroah-Hartman
maintainerPATCH 468/532 jfs: jfs_dmap: Validate db_l2nbperpage while mounting
In reply to Greg Kroah-HartmanFrom: Siddh Raman Pant <[email protected]>
commit 11509910c599cbd04585ec35a6d5e1a0053d84c1 upstream.
In jfs_dmap.c at line 381, BLKTODMAP is used to get a logical block number inside dbFree(). db_l2nbperpage, which is the log2 number of blocks per page, is passed as an argument to BLKTODMAP which uses it for shifting.
Syzbot reported a shift out-of-bounds crash because db_l2nbperpage is too big. This happens because the large value is set without any validation in dbMount() at line 181.
Thus, make sure that db_l2nbperpage is correct while mounting.
Max number of blocks per page = Page size / Min block size => log2(Max num_block per page) = log2(Page size / Min block size)
= log2(Page size) - log2(Min block size)
=> Max db_l2nbperpage = L2PSIZE - L2MINBLOCKSIZE
--- fs/jfs/jfs_dmap.c | 6 ++++++ fs/jfs/jfs_filsys.h | 2 ++ 2 files changed, 8 insertions(+)
fs/jfs/jfs_dmap.c +6 -0
@@ -178,7 +178,13 @@ int dbMount(struct inode *ipbmap) dbmp_le = (struct dbmap_disk *) mp->data; bmp->db_mapsize =le64_to_cpu (dbmp_le->dn_mapsize); bmp->db_nfree =le64_to_cpu (dbmp_le->dn_nfree); + bmp->db_l2nbperpage =le32_to_cpu (dbmp_le->dn_l2nbperpage); +if (bmp->db_l2nbperpage >L2PSIZE -L2MINBLOCKSIZE ) { + err = -EINVAL ; + goto err_release_metapage; + } + bmp->db_numag =le32_to_cpu (dbmp_le->dn_numag);if (!bmp->db_numag) { err = -EINVAL ;
fs/jfs/jfs_filsys.h +2 -0
@@ -122,7 +122,9 @@#define NUM_INODE_PER_IAG INOSPERIAG#define MINBLOCKSIZE 512 +#define L2MINBLOCKSIZE 9#define MAXBLOCKSIZE 4096 +#define L2MAXBLOCKSIZE 12#define MAXFILESIZE ((s64)1 << 52)#define JFS_LINK_MAX 0xffffffff
Greg Kroah-Hartman
maintainerPATCH 469/532 hwrng: imx-rngc - fix the timeout for init and self check
In reply to Greg Kroah-HartmanFrom: Martin Kaiser <[email protected]>
commit d744ae7477190967a3ddc289e2cd4ae59e8b1237 upstream.
Fix the timeout that is used for the initialisation and for the self test. wait_for_completion_timeout expects a timeout in jiffies, but RNGC_TIMEOUT is in milliseconds. Call msecs_to_jiffies to do the conversion.
--- drivers/char/hw_random/imx-rngc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/char/hw_random/imx-rngc.c +2 -4
@@ -110,7 +110,7 @@ static int imx_rngc_self_test(struct imx cmd =readl (rngc->base +RNGC_COMMAND );writel (cmd |RNGC_CMD_SELF_TEST , rngc->base +RNGC_COMMAND ); - ret =wait_for_completion_timeout (&rngc->rng_op_done,RNGC_TIMEOUT ); + ret =wait_for_completion_timeout (&rngc->rng_op_done,msecs_to_jiffies (RNGC_TIMEOUT ));imx_rngc_irq_mask_clear (rngc);if (!ret)return -ETIMEDOUT ;
@@ -187,9 +187,7 @@ static int imx_rngc_init(struct hwrng *r cmd =readl (rngc->base +RNGC_COMMAND );writel (cmd |RNGC_CMD_SEED , rngc->base +RNGC_COMMAND ); - ret =wait_for_completion_timeout (&rngc->rng_op_done, -RNGC_TIMEOUT ); - + ret =wait_for_completion_timeout (&rngc->rng_op_done,msecs_to_jiffies (RNGC_TIMEOUT ));if (!ret) { ret = -ETIMEDOUT ; goto err;
Greg Kroah-Hartman
maintainerPATCH 470/532 dm integrity: reduce vmalloc space footprint on 32-bit architectures
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit 6d50eb4725934fd22f5eeccb401000687c790fd0 upstream.
It was reported that dm-integrity runs out of vmalloc space on 32-bit architectures. On x86, there is only 128MiB vmalloc space and dm-integrity consumes it quickly because it has a 64MiB journal and 8MiB recalculate buffer.
Fix this by reducing the size of the journal to 4MiB and the size of the recalculate buffer to 1MiB, so that multiple dm-integrity devices can be created and activated on 32-bit architectures.
--- drivers/md/dm-integrity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-integrity.c +2 -2
@@ -31,11 +31,11 @@#define DEFAULT_BUFFER_SECTORS 128#define DEFAULT_JOURNAL_WATERMARK 50#define DEFAULT_SYNC_MSEC 10000 -#define DEFAULT_MAX_JOURNAL_SECTORS 131072 +#define DEFAULT_MAX_JOURNAL_SECTORS (IS_ENABLED(CONFIG_64BIT) ? 131072 : 8192)#define MIN_LOG2_INTERLEAVE_SECTORS 3#define MAX_LOG2_INTERLEAVE_SECTORS 31#define METADATA_WORKQUEUE_MAX_ACTIVE 16 -#define RECALC_SECTORS 32768 +#define RECALC_SECTORS (IS_ENABLED(CONFIG_64BIT) ? 32768 : 2048)#define RECALC_WRITE_SUPER 16#define BITMAP_BLOCK_SIZE 4096/* don't change it */ #define BITMAP_FLUSH_INTERVAL (10 * HZ)
Greg Kroah-Hartman
maintainerPATCH 471/532 PCI/PM: Avoid putting EloPOS E2/S2/H2 PCIe Ports in D3cold
In reply to Greg Kroah-HartmanFrom: Ondrej Zary <[email protected]>
commit 9e30fd26f43b89cb6b4e850a86caa2e50dedb454 upstream.
The quirk for Elo i2 introduced in commit 92597f97a40b ("PCI/PM: Avoid putting Elo i2 PCIe Ports in D3cold") is also needed by EloPOS E2/S2/H2 which uses the same Continental Z2 board.
Change the quirk to match the board instead of system.
--- drivers/pci/pci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/pci/pci.c +5 -5
@@ -2886,13 +2886,13 @@ static const struct dmi_system_id bridge { /* * Downstream device is not accessible after putting a root port - * into D3cold and back into D0 on Elo i2. + * into D3cold and back into D0 on Elo Continental Z2 board */ - .ident = "Elo i2", + .ident = "Elo Continental Z2", .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Elo Touch Solutions"), - DMI_MATCH(DMI_PRODUCT_NAME, "Elo i2"), - DMI_MATCH(DMI_PRODUCT_VERSION, "RevB"), + DMI_MATCH(DMI_BOARD_VENDOR, "Elo Touch Solutions"), + DMI_MATCH(DMI_BOARD_NAME, "Geminilake"), + DMI_MATCH(DMI_BOARD_VERSION, "Continental Z2"), }, }, #endif
Greg Kroah-Hartman
maintainerPATCH 472/532 PCI: Add function 1 DMA alias quirk for Marvell 88SE9235
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
commit 88d341716b83abd355558523186ca488918627ee upstream.
Marvell's own product brief implies the 92xx series are a closely related family, and sure enough it turns out that 9235 seems to need the same quirk as the other three, although possibly only when certain ports are used.
--- drivers/pci/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/quirks.c +2 -0
@@ -4149,6 +4149,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_M/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c49 */ DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_MARVELL_EXT ,0x9230 , quirk_dma_func1_alias); +DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_MARVELL_EXT ,0x9235 , + quirk_dma_func1_alias);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_TTI ,0x0642 , quirk_dma_func1_alias); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0645,
Greg Kroah-Hartman
maintainerPATCH 473/532 PCI: acpiphp: Reassign resources on bridge if necessary
In reply to Greg Kroah-HartmanFrom: Igor Mammedov <[email protected]>
commit 40613da52b13fb21c5566f10b287e0ca8c12c4e9 upstream.
When using ACPI PCI hotplug, hotplugging a device with large BARs may fail if bridge windows programmed by firmware are not large enough.
Reproducer:
$ qemu-kvm -monitor stdio -M q35 -m 4G \
-global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=on \
-device id=rp1,pcie-root-port,bus=pcie.0,chassis=4 \
disk_image wait till linux guest boots, then hotplug device:
(qemu) device_add qxl,bus=rp1
hotplug on guest side fails with:
pci 0000:01:00.0: [1b36:0100] type 00 class 0x038000 pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x03ffffff] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x03ffffff] pci 0000:01:00.0: reg 0x18: [mem 0x00000000-0x00001fff] pci 0000:01:00.0: reg 0x1c: [io 0x0000-0x001f]
pci 0000:01:00.0: BAR 0: no space for [mem size 0x04000000] pci 0000:01:00.0: BAR 0: failed to assign [mem size 0x04000000] pci 0000:01:00.0: BAR 1: no space for [mem size 0x04000000] pci 0000:01:00.0: BAR 1: failed to assign [mem size 0x04000000] pci 0000:01:00.0: BAR 2: assigned [mem 0xfe800000-0xfe801fff] pci 0000:01:00.0: BAR 3: assigned [io 0x1000-0x101f] qxl 0000:01:00.0: enabling device (0000 -> 0003) Unable to create vram_mapping
qxl: probe of 0000:01:00.0 failed with error -12
However when using native PCIe hotplug
'-global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off'
it works fine, since kernel attempts to reassign unused resources.
Use the same machinery as native PCIe hotplug to (re)assign resources.
--- drivers/pci/hotplug/acpiphp_glue.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +1 -4
@@ -489,7 +489,6 @@ static void enable_slot(struct acpiphp_sacpiphp_native_scan_bridge (dev); } }else { -LIST_HEAD (add_list);int max, pass;acpiphp_rescan_slot (slot);
@@ -503,12 +502,10 @@ static void enable_slot(struct acpiphp_sif (pass && dev->subordinate) {check_hotplug_bridge (slot, dev);pcibios_resource_survey_bus (dev->subordinate); -__pci_bus_size_bridges (dev->subordinate, - &add_list); } } } -__pci_bus_assign_resources (bus, &add_list,NULL ); +pci_assign_unassigned_bridge_resources (bus->self); }acpiphp_sanitize_bus (bus);
Greg Kroah-Hartman
maintainerPATCH 474/532 PCI: qcom: Disable write access to read only registers for IP v2.3.3
In reply to Greg Kroah-HartmanFrom: Manivannan Sadhasivam <[email protected]>
commit a33d700e8eea76c62120cb3dbf5e01328f18319a upstream.
In the post init sequence of v2.9.0, write access to read only registers are not disabled after updating the registers. Fix it by disabling the access after register update.
--- drivers/pci/controller/dwc/pcie-qcom.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/controller/dwc/pcie-qcom.c +2 -0
@@ -1134,6 +1134,8 @@ static int qcom_pcie_post_init_2_3_3(strwritel (PCI_EXP_DEVCTL2_COMP_TMOUT_DIS , pci->dbi_base + offset +PCI_EXP_DEVCTL2 ); +dw_pcie_dbi_ro_wr_dis (pci); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 475/532 PCI: rockchip: Assert PCI Configuration Enable bit after probe
In reply to Greg Kroah-HartmanFrom: Rick Wertenbroek <[email protected]>
commit f397fd4ac1fa3afcabd8cee030f953ccaed2a364 upstream.
Assert PCI Configuration Enable bit after probe. When this bit is left to 0 in the endpoint mode, the RK3399 PCIe endpoint core will generate configuration request retry status (CRS) messages back to the root complex. Assert this bit after probe to allow the RK3399 PCIe endpoint core to reply to configuration requests from the root complex.
This is documented in section 17.5.8.1.2 of the RK3399 TRM.
--- drivers/pci/controller/pcie-rockchip-ep.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pci/controller/pcie-rockchip-ep.c +3 -0
@@ -631,6 +631,9 @@ static int rockchip_pcie_ep_probe(struct ep->irq_pci_addr =ROCKCHIP_PCIE_EP_DUMMY_IRQ_ADDR ; +rockchip_pcie_write (rockchip,PCIE_CLIENT_CONF_ENABLE , +PCIE_CLIENT_CONFIG ); +return 0 ; err_epc_mem_exit:pci_epc_mem_exit (epc);
Greg Kroah-Hartman
maintainerPATCH 476/532 PCI: rockchip: Write PCI Device ID to correct register
In reply to Greg Kroah-HartmanFrom: Rick Wertenbroek <[email protected]>
commit 1f1c42ece18de365c976a060f3c8eb481b038e3a upstream.
Write PCI Device ID (DID) to the correct register. The Device ID was not updated through the correct register. Device ID was written to a read-only register and therefore did not work. The Device ID is now set through the correct register. This is documented in the RK3399 TRM section 17.6.6.1.1
--- drivers/pci/controller/pcie-rockchip-ep.c | 6 ++++-- drivers/pci/controller/pcie-rockchip.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-rockchip-ep.c +4 -2
@@ -125,6 +125,7 @@ static void rockchip_pcie_prog_ep_ob_atustatic int rockchip_pcie_ep_write_header (struct pci_epc *epc,u8 fn,u8 vfn,struct pci_epf_header *hdr) { +u32 reg;struct rockchip_pcie_ep *ep =epc_get_drvdata (epc);struct rockchip_pcie *rockchip = &ep->rockchip;
@@ -137,8 +138,9 @@ static int rockchip_pcie_ep_write_header PCIE_CORE_CONFIG_VENDOR); } -rockchip_pcie_write (rockchip, hdr->deviceid <<16 , -ROCKCHIP_PCIE_EP_FUNC_BASE (fn) +PCI_VENDOR_ID ); + reg =rockchip_pcie_read (rockchip,PCIE_EP_CONFIG_DID_VID ); + reg = (reg &0xFFFF ) | (hdr->deviceid <<16 ); +rockchip_pcie_write (rockchip, reg,PCIE_EP_CONFIG_DID_VID ); rockchip_pcie_write(rockchip, hdr->revid |
drivers/pci/controller/pcie-rockchip.h +2 -0
@@ -133,6 +133,8 @@#define PCIE_RC_RP_ATS_BASE 0x400000#define PCIE_RC_CONFIG_NORMAL_BASE 0x800000#define PCIE_RC_CONFIG_BASE 0xa00000 +#define PCIE_EP_CONFIG_BASE 0xa00000 +#define PCIE_EP_CONFIG_DID_VID (PCIE_EP_CONFIG_BASE + 0x00)#define PCIE_RC_CONFIG_RID_CCR (PCIE_RC_CONFIG_BASE + 0x08)#define PCIE_RC_CONFIG_SCC_SHIFT 16#define PCIE_RC_CONFIG_DCR (PCIE_RC_CONFIG_BASE + 0xc4)
Greg Kroah-Hartman
maintainerPATCH 477/532 PCI: rockchip: Add poll and timeout to wait for PHY PLLs to be locked
In reply to Greg Kroah-HartmanFrom: Rick Wertenbroek <[email protected]>
commit 9dd3c7c4c8c3f7f010d9cdb7c3f42506d93c9527 upstream.
The RK3399 PCIe controller should wait until the PHY PLLs are locked. Add poll and timeout to wait for PHY PLLs to be locked. If they cannot be locked generate error message and jump to error handler. Accessing registers in the PHY clock domain when PLLs are not locked causes hang The PHY PLLs status is checked through a side channel register. This is documented in the TRM section 17.5.8.1 "PCIe Initialization Sequence".
--- drivers/pci/controller/pcie-rockchip.c | 17 +++++++++++++++++ drivers/pci/controller/pcie-rockchip.h | 2 ++ 2 files changed, 19 insertions(+)
drivers/pci/controller/pcie-rockchip.c +17 -0
@@ -14,6 +14,7 @@#include <linux/clk.h> #include <linux/delay.h> #include <linux/gpio/consumer.h> +#include <linux/iopoll.h> #include <linux/of_pci.h> #include <linux/phy/phy.h> #include <linux/platform_device.h>
@@ -153,6 +154,12 @@ int rockchip_pcie_parse_dt(struct rockch }EXPORT_SYMBOL_GPL (rockchip_pcie_parse_dt); +#define rockchip_pcie_read_addr (addr) rockchip_pcie_read(rockchip, addr) +/* 100 ms max wait time for PHY PLLs to lock */ +#define RK_PHY_PLL_LOCK_TIMEOUT_US 100000 +/* Sleep should be less than 20ms */ +#define RK_PHY_PLL_LOCK_SLEEP_US 1000 +int rockchip_pcie_init_port (struct rockchip_pcie *rockchip) {struct device *dev = rockchip->dev;
@@ -254,6 +261,16 @@ int rockchip_pcie_init_port(struct rockc } } + err =readx_poll_timeout (rockchip_pcie_read_addr, +PCIE_CLIENT_SIDE_BAND_STATUS , + regs, !(regs &PCIE_CLIENT_PHY_ST ), +RK_PHY_PLL_LOCK_SLEEP_US , +RK_PHY_PLL_LOCK_TIMEOUT_US ); +if (err) { +dev_err (dev,"PHY PLLs could not lock, %d\n" , err); + goto err_power_off_phy; + } +/* * Please don't reorder the deassert sequence of the following * four reset pins.
drivers/pci/controller/pcie-rockchip.h +2 -0
@@ -38,6 +38,8 @@#define PCIE_CLIENT_MODE_EP HIWORD_UPDATE(0x0040, 0)#define PCIE_CLIENT_GEN_SEL_1 HIWORD_UPDATE(0x0080, 0)#define PCIE_CLIENT_GEN_SEL_2 HIWORD_UPDATE_BIT(0x0080) +#define PCIE_CLIENT_SIDE_BAND_STATUS (PCIE_CLIENT_BASE + 0x20) +#define PCIE_CLIENT_PHY_ST BIT(12)#define PCIE_CLIENT_DEBUG_OUT_0 (PCIE_CLIENT_BASE + 0x3c)#define PCIE_CLIENT_DEBUG_LTSSM_MASK GENMASK(5, 0)#define PCIE_CLIENT_DEBUG_LTSSM_L1 0x18
Greg Kroah-Hartman
maintainerPATCH 478/532 PCI: rockchip: Fix legacy IRQ generation for RK3399 PCIe endpoint core
In reply to Greg Kroah-HartmanFrom: Rick Wertenbroek <[email protected]>
commit 166e89d99dd85a856343cca51eee781b793801f2 upstream.
Fix legacy IRQ generation for RK3399 PCIe endpoint core according to the technical reference manual (TRM). Assert and deassert legacy interrupt (INTx) through the legacy interrupt control register ("PCIE_CLIENT_LEGACY_INT_CTRL") instead of manually generating a PCIe message. The generation of the legacy interrupt was tested and validated with the PCIe endpoint test driver.
--- drivers/pci/controller/pcie-rockchip-ep.c | 45 +++++++----------------------- drivers/pci/controller/pcie-rockchip.h | 6 +++- 2 files changed, 16 insertions(+), 35 deletions(-)
drivers/pci/controller/pcie-rockchip-ep.c +11 -34
@@ -347,48 +347,25 @@ static int rockchip_pcie_ep_get_msi(stru }static void rockchip_pcie_ep_assert_intx (struct rockchip_pcie_ep *ep,u8 fn, -u8 intx,bool is_asserted) +u8 intx,bool do_assert) {struct rockchip_pcie *rockchip = &ep->rockchip; -u32 r = ep->max_regions -1 ; -u32 offset; -u32 status; -u8 msg_code; - -if (unlikely (ep->irq_pci_addr !=ROCKCHIP_PCIE_EP_PCI_LEGACY_IRQ_ADDR || - ep->irq_pci_fn != fn)) { -rockchip_pcie_prog_ep_ob_atu (rockchip, fn, r, -AXI_WRAPPER_NOR_MSG , - ep->irq_phys_addr,0 ,0 ); - ep->irq_pci_addr =ROCKCHIP_PCIE_EP_PCI_LEGACY_IRQ_ADDR ; - ep->irq_pci_fn = fn; - } intx &=3 ; -if (is_asserted) { + +if (do_assert) { ep->irq_pending |=BIT (intx); - msg_code =ROCKCHIP_PCIE_MSG_CODE_ASSERT_INTA + intx; +rockchip_pcie_write (rockchip, +PCIE_CLIENT_INT_IN_ASSERT | +PCIE_CLIENT_INT_PEND_ST_PEND , +PCIE_CLIENT_LEGACY_INT_CTRL ); }else { ep->irq_pending &= ~BIT (intx); - msg_code =ROCKCHIP_PCIE_MSG_CODE_DEASSERT_INTA + intx; +rockchip_pcie_write (rockchip, +PCIE_CLIENT_INT_IN_DEASSERT | +PCIE_CLIENT_INT_PEND_ST_NORMAL , +PCIE_CLIENT_LEGACY_INT_CTRL ); } - - status =rockchip_pcie_read (rockchip, -ROCKCHIP_PCIE_EP_FUNC_BASE (fn) + -ROCKCHIP_PCIE_EP_CMD_STATUS ); - status &=ROCKCHIP_PCIE_EP_CMD_STATUS_IS ; - -if ((status !=0 ) ^ (ep->irq_pending !=0 )) { - status ^=ROCKCHIP_PCIE_EP_CMD_STATUS_IS ; -rockchip_pcie_write (rockchip, status, -ROCKCHIP_PCIE_EP_FUNC_BASE (fn) + -ROCKCHIP_PCIE_EP_CMD_STATUS ); - } - - offset = -ROCKCHIP_PCIE_MSG_ROUTING (ROCKCHIP_PCIE_MSG_ROUTING_LOCAL_INTX ) | -ROCKCHIP_PCIE_MSG_CODE (msg_code) |ROCKCHIP_PCIE_MSG_NO_DATA ; -writel (0 , ep->irq_cpu_addr + offset); } static int rockchip_pcie_ep_send_legacy_irq(struct rockchip_pcie_ep *ep, u8 fn,
drivers/pci/controller/pcie-rockchip.h +5 -1
@@ -38,6 +38,11 @@#define PCIE_CLIENT_MODE_EP HIWORD_UPDATE(0x0040, 0)#define PCIE_CLIENT_GEN_SEL_1 HIWORD_UPDATE(0x0080, 0)#define PCIE_CLIENT_GEN_SEL_2 HIWORD_UPDATE_BIT(0x0080) +#define PCIE_CLIENT_LEGACY_INT_CTRL (PCIE_CLIENT_BASE + 0x0c) +#define PCIE_CLIENT_INT_IN_ASSERT HIWORD_UPDATE_BIT(0x0002) +#define PCIE_CLIENT_INT_IN_DEASSERT HIWORD_UPDATE(0x0002, 0) +#define PCIE_CLIENT_INT_PEND_ST_PEND HIWORD_UPDATE_BIT(0x0001) +#define PCIE_CLIENT_INT_PEND_ST_NORMAL HIWORD_UPDATE(0x0001, 0)#define PCIE_CLIENT_SIDE_BAND_STATUS (PCIE_CLIENT_BASE + 0x20)#define PCIE_CLIENT_PHY_ST BIT(12)#define PCIE_CLIENT_DEBUG_OUT_0 (PCIE_CLIENT_BASE + 0x3c)
@@ -228,7 +233,6 @@#define ROCKCHIP_PCIE_EP_MSI_CTRL_ME BIT(16)#define ROCKCHIP_PCIE_EP_MSI_CTRL_MASK_MSI_CAP BIT(24)#define ROCKCHIP_PCIE_EP_DUMMY_IRQ_ADDR 0x1 -#define ROCKCHIP_PCIE_EP_PCI_LEGACY_IRQ_ADDR 0x3#define ROCKCHIP_PCIE_EP_FUNC_BASE (fn) (((fn) << 12) & GENMASK(19, 12))#define ROCKCHIP_PCIE_AT_IB_EP_FUNC_BAR_ADDR0 (fn, bar) \ (PCIE_RC_RP_ATS_BASE + 0x0840 + (fn) * 0x0040 + (bar) * 0x0008)
Greg Kroah-Hartman
maintainerPATCH 479/532 PCI: rockchip: Use u32 variable to access 32-bit registers
In reply to Greg Kroah-HartmanFrom: Rick Wertenbroek <[email protected]>
commit 8962b2cb39119cbda4fc69a1f83957824f102f81 upstream.
Previously u16 variables were used to access 32-bit registers, this resulted in not all of the data being read from the registers. Also the left shift of more than 16-bits would result in moving data out of the variable. Use u32 variables to access 32-bit registers
--- drivers/pci/controller/pcie-rockchip-ep.c | 10 +++++----- drivers/pci/controller/pcie-rockchip.h | 1 + 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/pci/controller/pcie-rockchip-ep.c +5 -5
@@ -314,15 +314,15 @@ static int rockchip_pcie_ep_set_msi(stru {struct rockchip_pcie_ep *ep =epc_get_drvdata (epc);struct rockchip_pcie *rockchip = &ep->rockchip; -u16 flags; +u32 flags; flags =rockchip_pcie_read (rockchip,ROCKCHIP_PCIE_EP_FUNC_BASE (fn) +ROCKCHIP_PCIE_EP_MSI_CTRL_REG ); flags &= ~ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_MASK ; flags |= - ((multi_msg_cap <<1 ) <<ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_OFFSET ) | -PCI_MSI_FLAGS_64BIT ; + (multi_msg_cap <<ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_OFFSET ) | + (PCI_MSI_FLAGS_64BIT <<ROCKCHIP_PCIE_EP_MSI_FLAGS_OFFSET ); flags &= ~ROCKCHIP_PCIE_EP_MSI_CTRL_MASK_MSI_CAP ; rockchip_pcie_write(rockchip, flags, ROCKCHIP_PCIE_EP_FUNC_BASE(fn) +
@@ -334,7 +334,7 @@ static int rockchip_pcie_ep_get_msi(stru {struct rockchip_pcie_ep *ep =epc_get_drvdata (epc);struct rockchip_pcie *rockchip = &ep->rockchip; -u16 flags; +u32 flags; flags = rockchip_pcie_read(rockchip, ROCKCHIP_PCIE_EP_FUNC_BASE(fn) +
@@ -395,7 +395,7 @@ static int rockchip_pcie_ep_send_msi_irq u8 interrupt_num) {struct rockchip_pcie *rockchip = &ep->rockchip; -u16 flags, mme, data, data_mask; +u32 flags, mme, data, data_mask;u8 msi_count;u64 pci_addr, pci_addr_mask =0xff ;
drivers/pci/controller/pcie-rockchip.h +1 -0
@@ -226,6 +226,7 @@#define ROCKCHIP_PCIE_EP_CMD_STATUS 0x4#define ROCKCHIP_PCIE_EP_CMD_STATUS_IS BIT(19)#define ROCKCHIP_PCIE_EP_MSI_CTRL_REG 0x90 +#define ROCKCHIP_PCIE_EP_MSI_FLAGS_OFFSET 16#define ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_OFFSET 17#define ROCKCHIP_PCIE_EP_MSI_CTRL_MMC_MASK GENMASK(19, 17)#define ROCKCHIP_PCIE_EP_MSI_CTRL_MME_OFFSET 20
Greg Kroah-Hartman
maintainerPATCH 480/532 PCI: rockchip: Set address alignment for endpoint mode
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
commit 7e6689b34a815bd379dfdbe9855d36f395ef056c upstream.
The address translation unit of the rockchip EP controller does not use the lower 8 bits of a PCIe-space address to map local memory. Thus we must set the align feature field to 256 to let the user know about this constraint.
--- drivers/pci/controller/pcie-rockchip-ep.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/pcie-rockchip-ep.c +1 -0
@@ -485,6 +485,7 @@ static const struct pci_epc_features roc .linkup_notifier = false, .msi_capable = true, .msix_capable = false, + .align = 256, }; static const struct pci_epc_features*
Greg Kroah-Hartman
maintainerPATCH 481/532 misc: pci_endpoint_test: Free IRQs before removing the device
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
commit f61b7634a3249d12b9daa36ffbdb9965b6f24c6c upstream.
In pci_endpoint_test_remove(), freeing the IRQs after removing the device creates a small race window for IRQs to be received with the test device memory already released, causing the IRQ handler to access invalid memory, resulting in an oops.
Free the device IRQs before removing the device to avoid this issue.
--- drivers/misc/pci_endpoint_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/misc/pci_endpoint_test.c +3 -3
@@ -937,6 +937,9 @@ static void pci_endpoint_test_remove(strif (id <0 )return ; +pci_endpoint_test_release_irq (test); +pci_endpoint_test_free_irq_vectors (test); +misc_deregister (&test->miscdev);kfree (misc_device->name);kfree (test->name);
@@ -946,9 +949,6 @@ static void pci_endpoint_test_remove(strpci_iounmap (pdev, test->bar[bar]); } -pci_endpoint_test_release_irq (test); -pci_endpoint_test_free_irq_vectors (test); -pci_release_regions (pdev);pci_disable_device (pdev); }
Greg Kroah-Hartman
maintainerPATCH 482/532 misc: pci_endpoint_test: Re-init completion for every test
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
commit fb620ae73b70c2f57b9d3e911fc24c024ba2324f upstream.
The irq_raised completion used to detect the end of a test case is initialized when the test device is probed, but never reinitialized again before a test case. As a result, the irq_raised completion synchronization is effective only for the first ioctl test case executed. Any subsequent call to wait_for_completion() by another ioctl() call will immediately return, potentially too early, leading to false positive failures.
Fix this by reinitializing the irq_raised completion before starting a new ioctl() test command.
--- drivers/misc/pci_endpoint_test.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/misc/pci_endpoint_test.c +4 -0
@@ -728,6 +728,10 @@ static long pci_endpoint_test_ioctl(strustruct pci_dev *pdev = test->pdev;mutex_lock (&test->mutex); + +reinit_completion (&test->irq_raised); + test->last_irq = -ENODATA ; +switch (cmd) {case PCITEST_BAR : bar = arg;
Greg Kroah-Hartman
maintainerPATCH 483/532 mfd: pm8008: Fix module autoloading
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit d420c9886f5369697047b880221789bf0054e438 upstream.
Add the missing module device table alias to that the driver can be autoloaded when built as a module.
--- drivers/mfd/qcom-pm8008.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/qcom-pm8008.c +1 -0
@@ -233,6 +233,7 @@ static const struct of_device_id pm8008_ { .compatible = "qcom,pm8008", }, { }, }; +MODULE_DEVICE_TABLE (of, pm8008_match);static struct i2c_driver pm8008_mfd_driver = { .driver = {
Greg Kroah-Hartman
maintainerPATCH 484/532 md/raid0: add discard support for the original layout
In reply to Greg Kroah-HartmanFrom: Jason Baron <[email protected]>
commit e836007089ba8fdf24e636ef2b007651fb4582e6 upstream.
We've found that using raid0 with the 'original' layout and discard enabled with different disk sizes (such that at least two zones are created) can result in data corruption. This is due to the fact that the discard handling in 'raid0_handle_discard()' assumes the 'alternate' layout. We've seen this corruption using ext4 but other filesystems are likely susceptible as well.
More specifically, while multiple zones are necessary to create the corruption, the corruption may not occur with multiple zones if they layout in such a way the layout matches what the 'alternate' layout would have produced. Thus, not all raid0 devices with the 'original' layout, different size disks and discard enabled will encounter this corruption.
The 3.14 kernel inadvertently changed the raid0 disk layout for different size disks. Thus, running a pre-3.14 kernel and post-3.14 kernel on the same raid0 array could corrupt data. This lead to the creation of the 'original' layout (to match the pre-3.14 layout) and the 'alternate' layout (to match the post 3.14 layout) in the 5.4 kernel time frame and an option to tell the kernel which layout to use (since it couldn't be autodetected). However, when the 'original' layout was added back to 5.4 discard support for the 'original' layout was not added leading this issue.
I've been able to reliably reproduce the corruption with the following test case:
1. create raid0 array with different size disks using original layout
2. mkfs
3. mount -o discard
4. create lots of files
5. remove 1/2 the files
6. fstrim -a (or just the mount point for the raid0 array)
7. umount
8. fsck -fn /dev/md0 (spews all sorts of corruptions)
Let's fix this by adding proper discard support to the 'original' layout. The fix 'maps' the 'original' layout disks to the order in which they are read/written such that we can compare the disks in the same way that the current 'alternate' layout does. A 'disk_shift' field is added to 'struct strip_zone'. This could be computed on the fly in raid0_handle_discard() but by adding this field, we save some computation in the discard path.
Note we could also potentially fix this by re-ordering the disks in the zones that follow the first one, and then always read/writing them using the 'alternate' layout. However, that is seen as a more substantial change, and we are attempting the least invasive fix at this time to remedy the corruption.
I've verified the change using the reproducer mentioned above. Typically, the corruption is seen after less than 3 iterations, while the patch has run 500+ iterations.
--- drivers/md/raid0.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++------- drivers/md/raid0.h | 1 2 files changed, 55 insertions(+), 8 deletions(-)
drivers/md/raid0.c +54 -8
@@ -274,6 +274,18 @@ static int create_strip_zones(struct mdd goto abort; } +if (conf->layout ==RAID0_ORIG_LAYOUT ) { +for (i =1 ; i < conf->nr_strip_zones; i++) { +sector_t first_sector = conf->strip_zone[i-1 ].zone_end; + +sector_div (first_sector, mddev->chunk_sectors); + zone = conf->strip_zone + i; +/* disk_shift is first disk index used in the zone */ + zone->disk_shift =sector_div (first_sector, + zone->nb_dev); + } + } +pr_debug ("md/raid0:%s: done.\n" ,mdname (mddev)); *private_conf = conf;
@@ -444,6 +456,20 @@ exit_acct_set:return ret; } +/* +* Convert disk_index to the disk order in which it is read/written. +* For example, if we have 4 disks, they are numbered 0,1,2,3. If we +* write the disks starting at disk 3, then the read/write order would +* be disk 3, then 0, then 1, and then disk 2 and we want map_disk_shift() +* to map the disks as follows 0,1,2,3 => 1,2,3,0. So disk 0 would map +* to 1, 1 to 2, 2 to 3, and 3 to 0. That way we can compare disks in +* that 'output' space to understand the read/write disk ordering. +*/ +static int map_disk_shift (int disk_index,int num_disks,int disk_shift) +{ +return ((disk_index + num_disks - disk_shift) % num_disks); +} +static void raid0_handle_discard (struct mddev *mddev,struct bio *bio) {struct r0conf *conf = mddev->private;
@@ -457,7 +483,9 @@ static void raid0_handle_discard(structsector_t end_disk_offset;unsigned int end_disk_index;unsigned int disk; +sector_t orig_start, orig_end; + orig_start = start; zone =find_zone (conf, &start);if (bio_end_sector (bio) > zone->zone_end) {
@@ -471,6 +499,7 @@ static void raid0_handle_discard(struct }else end =bio_end_sector (bio); + orig_end = end;if (zone != conf->strip_zone) end = end - zone[-1 ].zone_end;
@@ -482,13 +511,26 @@ static void raid0_handle_discard(struct last_stripe_index = end;sector_div (last_stripe_index, stripe_size); - start_disk_index = (int )(start - first_stripe_index * stripe_size) / - mddev->chunk_sectors; +/* In the first zone the original and alternate layouts are the same */ +if ((conf->layout ==RAID0_ORIG_LAYOUT ) && (zone != conf->strip_zone)) { +sector_div (orig_start, mddev->chunk_sectors); + start_disk_index =sector_div (orig_start, zone->nb_dev); + start_disk_index =map_disk_shift (start_disk_index, + zone->nb_dev, + zone->disk_shift); +sector_div (orig_end, mddev->chunk_sectors); + end_disk_index =sector_div (orig_end, zone->nb_dev); + end_disk_index =map_disk_shift (end_disk_index, + zone->nb_dev, zone->disk_shift); + }else { + start_disk_index = (int )(start - first_stripe_index * stripe_size) / + mddev->chunk_sectors; + end_disk_index = (int )(end - last_stripe_index * stripe_size) / + mddev->chunk_sectors; + } start_disk_offset = ((int )(start - first_stripe_index * stripe_size) % mddev->chunk_sectors) + first_stripe_index * mddev->chunk_sectors; - end_disk_index = (int )(end - last_stripe_index * stripe_size) / - mddev->chunk_sectors; end_disk_offset = ((int )(end - last_stripe_index * stripe_size) % mddev->chunk_sectors) + last_stripe_index * mddev->chunk_sectors;
@@ -496,18 +538,22 @@ static void raid0_handle_discard(structfor (disk =0 ; disk < zone->nb_dev; disk++) {sector_t dev_start, dev_end;struct md_rdev *rdev; +int compare_disk; + + compare_disk =map_disk_shift (disk, zone->nb_dev, + zone->disk_shift); -if (disk < start_disk_index) +if (compare_disk < start_disk_index) dev_start = (first_stripe_index +1 ) * mddev->chunk_sectors; -else if (disk > start_disk_index) +else if (compare_disk > start_disk_index) dev_start = first_stripe_index * mddev->chunk_sectors;else dev_start = start_disk_offset; -if (disk < end_disk_index) +if (compare_disk < end_disk_index) dev_end = (last_stripe_index +1 ) * mddev->chunk_sectors; -else if (disk > end_disk_index) +else if (compare_disk > end_disk_index) dev_end = last_stripe_index * mddev->chunk_sectors;else dev_end = end_disk_offset;
drivers/md/raid0.h +1 -0
@@ -6,6 +6,7 @@ struct strip_zone {sector_t zone_end;/* Start of the next zone (in sectors) */ sector_t dev_start;/* Zone offset in real dev (in sectors) */ int nb_dev;/* # of devices attached to the zone */ +int disk_shift;/* start disk for the original layout */ };/* Linux 3.14 (20d0189b101) made an unintended change to
Greg Kroah-Hartman
maintainerPATCH 485/532 dm init: add dm-mod.waitfor to wait for asynchronously probed block devices
In reply to Greg Kroah-HartmanFrom: Peter Korsgaard <[email protected]>
commit 035641b01e72af4f6c6cf22a4bdb5d7dfc4e8e8e upstream.
Just calling wait_for_device_probe() is not enough to ensure that asynchronously probed block devices are available (E.G. mmc, usb), so add a "dm-mod.waitfor=<device1>[,..,<deviceN>]" parameter to get dm-init to explicitly wait for specific block devices before initializing the tables with logic similar to the rootwait logic that was introduced with commit cc1ed7542c8c ("init: wait for asynchronously scanned block devices").
E.G. with dm-verity on mmc using:
dm-mod.waitfor="PARTLABEL=hash-a,PARTLABEL=root-a"
[ 0.671671] device-mapper: init: waiting for all devices to be available before creating mapped devices [ 0.671679] device-mapper: init: waiting for device PARTLABEL=hash-a ... [ 0.710695] mmc0: new HS200 MMC card at address 0001 [ 0.711158] mmcblk0: mmc0:0001 004GA0 3.69 GiB [ 0.715954] mmcblk0boot0: mmc0:0001 004GA0 partition 1 2.00 MiB [ 0.722085] mmcblk0boot1: mmc0:0001 004GA0 partition 2 2.00 MiB [ 0.728093] mmcblk0rpmb: mmc0:0001 004GA0 partition 3 512 KiB, chardev (249:0) [ 0.738274] mmcblk0: p1 p2 p3 p4 p5 p6 p7 [ 0.751282] device-mapper: init: waiting for device PARTLABEL=root-a ... [ 0.751306] device-mapper: init: all devices available [ 0.751683] device-mapper: verity: sha256 using implementation "sha256-generic" [ 0.759344] device-mapper: ioctl: dm-0 (vroot) is ready [ 0.766540] VFS: Mounted root (squashfs filesystem) readonly on device 254:0.
--- Documentation/admin-guide/device-mapper/dm-init.rst | 8 +++++++ drivers/md/dm-init.c | 22 +++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
Documentation/admin-guide/device-mapper/dm-init.rst +8 -0
@@ -123,3 +123,11 @@ Other examples (per target): 0 1638400 verity 1 8:1 8:2 4096 4096 204800 1 sha256 fb1a5a0f00deb908d8b53cb270858975e76cf64105d412ce764225d53b8f3cfd 51934789604d1b92399c52e7cb149d1b3a1b74bbbcb103b2a0aaacbed5c08584 + +For setups using device-mapper on top of asynchronously probed block +devices (MMC, USB, ..), it may be necessary to tell dm-init to +explicitly wait for them to become available before setting up the +device-mapper tables. This can be done with the "dm-mod.waitfor=" +module parameter, which takes a list of devices to wait for:: + + dm-mod.waitfor=<device1>[,..,<deviceN>]
drivers/md/dm-init.c +21 -1
@@ -8,6 +8,7 @@*/ #include <linux/ctype.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/device-mapper.h> #include <linux/init.h>
@@ -18,12 +19,17 @@#define DM_MAX_DEVICES 256#define DM_MAX_TARGETS 256#define DM_MAX_STR_SIZE 4096 +#define DM_MAX_WAITFOR 256static char *create; +static char *waitfor[DM_MAX_WAITFOR ]; +/* * Format: dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+] * Table format: <start_sector> <num_sectors> <target_type> <target_args> +* Block devices to wait for to become available before setting up tables: +* dm-mod.waitfor=<device1>[,..,<deviceN>] * * See Documentation/admin-guide/device-mapper/dm-init.rst for dm-mod.create="..." format * details.
@@ -266,7 +272,7 @@ static int __init dm_init_init(void)struct dm_device *dev;LIST_HEAD (devices);char *str; -int r; +int i, r;if (!create)return 0 ;
@@ -286,6 +292,17 @@ static int __init dm_init_init(void)DMINFO ("waiting for all devices to be available before creating mapped devices" );wait_for_device_probe (); +for (i =0 ; i <ARRAY_SIZE (waitfor); i++) { +if (waitfor[i]) { +DMINFO ("waiting for device %s ..." , waitfor[i]); +while (!dm_get_dev_t (waitfor[i])) +msleep (5 ); + } + } + +if (waitfor[0 ]) +DMINFO ("all devices available" ); +list_for_each_entry (dev, &devices, list) {if (dm_early_create (&dev->dmi, dev->table, dev->target_args_array))
@@ -301,3 +318,6 @@ late_initcall(dm_init_init);module_param (create, charp,0 );MODULE_PARM_DESC (create,"Create a mapped device in early boot" ); + +module_param_array (waitfor, charp,NULL ,0 ); +MODULE_PARM_DESC (waitfor,"Devices to wait for before setting up tables" );
Greg Kroah-Hartman
maintainerPATCH 486/532 fs: dlm: return positive pid value for F_GETLK
In reply to Greg Kroah-HartmanFrom: Alexander Aring <[email protected]>
commit 92655fbda5c05950a411eaabc19e025e86e2a291 upstream.
The GETLK pid values have all been negated since commit 9d5b86ac13c5 ("fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks"). Revert this for local pids, and leave in place negative pids for remote owners.
--- fs/dlm/plock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/dlm/plock.c +3 -1
@@ -363,7 +363,9 @@ int dlm_posix_get(dlm_lockspace_t *lockslocks_init_lock (fl); fl->fl_type = (op->info.ex) ?F_WRLCK :F_RDLCK ; fl->fl_flags =FL_POSIX ; - fl->fl_pid = -op->info.pid; + fl->fl_pid = op->info.pid; +if (op->info.nodeid !=dlm_our_nodeid ()) + fl->fl_pid = -fl->fl_pid; fl->fl_start = op->info.start; fl->fl_end = op->info.end; rv =0 ;
Greg Kroah-Hartman
maintainerPATCH 487/532 drm/atomic: Allow vblank-enabled + self-refresh "disable"
In reply to Greg Kroah-HartmanFrom: Brian Norris <[email protected]>
commit 9d0e3cac3517942a6e00eeecfe583a98715edb16 upstream.
The self-refresh helper framework overloads "disable" to sometimes mean "go into self-refresh mode," and this mode activates automatically (e.g., after some period of unchanging display output). In such cases, the display pipe is still considered "on", and user-space is not aware that we went into self-refresh mode. Thus, users may expect that vblank-related features (such as DRM_IOCTL_WAIT_VBLANK) still work properly.
However, we trigger the WARN_ONCE() here if a CRTC driver tries to leave vblank enabled.
Add a different expectation: that CRTCs *should* leave vblank enabled when going into self-refresh.
This patch is preparation for another patch -- "drm/rockchip: vop: Leave vblank enabled in self-refresh" -- which resolves conflicts between the above self-refresh behavior and the API tests in IGT's kms_vblank test module.
== Some alternatives discussed: ==
It's likely that on many display controllers, vblank interrupts will turn off when the CRTC is disabled, and so in some cases, self-refresh may not support vblank. To support such cases, we might consider additions to the generic helpers such that we fire vblank events based on a timer.
However, there is currently only one driver using the common self-refresh helpers (i.e., rockchip), and at least as of commit bed030a49f3e ("drm/rockchip: Don't fully disable vop on self refresh"), the CRTC hardware is powered enough to continue to generate vblank interrupts.
So we chose the simpler option of leaving vblank interrupts enabled. We can reevaluate this decision and perhaps augment the helpers if/when we gain a second driver that has different requirements.
v3:
* include discussion summary
v2:
* add 'ret != 0' warning case for self-refresh
* describe failing test case and relation to drm/rockchip patch better
# vblank enabled in self-refresh" Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Sean Paul <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20230109171809.v3.1.I3904f697863649eb1be540ecca147a66e42bfad7@changeid Signed-off-by: Greg Kroah-Hartman <[email protected]> --- drivers/gpu/drm/drm_atomic_helper.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_helper.c +10 -1
@@ -1115,7 +1115,16 @@ disable_outputs(struct drm_device *dev,continue ; ret =drm_crtc_vblank_get (crtc); -WARN_ONCE (ret != -EINVAL ,"driver forgot to call drm_crtc_vblank_off()\n" ); +/* +* Self-refresh is not a true "disable"; ensure vblank remains +* enabled. +*/ +if (new_crtc_state->self_refresh_active) +WARN_ONCE (ret !=0 , +"driver disabled vblank in self-refresh\n" ); +else +WARN_ONCE (ret != -EINVAL , +"driver forgot to call drm_crtc_vblank_off()\n" );if (ret ==0 )drm_crtc_vblank_put (crtc); }
Greg Kroah-Hartman
maintainerPATCH 488/532 drm/rockchip: vop: Leave vblank enabled in self-refresh
In reply to Greg Kroah-HartmanFrom: Brian Norris <[email protected]>
commit 2bdba9d4a3baa758c2ca7f5b37b35c7b3391dc42 upstream.
If we disable vblank when entering self-refresh, vblank APIs (like DRM_IOCTL_WAIT_VBLANK) no longer work. But user space is not aware when we enter self-refresh, so this appears to be an API violation -- that DRM_IOCTL_WAIT_VBLANK fails with EINVAL whenever the display is idle and enters self-refresh.
The downstream driver used by many of these systems never used to disable vblank for PSR, and in fact, even upstream, we didn't do that until radically redesigning the state machine in commit 6c836d965bad ("drm/rockchip: Use the helpers for PSR").
Thus, it seems like a reasonable API fix to simply restore that behavior, and leave vblank enabled.
Note that this appears to potentially unbalance the drm_crtc_vblank_{off,on}() calls in some cases, but:
(a) drm_crtc_vblank_on() documents this as OK and
(b) if I do the naive balancing, I find state machine issues such that we're not in sync properly; so it's easier to take advantage of (a).
This issue was exposed by IGT's kms_vblank tests, and reported by KernelCI. The bug has been around a while (longer than KernelCI noticed), but was only exposed once self-refresh was bugfixed more recently, and so KernelCI could properly test it. Some other notes in:
https://lore.kernel.org/dri-devel/[email protected]/
Re: renesas/master bisection: igt-kms-rockchip.kms_vblank.pipe-A-wait-forked on rk3399-gru-kevin
== Backporting notes: ==
Marking as 'Fixes' commit 6c836d965bad ("drm/rockchip: Use the helpers for PSR"), but it probably depends on commit bed030a49f3e ("drm/rockchip: Don't fully disable vop on self refresh") as well.
We also need the previous patch ("drm/atomic: Allow vblank-enabled + self-refresh "disable""), of course.
v3:
* no update
v2:
* skip unnecessary lock/unlock
--- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +4 -4
@@ -703,13 +703,13 @@ static void vop_crtc_atomic_disable(struif (crtc->state->self_refresh_active)rockchip_drm_set_win_enabled (crtc, false); +if (crtc->state->self_refresh_active) + goto out; +mutex_lock (&vop->vop_lock);drm_crtc_vblank_off (crtc); -if (crtc->state->self_refresh_active) - goto out; -/* * Vop standby will take effect at end of current frame, * if dsp hold valid irq happen, it means standby complete.
@@ -741,9 +741,9 @@ static void vop_crtc_atomic_disable(struvop_core_clks_disable (vop);pm_runtime_put (vop->dev); -out:mutex_unlock (&vop->vop_lock); +out:if (crtc->state->event && !crtc->state->active) {spin_lock_irq (&crtc->dev->event_lock);drm_crtc_send_vblank_event (crtc, crtc->state->event);
Greg Kroah-Hartman
maintainerPATCH 489/532 drm/amdgpu: fix clearing mappings for BOs that are always valid in VM
In reply to Greg Kroah-HartmanFrom: Samuel Pitoiset <[email protected]>
commit ea2c3c08554601b051d91403a241266e1cf490a5 upstream.
Per VM BOs must be marked as moved or otherwise their ranges are not updated on use which might be necessary when the replace operation splits mappings.
This fixes random GPU hangs when replacing sparse mappings from the userspace, while OP_MAP/OP_UNMAP works fine because always valid BOs are correctly handled there.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +12 -0
@@ -2575,18 +2575,30 @@ int amdgpu_vm_bo_clear_mappings(struct a/* Insert partial mapping before the range */ if (!list_empty (&before->list)) { +struct amdgpu_bo *bo = before->bo_va->base.bo; +amdgpu_vm_it_insert (before, &vm->va);if (before->flags &AMDGPU_PTE_PRT )amdgpu_vm_prt_get (adev); + +if (bo && bo->tbo.base.resv == vm->root.bo->tbo.base.resv && + !before->bo_va->base.moved) +amdgpu_vm_bo_moved (&before->bo_va->base); }else {kfree (before); }/* Insert partial mapping after the range */ if (!list_empty (&after->list)) { +struct amdgpu_bo *bo = after->bo_va->base.bo; +amdgpu_vm_it_insert (after, &vm->va);if (after->flags &AMDGPU_PTE_PRT )amdgpu_vm_prt_get (adev); + +if (bo && bo->tbo.base.resv == vm->root.bo->tbo.base.resv && + !after->bo_va->base.moved) +amdgpu_vm_bo_moved (&after->bo_va->base); }else {kfree (after); }
Greg Kroah-Hartman
maintainerPATCH 490/532 drm/amd/display: Correct `DMUB_FW_VERSION` macro
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit 274d205cb59f43815542e04b42a9e6d0b9b95eff upstream.
The DMUB_FW_VERSION macro has a mistake in that the revision field is off by one byte. The last byte is typically used for other purposes and not a revision.
--- drivers/gpu/drm/amd/display/dmub/dmub_srv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dmub/dmub_srv.h +1 -1
@@ -445,7 +445,7 @@ struct dmub_notification {* of a firmware to know if feature or functionality is supported or present. */ #define DMUB_FW_VERSION (major, minor, revision) \ - ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | ((revision) & 0xFFFF)) + ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | (((revision) & 0xFF) << 8))/** * dmub_srv_create() - creates the DMUB service.
Greg Kroah-Hartman
maintainerPATCH 491/532 drm/amdgpu: avoid restore process run into dead loop.
In reply to Greg Kroah-HartmanFrom: gaba <[email protected]>
commit 8a774fe912ff09e39c2d3a3589c729330113f388 upstream.
In restore process worker, pinned BO cause update PTE fail, then the function re-schedule the restore_work. This will generate dead loop.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3 -0
@@ -2350,6 +2350,9 @@ int amdgpu_amdkfd_gpuvm_restore_process_if (!attachment->is_mapped)continue ; +if (attachment->bo_va->base.bo->tbo.pin_count) +continue ; +kfd_mem_dmaunmap_attachment (mem, attachment); ret =update_gpuvm_pte (mem, attachment, &sync_obj,NULL );if (ret) {
Greg Kroah-Hartman
maintainerPATCH 492/532 drm/ttm: Dont leak a resource on swapout move error
In reply to Greg Kroah-HartmanFrom: Thomas Hellström <[email protected]>
commit a590f03d8de7c4cb7ce4916dc7f2fd10711faabe upstream.
If moving the bo to system for swapout failed, we were leaking a resource. Fix.
--- drivers/gpu/drm/ttm/ttm_bo.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_bo.c +1 -0
@@ -1187,6 +1187,7 @@ int ttm_bo_swapout(struct ttm_buffer_obj ret =ttm_bo_handle_move_mem (bo, evict_mem, true, &ctx, &hop);if (unlikely (ret !=0 )) {WARN (ret == -EMULTIHOP ,"Unexpected multihop in swaput - likely driver bug.\n" ); +ttm_resource_free (bo, &evict_mem); goto out; } }
Greg Kroah-Hartman
maintainerPATCH 493/532 drm/ttm: never consider pinned BOs for eviction&swap
In reply to Greg Kroah-HartmanFrom: Christian König <[email protected]>
commit a2848d08742c8e8494675892c02c0d22acbe3cf8 upstream.
There is a small window where we have already incremented the pin count but not yet moved the bo from the lru to the pinned list.
--- drivers/gpu/drm/ttm/ttm_bo.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/ttm/ttm_bo.c +6 -0
@@ -603,6 +603,12 @@ static bool ttm_bo_evict_swapout_allowab {bool ret = false; +if (bo->pin_count) { + *locked = false; + *busy = false; +return false; + } +if (bo->base.resv == ctx->resv) {dma_resv_assert_held (bo->base.resv);if (ctx->allow_res_evict)
Greg Kroah-Hartman
maintainerPATCH 494/532 serial: atmel: dont enable IRQs prematurely
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 27a826837ec9a3e94cc44bd9328b8289b0fcecd7 upstream.
The atmel_complete_tx_dma() function disables IRQs at the start of the function by calling spin_lock_irqsave(&port->lock, flags); There is no need to disable them a second time using the spin_lock_irq() function and, in fact, doing so is a bug because it will enable IRQs prematurely when we call spin_unlock_irq().
Just use spin_lock/unlock() instead without disabling or enabling IRQs.
--- drivers/tty/serial/atmel_serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/atmel_serial.c +2 -2
@@ -873,11 +873,11 @@ static void atmel_complete_tx_dma(void * port->icount.tx += atmel_port->tx_len; -spin_lock_irq (&atmel_port->lock_tx); +spin_lock (&atmel_port->lock_tx);async_tx_ack (atmel_port->desc_tx); atmel_port->cookie_tx = -EINVAL ; atmel_port->desc_tx =NULL ; -spin_unlock_irq (&atmel_port->lock_tx); +spin_unlock (&atmel_port->lock_tx);if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )uart_write_wakeup (port);
Greg Kroah-Hartman
maintainerPATCH 495/532 tty: serial: samsung_tty: Fix a memory leak in s3c24xx_serial_getclk() in case of error
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
commit a9c09546e903f1068acfa38e1ee18bded7114b37 upstream.
If clk_get_rate() fails, the clk that has just been allocated needs to be freed.
Message-ID: <e4baf6039368f52e5a5453982ddcb9a330fc689e.1686412569.git.christophe.jaillet@wanadoo.fr>
--- drivers/tty/serial/samsung_tty.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/tty/serial/samsung_tty.c +5 -1
@@ -1478,8 +1478,12 @@ static unsigned int s3c24xx_serial_getclcontinue ; rate =clk_get_rate (clk); -if (!rate) +if (!rate) { +dev_err (ourport->port.dev, +"Failed to get clock rate for %s.\n" , clkname); +clk_put (clk);continue ; + }if (ourport->info->has_divslot) {unsigned long div = rate / req_baud;
Greg Kroah-Hartman
maintainerPATCH 496/532 tty: serial: samsung_tty: Fix a memory leak in s3c24xx_serial_getclk() when iterating clk
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
commit 832e231cff476102e8204a9e7bddfe5c6154a375 upstream.
When the best clk is searched, we iterate over all possible clk.
If we find a better match, the previous one, if any, needs to be freed. If a better match has already been found, we still need to free the new one, otherwise it leaks.
Message-ID: <cf3e0053d2fc7391b2d906a86cd01a5ef15fb9dc.1686412569.git.christophe.jaillet@wanadoo.fr>
--- drivers/tty/serial/samsung_tty.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/tty/serial/samsung_tty.c +8 -0
@@ -1509,10 +1509,18 @@ static unsigned int s3c24xx_serial_getcl calc_deviation = -calc_deviation;if (calc_deviation < deviation) { +/* +* If we find a better clk, release the previous one, if +* any. +*/ +if (!IS_ERR (*best_clk)) +clk_put (*best_clk); *best_clk = clk; best_quot = quot; *clk_num = cnt; deviation = calc_deviation; + }else { +clk_put (clk); } }
Greg Kroah-Hartman
maintainerPATCH 497/532 tty: serial: imx: fix rs485 rx after tx
In reply to Greg Kroah-HartmanFrom: Martin Fuzzey <[email protected]>
commit 639949a7031e04c59ec91614eceb9543e9120f43 upstream.
Since commit 79d0224f6bf2 ("tty: serial: imx: Handle RS485 DE signal active high") RS485 reception no longer works after a transmission.
The following scenario shows the problem:
1) Open a port in RS485 mode
2) Receive data from remote (OK)
3) Transmit data to remote (OK)
4) Receive data from remote (Nothing received)
In RS485 mode, imx_uart_start_tx() calls imx_uart_stop_rx() and, when the transmission is complete, imx_uart_stop_tx() calls imx_uart_start_rx().
Since the above commit imx_uart_stop_rx() now sets the loopback bit but imx_uart_start_rx() does not clear it causing the hardware to remain in loopback mode and not receive external data.
Fix this by moving the existing loopback disable code to a helper function and calling it from imx_uart_start_rx() too.
--- drivers/tty/serial/imx.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/tty/serial/imx.c +13 -5
@@ -397,6 +397,16 @@ static void start_hrtimer_ms(struct hrtihrtimer_start (hrt,ms_to_ktime (msec),HRTIMER_MODE_REL ); } +static void imx_uart_disable_loopback_rs485 (struct imx_port *sport) +{ +unsigned int uts; + +/* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ + uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); + uts &= ~UTS_LOOP ; +imx_uart_writel (sport, uts,imx_uart_uts_reg (sport)); +} +/* called with port.lock taken and irqs off */ static void imx_uart_start_rx (struct uart_port *port) {
@@ -418,6 +428,7 @@ static void imx_uart_start_rx(struct uar/* Write UCR2 first as it includes RXEN */ imx_uart_writel (sport, ucr2,UCR2 );imx_uart_writel (sport, ucr1,UCR1 ); +imx_uart_disable_loopback_rs485 (sport); }/* called with port.lock taken and irqs off */
@@ -1394,7 +1405,7 @@ static int imx_uart_startup(struct uart_int retval, i;unsigned long flags;int dma_is_inited =0 ; -u32 ucr1, ucr2, ucr3, ucr4, uts; +u32 ucr1, ucr2, ucr3, ucr4; retval =clk_prepare_enable (sport->clk_per);if (retval)
@@ -1499,10 +1510,7 @@ static int imx_uart_startup(struct uart_imx_uart_writel (sport, ucr2,UCR2 ); } -/* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ - uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); - uts &= ~UTS_LOOP ; -imx_uart_writel (sport, uts,imx_uart_uts_reg (sport)); +imx_uart_disable_loopback_rs485 (sport);spin_unlock_irqrestore (&sport->port.lock, flags);
Greg Kroah-Hartman
maintainerPATCH 498/532 firmware: stratix10-svc: Fix a potential resource leak in svc_create_memory_pool()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
commit 1995f15590ca222f91193ed11461862b450abfd6 upstream.
svc_create_memory_pool() is only called from stratix10_svc_drv_probe(). Most of resources in the probe are managed, but not this memremap() call.
There is also no memunmap() call in the file.
So switch to devm_memremap() to avoid a resource leak.
Message-ID: <[email protected]>
--- drivers/firmware/stratix10-svc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/stratix10-svc.c +1 -1
@@ -622,7 +622,7 @@ svc_create_memory_pool(struct platform_d end =rounddown (sh_memory->addr + sh_memory->size,PAGE_SIZE ); paddr = begin; size = end - begin; - va =memremap (paddr, size,MEMREMAP_WC ); + va =devm_memremap (dev, paddr, size,MEMREMAP_WC );if (!va) {dev_err (dev,"fail to remap shared memory\n" );return ERR_PTR (-EINVAL );
Greg Kroah-Hartman
maintainerPATCH 499/532 libceph: harden msgr2.1 frame segment length checks
In reply to Greg Kroah-HartmanFrom: Ilya Dryomov <[email protected]>
commit a282a2f10539dce2aa619e71e1817570d557fc97 upstream.
ceph_frame_desc::fd_lens is an int array. decode_preamble() thus effectively casts u32 -> int but the checks for segment lengths are written as if on unsigned values. While reading in HELLO or one of the AUTH frames (before authentication is completed), arithmetic in head_onwire_len() can get duped by negative ctrl_len and produce head_len which is less than CEPH_PREAMBLE_LEN but still positive. This would lead to a buffer overrun in prepare_read_control() as the preamble gets copied to the newly allocated buffer of size head_len.
--- net/ceph/messenger_v2.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-)
net/ceph/messenger_v2.c +26 -15
@@ -391,6 +391,8 @@ static int head_onwire_len(int ctrl_len,int head_len;int rem_len; +BUG_ON (ctrl_len <0 || ctrl_len >CEPH_MSG_MAX_CONTROL_LEN ); +if (secure) { head_len =CEPH_PREAMBLE_SECURE_LEN ;if (ctrl_len >CEPH_PREAMBLE_INLINE_LEN ) {
@@ -409,6 +411,10 @@ static int head_onwire_len(int ctrl_len,static int __tail_onwire_len (int front_len,int middle_len,int data_len,bool secure) { +BUG_ON (front_len <0 || front_len >CEPH_MSG_MAX_FRONT_LEN || + middle_len <0 || middle_len >CEPH_MSG_MAX_MIDDLE_LEN || + data_len <0 || data_len >CEPH_MSG_MAX_DATA_LEN ); +if (!front_len && !middle_len && !data_len)return 0 ;
@@ -521,29 +527,34 @@ static int decode_preamble(void *p, stru desc->fd_aligns[i] =ceph_decode_16 (&p); } -/* -* This would fire for FRAME_TAG_WAIT (it has one empty -* segment), but we should never get it as client. -*/ -if (!desc->fd_lens[desc->fd_seg_cnt -1 ]) { -pr_err ("last segment empty\n" ); +if (desc->fd_lens[0 ] <0 || + desc->fd_lens[0 ] >CEPH_MSG_MAX_CONTROL_LEN ) { +pr_err ("bad control segment length %d\n" , desc->fd_lens[0 ]);return -EINVAL ; } - -if (desc->fd_lens[0 ] >CEPH_MSG_MAX_CONTROL_LEN ) { -pr_err ("control segment too big %d\n" , desc->fd_lens[0 ]); +if (desc->fd_lens[1 ] <0 || + desc->fd_lens[1 ] >CEPH_MSG_MAX_FRONT_LEN ) { +pr_err ("bad front segment length %d\n" , desc->fd_lens[1 ]);return -EINVAL ; } -if (desc->fd_lens[1 ] >CEPH_MSG_MAX_FRONT_LEN ) { -pr_err ("front segment too big %d\n" , desc->fd_lens[1 ]); +if (desc->fd_lens[2 ] <0 || + desc->fd_lens[2 ] >CEPH_MSG_MAX_MIDDLE_LEN ) { +pr_err ("bad middle segment length %d\n" , desc->fd_lens[2 ]);return -EINVAL ; } -if (desc->fd_lens[2 ] >CEPH_MSG_MAX_MIDDLE_LEN ) { -pr_err ("middle segment too big %d\n" , desc->fd_lens[2 ]); +if (desc->fd_lens[3 ] <0 || + desc->fd_lens[3 ] >CEPH_MSG_MAX_DATA_LEN ) { +pr_err ("bad data segment length %d\n" , desc->fd_lens[3 ]);return -EINVAL ; } -if (desc->fd_lens[3 ] >CEPH_MSG_MAX_DATA_LEN ) { -pr_err ("data segment too big %d\n" , desc->fd_lens[3 ]); + +/* +* This would fire for FRAME_TAG_WAIT (it has one empty +* segment), but we should never get it as client. +*/ +if (!desc->fd_lens[desc->fd_seg_cnt -1 ]) { +pr_err ("last segment empty, segment count %d\n" , + desc->fd_seg_cnt);return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 500/532 ceph: dont let check_caps skip sending responses for revoke msgs
In reply to Greg Kroah-HartmanFrom: Xiubo Li <[email protected]>
commit 257e6172ab36ebbe295a6c9ee9a9dd0fe54c1dc2 upstream.
If a client sends out a cap update dropping caps with the prior 'seq' just before an incoming cap revoke request, then the client may drop the revoke because it believes it's already released the requested capabilities.
This causes the MDS to wait indefinitely for the client to respond to the revoke. It's therefore always a good idea to ack the cap revoke request with the bumped up 'seq'.
--- fs/ceph/caps.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/ceph/caps.c +9 -0
@@ -3517,6 +3517,15 @@ static void handle_cap_grant(struct inod }BUG_ON (cap->issued & ~cap->implemented); +/* don't let check_caps skip sending a response to MDS for revoke msgs */ +if (le32_to_cpu (grant->op) ==CEPH_CAP_OP_REVOKE ) { + cap->mds_wanted =0 ; +if (cap == ci->i_auth_cap) + check_caps =1 ;/* check auth cap only */ +else + check_caps =2 ;/* check all caps */ + } +if (extra_info->inline_version >0 && extra_info->inline_version >= ci->i_inline_version) { ci->i_inline_version = extra_info->inline_version;
Greg Kroah-Hartman
maintainerPATCH 501/532 xhci: Fix resume issue of some ZHAOXIN hosts
In reply to Greg Kroah-HartmanFrom: Weitao Wang <[email protected]>
commit f927728186f0de1167262d6a632f9f7e96433d1a upstream.
On ZHAOXIN ZX-100 project, xHCI can't work normally after resume from system Sx state. To fix this issue, when resume from system Sx state, reinitialize xHCI instead of restore.
So, Add XHCI_RESET_ON_RESUME quirk for ZX-100 to fix issue of resuming from system Sx state.
Message-ID: <[email protected]>
--- drivers/usb/host/xhci-pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/host/xhci-pci.c +5 -0
@@ -336,6 +336,11 @@ static void xhci_pci_quirks(struct devic pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4)) xhci->quirks |= XHCI_NO_SOFT_RETRY; +if (pdev->vendor ==PCI_VENDOR_ID_ZHAOXIN ) { +if (pdev->device ==0x9202 ) + xhci->quirks |=XHCI_RESET_ON_RESUME ; + } +/* xHC spec requires PCI devices to support D3hot and D3cold */ if (xhci->hci_version >=0x120 ) xhci->quirks |=XHCI_DEFAULT_PM_RUNTIME_ALLOW ;
Greg Kroah-Hartman
maintainerPATCH 502/532 xhci: Fix TRB prefetch issue of ZHAOXIN hosts
In reply to Greg Kroah-HartmanFrom: Weitao Wang <[email protected]>
commit 2a865a652299f5666f3b785cbe758c5f57453036 upstream.
On some ZHAOXIN hosts, xHCI will prefetch TRB for performance improvement. However this TRB prefetch mechanism may cross page boundary, which may access memory not allocated by xHCI driver. In order to fix this issue, two pages was allocated for a segment and only the first page will be used. And add a quirk XHCI_ZHAOXIN_TRB_FETCH for this issue.
Message-ID: <[email protected]>
--- drivers/usb/host/xhci-mem.c | 8 ++++++-- drivers/usb/host/xhci-pci.c | 7 ++++++- drivers/usb/host/xhci.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-)
drivers/usb/host/xhci-mem.c +6 -2
@@ -2454,8 +2454,12 @@ int xhci_mem_init(struct xhci_hcd *xhci,* and our use of dma addresses in the trb_address_map radix tree needs * TRB_SEGMENT_SIZE alignment, so we pick the greater alignment need. */ - xhci->segment_pool =dma_pool_create ("xHCI ring segments" , dev, -TRB_SEGMENT_SIZE ,TRB_SEGMENT_SIZE , xhci->page_size); +if (xhci->quirks &XHCI_ZHAOXIN_TRB_FETCH ) + xhci->segment_pool =dma_pool_create ("xHCI ring segments" , dev, +TRB_SEGMENT_SIZE *2 ,TRB_SEGMENT_SIZE *2 , xhci->page_size *2 ); +else + xhci->segment_pool =dma_pool_create ("xHCI ring segments" , dev, +TRB_SEGMENT_SIZE ,TRB_SEGMENT_SIZE , xhci->page_size);/* See Table 46 and Note on Figure 55 */ xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev,
drivers/usb/host/xhci-pci.c +6 -1
@@ -337,8 +337,13 @@ static void xhci_pci_quirks(struct devic xhci->quirks |=XHCI_NO_SOFT_RETRY ;if (pdev->vendor ==PCI_VENDOR_ID_ZHAOXIN ) { -if (pdev->device ==0x9202 ) +if (pdev->device ==0x9202 ) { xhci->quirks |=XHCI_RESET_ON_RESUME ; + xhci->quirks |=XHCI_ZHAOXIN_TRB_FETCH ; + } + +if (pdev->device ==0x9203 ) + xhci->quirks |=XHCI_ZHAOXIN_TRB_FETCH ; }/* xHC spec requires PCI devices to support D3hot and D3cold */
drivers/usb/host/xhci.h +1 -0
@@ -1906,6 +1906,7 @@ struct xhci_hcd {#define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42)#define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43)#define XHCI_RESET_TO_DEFAULT BIT_ULL(44) +#define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45)unsigned int num_active_eps;unsigned int limit_active_eps;
Greg Kroah-Hartman
maintainerPATCH 503/532 xhci: Show ZHAOXIN xHCI root hub speed correctly
In reply to Greg Kroah-HartmanFrom: Weitao Wang <[email protected]>
commit d9b0328d0b8b8298dfdc97cd8e0e2371d4bcc97b upstream.
Some ZHAOXIN xHCI controllers follow usb3.1 spec, but only support gen1 speed 5Gbps. While in Linux kernel, if xHCI suspport usb3.1, root hub speed will show on 10Gbps.
To fix this issue of ZHAOXIN xHCI platforms, read usb speed ID supported by xHCI to determine root hub speed. And add a quirk XHCI_ZHAOXIN_HOST for this issue.
[fix warning about uninitialized symbol -Mathias]
Message-ID: <[email protected]>
--- drivers/usb/host/xhci-mem.c | 31 ++++++++++++++++++++++++------- drivers/usb/host/xhci-pci.c | 2 ++ drivers/usb/host/xhci.h | 1 + 3 files changed, 27 insertions(+), 7 deletions(-)
drivers/usb/host/xhci-mem.c +24 -7
@@ -2128,7 +2128,7 @@ static void xhci_add_in_port(struct xhci {u32 temp, port_offset, port_count;int i; -u8 major_revision, minor_revision; +u8 major_revision, minor_revision, tmp_minor_revision;struct xhci_hub *rhub;struct device *dev =xhci_to_hcd (xhci)->self.sysdev;struct xhci_port_cap *port_cap;
@@ -2148,6 +2148,15 @@ static void xhci_add_in_port(struct xhci*/ if (minor_revision >0x00 && minor_revision <0x10 ) minor_revision <<=4 ; +/* +* Some zhaoxin's xHCI controller that follow usb3.1 spec +* but only support Gen1. +*/ +if (xhci->quirks &XHCI_ZHAOXIN_HOST ) { + tmp_minor_revision = minor_revision; + minor_revision =0 ; + } + }else if (major_revision <=0x02 ) { rhub = &xhci->usb2_rhub; }else {
@@ -2157,10 +2166,6 @@ static void xhci_add_in_port(struct xhci/* Ignoring port protocol we can't understand. FIXME */ return ; } - rhub->maj_rev =XHCI_EXT_PORT_MAJOR (temp); - -if (rhub->min_rev < minor_revision) - rhub->min_rev = minor_revision;/* Port offset and count in the third dword, see section 7.2 */ temp =readl (addr +2 );
@@ -2179,8 +2184,6 @@ static void xhci_add_in_port(struct xhciif (xhci->num_port_caps > max_caps)return ; - port_cap->maj_rev = major_revision; - port_cap->min_rev = minor_revision; port_cap->psi_count =XHCI_EXT_PORT_PSIC (temp);if (port_cap->psi_count) {
@@ -2201,6 +2204,11 @@ static void xhci_add_in_port(struct xhci XHCI_EXT_PORT_PSIV(port_cap->psi[i - 1]))) port_cap->psi_uid_count++; +if (xhci->quirks &XHCI_ZHAOXIN_HOST && + major_revision ==0x03 && +XHCI_EXT_PORT_PSIV (port_cap->psi[i]) >=5 ) + minor_revision = tmp_minor_revision; + xhci_dbg(xhci, "PSIV:%d PSIE:%d PLT:%d PFD:%d LP:%d PSIM:%d\n", XHCI_EXT_PORT_PSIV(port_cap->psi[i]), XHCI_EXT_PORT_PSIE(port_cap->psi[i]),
@@ -2210,6 +2218,15 @@ static void xhci_add_in_port(struct xhci XHCI_EXT_PORT_PSIM(port_cap->psi[i])); } } + + rhub->maj_rev = major_revision; + +if (rhub->min_rev < minor_revision) + rhub->min_rev = minor_revision; + + port_cap->maj_rev = major_revision; + port_cap->min_rev = minor_revision; +/* cache usb2 port capabilities */ if (major_revision <0x03 && xhci->num_ext_caps < max_caps) xhci->ext_caps[xhci->num_ext_caps++] = temp;
drivers/usb/host/xhci-pci.c +2 -0
@@ -337,6 +337,8 @@ static void xhci_pci_quirks(struct devic xhci->quirks |=XHCI_NO_SOFT_RETRY ;if (pdev->vendor ==PCI_VENDOR_ID_ZHAOXIN ) { + xhci->quirks |=XHCI_ZHAOXIN_HOST ; +if (pdev->device ==0x9202 ) { xhci->quirks |=XHCI_RESET_ON_RESUME ; xhci->quirks |=XHCI_ZHAOXIN_TRB_FETCH ;
drivers/usb/host/xhci.h +1 -0
@@ -1907,6 +1907,7 @@ struct xhci_hcd {#define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43)#define XHCI_RESET_TO_DEFAULT BIT_ULL(44)#define XHCI_ZHAOXIN_TRB_FETCH BIT_ULL(45) +#define XHCI_ZHAOXIN_HOST BIT_ULL(46)unsigned int num_active_eps;unsigned int limit_active_eps;
Greg Kroah-Hartman
maintainerPATCH 504/532 meson saradc: fix clock divider mask length
In reply to Greg Kroah-HartmanFrom: George Stark <[email protected]>
commit c57fa0037024c92c2ca34243e79e857da5d2c0a9 upstream.
According to the datasheets of supported meson SoCs length of ADC_CLK_DIV field is 6-bit. Although all supported SoCs have the register with that field documented later SoCs use external clock rather than ADC internal clock so this patch affects only meson8 family (S8* SoCs).
--- drivers/iio/adc/meson_saradc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/meson_saradc.c +1 -1
@@ -71,7 +71,7 @@#define MESON_SAR_ADC_REG3_PANEL_DETECT_COUNT_MASK GENMASK(20, 18)#define MESON_SAR_ADC_REG3_PANEL_DETECT_FILTER_TB_MASK GENMASK(17, 16)#define MESON_SAR_ADC_REG3_ADC_CLK_DIV_SHIFT 10 -#define MESON_SAR_ADC_REG3_ADC_CLK_DIV_WIDTH 5 +#define MESON_SAR_ADC_REG3_ADC_CLK_DIV_WIDTH 6#define MESON_SAR_ADC_REG3_BLOCK_DLY_SEL_MASK GENMASK(9, 8)#define MESON_SAR_ADC_REG3_BLOCK_DLY_MASK GENMASK(7, 0)
Greg Kroah-Hartman
maintainerPATCH 505/532 opp: Fix use-after-free in lazy_opp_tables after probe deferral
In reply to Greg Kroah-HartmanFrom: Stephan Gerhold <[email protected]>
commit b2a2ab039bd58f51355e33d7d3fc64605d7f870d upstream.
When dev_pm_opp_of_find_icc_paths() in _allocate_opp_table() returns -EPROBE_DEFER, the opp_table is freed again, to wait until all the interconnect paths are available.
However, if the OPP table is using required-opps then it may already have been added to the global lazy_opp_tables list. The error path does not remove the opp_table from the list again.
This can cause crashes later when the provider of the required-opps is added, since we will iterate over OPP tables that have already been freed. E.g.:
Unable to handle kernel NULL pointer dereference when read CPU: 0 PID: 7 Comm: kworker/0:0 Not tainted 6.4.0-rc3 PC is at _of_add_opp_table_v2 (include/linux/of.h:949 drivers/opp/of.c:98 drivers/opp/of.c:344 drivers/opp/of.c:404 drivers/opp/of.c:1032) -> lazy_link_required_opp_table()
Fix this by calling _of_clear_opp_table() to remove the opp_table from the list and clear other allocated resources. While at it, also add the missing mutex_destroy() calls in the error path.
--- drivers/opp/core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/opp/core.c +3 -0
@@ -1249,7 +1249,10 @@ static struct opp_table *_allocate_opp_treturn opp_table; remove_opp_dev: +_of_clear_opp_table (opp_table);_remove_opp_dev (opp_dev, opp_table); +mutex_destroy (&opp_table->genpd_virt_dev_lock); +mutex_destroy (&opp_table->lock); err:kfree (opp_table);return ERR_PTR (ret);
Greg Kroah-Hartman
maintainerPATCH 506/532 soundwire: qcom: fix storing port config out-of-bounds
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 490937d479abe5f6584e69b96df066bc87be92e9 upstream.
The 'qcom_swrm_ctrl->pconfig' has size of QCOM_SDW_MAX_PORTS (14), however we index it starting from 1, not 0, to match real port numbers. This can lead to writing port config past 'pconfig' bounds and overwriting next member of 'qcom_swrm_ctrl' struct. Reported also by smatch:
drivers/soundwire/qcom.c:1269 qcom_swrm_get_port_config() error: buffer overflow 'ctrl->pconfig' 14 <= 14
--- drivers/soundwire/qcom.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/soundwire/qcom.c +2 -1
@@ -146,7 +146,8 @@ struct qcom_swrm_ctrl {u32 intr_mask;u8 rcmd_id;u8 wcmd_id; -struct qcom_swrm_port_config pconfig[QCOM_SDW_MAX_PORTS ]; +/* Port numbers are 1 - 14 */ +struct qcom_swrm_port_config pconfig[QCOM_SDW_MAX_PORTS +1 ];struct sdw_stream_runtime *sruntime[SWRM_MAX_DAIS ];enum sdw_slave_status status[SDW_MAX_DEVICES +1 ];int (*reg_read)(struct qcom_swrm_ctrl *ctrl,int reg,u32 *val);
Greg Kroah-Hartman
maintainerPATCH 507/532 Revert "8250: add support for ASIX devices with a FIFO bug"
In reply to Greg Kroah-HartmanFrom: Jiaqing Zhao <[email protected]>
commit a82d62f708545d22859584e0e0620da8e3759bbc upstream.
This reverts commit eb26dfe8aa7eeb5a5aa0b7574550125f8aa4c3b3.
Commit eb26dfe8aa7e ("8250: add support for ASIX devices with a FIFO bug") merged on Jul 13, 2012 adds a quirk for PCI_VENDOR_ID_ASIX (0x9710). But that ID is the same as PCI_VENDOR_ID_NETMOS defined in 1f8b061050c7 ("[PATCH] Netmos parallel/serial/combo support") merged on Mar 28, 2005. In pci_serial_quirks array, the NetMos entry always takes precedence over the ASIX entry even since it was initially merged, code in that commit is always unreachable.
In my tests, adding the FIFO workaround to pci_netmos_init() makes no difference, and the vendor driver also does not have such workaround. Given that the code was never used for over a decade, it's safe to revert it.
Also, the real PCI_VENDOR_ID_ASIX should be 0x125b, which is used on their newer AX99100 PCIe serial controllers released on 2016. The FIFO workaround should not be intended for these newer controllers, and it was never implemented in vendor driver.
--- drivers/tty/serial/8250/8250.h | 1 - drivers/tty/serial/8250/8250_pci.c | 19 ------------------- drivers/tty/serial/8250/8250_port.c | 11 +++-------- include/linux/serial_8250.h | 1 - 4 files changed, 3 insertions(+), 29 deletions(-)
drivers/tty/serial/8250/8250.h +0 -1
@@ -90,7 +90,6 @@ struct serial8250_config {#define UART_BUG_TXEN BIT(1)/* UART has buggy TX IIR status */ #define UART_BUG_NOMSR BIT(2)/* UART has buggy MSR status bits (Au1x00) */ #define UART_BUG_THRE BIT(3)/* UART has buggy THRE reassertion */ -#define UART_BUG_PARITY BIT(4)/* UART mishandles parity if FIFO enabled */ #define UART_BUG_TXRACE BIT(5)/* UART Tx fails to set remote DR */
drivers/tty/serial/8250/8250_pci.c +0 -19
@@ -1252,14 +1252,6 @@ static int pci_oxsemi_tornado_setup(strureturn pci_default_setup (priv, board, up, idx); } -static int pci_asix_setup (struct serial_private *priv, -const struct pciserial_board *board, -struct uart_8250_port *port,int idx) -{ - port->bugs |=UART_BUG_PARITY ; -return pci_default_setup (priv, board, port, idx); -} -/* Quatech devices have their own extra interface features */ struct quatech_feature {
@@ -2082,7 +2074,6 @@ pci_moxa_setup(struct serial_private *pr#define PCI_DEVICE_ID_WCH_CH355_4S 0x7173#define PCI_VENDOR_ID_AGESTAR 0x5372#define PCI_DEVICE_ID_AGESTAR_9375 0x6872 -#define PCI_VENDOR_ID_ASIX 0x9710#define PCI_DEVICE_ID_BROADCOM_TRUMANAGE 0x160a#define PCI_DEVICE_ID_AMCC_ADDIDATA_APCI7800 0x818e
@@ -2893,16 +2884,6 @@ static struct pci_serial_quirk pci_seria .setup = pci_wch_ch38x_setup, },/* -* ASIX devices with FIFO bug -*/ - { - .vendor = PCI_VENDOR_ID_ASIX, - .device = PCI_ANY_ID, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .setup = pci_asix_setup, - }, -/* * Broadcom TruManage (NetXtreme) */ {
drivers/tty/serial/8250/8250_port.c +3 -8
@@ -2620,11 +2620,8 @@ static unsigned char serial8250_compute_if (c_cflag &CSTOPB ) cval |=UART_LCR_STOP ; -if (c_cflag &PARENB ) { +if (c_cflag &PARENB ) cval |=UART_LCR_PARITY ; -if (up->bugs &UART_BUG_PARITY ) - up->fifo_bug = true; - }if (!(c_cflag &PARODD )) cval |=UART_LCR_EPAR ;#ifdef CMSPAR
@@ -2787,8 +2784,7 @@ serial8250_do_set_termios(struct uart_po up->lcr = cval;/* Save computed LCR */ if (up->capabilities &UART_CAP_FIFO && port->fifosize >1 ) { -/* NOTE: If fifo_bug is not set, a user can set RX_trigger. */ -if ((baud <2400 && !up->dma) || up->fifo_bug) { +if (baud <2400 && !up->dma) { up->fcr &= ~UART_FCR_TRIGGER_MASK ; up->fcr |=UART_FCR_TRIGGER_1 ; }
@@ -3124,8 +3120,7 @@ static int do_set_rxtrig(struct tty_portstruct uart_8250_port *up =up_to_u8250p (uport);int rxtrig; -if (!(up->capabilities &UART_CAP_FIFO ) || uport->fifosize <=1 || - up->fifo_bug) +if (!(up->capabilities &UART_CAP_FIFO ) || uport->fifosize <=1 )return -EINVAL ; rxtrig =bytes_to_fcr_rxtrig (up, bytes);
include/linux/serial_8250.h +0 -1
@@ -98,7 +98,6 @@ struct uart_8250_port {struct list_head list;/* ports on this IRQ */ u32 capabilities;/* port capabilities */ unsigned short bugs;/* port bugs */ -bool fifo_bug;/* min RX trigger if enabled */ unsigned int tx_loadsz;/* transmit fifo load size */ unsigned char acr;unsigned char fcr;
Greg Kroah-Hartman
maintainerPATCH 508/532 bus: ixp4xx: fix IXP4XX_EXP_T1_MASK
In reply to Greg Kroah-HartmanFrom: Jonas Gorski <[email protected]>
commit 6722e46513e0af8e2fff4698f7cb78bc50a9f13f upstream.
The IXP4XX_EXP_T1_MASK was shifted one bit to the right, overlapping IXP4XX_EXP_T2_MASK and leaving bit 29 unused. The offset being wrong is also confirmed at least by the datasheet of IXP45X/46X [1].
Fix this by aligning it to IXP4XX_EXP_T1_SHIFT.
--- drivers/bus/intel-ixp4xx-eb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/intel-ixp4xx-eb.c +1 -1
@@ -33,7 +33,7 @@#define IXP4XX_EXP_TIMING_STRIDE 0x04#define IXP4XX_EXP_CS_EN BIT(31)#define IXP456_EXP_PAR_EN BIT(30)/* Only on IXP45x and IXP46x */ -#define IXP4XX_EXP_T1_MASK GENMASK(28, 27) +#define IXP4XX_EXP_T1_MASK GENMASK(29, 28)#define IXP4XX_EXP_T1_SHIFT 28#define IXP4XX_EXP_T2_MASK GENMASK(27, 26)#define IXP4XX_EXP_T2_SHIFT 26
Signature · 1 line
2.41.0
Greg Kroah-Hartman
maintainerPATCH 509/532 s390/decompressor: fix misaligned symbol build error
In reply to Greg Kroah-HartmanFrom: Heiko Carstens <[email protected]>
commit 938f0c35d7d93a822ab9c9728e3205e8e57409d0 upstream.
Nathan Chancellor reported a kernel build error on Fedora 39:
$ clang --version | head -1 clang version 16.0.5 (Fedora 16.0.5-1.fc39)
$ s390x-linux-gnu-ld --version | head -1 GNU ld version 2.40-1.fc39
$ make -skj"$(nproc)" ARCH=s390 CC=clang CROSS_COMPILE=s390x-linux-gnu- olddefconfig all s390x-linux-gnu-ld: arch/s390/boot/startup.o(.text+0x5b4): misaligned symbol `_decompressor_end' (0x35b0f) for relocation R_390_PC32DBL make[3]: *** [.../arch/s390/boot/Makefile:78: arch/s390/boot/vmlinux] Error 1
It turned out that the problem with misaligned symbols on s390 was fixed with commit 80ddf5ce1c92 ("s390: always build relocatable kernel") for the kernel image, but did not take into account that the decompressor uses its own set of CFLAGS, which come without -fPIE.
Add the -fPIE flag also to the decompresser CFLAGS to fix this.
--- arch/s390/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/s390/Makefile +1 -0
@@ -29,6 +29,7 @@ KBUILD_CFLAGS_DECOMPRESSOR += -fno-delet KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables KBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding KBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector +KBUILD_CFLAGS_DECOMPRESSOR += -fPIE KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member) KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g) KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
Greg Kroah-Hartman
maintainerPATCH 510/532 tracing/histograms: Add histograms to hist_vars if they have referenced variables
In reply to Greg Kroah-HartmanFrom: Mohamed Khalfella <[email protected]>
commit 6018b585e8c6fa7d85d4b38d9ce49a5b67be7078 upstream.
Hist triggers can have referenced variables without having direct variables fields. This can be the case if referenced variables are added for trigger actions. In this case the newly added references will not have field variables. Not taking such referenced variables into consideration can result in a bug where it would be possible to remove hist trigger with variables being refenced. This will result in a bug that is easily reproducable like so
$ cd /sys/kernel/tracing $ echo 'synthetic_sys_enter char[] comm; long id' >> synthetic_events $ echo 'hist:keys=common_pid.execname,id.syscall:vals=hitcount:comm=common_pid.execname' >> events/raw_syscalls/sys_enter/trigger $ echo 'hist:keys=common_pid.execname,id.syscall:onmatch(raw_syscalls.sys_enter).synthetic_sys_enter($comm, id)' >> events/raw_syscalls/sys_enter/trigger $ echo '!hist:keys=common_pid.execname,id.syscall:vals=hitcount:comm=common_pid.execname' >> events/raw_syscalls/sys_enter/trigger
[ 100.263533] ================================================================== [ 100.264634] BUG: KASAN: slab-use-after-free in resolve_var_refs+0xc7/0x180 [ 100.265520] Read of size 8 at addr ffff88810375d0f0 by task bash/439 [ 100.266320] [ 100.266533] CPU: 2 PID: 439 Comm: bash Not tainted 6.5.0-rc1 #4 [ 100.267277] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-20220807_005459-localhost 04/01/2014 [ 100.268561] Call Trace: [ 100.268902] <TASK> [ 100.269189] dump_stack_lvl+0x4c/0x70 [ 100.269680] print_report+0xc5/0x600 [ 100.270165] ? resolve_var_refs+0xc7/0x180 [ 100.270697] ? kasan_complete_mode_report_info+0x80/0x1f0 [ 100.271389] ? resolve_var_refs+0xc7/0x180 [ 100.271913] kasan_report+0xbd/0x100 [ 100.272380] ? resolve_var_refs+0xc7/0x180 [ 100.272920] __asan_load8+0x71/0xa0 [ 100.273377] resolve_var_refs+0xc7/0x180 [ 100.273888] event_hist_trigger+0x749/0x860 [ 100.274505] ? kasan_save_stack+0x2a/0x50 [ 100.275024] ? kasan_set_track+0x29/0x40 [ 100.275536] ? __pfx_event_hist_trigger+0x10/0x10 [ 100.276138] ? ksys_write+0xd1/0x170 [ 100.276607] ? do_syscall_64+0x3c/0x90 [ 100.277099] ? entry_SYSCALL_64_after_hwframe+0x6e/0xd8 [ 100.277771] ? destroy_hist_data+0x446/0x470 [ 100.278324] ? event_hist_trigger_parse+0xa6c/0x3860 [ 100.278962] ? __pfx_event_hist_trigger_parse+0x10/0x10 [ 100.279627] ? __kasan_check_write+0x18/0x20 [ 100.280177] ? mutex_unlock+0x85/0xd0 [ 100.280660] ? __pfx_mutex_unlock+0x10/0x10 [ 100.281200] ? kfree+0x7b/0x120 [ 100.281619] ? ____kasan_slab_free+0x15d/0x1d0 [ 100.282197] ? event_trigger_write+0xac/0x100 [ 100.282764] ? __kasan_slab_free+0x16/0x20 [ 100.283293] ? __kmem_cache_free+0x153/0x2f0 [ 100.283844] ? sched_mm_cid_remote_clear+0xb1/0x250 [ 100.284550] ? __pfx_sched_mm_cid_remote_clear+0x10/0x10 [ 100.285221] ? event_trigger_write+0xbc/0x100 [ 100.285781] ? __kasan_check_read+0x15/0x20 [ 100.286321] ? __bitmap_weight+0x66/0xa0 [ 100.286833] ? _find_next_bit+0x46/0xe0 [ 100.287334] ? task_mm_cid_work+0x37f/0x450 [ 100.287872] event_triggers_call+0x84/0x150 [ 100.288408] trace_event_buffer_commit+0x339/0x430 [ 100.289073] ? ring_buffer_event_data+0x3f/0x60 [ 100.292189] trace_event_raw_event_sys_enter+0x8b/0xe0 [ 100.295434] syscall_trace_enter.constprop.0+0x18f/0x1b0 [ 100.298653] syscall_enter_from_user_mode+0x32/0x40 [ 100.301808] do_syscall_64+0x1a/0x90 [ 100.304748] entry_SYSCALL_64_after_hwframe+0x6e/0xd8 [ 100.307775] RIP: 0033:0x7f686c75c1cb [ 100.310617] Code: 73 01 c3 48 8b 0d 65 3c 10 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 21 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 35 3c 10 00 f7 d8 64 89 01 48 [ 100.317847] RSP: 002b:00007ffc60137a38 EFLAGS: 00000246 ORIG_RAX: 0000000000000021 [ 100.321200] RAX: ffffffffffffffda RBX: 000055f566469ea0 RCX: 00007f686c75c1cb [ 100.324631] RDX: 0000000000000001 RSI: 0000000000000001 RDI: 000000000000000a [ 100.328104] RBP: 00007ffc60137ac0 R08: 00007f686c818460 R09: 000000000000000a [ 100.331509] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000009 [ 100.334992] R13: 0000000000000007 R14: 000000000000000a R15: 0000000000000007 [ 100.338381] </TASK>
We hit the bug because when second hist trigger has was created has_hist_vars() returned false because hist trigger did not have variables. As a result of that save_hist_vars() was not called to add the trigger to trace_array->hist_vars. Later on when we attempted to remove the first histogram find_any_var_ref() failed to detect it is being used because it did not find the second trigger in hist_vars list.
With this change we wait until trigger actions are created so we can take into consideration if hist trigger has variable references. Also, now we check the return value of save_hist_vars() and fail trigger creation if save_hist_vars() fails.
--- kernel/trace/trace_events_hist.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/trace/trace_events_hist.c +5 -3
@@ -5944,13 +5944,15 @@ static int event_hist_trigger_func(strucif (get_named_trigger_data (trigger_data)) goto enable; -if (has_hist_vars (hist_data)) -save_hist_vars (hist_data); - ret =create_actions (hist_data);if (ret) goto out_unreg; +if (has_hist_vars (hist_data) || hist_data->n_var_refs) { +if (save_hist_vars (hist_data)) + goto out_unreg; + } + ret =tracing_map_init (hist_data->map);if (ret) goto out_unreg;
Greg Kroah-Hartman
maintainerPATCH 511/532 tracing: Fix memory leak of iter->temp when reading trace_pipe
In reply to Greg Kroah-HartmanFrom: Zheng Yejian <[email protected]>
commit d5a821896360cc8b93a15bd888fabc858c038dc0 upstream.
kmemleak reports:
unreferenced object 0xffff88814d14e200 (size 256):
comm "cat", pid 336, jiffies 4294871818 (age 779.490s)
hex dump (first 32 bytes):
04 00 01 03 00 00 00 00 08 00 00 00 00 00 00 00 ................
0c d8 c8 9b ff ff ff ff 04 5a ca 9b ff ff ff ff .........Z......
backtrace:
[<ffffffff9bdff18f>] __kmalloc+0x4f/0x140
[<ffffffff9bc9238b>] trace_find_next_entry+0xbb/0x1d0
[<ffffffff9bc9caef>] trace_print_lat_context+0xaf/0x4e0
[<ffffffff9bc94490>] print_trace_line+0x3e0/0x950
[<ffffffff9bc95499>] tracing_read_pipe+0x2d9/0x5a0
[<ffffffff9bf03a43>] vfs_read+0x143/0x520
[<ffffffff9bf04c2d>] ksys_read+0xbd/0x160
[<ffffffff9d0f0edf>] do_syscall_64+0x3f/0x90
[<ffffffff9d2000aa>] entry_SYSCALL_64_after_hwframe+0x6e/0xd8when reading file 'trace_pipe', 'iter->temp' is allocated or relocated in trace_find_next_entry() but not freed before 'trace_pipe' is closed.
To fix it, free 'iter->temp' in tracing_release_pipe().
--- kernel/trace/trace.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/trace.c +1 -0
@@ -6650,6 +6650,7 @@ static int tracing_release_pipe(struct ifree_cpumask_var (iter->started);kfree (iter->fmt); +kfree (iter->temp);mutex_destroy (&iter->mutex);kfree (iter);
Greg Kroah-Hartman
maintainerPATCH 512/532 samples: ftrace: Save required argument registers in sample trampolines
In reply to Greg Kroah-HartmanFrom: Florent Revest <[email protected]>
commit 8564c315876ab86fcaf8e7f558d6a84cb2ce5590 upstream.
The ftrace-direct-too sample traces the handle_mm_fault function whose signature changed since the introduction of the sample. Since:
commit bce617edecad ("mm: do page fault accounting in handle_mm_fault") handle_mm_fault now has 4 arguments. Therefore, the sample trampoline should save 4 argument registers.
s390 saves all argument registers already so it does not need a change but x86_64 needs an extra push and pop.
This also evolves the signature of the tracing function to make it mirror the signature of the traced function.
--- samples/ftrace/ftrace-direct-too.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
samples/ftrace/ftrace-direct-too.c +8 -6
@@ -4,14 +4,14 @@#include <linux/mm.h> /* for handle_mm_fault() */ #include <linux/ftrace.h> -extern void my_direct_func (struct vm_area_struct *vma, -unsigned long address,unsigned int flags); +extern void my_direct_func (struct vm_area_struct *vma,unsigned long address, +unsigned int flags,struct pt_regs *regs); -void my_direct_func (struct vm_area_struct *vma, -unsigned long address,unsigned int flags) +void my_direct_func (struct vm_area_struct *vma,unsigned long address, +unsigned int flags,struct pt_regs *regs) { -trace_printk ("handle mm fault vma=%p address=%lx flags=%x\n" , - vma, address, flags); +trace_printk ("handle mm fault vma=%p address=%lx flags=%x regs=%p\n" , + vma, address, flags, regs); }extern void my_tramp (void *);
@@ -26,7 +26,9 @@ asm (" pushq %rdi\n" " pushq %rsi\n" " pushq %rdx\n" +" pushq %rcx\n" " call my_direct_func\n" +" popq %rcx\n" " popq %rdx\n" " popq %rsi\n" " popq %rdi\n"
Greg Kroah-Hartman
maintainerPATCH 513/532 net: ena: fix shift-out-of-bounds in exponential backoff
In reply to Greg Kroah-HartmanFrom: Krister Johansen <[email protected]>
commit 1e9cb763e9bacf0c932aa948f50dcfca6f519a26 upstream.
The ENA adapters on our instances occasionally reset. Once recently logged a UBSAN failure to console in the process:
UBSAN: shift-out-of-bounds in build/linux/drivers/net/ethernet/amazon/ena/ena_com.c:540:13 shift exponent 32 is too large for 32-bit type 'unsigned int' CPU: 28 PID: 70012 Comm: kworker/u72:2 Kdump: loaded not tainted 5.15.117 Hardware name: Amazon EC2 c5d.9xlarge/, BIOS 1.0 10/16/2017 Workqueue: ena ena_fw_reset_device [ena] Call Trace: <TASK> dump_stack_lvl+0x4a/0x63 dump_stack+0x10/0x16 ubsan_epilogue+0x9/0x36 __ubsan_handle_shift_out_of_bounds.cold+0x61/0x10e ? __const_udelay+0x43/0x50 ena_delay_exponential_backoff_us.cold+0x16/0x1e [ena] wait_for_reset_state+0x54/0xa0 [ena] ena_com_dev_reset+0xc8/0x110 [ena] ena_down+0x3fe/0x480 [ena] ena_destroy_device+0xeb/0xf0 [ena] ena_fw_reset_device+0x30/0x50 [ena] process_one_work+0x22b/0x3d0 worker_thread+0x4d/0x3f0 ? process_one_work+0x3d0/0x3d0 kthread+0x12a/0x150 ? set_kthread_struct+0x50/0x50 ret_from_fork+0x22/0x30 </TASK>
Apparently, the reset delays are getting so large they can trigger a UBSAN panic.
Looking at the code, the current timeout is capped at 5000us. Using a base value of 100us, the current code will overflow after (1<<29). Even at values before 32, this function wraps around, perhaps unintentionally.
Cap the value of the exponent used for this backoff at (1<<16) which is larger than currently necessary, but large enough to support bigger values in the future.
--- drivers/net/ethernet/amazon/ena/ena_com.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/amazon/ena/ena_com.c +3 -0
@@ -35,6 +35,8 @@#define ENA_REGS_ADMIN_INTR_MASK 1 +#define ENA_MAX_BACKOFF_DELAY_EXP 16U +#define ENA_MIN_ADMIN_POLL_US 100#define ENA_MAX_ADMIN_POLL_US 5000
@@ -536,6 +538,7 @@ static int ena_com_comp_status_to_errno(static void ena_delay_exponential_backoff_us (u32 exp,u32 delay_us) { + exp =min_t (u32, exp,ENA_MAX_BACKOFF_DELAY_EXP ); delay_us =max_t (u32,ENA_MIN_ADMIN_POLL_US , delay_us); delay_us =min_t (u32, delay_us * (1U << exp),ENA_MAX_ADMIN_POLL_US );usleep_range (delay_us,2 * delay_us);
Greg Kroah-Hartman
maintainerPATCH 514/532 ring-buffer: Fix deadloop issue on reading trace_pipe
In reply to Greg Kroah-HartmanFrom: Zheng Yejian <[email protected]>
commit 7e42907f3a7b4ce3a2d1757f6d78336984daf8f5 upstream.
Soft lockup occurs when reading file 'trace_pipe':
watchdog: BUG: soft lockup - CPU#6 stuck for 22s! [cat:4488] [...] RIP: 0010:ring_buffer_empty_cpu+0xed/0x170 RSP: 0018:ffff88810dd6fc48 EFLAGS: 00000246 RAX: 0000000000000000 RBX: 0000000000000246 RCX: ffffffff93d1aaeb RDX: ffff88810a280040 RSI: 0000000000000008 RDI: ffff88811164b218 RBP: ffff88811164b218 R08: 0000000000000000 R09: ffff88815156600f R10: ffffed102a2acc01 R11: 0000000000000001 R12: 0000000051651901 R13: 0000000000000000 R14: ffff888115e49500 R15: 0000000000000000 [...] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f8d853c2000 CR3: 000000010dcd8000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __find_next_entry+0x1a8/0x4b0 ? peek_next_entry+0x250/0x250 ? down_write+0xa5/0x120 ? down_write_killable+0x130/0x130 trace_find_next_entry_inc+0x3b/0x1d0 tracing_read_pipe+0x423/0xae0 ? tracing_splice_read_pipe+0xcb0/0xcb0 vfs_read+0x16b/0x490 ksys_read+0x105/0x210 ? __ia32_sys_pwrite64+0x200/0x200 ? switch_fpu_return+0x108/0x220 do_syscall_64+0x33/0x40 entry_SYSCALL_64_after_hwframe+0x61/0xc6
Through the vmcore, I found it's because in tracing_read_pipe(), ring_buffer_empty_cpu() found some buffer is not empty but then it cannot read anything due to "rb_num_of_entries() == 0" always true, Then it infinitely loop the procedure due to user buffer not been filled, see following code path:
tracing_read_pipe() {
... ...
waitagain:
tracing_wait_pipe() // 1. find non-empty buffer here
trace_find_next_entry_inc() // 2. loop here try to find an entry
__find_next_entry()
ring_buffer_empty_cpu(); // 3. find non-empty buffer
peek_next_entry() // 4. but peek always return NULL
ring_buffer_peek()
rb_buffer_peek()
rb_get_reader_page()
// 5. because rb_num_of_entries() == 0 always true here
// then return NULL
// 6. user buffer not been filled so goto 'waitgain'
// and eventually leads to an deadloop in kernel!!!}
By some analyzing, I found that when resetting ringbuffer, the 'entries' of its pages are not all cleared (see rb_reset_cpu()). Then when reducing the ringbuffer, and if some reduced pages exist dirty 'entries' data, they will be added into 'cpu_buffer->overrun' (see rb_remove_pages()), which cause wrong 'overrun' count and eventually cause the deadloop issue.
To fix it, we need to clear every pages in rb_reset_cpu().
--- kernel/trace/ring_buffer.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
kernel/trace/ring_buffer.c +15 -9
@@ -5196,28 +5196,34 @@ unsigned long ring_buffer_size(struct tr }EXPORT_SYMBOL_GPL (ring_buffer_size); +static void rb_clear_buffer_page (struct buffer_page *page) +{ +local_set (&page->write,0 ); +local_set (&page->entries,0 ); +rb_init_page (page->page); + page->read =0 ; +} +static void rb_reset_cpu (struct ring_buffer_per_cpu *cpu_buffer) { +struct buffer_page *page; +rb_head_page_deactivate (cpu_buffer); cpu_buffer->head_page = list_entry(cpu_buffer->pages, struct buffer_page, list); -local_set (&cpu_buffer->head_page->write,0 ); -local_set (&cpu_buffer->head_page->entries,0 ); -local_set (&cpu_buffer->head_page->page->commit,0 ); - - cpu_buffer->head_page->read =0 ; +rb_clear_buffer_page (cpu_buffer->head_page); +list_for_each_entry (page, cpu_buffer->pages, list) { +rb_clear_buffer_page (page); + } cpu_buffer->tail_page = cpu_buffer->head_page; cpu_buffer->commit_page = cpu_buffer->head_page;INIT_LIST_HEAD (&cpu_buffer->reader_page->list);INIT_LIST_HEAD (&cpu_buffer->new_pages); -local_set (&cpu_buffer->reader_page->write,0 ); -local_set (&cpu_buffer->reader_page->entries,0 ); -local_set (&cpu_buffer->reader_page->page->commit,0 ); - cpu_buffer->reader_page->read =0 ; +rb_clear_buffer_page (cpu_buffer->reader_page);local_set (&cpu_buffer->entries_bytes,0 );local_set (&cpu_buffer->overrun,0 );
Greg Kroah-Hartman
maintainerPATCH 515/532 ftrace: Fix possible warning on checking all pages used in ftrace_process_locs()
In reply to Greg Kroah-HartmanFrom: Zheng Yejian <[email protected]>
commit 26efd79c4624294e553aeaa3439c646729bad084 upstream.
As comments in ftrace_process_locs(), there may be NULL pointers in mcount_loc section:
Quoted 4 lines
Some architecture linkers will pad between the different
mcount_locsections of different object files to satisfy alignments. Skip any NULL pointers.
After commit 20e5227e9f55 ("ftrace: allow NULL pointers in mcount_loc"), NULL pointers will be accounted when allocating ftrace pages but skipped before adding into ftrace pages, this may result in some pages not being used. Then after commit 706c81f87f84 ("ftrace: Remove extra helper functions"), warning may occur at:
WARN_ON(pg->next);
To fix it, only warn for case that no pointers skipped but pages not used up, then free those unused pages after releasing ftrace_lock.
--- kernel/trace/ftrace.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-)
kernel/trace/ftrace.c +31 -14
@@ -3192,6 +3192,22 @@ static int ftrace_allocate_records(strucreturn cnt; } +static void ftrace_free_pages (struct ftrace_page *pages) +{ +struct ftrace_page *pg = pages; + +while (pg) { +if (pg->records) { +free_pages ((unsigned long )pg->records, pg->order); + ftrace_number_of_pages -=1 << pg->order; + } + pages = pg->next; +kfree (pg); + pg = pages; + ftrace_number_of_groups--; + } +} +static struct ftrace_page *ftrace_allocate_pages (unsigned long num_to_init) {
@@ -3230,17 +3246,7 @@ ftrace_allocate_pages(unsigned long num_return start_pg; free_pages: - pg = start_pg; -while (pg) { -if (pg->records) { -free_pages ((unsigned long )pg->records, pg->order); - ftrace_number_of_pages -=1 << pg->order; - } - start_pg = pg->next; -kfree (pg); - pg = start_pg; - ftrace_number_of_groups--; - } +ftrace_free_pages (start_pg);pr_info ("ftrace: FAILED to allocate memory for functions\n" );return NULL ; }
@@ -6184,9 +6190,11 @@ static int ftrace_process_locs(struct mounsigned long *start, unsigned long *end) { + struct ftrace_page *pg_unuse = NULL;struct ftrace_page *start_pg;struct ftrace_page *pg;struct dyn_ftrace *rec; +unsigned long skipped =0 ;unsigned long count;unsigned long *p;unsigned long addr;
@@ -6240,8 +6248,10 @@ static int ftrace_process_locs(struct mo* object files to satisfy alignments. * Skip any NULL pointers. */ -if (!addr) +if (!addr) { + skipped++;continue ; + } end_offset = (pg->index+1 ) *sizeof (pg->records[0 ]);if (end_offset >PAGE_SIZE << pg->order) {
@@ -6255,8 +6265,10 @@ static int ftrace_process_locs(struct mo rec->ip = addr; } -/* We should have used all pages */ -WARN_ON (pg->next); +if (pg->next) { + pg_unuse = pg->next; + pg->next =NULL ; + }/* Assign the last page to ftrace_pages */ ftrace_pages = pg;
@@ -6278,6 +6290,11 @@ static int ftrace_process_locs(struct mo out:mutex_unlock (&ftrace_lock); +/* We should have used all pages unless we skipped some */ +if (pg_unuse) { +WARN_ON (!skipped); +ftrace_free_pages (pg_unuse); + }return ret; }
Greg Kroah-Hartman
maintainerPATCH 516/532 xtensa: ISS: fix call to split_if_spec
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit bc8d5916541fa19ca5bc598eb51a5f78eb891a36 upstream.
split_if_spec expects a NULL-pointer as an end marker for the argument list, but tuntap_probe never supplied that terminating NULL. As a result incorrectly formatted interface specification string may cause a crash because of the random memory access. Fix that by adding NULL terminator to the split_if_spec argument list.
--- arch/xtensa/platforms/iss/network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/xtensa/platforms/iss/network.c +1 -1
@@ -231,7 +231,7 @@ static int tuntap_probe(struct iss_net_p init +=sizeof (TRANSPORT_TUNTAP_NAME ) -1 ;if (*init ==',' ) { - rem =split_if_spec (init +1 , &mac_str, &dev_name); + rem =split_if_spec (init +1 , &mac_str, &dev_name,NULL );if (rem !=NULL ) {pr_err ("%s: extra garbage on specification : '%s'\n" , dev->name, rem);
Greg Kroah-Hartman
maintainerPATCH 517/532 tracing: Fix null pointer dereference in tracing_err_log_open()
In reply to Greg Kroah-HartmanFrom: Mateusz Stachyra <[email protected]>
commit 02b0095e2fbbc060560c1065f86a211d91e27b26 upstream.
Fix an issue in function 'tracing_err_log_open'.
The function doesn't call 'seq_open' if the file is opened only with write permissions, which results in 'file->private_data' being left as null. If we then use 'lseek' on that opened file, 'seq_lseek' dereferences 'file->private_data' in 'mutex_lock(&m->lock)', resulting in a kernel panic. Writing to this node requires root privileges, therefore this bug has very little security impact.
Tracefs node: /sys/kernel/tracing/error_log
Example Kernel panic:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000038 Call trace: mutex_lock+0x30/0x110 seq_lseek+0x34/0xb8 __arm64_sys_lseek+0x6c/0xb8 invoke_syscall+0x58/0x13c el0_svc_common+0xc4/0x10c do_el0_svc+0x24/0x98 el0_svc+0x24/0x88 el0t_64_sync_handler+0x84/0xe4 el0t_64_sync+0x1b4/0x1b8 Code: d503201f aa0803e0 aa1f03e1 aa0103e9 (c8e97d02) ---[ end trace 561d1b49c12cf8a5 ]--- Kernel panic - not syncing: Oops: Fatal exception
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -8014,7 +8014,7 @@ static const struct file_operations trac .open = tracing_err_log_open, .write = tracing_err_log_write, .read = seq_read, - .llseek = seq_lseek, + .llseek = tracing_lseek, .release = tracing_err_log_release, };
Greg Kroah-Hartman
maintainerPATCH 518/532 selftests: mptcp: sockopt: return error if wrong mark
In reply to Greg Kroah-HartmanFrom: Matthieu Baerts <[email protected]>
commit 9ac4c28eb70cd5ea5472a5e1c495dcdd597d4597 upstream.
When an error was detected when checking the marks, a message was correctly printed mentioning the error but followed by another one saying everything was OK and the selftest was not marked as failed as expected.
Now the 'ret' variable is directly set to 1 in order to make sure the exit is done with an error, similar to what is done in other functions. While at it, the error is correctly propagated to the caller.
--- tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +5 -4
@@ -119,6 +119,7 @@ check_mark() for v in $values; do if [ $v -ne 0 ]; then echo "FAIL: got $tables $values in ns $ns , not 0 - not all expected packets marked" 1>&2 + ret=1 return 1 fi done
@@ -213,11 +214,11 @@ do_transfer() fi if [ $local_addr = "::" ];then - check_mark $listener_ns 6 - check_mark $connector_ns 6 + check_mark $listener_ns 6 || retc=1 + check_mark $connector_ns 6 || retc=1 else - check_mark $listener_ns 4 - check_mark $connector_ns 4 + check_mark $listener_ns 4 || retc=1 + check_mark $connector_ns 4 || retc=1 fi check_transfer $cin $sout "file received by server"
Greg Kroah-Hartman
maintainerPATCH 519/532 selftests: mptcp: depend on SYN_COOKIES
In reply to Greg Kroah-HartmanFrom: Matthieu Baerts <[email protected]>
commit 6c8880fcaa5c45355179b759c1d11737775e31fc upstream.
MPTCP selftests are using TCP SYN Cookies for quite a while now, since v5.9.
Some CIs don't have this config option enabled and this is causing issues in the tests:
# ns1 MPTCP -> ns1 (10.0.1.1:10000 ) MPTCP (duration 167ms) sysctl: cannot stat /proc/sys/net/ipv4/tcp_syncookies: No such file or directory # [ OK ]./mptcp_connect.sh: line 554: [: -eq: unary operator expected
There is no impact in the results but the test is not doing what it is supposed to do.
--- tools/testing/selftests/net/mptcp/config | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/net/mptcp/config +1 -0
@@ -6,6 +6,7 @@ CONFIG_INET_DIAG=m CONFIG_INET_MPTCP_DIAG=m CONFIG_VETH=y CONFIG_NET_SCH_NETEM=m +CONFIG_SYN_COOKIES=y CONFIG_NETFILTER=y CONFIG_NETFILTER_ADVANCED=y CONFIG_NETFILTER_NETLINK=m
Greg Kroah-Hartman
maintainerPATCH 520/532 tracing/probes: Fix not to count error code to total length
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu (Google) <[email protected]>
commit b41326b5e0f82e93592c4366359917b5d67b529f upstream.
Fix not to count the error code (which is minus value) to the total used length of array, because it can mess up the return code of process_fetch_insn_bottom(). Also clear the 'ret' value because it will be used for calculating next data_loc entry.
--- kernel/trace/trace_probe_tmpl.h | 2 ++ 1 file changed, 2 insertions(+)
kernel/trace/trace_probe_tmpl.h +2 -0
@@ -143,6 +143,8 @@ stage3: array:/* the last stage: Loop on array */ if (code->op ==FETCH_OP_LP_ARRAY ) { +if (ret <0 ) + ret =0 ; total += ret;if (++i < code->param) { code = s3;
Greg Kroah-Hartman
maintainerPATCH 521/532 tracing/probes: Fix to update dynamic data counter if fetcharg uses it
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu (Google) <[email protected]>
commit e38e2c6a9efc435f9de344b7c91f7697e01b47d5 upstream.
Fix to update dynamic data counter ('dyndata') and max length ('maxlen') only if the fetcharg uses the dynamic data. Also get out arg->dynamic from unlikely(). This makes dynamic data address wrong if process_fetch_insn() returns error on !arg->dynamic case.
--- kernel/trace/trace_probe_tmpl.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
kernel/trace/trace_probe_tmpl.h +7 -5
@@ -206,11 +206,13 @@ store_trace_args(void *data, struct tracif (unlikely (arg->dynamic)) *dl =make_data_loc (maxlen, dyndata - base); ret =process_fetch_insn (arg->code, rec, dl, base); -if (unlikely (ret <0 && arg->dynamic)) { - *dl =make_data_loc (0 , dyndata - base); - }else { - dyndata += ret; - maxlen -= ret; +if (arg->dynamic) { +if (unlikely (ret <0 )) { + *dl =make_data_loc (0 , dyndata - base); + }else { + dyndata += ret; + maxlen -= ret; + } } } }
Greg Kroah-Hartman
maintainerPATCH 522/532 scsi: qla2xxx: Wait for io return on terminate rport
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit fc0cba0c7be8261a1625098bd1d695077ec621c9 upstream.
System crash due to use after free.
Current code allows terminate_rport_io to exit before making sure all IOs has returned. For FCP-2 device, IO's can hang on in HW because driver has not tear down the session in FW at first sign of cable pull. When dev_loss_tmo timer pops, terminate_rport_io is called and upper layer is about to free various resources. Terminate_rport_io trigger qla to do the final cleanup, but the cleanup might not be fast enough where it leave qla still holding on to the same resource.
Wait for IO's to return to upper layer before resources are freed.
--- drivers/scsi/qla2xxx/qla_attr.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/scsi/qla2xxx/qla_attr.c +13 -0
@@ -2738,6 +2738,7 @@ static void qla2x00_terminate_rport_io(struct fc_rport *rport) {fc_port_t *fcport = *(fc_port_t **)rport->dd_data; +scsi_qla_host_t *vha;if (!fcport)return ;
@@ -2747,9 +2748,12 @@ qla2x00_terminate_rport_io(struct fc_rpoif (test_bit (ABORT_ISP_ACTIVE , &fcport->vha->dpc_flags))return ; + vha = fcport->vha;if (unlikely (pci_channel_offline (fcport->vha->hw->pdev))) {qla2x00_abort_all_cmds (fcport->vha,DID_NO_CONNECT <<16 ); +qla2x00_eh_wait_for_pending_commands (fcport->vha, fcport->d_id.b24, +0 ,WAIT_TARGET );return ; }/*
@@ -2774,6 +2778,15 @@ qla2x00_terminate_rport_io(struct fc_rpoqla2x00_port_logout (fcport->vha, fcport); } } + +/* check for any straggling io left behind */ +if (qla2x00_eh_wait_for_pending_commands (fcport->vha, fcport->d_id.b24,0 ,WAIT_TARGET )) { +ql_log (ql_log_warn, vha,0x300b , +"IO not return. Resetting. \n" ); +set_bit (ISP_ABORT_NEEDED , &vha->dpc_flags); +qla2xxx_wake_dpc (vha); +qla2x00_wait_for_chip_reset (vha); + } } static int
Greg Kroah-Hartman
maintainerPATCH 523/532 scsi: qla2xxx: Array index may go out of bound
In reply to Greg Kroah-HartmanFrom: Nilesh Javali <[email protected]>
commit d721b591b95cf3f290f8a7cbe90aa2ee0368388d upstream.
Klocwork reports array 'vha->host_str' of size 16 may use index value(s) 16..19. Use snprintf() instead of sprintf().
--- drivers/scsi/qla2xxx/qla_os.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_os.c +2 -1
@@ -5042,7 +5042,8 @@ struct scsi_qla_host *qla2x00_create_hos }INIT_DELAYED_WORK (&vha->scan.scan_work, qla_scan_work_fn); -sprintf (vha->host_str,"%s_%lu" ,QLA2XXX_DRIVER_NAME , vha->host_no); +snprintf (vha->host_str,sizeof (vha->host_str),"%s_%lu" , +QLA2XXX_DRIVER_NAME , vha->host_no); ql_dbg(ql_dbg_init, vha, 0x0041, "Allocated the host=%p hw=%p vha=%p dev_name=%s", vha->host, vha->hw, vha,
Greg Kroah-Hartman
maintainerPATCH 524/532 scsi: qla2xxx: Avoid fcport pointer dereference
In reply to Greg Kroah-HartmanFrom: Nilesh Javali <[email protected]>
commit 6b504d06976fe4a61cc05dedc68b84fadb397f77 upstream.
Klocwork reported warning of NULL pointer may be dereferenced. The routine exits when sa_ctl is NULL and fcport is allocated after the exit call thus causing NULL fcport pointer to dereference at the time of exit.
To avoid fcport pointer dereference, exit the routine when sa_ctl is NULL.
--- drivers/scsi/qla2xxx/qla_edif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_edif.c +2 -2
@@ -2230,8 +2230,8 @@ qla24xx_issue_sa_replace_iocb(scsi_qla_hif (!sa_ctl) {ql_dbg (ql_dbg_edif, vha,0x70e6 ,"sa_ctl allocation failed\n" ); - rval = -ENOMEM ; - goto done; + rval = -ENOMEM ; +return rval; } fcport = sa_ctl->fcport;
Greg Kroah-Hartman
maintainerPATCH 525/532 scsi: qla2xxx: Fix buffer overrun
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
commit b68710a8094fdffe8dd4f7a82c82649f479bb453 upstream.
Klocwork warning: Buffer Overflow - Array Index Out of Bounds
Driver uses fc_els_flogi to calculate size of buffer. The actual buffer is nested inside of fc_els_flogi which is smaller.
Replace structure name to allow proper size calculation.
--- drivers/scsi/qla2xxx/qla_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_init.c +1 -1
@@ -5359,7 +5359,7 @@ static void qla_get_login_template(scsi___be32 *q;memset (ha->init_cb,0 , ha->init_cb_size); - sz =min_t (int,sizeof (struct fc_els_flogi ), ha->init_cb_size); + sz =min_t (int,sizeof (struct fc_els_csp ), ha->init_cb_size); rval =qla24xx_get_port_login_templ (vha, ha->init_cb_dma, ha->init_cb, sz);if (rval !=QLA_SUCCESS ) {
Greg Kroah-Hartman
maintainerPATCH 526/532 scsi: qla2xxx: Fix potential NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Bikash Hazarika <[email protected]>
commit 464ea494a40c6e3e0e8f91dd325408aaf21515ba upstream.
Klocwork tool reported 'cur_dsd' may be dereferenced. Add fix to validate pointer before dereferencing the pointer.
--- drivers/scsi/qla2xxx/qla_iocb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_iocb.c +2 -1
@@ -603,7 +603,8 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sput_unaligned_le32 (COMMAND_TYPE_6 , &cmd_pkt->entry_type);/* No data transfer */ -if (!scsi_bufflen (cmd) || cmd->sc_data_direction ==DMA_NONE ) { +if (!scsi_bufflen (cmd) || cmd->sc_data_direction ==DMA_NONE || + tot_dsds ==0 ) { cmd_pkt->byte_count =cpu_to_le32 (0 );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 527/532 scsi: qla2xxx: Check valid rport returned by fc_bsg_to_rport()
In reply to Greg Kroah-HartmanFrom: Nilesh Javali <[email protected]>
commit af73f23a27206ffb3c477cac75b5fcf03410556e upstream.
Klocwork reported warning of rport maybe NULL and will be dereferenced. rport returned by call to fc_bsg_to_rport() could be NULL and dereferenced.
Check valid rport returned by fc_bsg_to_rport().
--- drivers/scsi/qla2xxx/qla_bsg.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/qla2xxx/qla_bsg.c +4 -0
@@ -283,6 +283,10 @@ qla2x00_process_els(struct bsg_job *bsg_if (bsg_request->msgcode ==FC_BSG_RPT_ELS ) { rport =fc_bsg_to_rport (bsg_job); +if (!rport) { + rval = -ENOMEM ; + goto done; + } fcport = *(fc_port_t **) rport->dd_data; host =rport_to_shost (rport); vha =shost_priv (host);
Greg Kroah-Hartman
maintainerPATCH 528/532 scsi: qla2xxx: Correct the index of array
In reply to Greg Kroah-HartmanFrom: Bikash Hazarika <[email protected]>
commit b1b9d3825df4c757d653d0b1df66f084835db9c3 upstream.
Klocwork reported array 'port_dstate_str' of size 10 may use index value(s) 10..15.
Add a fix to correct the index of array.
--- drivers/scsi/qla2xxx/qla_inline.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_inline.h +4 -1
@@ -109,11 +109,13 @@ qla2x00_set_fcport_disc_state(fc_port_t {int old_val;uint8_t shiftbits, mask; +uint8_t port_dstate_str_sz;/* This will have to change when the max no. of states > 16 */ shiftbits =4 ; mask = (1 << shiftbits) -1 ; + port_dstate_str_sz =sizeof (port_dstate_str) /sizeof (char *); fcport->disc_state = state;while (1 ) { old_val =atomic_read (&fcport->shadow_disc_state);
@@ -121,7 +123,8 @@ qla2x00_set_fcport_disc_state(fc_port_t old_val, (old_val << shiftbits) | state)) {ql_dbg (ql_dbg_disc, fcport->vha,0x2134 ,"FCPort %8phC disc_state transition: %s to %s - portid=%06x.\n" , - fcport->port_name, port_dstate_str[old_val & mask], + fcport->port_name, (old_val & mask) < port_dstate_str_sz ? + port_dstate_str[old_val & mask] :"Unknown" , port_dstate_str[state], fcport->d_id.b24);return ; }
Greg Kroah-Hartman
maintainerPATCH 529/532 scsi: qla2xxx: Pointer may be dereferenced
In reply to Greg Kroah-HartmanFrom: Shreyas Deodhar <[email protected]>
commit 00eca15319d9ce8c31cdf22f32a3467775423df4 upstream.
Klocwork tool reported pointer 'rport' returned from call to function fc_bsg_to_rport() may be NULL and will be dereferenced.
Add a fix to validate rport before dereferencing.
--- drivers/scsi/qla2xxx/qla_bsg.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/qla2xxx/qla_bsg.c +2 -0
@@ -2903,6 +2903,8 @@ qla24xx_bsg_request(struct bsg_job *bsg_if (bsg_request->msgcode ==FC_BSG_RPT_ELS ) { rport =fc_bsg_to_rport (bsg_job); +if (!rport) +return ret; host =rport_to_shost (rport); vha =shost_priv (host); }else {
Greg Kroah-Hartman
maintainerPATCH 530/532 scsi: qla2xxx: Remove unused nvme_ls_waitq wait queue
In reply to Greg Kroah-HartmanFrom: Manish Rangankar <[email protected]>
commit 20fce500b232b970e40312a9c97e7f3b6d7a709c upstream.
System crash when qla2x00_start_sp(sp) returns error code EGAIN and wake_up gets called for uninitialized wait queue sp->nvme_ls_waitq.
qla2xxx [0000:37:00.1]-2121:5: Returning existing qpair of ffff8ae2c0513400 for idx=0
qla2xxx [0000:37:00.1]-700e:5: qla2x00_start_sp failed = 11
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
PGD 0 P4D 0
Oops: 0000 [#1] SMP NOPTI
Hardware name: HPE ProLiant DL360 Gen10/ProLiant DL360 Gen10, BIOS U32 09/03/2021
Workqueue: nvme-wq nvme_fc_connect_ctrl_work [nvme_fc]
RIP: 0010:__wake_up_common+0x4c/0x190
RSP: 0018:ffff95f3e0cb7cd0 EFLAGS: 00010086
RAX: 0000000000000000 RBX: ffff8b08d3b26328 RCX: 0000000000000000
RDX: 0000000000000001 RSI: 0000000000000003 RDI: ffff8b08d3b26320
RBP: 0000000000000001 R08: 0000000000000000 R09: ffffffffffffffe8
R10: 0000000000000000 R11: ffff95f3e0cb7a60 R12: ffff95f3e0cb7d20
R13: 0000000000000003 R14: 0000000000000000 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff8b2fdf6c0000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 0000002f1e410002 CR4: 00000000007706e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
__wake_up_common_lock+0x7c/0xc0
qla_nvme_ls_req+0x355/0x4c0 [qla2xxx]
? __nvme_fc_send_ls_req+0x260/0x380 [nvme_fc]
? nvme_fc_send_ls_req.constprop.42+0x1a/0x45 [nvme_fc]
? nvme_fc_connect_ctrl_work.cold.63+0x1e3/0xa7d [nvme_fc]Remove unused nvme_ls_waitq wait queue. nvme_ls_waitq logic was removed previously in the commits tagged Fixed: below.
--- drivers/scsi/qla2xxx/qla_def.h | 1 - drivers/scsi/qla2xxx/qla_nvme.c | 3 --- 2 files changed, 4 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +0 -1
@@ -676,7 +676,6 @@ typedef struct srb {struct iocb_resource iores;struct kref cmd_kref;/* need to migrate ref_count over to this */ void *priv; -wait_queue_head_t nvme_ls_waitq;struct fc_port *fcport;struct scsi_qla_host *vha; unsigned int start_timer:1;
drivers/scsi/qla2xxx/qla_nvme.c +0 -3
@@ -355,7 +355,6 @@ static int qla_nvme_ls_req(struct nvme_fif (rval !=QLA_SUCCESS ) {ql_log (ql_log_warn, vha,0x700e ,"qla2x00_start_sp failed = %d\n" , rval); -wake_up (&sp->nvme_ls_waitq); sp->priv =NULL ; priv->sp =NULL ;qla2x00_rel_sp (sp);
@@ -637,7 +636,6 @@ static int qla_nvme_post_cmd(struct nvmeif (!sp)return -EBUSY ; -init_waitqueue_head (&sp->nvme_ls_waitq);kref_init (&sp->cmd_kref);spin_lock_init (&priv->cmd_lock); sp->priv = priv;
@@ -656,7 +654,6 @@ static int qla_nvme_post_cmd(struct nvmeif (rval !=QLA_SUCCESS ) {ql_log (ql_log_warn, vha,0x212d ,"qla2x00_start_nvme_mq failed = %d\n" , rval); -wake_up (&sp->nvme_ls_waitq); sp->priv =NULL ; priv->sp =NULL ;qla2xxx_rel_qpair_sp (sp->qpair, sp);
Greg Kroah-Hartman
maintainerPATCH 531/532 MIPS: kvm: Fix build error with KVM_MIPS_DEBUG_COP0_COUNTERS enabled
In reply to Greg Kroah-HartmanFrom: Thomas Bogendoerfer <[email protected]>
commit 3a6dbb691782e88e07e5c70b327495dbd58a2e7f upstream.
Commit e4de20576986 ("MIPS: KVM: Fix NULL pointer dereference") missed converting one place accessing cop0 registers, which results in a build error, if KVM_MIPS_DEBUG_COP0_COUNTERS is enabled.
--- arch/mips/kvm/stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/kvm/stats.c +2 -2
@@ -54,9 +54,9 @@ void kvm_mips_dump_stats(struct kvm_vcpu *vcpu)kvm_info ("\nKVM VCPU[%d] COP0 Access Profile:\n" , vcpu->vcpu_id);for (i =0 ; i <N_MIPS_COPROC_REGS ; i++) {for (j =0 ; j <N_MIPS_COPROC_SEL ; j++) { -if (vcpu->arch.cop0->stat[i][j]) +if (vcpu->arch.cop0.stat[i][j])kvm_info ("%s[%d]: %lu\n" , kvm_cop0_str[i], j, - vcpu->arch.cop0->stat[i][j]); + vcpu->arch.cop0.stat[i][j]); } }#endif
Signature · 1 line
2.41.0
Greg Kroah-Hartman
maintainerPATCH 532/532 net/sched: sch_qfq: reintroduce lmax bound check for MTU
In reply to Greg Kroah-HartmanFrom: Pedro Tammela <[email protected]>
commit 158810b261d02fc7dd92ca9c392d8f8a211a2401 upstream.
25369891fcef deletes a check for the case where no 'lmax' is specified which 3037933448f6 previously fixed as 'lmax' could be set to the device's MTU without any bound checking for QFQ_LMAX_MIN and QFQ_LMAX_MAX. Therefore, reintroduce the check.
--- net/sched/sch_qfq.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/sched/sch_qfq.c +9 -2
@@ -428,10 +428,17 @@ static int qfq_change_class(struct Qdiscelse weight =1 ; -if (tb[TCA_QFQ_LMAX ]) +if (tb[TCA_QFQ_LMAX ]) { lmax =nla_get_u32 (tb[TCA_QFQ_LMAX ]); -else + }else { +/* MTU size is user controlled */ lmax =psched_mtu (qdisc_dev (sch)); +if (lmax <QFQ_MIN_LMAX || lmax >QFQ_MAX_LMAX ) { +NL_SET_ERR_MSG_MOD (extack, +"MTU size out of bounds for qfq" ); +return -EINVAL ; + } + } inv_w =ONE_FP / weight; weight =ONE_FP / inv_w;
Hi,
Quoted 5 lines · On Fri, 21 Jul 2023 17:58:24 +0200 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 5.15.121 release. There are 532 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.
Quoted 8 lines
Responses should be made by Sun, 23 Jul 2023 16:04:40 +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.15.121-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.
I confirmed that this rc kernel passes DAMON functionality test[1] on my test machine. Attaching the test results summary below.
[1] https://github.com/awslabs/damon-tests/tree/next/corr
Thanks,
SJ
[...]
---
ok 1 selftests: damon: debugfs_attrs.sh
ok 1 selftests: damon-tests: kunit.sh
ok 2 selftests: damon-tests: huge_count_read_write.sh
ok 3 selftests: damon-tests: buffer_overflow.sh
ok 4 selftests: damon-tests: rm_contexts.sh
ok 5 selftests: damon-tests: record_null_deref.sh
ok 6 selftests: damon-tests: dbgfs_target_ids_read_before_terminate_race.sh ok 7 selftests: damon-tests: dbgfs_target_ids_pid_leak.sh
ok 8 selftests: damon-tests: damo_tests.sh
ok 9 selftests: damon-tests: masim-record.sh
ok 10 selftests: damon-tests: build_i386.sh
ok 11 selftests: damon-tests: build_m68k.sh
ok 12 selftests: damon-tests: build_arm64.sh
ok 13 selftests: damon-tests: build_i386_idle_flag.sh
ok 14 selftests: damon-tests: build_i386_highpte.sh
ok 15 selftests: damon-tests: build_nomemcg.sh
PASS
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.121 release. There are 532 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 Sun, 23 Jul 2023 16:04:40 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.121-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.121 release. There are 532 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 Sun, 23 Jul 2023 16:04:40 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.121-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 5.15.121-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-5.15.y
* git commit: 48958c96454b9acda1f1117b5206838864697de8
* git describe: v5.15.120-533-g48958c96454b
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.15.y/build/v5.15.120-533-g48958c96454b
## Test Regressions (compared to v5.15.120)
## Metric Regressions (compared to v5.15.120)
## Test Fixes (compared to v5.15.120)
## Metric Fixes (compared to v5.15.120)
## Test result summary
total: 92345, pass: 74734, fail: 2019, skip: 15525, xfail: 67
## Build Summary
* arc: 5 total, 5 passed, 0 failed
* arm: 117 total, 116 passed, 1 failed
* arm64: 45 total, 43 passed, 2 failed
* i386: 35 total, 32 passed, 3 failed
* mips: 27 total, 26 passed, 1 failed
* parisc: 4 total, 4 passed, 0 failed
* powerpc: 27 total, 26 passed, 1 failed
* riscv: 11 total, 11 passed, 0 failed
* s390: 12 total, 11 passed, 1 failed
* sh: 14 total, 12 passed, 2 failed
* sparc: 8 total, 8 passed, 0 failed
* x86_64: 38 total, 36 passed, 2 failed
## Test suites summary
* boot
* kselftest-android
* kselftest-arm64
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers-dma-buf
* kselftest-efivarfs
* kselftest-exec
* kselftest-filesystems
* kselftest-filesystems-binderfs
* kselftest-filesytems-epoll
* kselftest-firmware
* kselftest-fpu
* kselftest-ftrace
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-kvm
* kselftest-lib
* kselftest-membarrier
* kselftest-memfd
* kselftest-memory-hotplug
* kselftest-mincore
* kselftest-mount
* kselftest-mqueue
* kselftest-net
* kselftest-net-forwarding
* kselftest-net-mptcp
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-splice
* kselftest-static_keys
* kselftest-sync
* kselftest-sysctl
* kselftest-tc-testing
* kselftest-timens
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user_events
* kselftest-vDSO
* kselftest-watchdog
* kselftest-x86
* kunit
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* rcutorture
--
Linaro LKFT
https://lkft.linaro.org
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.121 release. There are 532 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 Sun, 23 Jul 2023 16:04:40 +0000. Anything received after that time might be too late.
Build results:
total: 160 pass: 160 fail: 0 Qemu test results: total: 502 pass: 502 fail: 0
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.121 release. There are 532 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 Sun, 23 Jul 2023 16:04:40 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.121-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.121 release. There are 532 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 Sun, 23 Jul 2023 16:04:40 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.121-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.15:
11 builds: 11 pass, 0 fail
28 boots: 28 pass, 0 fail
114 tests: 114 pass, 0 failLinux version: 5.15.121-rc1-g48958c96454b
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
tegra20-ventana, tegra210-p2371-2180,
tegra210-p3450-0000, tegra30-cardhu-a04Jon
Hi Greg,
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.121 release. There are 532 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 Sun, 23 Jul 2023 16:04:40 +0000. Anything received after that time might be too late.
No problems seen on x86_64 and aarch64.
Thanks,
Harshit
Quoted 10 lines
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.121-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h