power: supply: bq24257_charger: Replace depends on REGMAP_I2C with select
Subsystems (43)
Sasha Levin
maintainerPATCH 169/266 arm64: tegra: Fix ethernet phy-mode for Jetson Xavier
In reply to Sasha LevinFrom: Jon Hunter <[email protected]>
[ Upstream commit bba25915b172c72f6fa635f091624d799e3c9cae ]
The 'phy-mode' property is currently defined as 'rgmii' for Jetson Xavier. This indicates that the RGMII RX and TX delays are set by the MAC and the internal delays set by the PHY are not used.
If the Marvell PHY driver is enabled, such that it is used and not the generic PHY, ethernet failures are seen (DHCP is failing to obtain an IP address) and this is caused because the Marvell PHY driver is disabling the internal RX and TX delays. For Jetson Xavier the internal PHY RX and TX delay should be used and so fix this by setting the 'phy-mode' to 'rgmii-id' and not 'rgmii'.
--- arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/nvidia/tegra194-p2888.dtsi +1 -1
@@ -32,7 +32,7 @@ ethernet@2490000 { phy-reset-gpios = <&gpio TEGRA194_MAIN_GPIO(G, 5) GPIO_ACTIVE_LOW>; phy-handle = <&phy>; - phy-mode = "rgmii"; + phy-mode = "rgmii-id"; mdio { #address-cells = <1>;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 170/266 arm64: tegra: Fix flag for 64-bit resources in 'ranges' property
In reply to Sasha LevinFrom: Vidya Sagar <[email protected]>
[ Upstream commit 3482a7afb261e2de9269a7f9ad0f4a3a82a83a53 ]
Fix flag in PCIe controllers device-tree nodes 'ranges' property to correctly represent 64-bit resources.
--- arch/arm64/boot/dts/nvidia/tegra194.dtsi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/nvidia/tegra194.dtsi +6 -6
@@ -1192,7 +1192,7 @@ pcie@14100000 { bus-range = <0x0 0xff>; ranges = <0x81000000 0x0 0x30100000 0x0 0x30100000 0x0 0x00100000 /* downstream I/O (1MB) */ - 0xc2000000 0x12 0x00000000 0x12 0x00000000 0x0 0x30000000 /* prefetchable memory (768MB) */ + 0xc3000000 0x12 0x00000000 0x12 0x00000000 0x0 0x30000000 /* prefetchable memory (768MB) */ 0x82000000 0x0 0x40000000 0x12 0x30000000 0x0 0x10000000>; /* non-prefetchable memory (256MB) */ };
@@ -1238,7 +1238,7 @@ pcie@14120000 { bus-range = <0x0 0xff>; ranges = <0x81000000 0x0 0x32100000 0x0 0x32100000 0x0 0x00100000 /* downstream I/O (1MB) */ - 0xc2000000 0x12 0x40000000 0x12 0x40000000 0x0 0x30000000 /* prefetchable memory (768MB) */ + 0xc3000000 0x12 0x40000000 0x12 0x40000000 0x0 0x30000000 /* prefetchable memory (768MB) */ 0x82000000 0x0 0x40000000 0x12 0x70000000 0x0 0x10000000>; /* non-prefetchable memory (256MB) */ };
@@ -1284,7 +1284,7 @@ pcie@14140000 { bus-range = <0x0 0xff>; ranges = <0x81000000 0x0 0x34100000 0x0 0x34100000 0x0 0x00100000 /* downstream I/O (1MB) */ - 0xc2000000 0x12 0x80000000 0x12 0x80000000 0x0 0x30000000 /* prefetchable memory (768MB) */ + 0xc3000000 0x12 0x80000000 0x12 0x80000000 0x0 0x30000000 /* prefetchable memory (768MB) */ 0x82000000 0x0 0x40000000 0x12 0xb0000000 0x0 0x10000000>; /* non-prefetchable memory (256MB) */ };
@@ -1330,7 +1330,7 @@ pcie@14160000 { bus-range = <0x0 0xff>; ranges = <0x81000000 0x0 0x36100000 0x0 0x36100000 0x0 0x00100000 /* downstream I/O (1MB) */ - 0xc2000000 0x14 0x00000000 0x14 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */ + 0xc3000000 0x14 0x00000000 0x14 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */ 0x82000000 0x0 0x40000000 0x17 0x40000000 0x0 0xc0000000>; /* non-prefetchable memory (3GB) */ };
@@ -1376,7 +1376,7 @@ pcie@14180000 { bus-range = <0x0 0xff>; ranges = <0x81000000 0x0 0x38100000 0x0 0x38100000 0x0 0x00100000 /* downstream I/O (1MB) */ - 0xc2000000 0x18 0x00000000 0x18 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */ + 0xc3000000 0x18 0x00000000 0x18 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */ 0x82000000 0x0 0x40000000 0x1b 0x40000000 0x0 0xc0000000>; /* non-prefetchable memory (3GB) */ };
@@ -1426,7 +1426,7 @@ pcie@141a0000 { bus-range = <0x0 0xff>; ranges = <0x81000000 0x0 0x3a100000 0x0 0x3a100000 0x0 0x00100000 /* downstream I/O (1MB) */ - 0xc2000000 0x1c 0x00000000 0x1c 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */ + 0xc3000000 0x1c 0x00000000 0x1c 0x00000000 0x3 0x40000000 /* prefetchable memory (13GB) */ 0x82000000 0x0 0x40000000 0x1f 0x40000000 0x0 0xc0000000>; /* non-prefetchable memory (3GB) */ };
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 171/266 powerpc/64s/pgtable: fix an undefined behaviour
In reply to Sasha LevinFrom: Qian Cai <[email protected]>
[ Upstream commit c2e929b18cea6cbf71364f22d742d9aad7f4677a ]
Booting a power9 server with hash MMU could trigger an undefined behaviour because pud_offset(p4d, 0) will do,
0 >> (PAGE_SHIFT:16 + PTE_INDEX_SIZE:8 + H_PMD_INDEX_SIZE:10)
Fix it by converting pud_index() and friends to static inline functions.
UBSAN: shift-out-of-bounds in arch/powerpc/mm/ptdump/ptdump.c:282:15 shift exponent 34 is too large for 32-bit type 'int' CPU: 6 PID: 1 Comm: swapper/0 Not tainted 5.6.0-rc4-next-20200303+ #13 Call Trace: dump_stack+0xf4/0x164 (unreliable) ubsan_epilogue+0x18/0x78 __ubsan_handle_shift_out_of_bounds+0x160/0x21c walk_pagetables+0x2cc/0x700 walk_pud at arch/powerpc/mm/ptdump/ptdump.c:282 (inlined by) walk_pagetables at arch/powerpc/mm/ptdump/ptdump.c:311 ptdump_check_wx+0x8c/0xf0 mark_rodata_ro+0x48/0x80 kernel_init+0x74/0x194 ret_from_kernel_thread+0x5c/0x74
--- arch/powerpc/include/asm/book3s/64/pgtable.h | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/book3s/64/pgtable.h +19 -4
@@ -998,10 +998,25 @@ extern struct page *pgd_page(pgd_t pgd);#define pud_page_vaddr (pud) __va(pud_val(pud) & ~PUD_MASKED_BITS)#define pgd_page_vaddr (pgd) __va(pgd_val(pgd) & ~PGD_MASKED_BITS) -#define pgd_index (address) (((address) >> (PGDIR_SHIFT)) & (PTRS_PER_PGD - 1)) -#define pud_index (address) (((address) >> (PUD_SHIFT)) & (PTRS_PER_PUD - 1)) -#define pmd_index (address) (((address) >> (PMD_SHIFT)) & (PTRS_PER_PMD - 1)) -#define pte_index (address) (((address) >> (PAGE_SHIFT)) & (PTRS_PER_PTE - 1)) +static inline unsigned long pgd_index (unsigned long address) +{ +return (address >>PGDIR_SHIFT ) & (PTRS_PER_PGD -1 ); +} + +static inline unsigned long pud_index (unsigned long address) +{ +return (address >>PUD_SHIFT ) & (PTRS_PER_PUD -1 ); +} + +static inline unsigned long pmd_index (unsigned long address) +{ +return (address >>PMD_SHIFT ) & (PTRS_PER_PMD -1 ); +} + +static inline unsigned long pte_index (unsigned long address) +{ +return (address >>PAGE_SHIFT ) & (PTRS_PER_PTE -1 ); +}/* * Find an entry in a page-table-directory. We combine the address region
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 172/266 dm zoned: return NULL if dmz_get_zone_for_reclaim() fails to find a zone
In reply to Sasha LevinFrom: Hannes Reinecke <[email protected]>
[ Upstream commit 489dc0f06a5837f87482c0ce61d830d24e17082e ]
The only case where dmz_get_zone_for_reclaim() cannot return a zone is if the respective lists are empty. So we should just return a simple NULL value here as we really don't have an error code which would make sense.
--- drivers/md/dm-zoned-metadata.c | 4 ++-- drivers/md/dm-zoned-reclaim.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/md/dm-zoned-metadata.c +2 -2
@@ -1589,7 +1589,7 @@ static struct dm_zone *dmz_get_rnd_zone_for_reclaim(struct dmz_metadata *zmd)return dzone; } -return ERR_PTR (-EBUSY ); +return NULL ; }/*
@@ -1609,7 +1609,7 @@ static struct dm_zone *dmz_get_seq_zone_for_reclaim(struct dmz_metadata *zmd)return zone; } -return ERR_PTR (-EBUSY ); +return NULL ; }/*
drivers/md/dm-zoned-reclaim.c +2 -2
@@ -349,8 +349,8 @@ static int dmz_do_reclaim(struct dmz_reclaim *zrc)/* Get a data zone */ dzone =dmz_get_zone_for_reclaim (zmd); -if (IS_ERR (dzone)) -return PTR_ERR (dzone); +if (!dzone) +return -EBUSY ; start = jiffies;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 173/266 PCI/PTM: Inherit Switch Downstream Port PTM settings from Upstream Port
In reply to Sasha LevinFrom: Bjorn Helgaas <[email protected]>
[ Upstream commit 7b38fd9760f51cc83d80eed2cfbde8b5ead9e93a ]
Except for Endpoints, we enable PTM at enumeration-time. Previously we did not account for the fact that Switch Downstream Ports are not permitted to have a PTM capability; their PTM behavior is controlled by the Upstream Port (PCIe r5.0, sec 7.9.16). Since Downstream Ports don't have a PTM capability, we did not mark them as "ptm_enabled", which meant that pci_enable_ptm() on an Endpoint failed because there was no PTM path to it.
Mark Downstream Ports as "ptm_enabled" if their Upstream Port has PTM enabled.
--- drivers/pci/pcie/ptm.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/pci/pcie/ptm.c +17 -5
@@ -39,10 +39,6 @@ void pci_ptm_init(struct pci_dev *dev)if (!pci_is_pcie (dev))return ; - pos =pci_find_ext_capability (dev,PCI_EXT_CAP_ID_PTM ); -if (!pos) -return ; -/* * Enable PTM only on interior devices (root ports, switch ports, * etc.) on the assumption that it causes no link traffic until an
@@ -52,6 +48,23 @@ void pci_ptm_init(struct pci_dev *dev) pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END))return ; +/* +* Switch Downstream Ports are not permitted to have a PTM +* capability; their PTM behavior is controlled by the Upstream +* Port (PCIe r5.0, sec 7.9.16). +*/ + ups =pci_upstream_bridge (dev); +if (pci_pcie_type (dev) ==PCI_EXP_TYPE_DOWNSTREAM && + ups && ups->ptm_enabled) { + dev->ptm_granularity = ups->ptm_granularity; + dev->ptm_enabled =1 ; +return ; + } + + pos =pci_find_ext_capability (dev,PCI_EXT_CAP_ID_PTM ); +if (!pos) +return ; +pci_read_config_dword (dev, pos +PCI_PTM_CAP , &cap); local_clock = (cap &PCI_PTM_GRANULARITY_MASK ) >>8 ;
@@ -61,7 +74,6 @@ void pci_ptm_init(struct pci_dev *dev)* the spec recommendation (PCIe r3.1, sec 7.32.3), select the * furthest upstream Time Source as the PTM Root. */ - ups =pci_upstream_bridge (dev);if (ups && ups->ptm_enabled) { ctrl =PCI_PTM_CTRL_ENABLE ;if (ups->ptm_granularity ==0 )
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 174/266 PCI: dwc: Fix inner MSI IRQ domain registration
In reply to Sasha LevinFrom: Marc Zyngier <[email protected]>
[ Upstream commit 0414b93e78d87ecc24ae1a7e61fe97deb29fa2f4 ]
On a system that uses the internal DWC MSI widget, I get this warning from debugfs when CONFIG_GENERIC_IRQ_DEBUGFS is selected:
debugfs: File ':soc:pcie@fc000000' in directory 'domains' already present!
This is due to the fact that the DWC MSI code tries to register two IRQ domains for the same firmware node, without telling the low level code how to distinguish them (by setting a bus token). This further confuses debugfs which tries to create corresponding files for each domain.
Fix it by tagging the inner domain as DOMAIN_BUS_NEXUS, which is the closest thing we have as to "generic MSI".
--- drivers/pci/controller/dwc/pcie-designware-host.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/controller/dwc/pcie-designware-host.c +2 -0
@@ -263,6 +263,8 @@ int dw_pcie_allocate_domains(struct pcie_port *pp)return -ENOMEM ; } +irq_domain_update_bus_token (pp->irq_domain,DOMAIN_BUS_NEXUS ); + pp->msi_domain =pci_msi_create_irq_domain (fwnode, &dw_pcie_msi_domain_info, pp->irq_domain);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 175/266 PCI: amlogic: meson: Don't use FAST_LINK_MODE to set up link
In reply to Sasha LevinFrom: Marc Zyngier <[email protected]>
[ Upstream commit 87dccf09323fc363bd0d072fcc12b96622ab8c69 ]
The vim3l board does not work with a standard PCIe switch (ASM1184e), spitting all kind of errors - hinting at HW misconfiguration (no link, port enumeration issues, etc).
According to the the Synopsys DWC PCIe Reference Manual, in the section dedicated to the PLCR register, bit 7 is described (FAST_LINK_MODE) as:
"Sets all internal timers to fast mode for simulation purposes."
it is sound to set this bit from a simulation perspective, but on actual silicon, which expects timers to have a nominal value, it is not.
Make sure the FAST_LINK_MODE bit is cleared when configuring the RC to solve this problem.
--- drivers/pci/controller/dwc/pci-meson.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-meson.c +2 -2
@@ -301,11 +301,11 @@ static void meson_pcie_init_dw(struct meson_pcie *mp)meson_cfg_writel (mp, val,PCIE_CFG0 ); val =meson_elb_readl (mp,PCIE_PORT_LINK_CTRL_OFF ); - val &= ~LINK_CAPABLE_MASK ; + val &= ~(LINK_CAPABLE_MASK |FAST_LINK_MODE );meson_elb_writel (mp, val,PCIE_PORT_LINK_CTRL_OFF ); val =meson_elb_readl (mp,PCIE_PORT_LINK_CTRL_OFF ); - val |=LINK_CAPABLE_X1 |FAST_LINK_MODE ; + val |=LINK_CAPABLE_X1 ;meson_elb_writel (mp, val,PCIE_PORT_LINK_CTRL_OFF ); val =meson_elb_readl (mp,PCIE_GEN2_CTRL_OFF );
Signature · 7 lines
2.25.1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Sasha Levin
maintainerPATCH 176/266 IB/cma: Fix ports memory leak in cma_configfs
In reply to Sasha LevinFrom: Maor Gottlieb <[email protected]>
[ Upstream commit 63a3345c2d42a9b29e1ce2d3a4043689b3995cea ]
The allocated ports structure in never freed. The free function should be called by release_cma_ports_group, but the group is never released since we don't remove its default group.
Remove default groups when device group is deleted.
--- drivers/infiniband/core/cma_configfs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/infiniband/core/cma_configfs.c +13 -0
@@ -322,8 +322,21 @@ static struct config_group *make_cma_dev(struct config_group *group,return ERR_PTR (err); } +static void drop_cma_dev (struct config_group *cgroup,struct config_item *item) +{ +struct config_group *group = + container_of(item, struct config_group, cg_item); +struct cma_dev_group *cma_dev_group = + container_of(group, struct cma_dev_group, device_group); + +configfs_remove_default_groups (&cma_dev_group->ports_group); +configfs_remove_default_groups (&cma_dev_group->device_group); +config_item_put (item); +} +static struct configfs_group_operations cma_subsys_group_ops = { .make_group = make_cma_dev, + .drop_item = drop_cma_dev, };static const struct config_item_type cma_subsys_type = {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 177/266 watchdog: da9062: No need to ping manually before setting timeout
In reply to Sasha LevinFrom: Stefan Riedmueller <[email protected]>
[ Upstream commit a0948ddba65f4f6d3cfb5e2b84685485d0452966 ]
There is actually no need to ping the watchdog before disabling it during timeout change. Disabling the watchdog already takes care of resetting the counter.
This fixes an issue during boot when the userspace watchdog handler takes over and the watchdog is already running. Opening the watchdog in this case leads to the first ping and directly after that without the required heartbeat delay a second ping issued by the set_timeout call. Due to the missing delay this resulted in a reset.
--- drivers/watchdog/da9062_wdt.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/watchdog/da9062_wdt.c +0 -5
@@ -55,11 +55,6 @@ static int da9062_wdt_update_timeout_register(struct da9062_watchdog *wdt, unsigned int regval) {struct da9062 *chip = wdt->hw; -int ret; - - ret =da9062_reset_watchdog_timer (wdt); -if (ret) -return ret; regmap_update_bits(chip->regmap, DA9062AA_CONTROL_D,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 178/266 usb: dwc2: gadget: move gadget resume after the core is in L0 state
In reply to Sasha LevinFrom: Fabrice Gasnier <[email protected]>
[ Upstream commit 8c935deacebb8fac8f41378701eb79d12f3c2e2d ]
When the remote wakeup interrupt is triggered, lx_state is resumed from L2 to L0 state. But when the gadget resume is called, lx_state is still L2. This prevents the resume callback to queue any request. Any attempt to queue a request from resume callback will result in:
- "submit request only in active state" debug message to be issued
- dwc2_hsotg_ep_queue() returns -EAGAIN
Call the gadget resume routine after the core is in L0 state.
--- drivers/usb/dwc2/core_intr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/dwc2/core_intr.c +5 -2
@@ -421,10 +421,13 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)if (ret && (ret != -ENOTSUPP ))dev_err (hsotg->dev,"exit power_down failed\n" ); +/* Change to L0 state */ + hsotg->lx_state =DWC2_L0 ;call_gadget (hsotg, resume); + }else { +/* Change to L0 state */ + hsotg->lx_state =DWC2_L0 ; } -/* Change to L0 state */ - hsotg->lx_state =DWC2_L0 ; }else {if (hsotg->params.power_down)return ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 179/266 USB: gadget: udc: s3c2410_udc: Remove pointless NULL check in s3c2410_udc_nuke
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 7a0fbcf7c308920bc6116b3a5fb21c8cc5fec128 ]
Clang warns:
drivers/usb/gadget/udc/s3c2410_udc.c:255:11: warning: comparison of address of 'ep->queue' equal to a null pointer is always false [-Wtautological-pointer-compare]
if (&ep->queue == NULL)
~~~~^~~~~ ~~~~1 warning generated.
It is not wrong, queue is not a pointer so if ep is not NULL, the address of queue cannot be NULL. No other driver does a check like this and this check has been around since the driver was first introduced, presumably with no issues so it does not seem like this check should be something else. Just remove it.
Commit afe956c577b2d ("kbuild: Enable -Wtautological-compare") exposed this but it is not the root cause of the warning.
--- drivers/usb/gadget/udc/s3c2410_udc.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/usb/gadget/udc/s3c2410_udc.c +0 -4
@@ -251,10 +251,6 @@ static void s3c2410_udc_done(struct s3c2410_ep *ep,static void s3c2410_udc_nuke (struct s3c2410_udc *udc,struct s3c2410_ep *ep,int status) { -/* Sanity check */ -if (&ep->queue ==NULL ) -return ; -while (!list_empty (&ep->queue)) {struct s3c2410_request *req; req = list_entry(ep->queue.next, struct s3c2410_request,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 180/266 usb: gadget: lpc32xx_udc: don't dereference ep pointer before null check
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
[ Upstream commit eafa80041645cd7604c4357b1a0cd4a3c81f2227 ]
Currently pointer ep is being dereferenced before it is null checked leading to a null pointer dereference issue. Fix this by only assigning pointer udc once ep is known to be not null. Also remove a debug message that requires a valid udc which may not be possible at that point.
Addresses-Coverity: ("Dereference before null check")
--- drivers/usb/gadget/udc/lpc32xx_udc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/usb/gadget/udc/lpc32xx_udc.c +6 -5
@@ -1614,17 +1614,17 @@ static int lpc32xx_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) { struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep); -struct lpc32xx_udc *udc = ep->udc; +struct lpc32xx_udc *udc;u16 maxpacket;u32 tmp;unsigned long flags;/* Verify EP data */ if ((!_ep) || (!ep) || (!desc) || - (desc->bDescriptorType !=USB_DT_ENDPOINT )) { -dev_dbg (udc->dev,"bad ep or descriptor\n" ); + (desc->bDescriptorType !=USB_DT_ENDPOINT ))return -EINVAL ; - } + + udc = ep->udc; maxpacket =usb_endpoint_maxp (desc);if ((maxpacket ==0 ) || (maxpacket > ep->maxpacket)) {dev_dbg (udc->dev,"bad ep descriptor's packet size\n" );
@@ -1872,7 +1872,7 @@ static int lpc32xx_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)static int lpc32xx_ep_set_halt (struct usb_ep *_ep,int value) { struct lpc32xx_ep *ep = container_of(_ep, struct lpc32xx_ep, ep); -struct lpc32xx_udc *udc = ep->udc; +struct lpc32xx_udc *udc;unsigned long flags;if ((!ep) || (ep->hwep_num <=1 ))
@@ -1882,6 +1882,7 @@ static int lpc32xx_ep_set_halt(struct usb_ep *_ep, int value)if (ep->is_in)return -EAGAIN ; + udc = ep->udc;spin_lock_irqsave (&udc->lock, flags);if (value ==1 ) {
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 181/266 usb: gadget: fix potential double-free in m66592_probe.
In reply to Sasha LevinFrom: Qiushi Wu <[email protected]>
[ Upstream commit 44734a594196bf1d474212f38fe3a0d37a73278b ]
m66592_free_request() is called under label "err_add_udc" and "clean_up", and m66592->ep0_req is not set to NULL after first free, leading to a double-free. Fix this issue by setting m66592->ep0_req to NULL after the first free.
--- drivers/usb/gadget/udc/m66592-udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/m66592-udc.c +1 -1
@@ -1667,7 +1667,7 @@ static int m66592_probe(struct platform_device *pdev) err_add_udc:m66592_free_request (&m66592->ep[0 ].ep, m66592->ep0_req); - + m66592->ep0_req =NULL ; clean_up3:if (m66592->pdata->on_chip) {clk_disable (m66592->clk);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 182/266 usb: gadget: Fix issue with config_ep_by_speed function
In reply to Sasha LevinFrom: Pawel Laszczak <[email protected]>
[ Upstream commit 5d363120aa548ba52d58907a295eee25f8207ed2 ]
This patch adds new config_ep_by_speed_and_alt function which extends the config_ep_by_speed about alt parameter.
This additional parameter allows to find proper usb_ss_ep_comp_descriptor.
Problem has appeared during testing f_tcm (BOT/UAS) driver function.
f_tcm function for SS use array of headers for both BOT/UAS alternate setting:
static struct usb_descriptor_header *uasp_ss_function_desc[] = {
(struct usb_descriptor_header *) &bot_intf_desc, (struct usb_descriptor_header *) &uasp_ss_bi_desc, (struct usb_descriptor_header *) &bot_bi_ep_comp_desc, (struct usb_descriptor_header *) &uasp_ss_bo_desc, (struct usb_descriptor_header *) &bot_bo_ep_comp_desc,
(struct usb_descriptor_header *) &uasp_intf_desc, (struct usb_descriptor_header *) &uasp_ss_bi_desc, (struct usb_descriptor_header *) &uasp_bi_ep_comp_desc, (struct usb_descriptor_header *) &uasp_bi_pipe_desc, (struct usb_descriptor_header *) &uasp_ss_bo_desc, (struct usb_descriptor_header *) &uasp_bo_ep_comp_desc, (struct usb_descriptor_header *) &uasp_bo_pipe_desc, (struct usb_descriptor_header *) &uasp_ss_status_desc, (struct usb_descriptor_header *) &uasp_status_in_ep_comp_desc, (struct usb_descriptor_header *) &uasp_status_pipe_desc, (struct usb_descriptor_header *) &uasp_ss_cmd_desc, (struct usb_descriptor_header *) &uasp_cmd_comp_desc, (struct usb_descriptor_header *) &uasp_cmd_pipe_desc, NULL,
};
The first 5 descriptors are associated with BOT alternate setting, and others are associated with UAS.
During handling UAS alternate setting f_tcm driver invokes config_ep_by_speed and this function sets incorrect companion endpoint descriptor in usb_ep object.
Instead setting ep->comp_desc to uasp_bi_ep_comp_desc function in this case set ep->comp_desc to uasp_ss_bi_desc.
This is due to the fact that it searches endpoint based on endpoint address:
for_each_ep_desc(speed_desc, d_spd) {
chosen_desc = (struct usb_endpoint_descriptor *)*d_spd;
if (chosen_desc->bEndpoitAddress == _ep->address)
goto ep_found;
}And in result it uses the descriptor from BOT alternate setting instead UAS.
Finally, it causes that controller driver during enabling endpoints detect that just enabled endpoint for bot.
--- drivers/usb/gadget/composite.c | 78 ++++++++++++++++++++++++++-------- include/linux/usb/composite.h | 3 ++ 2 files changed, 64 insertions(+), 17 deletions(-)
drivers/usb/gadget/composite.c +61 -17
@@ -96,40 +96,43 @@ function_descriptors(struct usb_function *f, }/** -* next_ep_desc() - advance to the next EP descriptor +* next_desc() - advance to the next desc_type descriptor * @t: currect pointer within descriptor array +* @desc_type: descriptor type * -* Return: next EP descriptor or NULL +* Return: next desc_type descriptor or NULL * -* Iterate over @t until either EP descriptor found or +* Iterate over @t until either desc_type descriptor found or * NULL (that indicates end of list) encountered */ static struct usb_descriptor_header ** -next_ep_desc (struct usb_descriptor_header **t) +next_desc (struct usb_descriptor_header **t,u8 desc_type) {for (; *t; t++) { -if ((*t)->bDescriptorType ==USB_DT_ENDPOINT ) +if ((*t)->bDescriptorType == desc_type)return t; }return NULL ; }/* -* for_each_ep_desc()- iterate over endpoint descriptors in the -* descriptors list -* @start: pointer within descriptor array. -* @ep_desc: endpoint descriptor to use as the loop cursor +* for_each_desc() - iterate over desc_type descriptors in the +* descriptors list +* @start: pointer within descriptor array. +* @iter_desc: desc_type descriptor to use as the loop cursor +* @desc_type: wanted descriptr type */ -#define for_each_ep_desc (start, ep_desc) \ - for (ep_desc = next_ep_desc(start); \ - ep_desc; ep_desc = next_ep_desc(ep_desc+1)) +#define for_each_desc (start, iter_desc, desc_type) \ + for (iter_desc = next_desc(start, desc_type); \ + iter_desc; iter_desc = next_desc(iter_desc + 1, desc_type))/** -* config_ep_by_speed() - configures the given endpoint +* config_ep_by_speed_and_alt() - configures the given endpoint * according to gadget speed. * @g: pointer to the gadget * @f: usb function * @_ep: the endpoint to configure +* @alt: alternate setting number * * Return: error code, 0 on success *
@@ -142,11 +145,13 @@ next_ep_desc(struct usb_descriptor_header **t)* Note: the supplied function should hold all the descriptors * for supported speeds */ -int config_ep_by_speed (struct usb_gadget *g, -struct usb_function *f, -struct usb_ep *_ep) +int config_ep_by_speed_and_alt (struct usb_gadget *g, +struct usb_function *f, +struct usb_ep *_ep, +u8 alt) {struct usb_endpoint_descriptor *chosen_desc =NULL ; +struct usb_interface_descriptor *int_desc =NULL ;struct usb_descriptor_header **speed_desc =NULL ;struct usb_ss_ep_comp_descriptor *comp_desc =NULL ;
@@ -182,8 +187,21 @@ int config_ep_by_speed(struct usb_gadget *g,default : speed_desc = f->fs_descriptors; } + +/* find correct alternate setting descriptor */ +for_each_desc (speed_desc, d_spd,USB_DT_INTERFACE ) { + int_desc = (struct usb_interface_descriptor *)*d_spd; + +if (int_desc->bAlternateSetting == alt) { + speed_desc = d_spd; + goto intf_found; + } + } +return -EIO ; + +intf_found:/* find descriptors */ -for_each_ep_desc (speed_desc, d_spd) { +for_each_desc (speed_desc, d_spd,USB_DT_ENDPOINT ) { chosen_desc = (struct usb_endpoint_descriptor *)*d_spd;if (chosen_desc->bEndpointAddress == _ep->address) goto ep_found;
@@ -237,6 +255,32 @@ int config_ep_by_speed(struct usb_gadget *g, }return 0 ; } +EXPORT_SYMBOL_GPL (config_ep_by_speed_and_alt); + +/** +* config_ep_by_speed() - configures the given endpoint +* according to gadget speed. +* @g: pointer to the gadget +* @f: usb function +* @_ep: the endpoint to configure +* +* Return: error code, 0 on success +* +* This function chooses the right descriptors for a given +* endpoint according to gadget speed and saves it in the +* endpoint desc field. If the endpoint already has a descriptor +* assigned to it - overwrites it with currently corresponding +* descriptor. The endpoint maxpacket field is updated according +* to the chosen descriptor. +* Note: the supplied function should hold all the descriptors +* for supported speeds +*/ +int config_ep_by_speed (struct usb_gadget *g, +struct usb_function *f, +struct usb_ep *_ep) +{ +return config_ep_by_speed_and_alt (g, f, _ep,0 ); +}EXPORT_SYMBOL_GPL (config_ep_by_speed);/**
include/linux/usb/composite.h +3 -0
@@ -249,6 +249,9 @@ int usb_function_activate(struct usb_function *);int usb_interface_id (struct usb_configuration *,struct usb_function *); +int config_ep_by_speed_and_alt (struct usb_gadget *g,struct usb_function *f, +struct usb_ep *_ep,u8 alt); +int config_ep_by_speed (struct usb_gadget *g,struct usb_function *f,struct usb_ep *_ep);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 183/266 scripts: headers_install: Exit with error on config leak
In reply to Sasha LevinFrom: Siddharth Gupta <[email protected]>
[ Upstream commit 5967577231f9b19acd5a59485e9075964065bbe3 ]
Misuse of CONFIG_* in UAPI headers should result in an error. These config options can be set in userspace by the user application which includes these headers to control the APIs and structures being used in a kernel which supports multiple targets.
--- scripts/headers_install.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
scripts/headers_install.sh +6 -5
@@ -64,7 +64,7 @@ configs=$(sed -e ' d ' $OUTFILE) -# The entries in the following list are not warned. +# The entries in the following list do not result in an error. # Please do not add a new entry. This list is only for existing ones. # The list will be reduced gradually, and deleted eventually. (hopefully) #
@@ -98,18 +98,19 @@ include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS for c in $configs do - warn=1 + leak_error=1 for ignore in $config_leak_ignores do if echo "$INFILE:$c" | grep -q "$ignore$"; then - warn= + leak_error= break fi done - if [ "$warn" = 1 ]; then - echo "warning: $INFILE: leak $c to user-space" >&2 + if [ "$leak_error" = 1 ]; then + echo "error: $INFILE: leak $c to user-space" >&2 + exit 1 fi done
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 184/266 RDMA/iw_cxgb4: cleanup device debugfs entries on ULD remove
In reply to Sasha LevinFrom: Potnuri Bharat Teja <[email protected]>
[ Upstream commit 49ea0c036ede81f126f1a9389d377999fdf5c5a1 ]
Remove device specific debugfs entries immediately if LLD detaches a particular ULD device in case of fatal PCI errors.
--- drivers/infiniband/hw/cxgb4/device.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/cxgb4/device.c +1 -0
@@ -953,6 +953,7 @@ void c4iw_dealloc(struct uld_ctx *ctx)static void c4iw_remove (struct uld_ctx *ctx) {pr_debug ("c4iw_dev %p\n" , ctx->dev); +debugfs_remove_recursive (ctx->dev->debugfs_root);c4iw_unregister_device (ctx->dev);c4iw_dealloc (ctx); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 185/266 x86/apic: Make TSC deadline timer detection message visible
In reply to Sasha LevinFrom: Borislav Petkov <[email protected]>
[ Upstream commit de308d1815c9e8fe602a958c5c76142ff6501d75 ]
The commit
c84cb3735fd5 ("x86/apic: Move TSC deadline timer debug printk")
removed the message which said that the deadline timer was enabled. It added a pr_debug() message which is issued when deadline timer validation succeeds.
Well, issued only when CONFIG_DYNAMIC_DEBUG is enabled - otherwise pr_debug() calls get optimized away if DEBUG is not defined in the compilation unit.
Therefore, make the above message pr_info() so that it is visible in dmesg.
--- arch/x86/kernel/apic/apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/apic/apic.c +1 -1
@@ -2099,7 +2099,7 @@ void __init init_apic_mappings(void)unsigned int new_apicid;if (apic_validate_deadline_timer ()) -pr_debug ("TSC deadline timer available\n" ); +pr_info ("TSC deadline timer available\n" );if (x2apic_mode) { boot_cpu_physical_apicid =read_apic_id ();
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 186/266 mfd: stmfx: Reset chip on resume as supply was disabled
In reply to Sasha LevinFrom: Amelie Delaunay <[email protected]>
[ Upstream commit e583649d87ec090444aa5347af0927cd6e8581ae ]
STMFX supply is disabled during suspend. To avoid a too early access to the STMFX firmware on resume, reset the chip and wait for its firmware to be loaded.
--- drivers/mfd/stmfx.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mfd/stmfx.c +7 -0
@@ -501,6 +501,13 @@ static int stmfx_resume(struct device *dev) } } +/* Reset STMFX - supply has been stopped during suspend */ + ret =stmfx_chip_reset (stmfx); +if (ret) { +dev_err (stmfx->dev,"Failed to reset chip: %d\n" , ret); +return ret; + } + ret =regmap_raw_write (stmfx->map,STMFX_REG_SYS_CTRL , &stmfx->bkp_sysctrl,sizeof (stmfx->bkp_sysctrl));if (ret)
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 187/266 mfd: stmfx: Fix stmfx_irq_init error path
In reply to Sasha LevinFrom: Amelie Delaunay <[email protected]>
[ Upstream commit 60c2c4bcb9202acad4cc26af20b44b6bd7874f7b ]
In case the interrupt signal can't be configured, IRQ domain needs to be removed.
--- drivers/mfd/stmfx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mfd/stmfx.c +7 -2
@@ -287,14 +287,19 @@ static int stmfx_irq_init(struct i2c_client *client) ret =regmap_write (stmfx->map,STMFX_REG_IRQ_OUT_PIN , irqoutpin);if (ret) -return ret; + goto irq_exit; ret =devm_request_threaded_irq (stmfx->dev, client->irq,NULL , stmfx_irq_handler, irqtrigger |IRQF_ONESHOT ,"stmfx" , stmfx);if (ret) -stmfx_irq_exit (client); + goto irq_exit; + +return 0 ; + +irq_exit: +stmfx_irq_exit (client);return ret; }
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 188/266 mfd: stmfx: Disable IRQ in suspend to avoid spurious interrupt
In reply to Sasha LevinFrom: Amelie Delaunay <[email protected]>
[ Upstream commit 97eda5dcc2cde5dcc778bef7a9344db3b6bf8ef5 ]
When STMFX supply is stopped, spurious interrupt can occur. To avoid that, disable the interrupt in suspend before disabling the regulator and re-enable it at the end of resume.
--- drivers/mfd/stmfx.c | 6 ++++++ include/linux/mfd/stmfx.h | 1 + 2 files changed, 7 insertions(+)
drivers/mfd/stmfx.c +6 -0
@@ -296,6 +296,8 @@ static int stmfx_irq_init(struct i2c_client *client)if (ret) goto irq_exit; + stmfx->irq = client->irq; +return 0 ; irq_exit:
@@ -486,6 +488,8 @@ static int stmfx_suspend(struct device *dev)if (ret)return ret; +disable_irq (stmfx->irq); +if (stmfx->vdd)return regulator_disable (stmfx->vdd);
@@ -529,6 +533,8 @@ static int stmfx_resume(struct device *dev)if (ret)return ret; +enable_irq (stmfx->irq); + return 0; }#endif
include/linux/mfd/stmfx.h +1 -0
@@ -109,6 +109,7 @@ struct stmfx {struct device *dev;struct regmap *map;struct regulator *vdd; +int irq;struct irq_domain *irq_domain;struct mutex lock;/* IRQ bus lock */ u8 irq_src;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 189/266 powerpc/32s: Don't warn when mapping RO data ROX.
In reply to Sasha LevinFrom: Christophe Leroy <[email protected]>
[ Upstream commit 4b19f96a81bceaf0bcf44d79c0855c61158065ec ]
Mapping RO data as ROX is not an issue since that data cannot be modified to introduce an exploit.
PPC64 accepts to have RO data mapped ROX, as a trade off between kernel size and strictness of protection.
On PPC32, kernel size is even more critical as amount of memory is usually small.
Depending on the number of available IBATs, the last IBATs might overflow the end of text. Only warn if it crosses the end of RO data.
--- arch/powerpc/mm/book3s32/mmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/mm/book3s32/mmu.c +4 -2
@@ -187,6 +187,7 @@ void mmu_mark_initmem_nx(void)int i;unsigned long base = (unsigned long )_stext -PAGE_OFFSET ;unsigned long top = (unsigned long )_etext -PAGE_OFFSET ; +unsigned long border = (unsigned long )__init_begin -PAGE_OFFSET ;unsigned long size;if (IS_ENABLED (CONFIG_PPC_BOOK3S_601 ))
@@ -201,9 +202,10 @@ void mmu_mark_initmem_nx(void) size =block_size (base, top); size =max (size,128UL <<10 );if ((top - base) > size) { -if (strict_kernel_rwx_enabled ()) -pr_warn ("Kernel _etext not properly aligned\n" ); size <<=1 ; +if (strict_kernel_rwx_enabled () && base + size > border) +pr_warn ("Some RW data is getting mapped X. " +"Adjust CONFIG_DATA_SHIFT to avoid that.\n" ); }setibat (i++,PAGE_OFFSET + base, base, size,PAGE_KERNEL_TEXT ); base += size;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 190/266 ASoC: fix incomplete error-handling in img_i2s_in_probe.
In reply to Sasha LevinFrom: Qiushi Wu <[email protected]>
[ Upstream commit 25bf943e4e7b47282bd86ae7d39e039217ebb007 ]
Function "pm_runtime_get_sync()" is not handled by "pm_runtime_put()" if "PTR_ERR(rst) == -EPROBE_DEFER". Fix this issue by adding "pm_runtime_put()" into this error path.
--- sound/soc/img/img-i2s-in.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/img/img-i2s-in.c +1 -0
@@ -482,6 +482,7 @@ static int img_i2s_in_probe(struct platform_device *pdev)if (IS_ERR (rst)) {if (PTR_ERR (rst) == -EPROBE_DEFER ) { ret = -EPROBE_DEFER ; +pm_runtime_put (&pdev->dev); goto err_suspend; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 191/266 vfio/pci: fix memory leaks of eventfd ctx
In reply to Sasha LevinFrom: Qian Cai <[email protected]>
[ Upstream commit 1518ac272e789cae8c555d69951b032a275b7602 ]
Finished a qemu-kvm (-device vfio-pci,host=0001:01:00.0) triggers a few memory leaks after a while because vfio_pci_set_ctx_trigger_single() calls eventfd_ctx_fdget() without the matching eventfd_ctx_put() later. Fix it by calling eventfd_ctx_put() for those memory in vfio_pci_release() before vfio_device_release().
unreferenced object 0xebff008981cc2b00 (size 128):
comm "qemu-kvm", pid 4043, jiffies 4294994816 (age 9796.310s) hex dump (first 32 bytes):
01 00 00 00 6b 6b 6b 6b 00 00 00 00 ad 4e ad de ....kkkk.....N.. ff ff ff ff 6b 6b 6b 6b ff ff ff ff ff ff ff ff ....kkkk........
backtrace:
[<00000000917e8f8d>] slab_post_alloc_hook+0x74/0x9c
[<00000000df0f2aa2>] kmem_cache_alloc_trace+0x2b4/0x3d4
[<000000005fcec025>] do_eventfd+0x54/0x1ac
[<0000000082791a69>] __arm64_sys_eventfd2+0x34/0x44
[<00000000b819758c>] do_el0_svc+0x128/0x1dc
[<00000000b244e810>] el0_sync_handler+0xd0/0x268
[<00000000d495ef94>] el0_sync+0x164/0x180unreferenced object 0x29ff008981cc4180 (size 128):
comm "qemu-kvm", pid 4043, jiffies 4294994818 (age 9796.290s) hex dump (first 32 bytes):
01 00 00 00 6b 6b 6b 6b 00 00 00 00 ad 4e ad de ....kkkk.....N.. ff ff ff ff 6b 6b 6b 6b ff ff ff ff ff ff ff ff ....kkkk........
backtrace:
[<00000000917e8f8d>] slab_post_alloc_hook+0x74/0x9c
[<00000000df0f2aa2>] kmem_cache_alloc_trace+0x2b4/0x3d4
[<000000005fcec025>] do_eventfd+0x54/0x1ac
[<0000000082791a69>] __arm64_sys_eventfd2+0x34/0x44
[<00000000b819758c>] do_el0_svc+0x128/0x1dc
[<00000000b244e810>] el0_sync_handler+0xd0/0x268
[<00000000d495ef94>] el0_sync+0x164/0x180--- drivers/vfio/pci/vfio_pci.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/vfio/pci/vfio_pci.c +4 -0
@@ -472,6 +472,10 @@ static void vfio_pci_release(void *device_data)if (!(--vdev->refcnt)) {vfio_spapr_pci_eeh_release (vdev->pdev);vfio_pci_disable (vdev); +if (vdev->err_trigger) +eventfd_ctx_put (vdev->err_trigger); +if (vdev->req_trigger) +eventfd_ctx_put (vdev->req_trigger); }mutex_unlock (&vdev->reflck->lock);
Signature · 1 line
2.25.1
Re: [PATCH AUTOSEL 5.4 191/266] vfio/pci: fix memory leaks of eventfd ctx
Quoted 49 lines · On Wed, 17 Jun 2020 21:15:16 -0400 Sasha Levin <[email protected]> wrote:
From: Qian Cai <[email protected]>
[ Upstream commit
1518ac272e789cae8c555d69951b032a275b7602]Finished a qemu-kvm (-device vfio-pci,host=0001:01:00.0) triggers a few memory leaks after a while because
vfio_pci_set_ctx_trigger_single()callseventfd_ctx_fdget()without the matchingeventfd_ctx_put()later. Fix it by callingeventfd_ctx_put()for those memory invfio_pci_release()beforevfio_device_release().unreferenced object
0xebff008981cc2b00(size 128):
comm "qemu-kvm", pid 4043, jiffies 4294994816 (age 9796.310s) hex dump (first 32 bytes):
01 00 00 00 6b 6b 6b 6b 00 00 00 00 ad 4e ad de ....kkkk.....N.. ff ff ff ff 6b 6b 6b 6b ff ff ff ff ff ff ff ff ....kkkk........
backtrace:[<00000000917e8f8d>] slab_post_alloc_hook+0x74/0x9c [<00000000df0f2aa2>] kmem_cache_alloc_trace+0x2b4/0x3d4 [<000000005fcec025>] do_eventfd+0x54/0x1ac [<0000000082791a69>] __arm64_sys_eventfd2+0x34/0x44 [<00000000b819758c>] do_el0_svc+0x128/0x1dc [<00000000b244e810>] el0_sync_handler+0xd0/0x268 [<00000000d495ef94>] el0_sync+0x164/0x180unreferenced object
0x29ff008981cc4180(size 128):
comm "qemu-kvm", pid 4043, jiffies 4294994818 (age 9796.290s) hex dump (first 32 bytes):
01 00 00 00 6b 6b 6b 6b 00 00 00 00 ad 4e ad de ....kkkk.....N.. ff ff ff ff 6b 6b 6b 6b ff ff ff ff ff ff ff ff ....kkkk........
backtrace:[<00000000917e8f8d>] slab_post_alloc_hook+0x74/0x9c [<00000000df0f2aa2>] kmem_cache_alloc_trace+0x2b4/0x3d4 [<000000005fcec025>] do_eventfd+0x54/0x1ac [<0000000082791a69>] __arm64_sys_eventfd2+0x34/0x44 [<00000000b819758c>] do_el0_svc+0x128/0x1dc [<00000000b244e810>] el0_sync_handler+0xd0/0x268 [<00000000d495ef94>] el0_sync+0x164/0x180Signed-off-by Qian Cai <[email protected]>Signed-off-by Alex Williamson <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/vfio/pci/vfio_pci.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/vfio/pci/vfio_pci.c +0
-0
drivers/vfio/pci/vfio_pci.c static void vfio_pci_release(void *device_data) · line 481
Quoted 10 lines
drivers/vfio/pci/vfio_pci.c +4
-0@@ -472,6 +472,10 @@ static void vfio_pci_release(void *device_data)if (!(--vdev->refcnt)) {vfio_spapr_pci_eeh_release (vdev->pdev);vfio_pci_disable (vdev); +if (vdev->err_trigger) +eventfd_ctx_put (vdev->err_trigger); +if (vdev->req_trigger) +eventfd_ctx_put (vdev->req_trigger); }mutex_unlock (&vdev->reflck->lock);
This has a fix pending, I'd suggest not picking it on its own:
https://lore.kernel.org/kvm/[email protected]/
https://lore.kernel.org/kvm/[email protected]/
Thanks,
Alex
Sasha Levin
maintainerPATCH 192/266 scsi: target: tcmu: Fix a use after free in tcmu_check_expired_queue_cmd()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 9d7464b18892332e35ff37f0b024429a1a9835e6 ]
The pr_debug() dereferences "cmd" after we already freed it by calling tcmu_free_cmd(cmd). The debug printk needs to be done earlier.
--- drivers/target/target_core_user.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/target/target_core_user.c +3 -3
@@ -1292,13 +1292,13 @@ static void tcmu_check_expired_queue_cmd(struct tcmu_cmd *cmd)if (!time_after (jiffies, cmd->deadline))return ; +pr_debug ("Timing out queued cmd %p on dev %s.\n" , + cmd, cmd->tcmu_dev->name); +list_del_init (&cmd->queue_entry); se_cmd = cmd->se_cmd;tcmu_free_cmd (cmd); -pr_debug ("Timing out queued cmd %p on dev %s.\n" , - cmd, cmd->tcmu_dev->name); -target_complete_cmd (se_cmd,SAM_STAT_TASK_SET_FULL ); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 193/266 clk: bcm2835: Fix return type of bcm2835_register_gate
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit f376c43bec4f8ee8d1ba5c5c4cfbd6e84fb279cb ]
bcm2835_register_gate is used as a callback for the clk_register member of bcm2835_clk_desc, which expects a struct clk_hw * return type but bcm2835_register_gate returns a struct clk *.
This discrepancy is hidden by the fact that bcm2835_register_gate is cast to the typedef bcm2835_clk_register by the _REGISTER macro. This turns out to be a control flow integrity violation, which is how this was noticed.
Change the return type of bcm2835_register_gate to be struct clk_hw * and use clk_hw_register_gate to do so. This should be a non-functional change as clk_register_gate calls clk_hw_register_gate anyways but this is needed to avoid issues with further changes.
--- drivers/clk/bcm/clk-bcm2835.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/clk/bcm/clk-bcm2835.c +5 -5
@@ -1448,13 +1448,13 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,return &clock->hw; } -static struct clk *bcm2835_register_gate (struct bcm2835_cprman *cprman, +static struct clk_hw *bcm2835_register_gate (struct bcm2835_cprman *cprman,const struct bcm2835_gate_data *data) { -return clk_register_gate (cprman->dev, data->name, data->parent, -CLK_IGNORE_UNUSED |CLK_SET_RATE_GATE , - cprman->regs + data->ctl_reg, -CM_GATE_BIT ,0 , &cprman->regs_lock); +return clk_hw_register_gate (cprman->dev, data->name, data->parent, +CLK_IGNORE_UNUSED |CLK_SET_RATE_GATE , + cprman->regs + data->ctl_reg, +CM_GATE_BIT ,0 , &cprman->regs_lock); } typedef struct clk_hw *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 194/266 scsi: ufs-qcom: Fix scheduling while atomic issue
In reply to Sasha LevinFrom: Jeffrey Hugo <[email protected]>
[ Upstream commit 3be60b564de49875e47974c37fabced893cd0931 ]
ufs_qcom_dump_dbg_regs() uses usleep_range, a sleeping function, but can be called from atomic context in the following flow:
ufshcd_intr -> ufshcd_sl_intr -> ufshcd_check_errors -> ufshcd_print_host_regs -> ufshcd_vops_dbg_register_dump -> ufs_qcom_dump_dbg_regs
This causes a boot crash on the Lenovo Miix 630 when the interrupt is handled on the idle thread.
Fix the issue by switching to udelay().
--- drivers/scsi/ufs/ufs-qcom.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/ufs/ufs-qcom.c +3 -3
@@ -1546,11 +1546,11 @@ static void ufs_qcom_dump_dbg_regs(struct ufs_hba *hba)/* sleep a bit intermittently as we are dumping too much data */ ufs_qcom_print_hw_debug_reg_all (hba,NULL , ufs_qcom_dump_regs_wrapper); -usleep_range (1000 ,1100 ); +udelay (1000 );ufs_qcom_testbus_read (hba); -usleep_range (1000 ,1100 ); +udelay (1000 );ufs_qcom_print_unipro_testbus (hba); -usleep_range (1000 ,1100 ); +udelay (1000 ); }/**
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 195/266 KVM: PPC: Book3S HV: Ignore kmemleak false positives
In reply to Sasha LevinFrom: Qian Cai <[email protected]>
[ Upstream commit 0aca8a5575544bd21b3363058afb8f1e81505150 ]
kvmppc_pmd_alloc() and kvmppc_pte_alloc() allocate some memory but then pud_populate() and pmd_populate() will use __pa() to reference the newly allocated memory.
Since kmemleak is unable to track the physical memory resulting in false positives, silence those by using kmemleak_ignore().
unreferenced object 0xc000201c382a1000 (size 4096):
comm "qemu-kvm", pid 124828, jiffies 4295733767 (age 341.250s) hex dump (first 32 bytes):
c0 00 20 09 f4 60 03 87 c0 00 20 10 72 a0 03 87 .. ..`.... .r... c0 00 20 0e 13 a0 03 87 c0 00 20 1b dc c0 03 87 .. ....... .....
backtrace:
[<000000004cc2790f>] kvmppc_create_pte+0x838/0xd20 [kvm_hv] kvmppc_pmd_alloc at arch/powerpc/kvm/book3s_64_mmu_radix.c:366 (inlined by) kvmppc_create_pte at arch/powerpc/kvm/book3s_64_mmu_radix.c:590 [<00000000d123c49a>] kvmppc_book3s_instantiate_page+0x2e0/0x8c0 [kvm_hv] [<00000000bb549087>] kvmppc_book3s_radix_page_fault+0x1b4/0x2b0 [kvm_hv] [<0000000086dddc0e>] kvmppc_book3s_hv_page_fault+0x214/0x12a0 [kvm_hv] [<000000005ae9ccc2>] kvmppc_vcpu_run_hv+0xc5c/0x15f0 [kvm_hv] [<00000000d22162ff>] kvmppc_vcpu_run+0x34/0x48 [kvm] [<00000000d6953bc4>] kvm_arch_vcpu_ioctl_run+0x314/0x420 [kvm] [<000000002543dd54>] kvm_vcpu_ioctl+0x33c/0x950 [kvm] [<0000000048155cd6>] ksys_ioctl+0xd8/0x130 [<0000000041ffeaa7>] sys_ioctl+0x28/0x40 [<000000004afc4310>] system_call_exception+0x114/0x1e0 [<00000000fb70a873>] system_call_common+0xf0/0x278
unreferenced object 0xc0002001f0c03900 (size 256):
comm "qemu-kvm", pid 124830, jiffies 4295735235 (age 326.570s) hex dump (first 32 bytes):
c0 00 20 10 fa a0 03 87 c0 00 20 10 fa a1 03 87 .. ....... ..... c0 00 20 10 fa a2 03 87 c0 00 20 10 fa a3 03 87 .. ....... .....
backtrace:
[<0000000023f675b8>] kvmppc_create_pte+0x854/0xd20 [kvm_hv] kvmppc_pte_alloc at arch/powerpc/kvm/book3s_64_mmu_radix.c:356 (inlined by) kvmppc_create_pte at arch/powerpc/kvm/book3s_64_mmu_radix.c:593 [<00000000d123c49a>] kvmppc_book3s_instantiate_page+0x2e0/0x8c0 [kvm_hv] [<00000000bb549087>] kvmppc_book3s_radix_page_fault+0x1b4/0x2b0 [kvm_hv] [<0000000086dddc0e>] kvmppc_book3s_hv_page_fault+0x214/0x12a0 [kvm_hv] [<000000005ae9ccc2>] kvmppc_vcpu_run_hv+0xc5c/0x15f0 [kvm_hv] [<00000000d22162ff>] kvmppc_vcpu_run+0x34/0x48 [kvm] [<00000000d6953bc4>] kvm_arch_vcpu_ioctl_run+0x314/0x420 [kvm] [<000000002543dd54>] kvm_vcpu_ioctl+0x33c/0x950 [kvm] [<0000000048155cd6>] ksys_ioctl+0xd8/0x130 [<0000000041ffeaa7>] sys_ioctl+0x28/0x40 [<000000004afc4310>] system_call_exception+0x114/0x1e0 [<00000000fb70a873>] system_call_common+0xf0/0x278
--- arch/powerpc/kvm/book3s_64_mmu_radix.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_radix.c +14 -2
@@ -353,7 +353,13 @@ static struct kmem_cache *kvm_pmd_cache;static pte_t *kvmppc_pte_alloc (void ) { -return kmem_cache_alloc (kvm_pte_cache,GFP_KERNEL ); +pte_t *pte; + + pte =kmem_cache_alloc (kvm_pte_cache,GFP_KERNEL ); +/* pmd_populate() will only reference _pa(pte). */ +kmemleak_ignore (pte); + +return pte; }static void kvmppc_pte_free (pte_t *ptep)
@@ -363,7 +369,13 @@ static void kvmppc_pte_free(pte_t *ptep)static pmd_t *kvmppc_pmd_alloc (void ) { -return kmem_cache_alloc (kvm_pmd_cache,GFP_KERNEL ); +pmd_t *pmd; + + pmd =kmem_cache_alloc (kvm_pmd_cache,GFP_KERNEL ); +/* pud_populate() will only reference _pa(pmd). */ +kmemleak_ignore (pmd); + +return pmd; }static void kvmppc_pmd_free (pmd_t *pmdp)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 196/266 KVM: PPC: Book3S: Fix some RCU-list locks
In reply to Sasha LevinFrom: Qian Cai <[email protected]>
[ Upstream commit ab8b65be183180c3eef405d449163964ecc4b571 ]
It is unsafe to traverse kvm->arch.spapr_tce_tables and stt->iommu_tables without the RCU read lock held. Also, add cond_resched_rcu() in places with the RCU read lock held that could take a while to finish.
arch/powerpc/kvm/book3s_64_vio.c:76 RCU-list traversed in non-reader section!!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
no locks held by qemu-kvm/4265.
stack backtrace: CPU: 96 PID: 4265 Comm: qemu-kvm Not tainted 5.7.0-rc4-next-20200508+ #2 Call Trace: [c000201a8690f720] [c000000000715948] dump_stack+0xfc/0x174 (unreliable) [c000201a8690f770] [c0000000001d9470] lockdep_rcu_suspicious+0x140/0x164 [c000201a8690f7f0] [c008000010b9fb48] kvm_spapr_tce_release_iommu_group+0x1f0/0x220 [kvm] [c000201a8690f870] [c008000010b8462c] kvm_spapr_tce_release_vfio_group+0x54/0xb0 [kvm] [c000201a8690f8a0] [c008000010b84710] kvm_vfio_destroy+0x88/0x140 [kvm] [c000201a8690f8f0] [c008000010b7d488] kvm_put_kvm+0x370/0x600 [kvm] [c000201a8690f990] [c008000010b7e3c0] kvm_vm_release+0x38/0x60 [kvm] [c000201a8690f9c0] [c0000000005223f4] __fput+0x124/0x330 [c000201a8690fa20] [c000000000151cd8] task_work_run+0xb8/0x130 [c000201a8690fa70] [c0000000001197e8] do_exit+0x4e8/0xfa0 [c000201a8690fb70] [c00000000011a374] do_group_exit+0x64/0xd0 [c000201a8690fbb0] [c000000000132c90] get_signal+0x1f0/0x1200 [c000201a8690fcc0] [c000000000020690] do_notify_resume+0x130/0x3c0 [c000201a8690fda0] [c000000000038d64] syscall_exit_prepare+0x1a4/0x280 [c000201a8690fe20] [c00000000000c8f8] system_call_common+0xf8/0x278
==
arch/powerpc/kvm/book3s_64_vio.c:368 RCU-list traversed in non-reader section!!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
2 locks held by qemu-kvm/4264:
#0: c000201ae2d000d8 (&vcpu->mutex){+.+.}-{3:3}, at: kvm_vcpu_ioctl+0xdc/0x950 [kvm] #1: c000200c9ed0c468 (&kvm->srcu){....}-{0:0}, at: kvmppc_h_put_tce+0x88/0x340 [kvm]
==
arch/powerpc/kvm/book3s_64_vio.c:108 RCU-list traversed in non-reader section!!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by qemu-kvm/4257:
#0: c000200b1b363a40 (&kv->lock){+.+.}-{3:3}, at: kvm_vfio_set_attr+0x598/0x6c0 [kvm]
==
arch/powerpc/kvm/book3s_64_vio.c:146 RCU-list traversed in non-reader section!!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by qemu-kvm/4257:
#0: c000200b1b363a40 (&kv->lock){+.+.}-{3:3}, at: kvm_vfio_set_attr+0x598/0x6c0 [kvm]
--- arch/powerpc/kvm/book3s_64_vio.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
arch/powerpc/kvm/book3s_64_vio.c +14 -4
@@ -74,6 +74,7 @@ extern void kvm_spapr_tce_release_iommu_group(struct kvm *kvm,struct kvmppc_spapr_tce_iommu_table *stit, *tmp;struct iommu_table_group *table_group =NULL ; +rcu_read_lock ();list_for_each_entry_rcu (stt, &kvm->arch.spapr_tce_tables, list) { table_group =iommu_group_get_iommudata (grp);
@@ -88,7 +89,9 @@ extern void kvm_spapr_tce_release_iommu_group(struct kvm *kvm,kref_put (&stit->kref, kvm_spapr_tce_liobn_put); } } +cond_resched_rcu (); } +rcu_read_unlock (); } extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
@@ -106,12 +109,14 @@ extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,if (!f.file)return -EBADF ; +rcu_read_lock ();list_for_each_entry_rcu (stt, &kvm->arch.spapr_tce_tables, list) {if (stt = f.file->private_data) { found = true;break ; } } +rcu_read_unlock ();fdput (f);
@@ -144,6 +149,7 @@ extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,if (!tbl)return -EINVAL ; +rcu_read_lock ();list_for_each_entry_rcu (stit, &stt->iommu_tables, next) {if (tbl != stit->tbl)continue ;
@@ -151,14 +157,17 @@ extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,if (!kref_get_unless_zero (&stit->kref)) {/* stit is being destroyed */ iommu_tce_table_put (tbl); +rcu_read_unlock ();return -ENOTTY ; }/* * The table is already known to this KVM, we just increased * its KVM reference counter and can return. */ +rcu_read_unlock ();return 0 ; } +rcu_read_unlock (); stit =kzalloc (sizeof (*stit),GFP_KERNEL );if (!stit) {
@@ -364,18 +373,19 @@ static long kvmppc_tce_validate(struct kvmppc_spapr_tce_table *stt,if (kvmppc_tce_to_ua (stt->kvm, tce, &ua))return H_TOO_HARD ; +rcu_read_lock ();list_for_each_entry_rcu (stit, &stt->iommu_tables, next) {unsigned long hpa =0 ;struct mm_iommu_table_group_mem_t *mem;long shift = stit->tbl->it_page_shift; mem =mm_iommu_lookup (stt->kvm->mm, ua,1ULL << shift); -if (!mem) -return H_TOO_HARD ; - -if (mm_iommu_ua_to_hpa (mem, ua, shift, &hpa)) +if (!mem ||mm_iommu_ua_to_hpa (mem, ua, shift, &hpa)) { +rcu_read_unlock ();return H_TOO_HARD ; + } } +rcu_read_unlock ();return H_SUCCESS ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 197/266 clk: sprd: return correct type of value for _sprd_pll_recalc_rate
In reply to Sasha LevinFrom: Chunyan Zhang <[email protected]>
[ Upstream commit c2f30986d418f26abefc2eec90ebf06716c970d2 ]
The function _sprd_pll_recalc_rate() defines return value to unsigned long, but it would return a negative value when malloc fail, changing to return its parent_rate makes more sense, since if the callback .recalc_rate() is not set, the framework returns the parent_rate as well.
--- drivers/clk/sprd/pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sprd/pll.c +1 -1
@@ -105,7 +105,7 @@ static unsigned long _sprd_pll_recalc_rate(const struct sprd_pll *pll, cfg =kcalloc (regs_num,sizeof (*cfg),GFP_KERNEL );if (!cfg) -return -ENOMEM ; +return parent_rate;for (i =0 ; i < regs_num; i++) cfg[i] =sprd_pll_read (pll, i);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 198/266 clk: ast2600: Fix AHB clock divider for A1
In reply to Sasha LevinFrom: Eddie James <[email protected]>
[ Upstream commit 2d491066ccd4286538450c227fc5094ceb04b494 ]
The latest specs for the AST2600 A1 chip include some different bit definitions for calculating the AHB clock divider. Implement these in order to get the correct AHB clock value in Linux.
--- drivers/clk/clk-ast2600.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)
drivers/clk/clk-ast2600.c +25 -6
@@ -599,14 +599,22 @@ static const u32 ast2600_a0_axi_ahb_div_table[] = { 2, 2, 3, 5, }; -static const u32 ast2600_a1_axi_ahb_div_table[] = { -4 ,6 ,2 ,4 , +static const u32 ast2600_a1_axi_ahb_div0_tbl[] = { +3 ,2 ,3 ,4 , +}; + +static const u32 ast2600_a1_axi_ahb_div1_tbl[] = { +3 ,4 ,6 ,8 , +}; + +static const u32 ast2600_a1_axi_ahb200_tbl[] = { +3 ,4 ,3 ,4 ,2 ,2 ,2 ,2 , };static void __init aspeed_g6_cc (struct regmap *map) {struct clk_hw *hw; -u32 val, div, chip_id, axi_div, ahb_div; +u32 val, div, divbits, chip_id, axi_div, ahb_div;clk_hw_register_fixed_rate (NULL ,"clkin" ,NULL ,0 ,25000000 );
@@ -636,11 +644,22 @@ static void __init aspeed_g6_cc(struct regmap *map)else axi_div =2 ; + divbits = (val >>11 ) &0x3 ;regmap_read (map,ASPEED_G6_SILICON_REV , &chip_id); -if (chip_id &BIT (16 )) - ahb_div = ast2600_a1_axi_ahb_div_table[(val >>11 ) &0x3 ]; -else +if (chip_id &BIT (16 )) { +if (!divbits) { + ahb_div = ast2600_a1_axi_ahb200_tbl[(val >>8 ) &0x3 ]; +if (val &BIT (16 )) + ahb_div *=2 ; + }else { +if (val &BIT (16 )) + ahb_div = ast2600_a1_axi_ahb_div1_tbl[divbits]; +else + ahb_div = ast2600_a1_axi_ahb_div0_tbl[divbits]; + } + }else { ahb_div = ast2600_a0_axi_ahb_div_table[(val >>11 ) &0x3 ]; + } hw =clk_hw_register_fixed_factor (NULL ,"ahb" ,"hpll" ,0 ,1 , axi_div * ahb_div); aspeed_g6_clk_data->hws[ASPEED_CLK_AHB ] = hw;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 199/266 misc: xilinx-sdfec: improve get_user_pages_fast() error handling
In reply to Sasha LevinFrom: John Hubbard <[email protected]>
[ Upstream commit 57343d51613227373759f5b0f2eede257fd4b82e ]
This fixes the case of get_user_pages_fast() returning a -errno. The result needs to be stored in a signed integer. And for safe signed/unsigned comparisons, it's best to keep everything signed. And get_user_pages_fast() also expects a signed value for number of pages to pin.
Therefore, change most relevant variables, from u32 to int. Leave "n" unsigned, for convenience in checking for overflow. And provide a WARN_ON_ONCE() and early return, if overflow occurs.
Also, as long as we're tidying up: rename the page array from page, to pages, in order to match the conventions used in most other call sites.
--- drivers/misc/xilinx_sdfec.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
drivers/misc/xilinx_sdfec.c +17 -10
@@ -602,10 +602,10 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset, const u32 depth) {u32 reg =0 ; -u32 res; -u32 n, i; +int res, i, nr_pages; +u32 n;u32 *addr =NULL ; -struct page *page[MAX_NUM_PAGES ]; +struct page *pages[MAX_NUM_PAGES ];/* * Writes that go beyond the length of
@@ -622,15 +622,22 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset,if ((len *XSDFEC_REG_WIDTH_JUMP ) %PAGE_SIZE ) n +=1 ; - res =get_user_pages_fast ((unsigned long )src_ptr, n,0 , page); -if (res < n) { -for (i =0 ; i < res; i++) -put_page (page[i]); +if (WARN_ON_ONCE (n >INT_MAX )) +return -EINVAL ; + + nr_pages = n; + + res =get_user_pages_fast ((unsigned long )src_ptr, nr_pages,0 , pages); +if (res < nr_pages) { +if (res >0 ) { +for (i =0 ; i < res; i++) +put_page (pages[i]); + }return -EINVAL ; } - for (i = 0; i < n; i++) { - addr = kmap(page[i]); + for (i = 0; i < nr_pages; i++) { + addr = kmap(pages[i]); do { xsdfec_regwrite(xsdfec, base_addr + ((offset + reg) *
@@ -639,7 +646,7 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset, reg++; }while ((reg < len) && ((reg *XSDFEC_REG_WIDTH_JUMP ) %PAGE_SIZE )); -put_page (page[i]); +put_page (pages[i]); }return reg; }
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RE: [PATCH AUTOSEL 5.4 199/266] misc: xilinx-sdfec: improve get_user_pages_fast() error handling
Hi Sasha,
Thank you for the patch.
Quoted 99 lines
-----Original Message-----
From: Sasha Levin <[email protected]>
Sent: Thursday 18 June 2020 02:15
To: [email protected]; [email protected]
Cc: John Hubbard <[email protected]>; Derek Kiernan <[email protected]>; Dragan Cvetic <[email protected]>; Arnd Bergmann <[email protected]>; Greg Kroah-Hartman <[email protected]>; Michal Simek <[email protected]>; linux-arm- [email protected]; Sasha Levin <[email protected]>
Subject: [PATCH AUTOSEL 5.4 199/266] misc: xilinx-sdfec: improveget_user_pages_fast()error handlingFrom: John Hubbard <[email protected]>
[ Upstream commit
57343d51613227373759f5b0f2eede257fd4b82e]This fixes the case of
get_user_pages_fast()returning a -errno. The result needs to be stored in a signed integer. And for safe signed/unsigned comparisons, it's best to keep everything signed. Andget_user_pages_fast()also expects a signed value for number of pages to pin.Therefore, change most relevant variables, from u32 to int. Leave "n" unsigned, for convenience in checking for overflow. And provide a
WARN_ON_ONCE()and early return, if overflow occurs.Also, as long as we're tidying up: rename the page array from page, to pages, in order to match the conventions used in most other call sites.
Fixes 20ec628e8007e ("misc: xilinx_sdfec: Add ability to configure LDPC")Cc Derek Kiernan <[email protected]>Cc Dragan Cvetic <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Michal Simek <[email protected]>Signed-off-by John Hubbard <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/misc/xilinx_sdfec.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)drivers/misc/xilinx_sdfec.c +17
-11@@ -602,10 +602,10 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset, const u32 depth) {u32 reg =0 ; -u32 res; -u32 n, i; +int res, i, nr_pages; +u32 n;u32 *addr =NULL ; -struct page *page[MAX_NUM_PAGES ]; +struct page *pages[MAX_NUM_PAGES ];/* * Writes that go beyond the length of @@ -622,15 +622,22 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset,if ((len *XSDFEC_REG_WIDTH_JUMP ) %PAGE_SIZE ) n +=1 ; - res =get_user_pages_fast ((unsigned long )src_ptr, n,0 , page); -if (res < n) { -for (i =0 ; i < res; i++) -put_page (page[i]); +if (WARN_ON_ONCE (n >INT_MAX )) +return -EINVAL ; + + nr_pages = n; + + res =get_user_pages_fast ((unsigned long )src_ptr, nr_pages,0 , pages); +if (res < nr_pages) { +if (res >0 ) { +for (i =0 ; i < res; i++) +put_page (pages[i]); + }return -EINVAL ; } - for (i = 0; i < n; i++) { - addr = kmap(page[i]); + for (i = 0; i < nr_pages; i++) { + addr = kmap(pages[i]); do { xsdfec_regwrite(xsdfec, base_addr + ((offset + reg) *@@ -639,7 +646,7 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset, reg++; }while ((reg < len) && ((reg *XSDFEC_REG_WIDTH_JUMP ) %PAGE_SIZE )); -put_page (page[i]); +put_page (pages[i]); }return reg; } --
Quoted 1 line
2.25.1
Regards
Dragan
Sasha Levin
maintainerPATCH 200/266 /dev/mem: Revoke mappings when a driver claims the region
In reply to Sasha LevinFrom: Dan Williams <[email protected]>
[ Upstream commit 3234ac664a870e6ea69ae3a57d824cd7edbeacc5 ]
Close the hole of holding a mapping over kernel driver takeover event of a given address range.
Commit 90a545e98126 ("restrict /dev/mem to idle io memory ranges") introduced CONFIG_IO_STRICT_DEVMEM with the goal of protecting the kernel against scenarios where a /dev/mem user tramples memory that a kernel driver owns. However, this protection only prevents *new* read(), write() and mmap() requests. Established mappings prior to the driver calling request_mem_region() are left alone.
Especially with persistent memory, and the core kernel metadata that is stored there, there are plentiful scenarios for a /dev/mem user to violate the expectations of the driver and cause amplified damage.
Teach request_mem_region() to find and shoot down active /dev/mem mappings that it believes it has successfully claimed for the exclusive use of the driver. Effectively a driver call to request_mem_region() becomes a hole-punch on the /dev/mem device.
The typical usage of unmap_mapping_range() is part of truncate_pagecache() to punch a hole in a file, but in this case the implementation is only doing the "first half" of a hole punch. Namely it is just evacuating current established mappings of the "hole", and it relies on the fact that /dev/mem establishes mappings in terms of absolute physical address offsets. Once existing mmap users are invalidated they can attempt to re-establish the mapping, or attempt to continue issuing read(2) / write(2) to the invalidated extent, but they will then be subject to the CONFIG_IO_STRICT_DEVMEM checking that can block those subsequent accesses.
--- drivers/char/mem.c | 101 ++++++++++++++++++++++++++++++++++++- include/linux/ioport.h | 6 +++ include/uapi/linux/magic.h | 1 + kernel/resource.c | 5 ++ 4 files changed, 111 insertions(+), 2 deletions(-)
drivers/char/mem.c +99 -2
@@ -31,11 +31,15 @@#include <linux/uio.h> #include <linux/uaccess.h> #include <linux/security.h> +#include <linux/pseudo_fs.h> +#include <uapi/linux/magic.h> +#include <linux/mount.h> #ifdef CONFIG_IA64 # include <linux/efi.h> #endif +#define DEVMEM_MINOR 1#define DEVPORT_MINOR 4 static inline unsigned long size_inside_page(unsigned long start,
@@ -805,12 +809,64 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)return ret; } +static struct inode *devmem_inode; + +#ifdef CONFIG_IO_STRICT_DEVMEM +void revoke_devmem (struct resource *res) +{ +struct inode *inode =READ_ONCE (devmem_inode); + +/* +* Check that the initialization has completed. Losing the race +* is ok because it means drivers are claiming resources before +* the fs_initcall level of init and prevent /dev/mem from +* establishing mappings. +*/ +if (!inode) +return ; + +/* +* The expectation is that the driver has successfully marked +* the resource busy by this point, so devmem_is_allowed() +* should start returning false, however for performance this +* does not iterate the entire resource range. +*/ +if (devmem_is_allowed (PHYS_PFN (res->start)) && +devmem_is_allowed (PHYS_PFN (res->end))) { +/* +* *cringe* iomem=relaxed says "go ahead, what's the +* worst that can happen?" +*/ +return ; + } + +unmap_mapping_range (inode->i_mapping, res->start,resource_size (res),1 ); +} +#endif +static int open_port (struct inode *inode,struct file *filp) { +int rc; +if (!capable (CAP_SYS_RAWIO ))return -EPERM ; -return security_locked_down (LOCKDOWN_DEV_MEM ); + rc =security_locked_down (LOCKDOWN_DEV_MEM ); +if (rc) +return rc; + +if (iminor (inode) !=DEVMEM_MINOR ) +return 0 ; + +/* +* Use a unified address space to have a single point to manage +* revocations when drivers want to take over a /dev/mem mapped +* range. +*/ + inode->i_mapping = devmem_inode->i_mapping; + filp->f_mapping = inode->i_mapping; + +return 0 ; }#define zero_lseek null_lseek
@@ -885,7 +941,7 @@ static const struct memdev {fmode_t fmode; } devlist[] = { #ifdef CONFIG_DEVMEM - [1] = { "mem", 0, &mem_fops, FMODE_UNSIGNED_OFFSET }, + [DEVMEM_MINOR] = { "mem", 0, &mem_fops, FMODE_UNSIGNED_OFFSET }, #endif #ifdef CONFIG_DEVKMEM [2] = { "kmem", 0, &kmem_fops, FMODE_UNSIGNED_OFFSET },
@@ -939,6 +995,45 @@ static char *mem_devnode(struct device *dev, umode_t *mode)static struct class *mem_class; +static int devmem_fs_init_fs_context (struct fs_context *fc) +{ +return init_pseudo (fc,DEVMEM_MAGIC ) ?0 : -ENOMEM ; +} + +static struct file_system_type devmem_fs_type = { + .name ="devmem" , + .owner =THIS_MODULE , + .init_fs_context = devmem_fs_init_fs_context, + .kill_sb = kill_anon_super, +}; + +static int devmem_init_inode (void ) +{ +static struct vfsmount *devmem_vfs_mount; +static int devmem_fs_cnt; +struct inode *inode; +int rc; + + rc =simple_pin_fs (&devmem_fs_type, &devmem_vfs_mount, &devmem_fs_cnt); +if (rc <0 ) { +pr_err ("Cannot mount /dev/mem pseudo filesystem: %d\n" , rc); +return rc; + } + + inode =alloc_anon_inode (devmem_vfs_mount->mnt_sb); +if (IS_ERR (inode)) { + rc =PTR_ERR (inode); +pr_err ("Cannot allocate inode for /dev/mem: %d\n" , rc); +simple_release_fs (&devmem_vfs_mount, &devmem_fs_cnt); +return rc; + } + +/* publish /dev/mem initialized */ +WRITE_ONCE (devmem_inode, inode); + +return 0 ; +} +static int __init chr_dev_init (void ) {int minor;
@@ -960,6 +1055,8 @@ static int __init chr_dev_init(void)*/ if ((minor ==DEVPORT_MINOR ) && !arch_has_dev_port ())continue ; +if ((minor ==DEVMEM_MINOR ) &&devmem_init_inode () !=0 ) +continue ;device_create (mem_class,NULL ,MKDEV (MEM_MAJOR , minor),NULL , devlist[minor].name);
include/linux/ioport.h +6 -0
@@ -300,5 +300,11 @@ struct resource *devm_request_free_mem_region(struct device *dev,struct resource *request_free_mem_region (struct resource *base,unsigned long size,const char *name); +#ifdef CONFIG_IO_STRICT_DEVMEM +void revoke_devmem (struct resource *res); +#else +static inline void revoke_devmem (struct resource *res) { }; +#endif +#endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */
include/uapi/linux/magic.h +1 -0
@@ -93,6 +93,7 @@#define BALLOON_KVM_MAGIC 0x13661366#define ZSMALLOC_MAGIC 0x58295829#define DMA_BUF_MAGIC 0x444d4142/* "DMAB" */ +#define DEVMEM_MAGIC 0x454d444d/* "DMEM" */ #define Z3FOLD_MAGIC 0x33#endif /* __LINUX_MAGIC_H__ */
kernel/resource.c +5 -0
@@ -1126,6 +1126,7 @@ struct resource * __request_region(struct resource *parent, {DECLARE_WAITQUEUE (wait, current);struct resource *res =alloc_resource (GFP_KERNEL ); +struct resource *orig_parent = parent;if (!res)return NULL ;
@@ -1176,6 +1177,10 @@ struct resource * __request_region(struct resource *parent,break ; }write_unlock (&resource_lock); + +if (res && orig_parent == &iomem_resource) +revoke_devmem (res); +return res; }EXPORT_SYMBOL (__request_region);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 201/266 net: sunrpc: Fix off-by-one issues in 'rpc_ntop6'
In reply to Sasha LevinFrom: Fedor Tokarev <[email protected]>
[ Upstream commit 118917d696dc59fd3e1741012c2f9db2294bed6f ]
Fix off-by-one issues in 'rpc_ntop6':
- 'snprintf' returns the number of characters which would have been written if enough space had been available, excluding the terminating null byte. Thus, a return value of 'sizeof(scopebuf)' means that the last character was dropped.
- 'strcat' adds a terminating null byte to the string, thus if len == buflen, the null byte is written past the end of the buffer.
--- net/sunrpc/addr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sunrpc/addr.c +2 -2
@@ -82,11 +82,11 @@ static size_t rpc_ntop6(const struct sockaddr *sap, rc =snprintf (scopebuf,sizeof (scopebuf),"%c%u" ,IPV6_SCOPE_DELIMITER , sin6->sin6_scope_id); -if (unlikely ((size_t )rc >sizeof (scopebuf))) +if (unlikely ((size_t )rc >=sizeof (scopebuf)))return 0 ; len += rc; -if (unlikely (len > buflen)) +if (unlikely (len >= buflen))return 0 ;strcat (buf, scopebuf);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 202/266 NFSv4.1 fix rpc_call_done assignment for BIND_CONN_TO_SESSION
In reply to Sasha LevinFrom: Olga Kornievskaia <[email protected]>
[ Upstream commit 1c709b766e73e54d64b1dde1b7cfbcf25bcb15b9 ]
--- fs/nfs/nfs4proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4proc.c +1 -1
@@ -7870,7 +7870,7 @@ nfs4_bind_one_conn_to_session_done(struct rpc_task *task, void *calldata) }static const struct rpc_call_ops nfs4_bind_one_conn_to_session_ops = { - .rpc_call_done = &nfs4_bind_one_conn_to_session_done, + .rpc_call_done = nfs4_bind_one_conn_to_session_done, };/*
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 203/266 PCI: Avoid FLR for AMD Matisse HD Audio & USB 3.0
In reply to Sasha LevinFrom: Marcos Scriven <[email protected]>
[ Upstream commit 0d14f06cd6657ba3446a5eb780672da487b068e7 ]
The AMD Matisse HD Audio & USB 3.0 devices advertise Function Level Reset support, but hang when an FLR is triggered.
To reproduce the problem, attach the device to a VM, then detach and try to attach again.
Rename the existing quirk_intel_no_flr(), which was not Intel-specific, to quirk_no_flr(), and apply it to prevent the use of FLR on these AMD devices.
--- drivers/pci/quirks.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/pci/quirks.c +14 -4
@@ -5130,13 +5130,23 @@ static void quirk_intel_qat_vf_cap(struct pci_dev *pdev) }DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x443 , quirk_intel_qat_vf_cap); -/* FLR may cause some 82579 devices to hang */ -static void quirk_intel_no_flr (struct pci_dev *dev) +/* +* FLR may cause the following to devices to hang: +* +* AMD Starship/Matisse HD Audio Controller 0x1487 +* AMD Matisse USB 3.0 Host Controller 0x149c +* Intel 82579LM Gigabit Ethernet Controller 0x1502 +* Intel 82579V Gigabit Ethernet Controller 0x1503 +* +*/ +static void quirk_no_flr (struct pci_dev *dev) { dev->dev_flags |=PCI_DEV_FLAGS_NO_FLR_RESET ; } -DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1502 , quirk_intel_no_flr); -DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1503 , quirk_intel_no_flr); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x1487 , quirk_no_flr); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x149c , quirk_no_flr); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1502 , quirk_no_flr); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1503 , quirk_no_flr);static void quirk_no_ext_tags (struct pci_dev *pdev) {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 204/266 PCI: Avoid FLR for AMD Starship USB 3.0
In reply to Sasha LevinFrom: Kevin Buettner <[email protected]>
[ Upstream commit 5727043c73fdfe04597971b5f3f4850d879c1f4f ]
The AMD Starship USB 3.0 host controller advertises Function Level Reset support, but it apparently doesn't work. Add a quirk to prevent use of FLR on this device.
Without this quirk, when attempting to assign (pass through) an AMD Starship USB 3.0 host controller to a guest OS, the system becomes increasingly unresponsive over the course of several minutes, eventually requiring a hard reset. Shortly after attempting to start the guest, I see these messages:
vfio-pci 0000:05:00.3: not ready 1023ms after FLR; waiting vfio-pci 0000:05:00.3: not ready 2047ms after FLR; waiting vfio-pci 0000:05:00.3: not ready 4095ms after FLR; waiting vfio-pci 0000:05:00.3: not ready 8191ms after FLR; waiting
And then eventually:
vfio-pci 0000:05:00.3: not ready 65535ms after FLR; giving up
INFO: NMI handler (perf_event_nmi_handler) took too long to run: 0.000 msecs
perf: interrupt took too long (642744 > 2500), lowering kernel.perf_event_max_sample_rate to 1000
INFO: NMI handler (perf_event_nmi_handler) took too long to run: 82.270 msecs
INFO: NMI handler (perf_event_nmi_handler) took too long to run: 680.608 msecs
INFO: NMI handler (perf_event_nmi_handler) took too long to run: 100.952 msecs
...
watchdog: BUG: soft lockup - CPU#3 stuck for 22s! [qemu-system-x86:7487]
Tested on a Micro-Star International Co., Ltd. MS-7C59/Creator TRX40 motherboard with an AMD Ryzen Threadripper 3970X.
--- drivers/pci/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/quirks.c +2 -0
@@ -5134,6 +5134,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x443, quirk_intel_qat_vf_cap);* FLR may cause the following to devices to hang: * * AMD Starship/Matisse HD Audio Controller 0x1487 +* AMD Starship USB 3.0 Host Controller 0x148c * AMD Matisse USB 3.0 Host Controller 0x149c * Intel 82579LM Gigabit Ethernet Controller 0x1502 * Intel 82579V Gigabit Ethernet Controller 0x1503
@@ -5144,6 +5145,7 @@ static void quirk_no_flr(struct pci_dev *dev) dev->dev_flags |=PCI_DEV_FLAGS_NO_FLR_RESET ; }DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x1487 , quirk_no_flr); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x148c , quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x149c , quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1502 , quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1503 , quirk_no_flr);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 205/266 of: Fix a refcounting bug in __of_attach_node_sysfs()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit 8a325dd06f2358ea0888e4ff1c9ca4bc23bd53f3 ]
The problem in this code is that if kobject_add() fails, then it should call of_node_put(np) to drop the reference count. I've actually moved the of_node_get(np) later in the function to avoid needing to do clean up.
--- drivers/of/kobj.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/of/kobj.c +1 -2
@@ -134,8 +134,6 @@ int __of_attach_node_sysfs(struct device_node *np)if (!name)return -ENOMEM ; -of_node_get (np); - rc =kobject_add (&np->kobj, parent,"%s" , name);kfree (name);if (rc)
@@ -144,6 +142,7 @@ int __of_attach_node_sysfs(struct device_node *np)for_each_property_of_node (np, pp)__of_add_property_sysfs (np, pp); +of_node_get (np);return 0 ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 206/266 input: i8042 - Remove special PowerPC handling
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit e4f4ffa8a98c24a4ab482669b1e2b4cfce3f52f4 ]
This causes a build error with CONFIG_WALNUT because kb_cs and kb_data were removed in commit 917f0af9e5a9 ("powerpc: Remove arch/ppc and include/asm-ppc").
ld.lld: error: undefined symbol: kb_cs
Quoted 6 lines
referenced by i8042-ppcio.h:28 (
drivers/input/serio/i8042-ppcio.h:28) input/serio/i8042.o:(__i8042_command) in archivedrivers/built-in.areferenced by i8042-ppcio.h:28 (drivers/input/serio/i8042-ppcio.h:28) input/serio/i8042.o:(__i8042_command) in archivedrivers/built-in.areferenced by i8042-ppcio.h:28 (drivers/input/serio/i8042-ppcio.h:28) input/serio/i8042.o:(__i8042_command) in archivedrivers/built-in.a
ld.lld: error: undefined symbol: kb_data
Quoted 7 lines
referenced by i8042.c:309 (
drivers/input/serio/i8042.c:309) input/serio/i8042.o:(__i8042_command) in archivedrivers/built-in.areferenced by i8042-ppcio.h:33 (drivers/input/serio/i8042-ppcio.h:33) input/serio/i8042.o:(__i8042_command) in archivedrivers/built-in.areferenced by i8042.c:319 (drivers/input/serio/i8042.c:319) input/serio/i8042.o:(__i8042_command) in archivedrivers/built-in.areferenced 15 more times
Presumably since nobody has noticed this for the last 12 years, there is not anyone actually trying to use this driver so we can just remove this special walnut code and use the generic header so it builds for all configurations.
--- drivers/input/serio/i8042-ppcio.h | 57 ------------------------------- drivers/input/serio/i8042.h | 2 -- 2 files changed, 59 deletions(-) delete mode 100644 drivers/input/serio/i8042-ppcio.h
drivers/input/serio/i8042-ppcio.h deleted +0 -57
@@ -1,57 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _I8042_PPCIO_H -#define _I8042_PPCIO_H - - -#if defined(CONFIG_WALNUT ) - -#define I8042_KBD_IRQ 25 -#define I8042_AUX_IRQ 26 - -#define I8042_KBD_PHYS_DESC "walnutps2/serio0" -#define I8042_AUX_PHYS_DESC "walnutps2/serio1" -#define I8042_MUX_PHYS_DESC "walnutps2/serio%d" - -extern void *kb_cs; -extern void *kb_data; - -#define I8042_COMMAND_REG (*(int *)kb_cs) -#define I8042_DATA_REG (*(int *)kb_data) - -static inline int i8042_read_data (void ) -{ -return readb (kb_data); -} - -static inline int i8042_read_status (void ) -{ -return readb (kb_cs); -} - -static inline void i8042_write_data (int val) -{ -writeb (val, kb_data); -} - -static inline void i8042_write_command (int val) -{ -writeb (val, kb_cs); -} - -static inline int i8042_platform_init (void ) -{ - i8042_reset =I8042_RESET_ALWAYS ; -return 0 ; -} - -static inline void i8042_platform_exit (void ) -{ -} - -#else - -#include "i8042-io.h" - -#endif - -#endif /* _I8042_PPCIO_H */
drivers/input/serio/i8042.h +0 -2
@@ -17,8 +17,6 @@#include "i8042-ip22io.h" #elif defined(CONFIG_SNI_RM )#include "i8042-snirm.h" -#elif defined(CONFIG_PPC ) -#include "i8042-ppcio.h" #elif defined(CONFIG_SPARC )#include "i8042-sparcio.h" #elif defined(CONFIG_X86 ) || defined(CONFIG_IA64 )
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 207/266 powerpc/4xx: Don't unmap NULL mbase
In reply to Sasha LevinFrom: huhai <[email protected]>
[ Upstream commit bcec081ecc940fc38730b29c743bbee661164161 ]
--- arch/powerpc/platforms/4xx/pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/powerpc/platforms/4xx/pci.c +1 -3
@@ -1242,7 +1242,7 @@ static void __init ppc460sx_pciex_check_link(struct ppc4xx_pciex_port *port)if (mbase ==NULL ) {printk (KERN_ERR "%pOF: Can't map internal config space !" , port->node); - goto done; +return ; } while (attempt && (0 == (in_le32(mbase + PECFG_460SX_DLLSTA)
@@ -1252,9 +1252,7 @@ static void __init ppc460sx_pciex_check_link(struct ppc4xx_pciex_port *port) }if (attempt) port->link =1 ; -done:iounmap (mbase); - }static struct ppc4xx_pciex_hwops ppc460sx_pcie_hwops__initdata = {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 208/266 extcon: adc-jack: Fix an error handling path in 'adc_jack_probe()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit bc84cff2c92ae5ccb2c37da73756e7174b1b430f ]
In some error handling paths, a call to 'iio_channel_get()' is not balanced by a corresponding call to 'iio_channel_release()'.
This can be achieved easily by using the devm_ variant of 'iio_channel_get()'.
This has the extra benefit to simplify the remove function.
--- drivers/extcon/extcon-adc-jack.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/extcon/extcon-adc-jack.c +1 -2
@@ -124,7 +124,7 @@ static int adc_jack_probe(struct platform_device *pdev)for (i =0 ; data->adc_conditions[i].id !=EXTCON_NONE ; i++); data->num_conditions = i; - data->chan =iio_channel_get (&pdev->dev, pdata->consumer_channel); + data->chan =devm_iio_channel_get (&pdev->dev, pdata->consumer_channel);if (IS_ERR (data->chan))return PTR_ERR (data->chan);
@@ -164,7 +164,6 @@ static int adc_jack_remove(struct platform_device *pdev)free_irq (data->irq, data);cancel_work_sync (&data->handler.work); -iio_channel_release (data->chan);return 0 ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 209/266 ASoC: fsl_asrc_dma: Fix dma_chan leak when config DMA channel failed
In reply to Sasha LevinFrom: Xiyu Yang <[email protected]>
[ Upstream commit 36124fb19f1ae68a500cd76a76d40c6e81bee346 ]
fsl_asrc_dma_hw_params() invokes dma_request_channel() or fsl_asrc_get_dma_channel(), which returns a reference of the specified dma_chan object to "pair->dma_chan[dir]" with increased refcnt.
The reference counting issue happens in one exception handling path of fsl_asrc_dma_hw_params(). When config DMA channel failed for Back-End, the function forgets to decrease the refcnt increased by dma_request_channel() or fsl_asrc_get_dma_channel(), causing a refcnt leak.
Fix this issue by calling dma_release_channel() when config DMA channel failed.
--- sound/soc/fsl/fsl_asrc_dma.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/fsl/fsl_asrc_dma.c +1 -0
@@ -241,6 +241,7 @@ static int fsl_asrc_dma_hw_params(struct snd_pcm_substream *substream, ret =dmaengine_slave_config (pair->dma_chan[dir], &config_be);if (ret) {dev_err (dev,"failed to config DMA channel for Back-End\n" ); +dma_release_channel (pair->dma_chan[dir]);return ret; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 210/266 vfio/mdev: Fix reference count leak in add_mdev_supported_type
In reply to Sasha LevinFrom: Qiushi Wu <[email protected]>
[ Upstream commit aa8ba13cae3134b8ef1c1b6879f66372531da738 ]
kobject_init_and_add() takes reference even when it fails. If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Thus, replace kfree() by kobject_put() to fix this issue. Previous commit "b8eb718348b8" fixed a similar problem.
--- drivers/vfio/mdev/mdev_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/mdev/mdev_sysfs.c +1 -1
@@ -110,7 +110,7 @@ static struct mdev_type *add_mdev_supported_type(struct mdev_parent *parent,"%s-%s" ,dev_driver_string (parent->dev), group->name);if (ret) { -kfree (type); +kobject_put (&type->kobj);return ERR_PTR (ret); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 211/266 rtc: rv3028: Add missed check for devm_regmap_init_i2c()
In reply to Sasha LevinFrom: Chuhong Yuan <[email protected]>
[ Upstream commit c3b29bf6f166f6ed5f04f9c125477358e0e25df8 ]
rv3028_probe() misses a check for devm_regmap_init_i2c(). Add the missed check to fix it.
--- drivers/rtc/rtc-rv3028.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/rtc/rtc-rv3028.c +2 -0
@@ -625,6 +625,8 @@ static int rv3028_probe(struct i2c_client *client)return -ENOMEM ; rv3028->regmap =devm_regmap_init_i2c (client, ®map_config); +if (IS_ERR (rv3028->regmap)) +return PTR_ERR (rv3028->regmap);i2c_set_clientdata (client, rv3028);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 212/266 mailbox: zynqmp-ipi: Fix NULL vs IS_ERR() check in zynqmp_ipi_mbox_probe()
In reply to Sasha LevinFrom: Wei Yongjun <[email protected]>
[ Upstream commit 445aeeb569f8d7904f8cf80b7c6826bb651ef80e ]
In case of error, the function devm_ioremap() returns NULL pointer not ERR_PTR(). So we should check whether the return value of devm_ioremap() is NULL instead of IS_ERR.
--- drivers/mailbox/zynqmp-ipi-mailbox.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/mailbox/zynqmp-ipi-mailbox.c +8 -12
@@ -504,10 +504,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox *ipi_mbox, mchan->req_buf_size =resource_size (&res); mchan->req_buf =devm_ioremap (mdev, res.start, mchan->req_buf_size); -if (IS_ERR (mchan->req_buf)) { +if (!mchan->req_buf) {dev_err (mdev,"Unable to map IPI buffer I/O memory\n" ); - ret =PTR_ERR (mchan->req_buf); -return ret; +return -ENOMEM ; } }else if (ret != -ENODEV ) {dev_err (mdev,"Unmatched resource %s, %d.\n" , name, ret);
@@ -520,10 +519,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox *ipi_mbox, mchan->resp_buf_size =resource_size (&res); mchan->resp_buf =devm_ioremap (mdev, res.start, mchan->resp_buf_size); -if (IS_ERR (mchan->resp_buf)) { +if (!mchan->resp_buf) {dev_err (mdev,"Unable to map IPI buffer I/O memory\n" ); - ret =PTR_ERR (mchan->resp_buf); -return ret; +return -ENOMEM ; } }else if (ret != -ENODEV ) {dev_err (mdev,"Unmatched resource %s.\n" , name);
@@ -543,10 +541,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox *ipi_mbox, mchan->req_buf_size =resource_size (&res); mchan->req_buf =devm_ioremap (mdev, res.start, mchan->req_buf_size); -if (IS_ERR (mchan->req_buf)) { +if (!mchan->req_buf) {dev_err (mdev,"Unable to map IPI buffer I/O memory\n" ); - ret =PTR_ERR (mchan->req_buf); -return ret; +return -ENOMEM ; } }else if (ret != -ENODEV ) {dev_err (mdev,"Unmatched resource %s.\n" , name);
@@ -559,10 +556,9 @@ static int zynqmp_ipi_mbox_probe(struct zynqmp_ipi_mbox *ipi_mbox, mchan->resp_buf_size =resource_size (&res); mchan->resp_buf =devm_ioremap (mdev, res.start, mchan->resp_buf_size); -if (IS_ERR (mchan->resp_buf)) { +if (!mchan->resp_buf) {dev_err (mdev,"Unable to map IPI buffer I/O memory\n" ); - ret =PTR_ERR (mchan->resp_buf); -return ret; +return -ENOMEM ; } }else if (ret != -ENODEV ) {dev_err (mdev,"Unmatched resource %s.\n" , name);
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 213/266 rxrpc: Adjust /proc/net/rxrpc/calls to display call->debug_id not user_ID
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit 32f71aa497cfb23d37149c2ef16ad71fce2e45e2 ]
The user ID value isn't actually much use - and leaks a kernel pointer or a userspace value - so replace it with the call debug ID, which appears in trace points.
--- net/rxrpc/proc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/rxrpc/proc.c +3 -3
@@ -68,7 +68,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)"Proto Local " " Remote " " SvID ConnID CallID End Use State Abort " - " UserID TxSeq TW RxSeq RW RxSerial RxTimo\n"); + " DebugId TxSeq TW RxSeq RW RxSerial RxTimo\n");return 0 ; }
@@ -100,7 +100,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v) rx_hard_ack =READ_ONCE (call->rx_hard_ack); seq_printf(seq, "UDP %-47.47s %-47.47s %4x %08x %08x %s %3u" - " %-8.8s %08x %lx %08x %02x %08x %02x %08x %06lx\n", + " %-8.8s %08x %08x %08x %02x %08x %02x %08x %06lx\n", lbuff, rbuff, call->service_id,
@@ -110,7 +110,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)atomic_read (&call->usage), rxrpc_call_states[call->state], call->abort_code, - call->user_call_ID, + call->debug_id, tx_hard_ack,READ_ONCE (call->tx_top) - tx_hard_ack, rx_hard_ack,READ_ONCE (call->rx_top) - rx_hard_ack, call->rx_serial,
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 214/266 openrisc: Fix issue with argument clobbering for clone/fork
In reply to Sasha LevinFrom: Stafford Horne <[email protected]>
[ Upstream commit 6bd140e14d9aaa734ec37985b8b20a96c0ece948 ]
Working on the OpenRISC glibc port I found that sometimes clone was working strange. That the tls data argument sent in r7 was always wrong. Further investigation revealed that the arguments were getting clobbered in the entry code. This patch removes the code that writes to the argument registers. This was likely due to some old code hanging around.
This patch fixes this up for clone and fork. This fork clobber is harmless but also useless so remove.
--- arch/openrisc/kernel/entry.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/openrisc/kernel/entry.S +2 -2
@@ -1166,13 +1166,13 @@ ENTRY(__sys_clone) l.movhi r29,hi(sys_clone) l.ori r29,r29,lo(sys_clone) l.j _fork_save_extra_regs_and_call - l.addi r7,r1,0 + l.nop ENTRY(__sys_fork) l.movhi r29,hi(sys_fork) l.ori r29,r29,lo(sys_fork) l.j _fork_save_extra_regs_and_call - l.addi r3,r1,0 + l.nop ENTRY(sys_rt_sigreturn) l.jal _sys_rt_sigreturn
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 215/266 drm/nouveau/disp/gm200-: fix NV_PDISP_SOR_HDMI2_CTRL(n) selection
In reply to Sasha LevinFrom: Ben Skeggs <[email protected]>
[ Upstream commit a1ef8bad506e4ffa0c57ac5f8cb99ab5cbc3b1fc ]
This is a SOR register, and not indexed by the bound head.
Fixes display not coming up on high-bandwidth HDMI displays under a number of configurations.
--- drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigm200.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigm200.c +2 -2
@@ -27,10 +27,10 @@ void gm200_hdmi_scdc(struct nvkm_ior *ior, int head, u8 scdc) { struct nvkm_device *device = ior->disp->engine.subdev.device; -const u32 hoff = head *0x800 ; +const u32 soff =nv50_ior_base (ior);const u32 ctrl = scdc &0x3 ; -nvkm_mask (device,0x61c5bc + hoff,0x00000003 , ctrl); +nvkm_mask (device,0x61c5bc + soff,0x00000003 , ctrl); ior->tmds.high_speed = !!(scdc &0x2 ); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 216/266 ceph: don't return -ESTALE if there's still an open file
In reply to Sasha LevinFrom: Luis Henriques <[email protected]>
[ Upstream commit 878dabb64117406abd40977b87544d05bb3031fc ]
Similarly to commit 03f219041fdb ("ceph: check i_nlink while converting a file handle to dentry"), this fixes another corner case with name_to_handle_at/open_by_handle_at. The issue has been detected by xfstest generic/467, when doing:
- name_to_handle_at("/cephfs/myfile")
- open("/cephfs/myfile")
- unlink("/cephfs/myfile")
- sync; sync;
- drop caches
- open_by_handle_at()
The call to open_by_handle_at should not fail because the file hasn't been deleted yet (only unlinked) and we do have a valid handle to it. -ESTALE shall be returned only if i_nlink is 0 *and* i_count is 1.
This patch also makes sure we have LINK caps before checking i_nlink.
--- fs/ceph/export.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/ceph/export.c +8 -1
@@ -172,9 +172,16 @@ struct inode *ceph_lookup_inode(struct super_block *sb, u64 ino)static struct dentry *__fh_to_dentry (struct super_block *sb,u64 ino) {struct inode *inode =__lookup_inode (sb, ino); +int err; +if (IS_ERR (inode))return ERR_CAST (inode); -if (inode->i_nlink ==0 ) { +/* We need LINK caps to reliably check i_nlink */ + err =ceph_do_getattr (inode,CEPH_CAP_LINK_SHARED , false); +if (err) +return ERR_PTR (err); +/* -ESTALE if inode as been unlinked and no file is open */ +if ((inode->i_nlink ==0 ) && (atomic_read (&inode->i_count) ==1 )) {iput (inode);return ERR_PTR (-ESTALE ); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 217/266 nfsd4: make drc_slab global, not per-net
In reply to Sasha LevinFrom: "J. Bruce Fields" <[email protected]>
[ Upstream commit 027690c75e8fd91b60a634d31c4891a6e39d45bd ]
I made every global per-network-namespace instead. But perhaps doing that to this slab was a step too far.
The kmem_cache_create call in our net init method also seems to be responsible for this lockdep warning:
[ 45.163710] Unable to find swap-space signature
[ 45.375718] trinity-c1 (855): attempted to duplicate a private mapping with mremap. This is not supported.
[ 46.055744] futex_wake_op: trinity-c1 tries to shift op by -209; fix this program
[ 51.011723]
[ 51.013378] ======================================================
[ 51.013875] WARNING: possible circular locking dependency detected
[ 51.014378] 5.2.0-rc2 #1 Not tainted
[ 51.014672] ------------------------------------------------------
[ 51.015182] trinity-c2/886 is trying to acquire lock:
[ 51.015593] 000000005405f099 (slab_mutex){+.+.}, at: slab_attr_store+0xa2/0x130
[ 51.016190]
[ 51.016190] but task is already holding lock:
[ 51.016652] 00000000ac662005 (kn->count#43){++++}, at: kernfs_fop_write+0x286/0x500
[ 51.017266]
[ 51.017266] which lock already depends on the new lock.
[ 51.017266]
[ 51.017909]
[ 51.017909] the existing dependency chain (in reverse order) is:
[ 51.018497]
[ 51.018497] -> #1 (kn->count#43){++++}:
[ 51.018956] __lock_acquire+0x7cf/0x1a20
[ 51.019317] lock_acquire+0x17d/0x390
[ 51.019658] __kernfs_remove+0x892/0xae0
[ 51.020020] kernfs_remove_by_name_ns+0x78/0x110
[ 51.020435] sysfs_remove_link+0x55/0xb0
[ 51.020832] sysfs_slab_add+0xc1/0x3e0
[ 51.021332] __kmem_cache_create+0x155/0x200
[ 51.021720] create_cache+0xf5/0x320
[ 51.022054] kmem_cache_create_usercopy+0x179/0x320
[ 51.022486] kmem_cache_create+0x1a/0x30
[ 51.022867] nfsd_reply_cache_init+0x278/0x560
[ 51.023266] nfsd_init_net+0x20f/0x5e0
[ 51.023623] ops_init+0xcb/0x4b0
[ 51.023928] setup_net+0x2fe/0x670
[ 51.024315] copy_net_ns+0x30a/0x3f0
[ 51.024653] create_new_namespaces+0x3c5/0x820
[ 51.025257] unshare_nsproxy_namespaces+0xd1/0x240
[ 51.025881] ksys_unshare+0x506/0x9c0
[ 51.026381] __x64_sys_unshare+0x3a/0x50
[ 51.026937] do_syscall_64+0x110/0x10b0
[ 51.027509] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 51.028175]
[ 51.028175] -> #0 (slab_mutex){+.+.}:
[ 51.028817] validate_chain+0x1c51/0x2cc0
[ 51.029422] __lock_acquire+0x7cf/0x1a20
[ 51.029947] lock_acquire+0x17d/0x390
[ 51.030438] __mutex_lock+0x100/0xfa0
[ 51.030995] mutex_lock_nested+0x27/0x30
[ 51.031516] slab_attr_store+0xa2/0x130
[ 51.032020] sysfs_kf_write+0x11d/0x180
[ 51.032529] kernfs_fop_write+0x32a/0x500
[ 51.033056] do_loop_readv_writev+0x21d/0x310
[ 51.033627] do_iter_write+0x2e5/0x380
[ 51.034148] vfs_writev+0x170/0x310
[ 51.034616] do_pwritev+0x13e/0x160
[ 51.035100] __x64_sys_pwritev+0xa3/0x110
[ 51.035633] do_syscall_64+0x110/0x10b0
[ 51.036200] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 51.036924]
[ 51.036924] other info that might help us debug this:
[ 51.036924]
[ 51.037876] Possible unsafe locking scenario:
[ 51.037876]
[ 51.038556] CPU0 CPU1
[ 51.039130] ---- ----
[ 51.039676] lock(kn->count#43);
[ 51.040084] lock(slab_mutex);
[ 51.040597] lock(kn->count#43);
[ 51.041062] lock(slab_mutex);
[ 51.041320]
[ 51.041320] *** DEADLOCK ***
[ 51.041320]
[ 51.041793] 3 locks held by trinity-c2/886:
[ 51.042128] #0: 000000001f55e152 (sb_writers#5){.+.+}, at: vfs_writev+0x2b9/0x310
[ 51.042739] #1: 00000000c7d6c034 (&of->mutex){+.+.}, at: kernfs_fop_write+0x25b/0x500
[ 51.043400] #2: 00000000ac662005 (kn->count#43){++++}, at: kernfs_fop_write+0x286/0x500--- fs/nfsd/cache.h | 2 ++ fs/nfsd/netns.h | 1 - fs/nfsd/nfscache.c | 29 +++++++++++++++++------------ fs/nfsd/nfsctl.c | 6 ++++++ 4 files changed, 25 insertions(+), 13 deletions(-)
fs/nfsd/cache.h +2 -0
@@ -78,6 +78,8 @@ enum {/* Checksum this amount of the request */ #define RC_CSUMLEN (256U) +int nfsd_drc_slab_create (void ); +void nfsd_drc_slab_free (void );int nfsd_reply_cache_init (struct nfsd_net *);void nfsd_reply_cache_shutdown (struct nfsd_net *);int nfsd_cache_lookup (struct svc_rqst *);
fs/nfsd/netns.h +0 -1
@@ -139,7 +139,6 @@ struct nfsd_net {* Duplicate reply cache */ struct nfsd_drc_bucket *drc_hashtbl; -struct kmem_cache *drc_slab;/* max number of entries allowed in the cache */ unsigned int max_drc_entries;
fs/nfsd/nfscache.c +17 -12
@@ -36,6 +36,8 @@ struct nfsd_drc_bucket {spinlock_t cache_lock; }; +static struct kmem_cache *drc_slab; +static int nfsd_cache_append (struct svc_rqst *rqstp,struct kvec *vec);static unsigned long nfsd_reply_cache_count (struct shrinker *shrink,struct shrink_control *sc);
@@ -95,7 +97,7 @@ nfsd_reply_cache_alloc(struct svc_rqst *rqstp, __wsum csum, {struct svc_cacherep *rp; - rp =kmem_cache_alloc (nn->drc_slab,GFP_KERNEL ); + rp =kmem_cache_alloc (drc_slab,GFP_KERNEL );if (rp) { rp->c_state =RC_UNUSED ; rp->c_type =RC_NOCACHE ;
@@ -129,7 +131,7 @@ nfsd_reply_cache_free_locked(struct nfsd_drc_bucket *b, struct svc_cacherep *rp,atomic_dec (&nn->num_drc_entries); nn->drc_mem_usage -=sizeof (*rp); } -kmem_cache_free (nn->drc_slab, rp); +kmem_cache_free (drc_slab, rp); } static void
@@ -141,6 +143,18 @@ nfsd_reply_cache_free(struct nfsd_drc_bucket *b, struct svc_cacherep *rp,spin_unlock (&b->cache_lock); } +int nfsd_drc_slab_create (void ) +{ + drc_slab =kmem_cache_create ("nfsd_drc" , +sizeof (struct svc_cacherep ),0 ,0 ,NULL ); +return drc_slab ?0 : -ENOMEM ; +} + +void nfsd_drc_slab_free (void ) +{ +kmem_cache_destroy (drc_slab); +} +int nfsd_reply_cache_init (struct nfsd_net *nn) {unsigned int hashsize;
@@ -159,18 +173,13 @@ int nfsd_reply_cache_init(struct nfsd_net *nn)if (status) goto out_nomem; - nn->drc_slab =kmem_cache_create ("nfsd_drc" , -sizeof (struct svc_cacherep ),0 ,0 ,NULL ); -if (!nn->drc_slab) - goto out_shrinker; - nn->drc_hashtbl =kcalloc (hashsize,sizeof (*nn->drc_hashtbl),GFP_KERNEL );if (!nn->drc_hashtbl) { nn->drc_hashtbl =vzalloc (array_size (hashsize,sizeof (*nn->drc_hashtbl)));if (!nn->drc_hashtbl) - goto out_slab; + goto out_shrinker; }for (i =0 ; i < hashsize; i++) {
@@ -180,8 +189,6 @@ int nfsd_reply_cache_init(struct nfsd_net *nn) nn->drc_hashsize = hashsize;return 0 ; -out_slab: -kmem_cache_destroy (nn->drc_slab); out_shrinker:unregister_shrinker (&nn->nfsd_reply_cache_shrinker); out_nomem:
@@ -209,8 +216,6 @@ void nfsd_reply_cache_shutdown(struct nfsd_net *nn) nn->drc_hashtbl =NULL ; nn->drc_hashsize =0 ; -kmem_cache_destroy (nn->drc_slab); - nn->drc_slab =NULL ; }/*
fs/nfsd/nfsctl.c +6 -0
@@ -1534,6 +1534,9 @@ static int __init init_nfsd(void) goto out_free_slabs;nfsd_fault_inject_init ();/* nfsd fault injection controls */ nfsd_stat_init ();/* Statistics */ + retval =nfsd_drc_slab_create (); +if (retval) + goto out_free_stat;nfsd_lockd_init ();/* lockd->nfsd callbacks */ retval =create_proc_exports_entry ();if (retval)
@@ -1547,6 +1550,8 @@ static int __init init_nfsd(void)remove_proc_entry ("fs/nfs" ,NULL ); out_free_lockd:nfsd_lockd_shutdown (); +nfsd_drc_slab_free (); +out_free_stat:nfsd_stat_shutdown ();nfsd_fault_inject_cleanup ();nfsd4_exit_pnfs ();
@@ -1561,6 +1566,7 @@ static int __init init_nfsd(void) static void __exit exit_nfsd(void) { +nfsd_drc_slab_free ();remove_proc_entry ("fs/nfs/exports" ,NULL );remove_proc_entry ("fs/nfs" ,NULL );nfsd_stat_shutdown ();
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 218/266 gfs2: Allow lock_nolock mount to specify jid=X
In reply to Sasha LevinFrom: Bob Peterson <[email protected]>
[ Upstream commit ea22eee4e6027d8927099de344f7fff43c507ef9 ]
Before this patch, a simple typo accidentally added \n to the jid= string for lock_nolock mounts. This made it impossible to mount a gfs2 file system with a journal other than journal0. Thus:
mount -tgfs2 -o hostdata="jid=1" <device> <mount pt>
Resulted in:
mount: wrong fs type, bad option, bad superblock on <device>
In most cases this is not a problem. However, for debugging and testing purposes we sometimes want to test the integrity of other journals. This patch removes the unnecessary \n and thus allows lock_nolock users to specify an alternate journal.
--- fs/gfs2/ops_fstype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/ops_fstype.c +1 -1
@@ -911,7 +911,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) }static const match_table_t nolock_tokens = { - { Opt_jid,"jid=%d\n" , }, + { Opt_jid,"jid=%d" , }, { Opt_err,NULL }, };
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 219/266 ovl: verify permissions in ovl_path_open()
In reply to Sasha LevinFrom: Miklos Szeredi <[email protected]>
[ Upstream commit 56230d956739b9cb1cbde439d76227d77979a04d ]
Check permission before opening a real file.
ovl_path_open() is used by readdir and copy-up routines.
ovl_permission() theoretically already checked copy up permissions, but it doesn't hurt to re-do these checks during the actual copy-up.
For directory reading ovl_permission() only checks access to topmost underlying layer. Readdir on a merged directory accesses layers below the topmost one as well. Permission wasn't checked for these layers.
Note: modifying ovl_permission() to perform this check would be far more complex and hence more bug prone. The result is less precise permissions returned in access(2). If this turns out to be an issue, we can revisit this bug.
--- fs/overlayfs/util.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
fs/overlayfs/util.c +26 -1
@@ -475,7 +475,32 @@ bool ovl_is_whiteout(struct dentry *dentry)struct file *ovl_path_open (struct path *path,int flags) { -return dentry_open (path, flags |O_NOATIME ,current_cred ()); +struct inode *inode =d_inode (path->dentry); +int err, acc_mode; + +if (flags & ~(O_ACCMODE |O_LARGEFILE )) +BUG (); + +switch (flags &O_ACCMODE ) { +case O_RDONLY : + acc_mode =MAY_READ ; +break ; +case O_WRONLY : + acc_mode =MAY_WRITE ; +break ; +default : +BUG (); + } + + err =inode_permission (inode, acc_mode |MAY_OPEN ); +if (err) +return ERR_PTR (err); + +/* O_NOATIME is an optimization, don't fail if not permitted */ +if (inode_owner_or_capable (inode)) + flags |=O_NOATIME ; + +return dentry_open (path, flags,current_cred ()); }/* Caller should hold ovl_inode->lock */
Signature · 1 line
2.25.1
Re: [PATCH AUTOSEL 5.4 219/266] ovl: verify permissions in ovl_path_open()
Quoted 32 lines · Sasha Levin
From: Miklos Szeredi <[email protected]>
[ Upstream commit
56230d956739b9cb1cbde439d76227d77979a04d]Check permission before opening a real file.
ovl_path_open()is used by readdir and copy-up routines.
ovl_permission()theoretically already checked copy up permissions, but it doesn't hurt to re-do these checks during the actual copy-up.For directory reading
ovl_permission()only checks access to topmost underlying layer. Readdir on a merged directory accesses layers below the topmost one as well. Permission wasn't checked for these layers.Note: modifying
ovl_permission()to perform this check would be far more complex and hence more bug prone. The result is less precise permissions returned in access(2). If this turns out to be an issue, we can revisit this bug.Signed-off-by Miklos Szeredi <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- fs/overlayfs/util.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)fs/overlayfs/util.c +0
-0
fs/overlayfs/util.c bool ovl_is_whiteout(struct dentry *dentry) · line 478
Quoted 4 lines
fs/overlayfs/util.c +0
-1@@ -475,7 +475,32 @@ bool ovl_is_whiteout(struct dentry *dentry)struct file *ovl_path_open (struct path *path,int flags) { - return dentsteps to reproduce:
- cd /opt/ltp
- ./runltp -s execveat03ry_open(path, flags | O_NOATIME,current_cred());
fs/overlayfs/util.c bool ovl_is_whiteout(struct dentry *dentry) · line 482
Quoted 5 lines
fs/overlayfs/util.c +5
-0+struct inode *inode =d_inode (path->dentry); +int err, acc_mode; + +if (flags & ~(O_ACCMODE |O_LARGEFILE )) +BUG ();
This BUG: triggered on stable-rc 5.7, 5.4, 4.19 and 4.14 on arm64 architecture.
steps to reproduce:
- cd /opt/ltp
- ./runltp -s execveat03
[ 461.024389] ------------[ cut here ]------------ [ 461.029029] kernel BUG at fs/overlayfs/util.c:482! [ 461.033832] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [ 461.039328] Modules linked in: overlay rfkill tda998x drm_kms_helper drm crct10dif_ce fuse [ 461.047637] CPU: 2 PID: 15049 Comm: execveat03 Not tainted 5.4.49-rc1-00549-g1d94fa9fbd5f #1 [ 461.056093] Hardware name: ARM Juno development board (r2) (DT) [ 461.062026] pstate: 60000005 (nZCv daif -PAN -UAO) [ 461.066879] pc : ovl_path_open+0xc4/0xc8 [overlay] [ 461.071723] lr : ovl_path_open+0x2c/0xc8 [overlay] [ 461.076521] sp : ffff0008d9d578d0 [ 461.079841] x29: ffff0008d9d578d0 x28: ffff00090821186c [ 461.085167] x27: ffff000908211800 x26: ffff000902fc7000 [ 461.090493] x25: ffffa0000956e800 x24: ffff000902fc7540 [ 461.095818] x23: ffff0008d9d57b80 x22: ffff00091149c880 [ 461.101143] x21: ffff0008d9d57b80 x20: ffff0008dd24cb10 [ 461.106467] x19: 0000000000004000 x18: 0000000000000000 [ 461.111791] x17: 0000000000000000 x16: 0000000000000000 [ 461.117114] x15: 0000000000000000 x14: ffffa00010395a3c [ 461.122439] x13: ffffa00010394ff0 x12: ffff80011baea816 [ 461.127763] x11: 1fffe0011baea815 x10: ffff80011baea815 [ 461.133087] x9 : dfffa00000000000 x8 : 0000000000000001 [ 461.138411] x7 : ffff0008dd7540a8 x6 : 00000000f1f1f1f1 [ 461.143735] x5 : 00000000f3000000 x4 : 000000000000002d [ 461.149059] x3 : dfffa00000000000 x2 : 0000000000000007 [ 461.154383] x1 : 0000000000004000 x0 : 0000000000000000 [ 461.159706] Call trace: [ 461.162201] ovl_path_open+0xc4/0xc8 [overlay] [ 461.166697] ovl_check_d_type_supported+0x98/0x178 [overlay] [ 461.172410] ovl_fill_super+0x8b4/0x1c78 [overlay] [ 461.177215] mount_nodev+0x4c/0xb8 [ 461.180665] ovl_mount+0x18/0x20 [overlay] [ 461.184772] legacy_get_tree+0x70/0xb8 [ 461.188531] vfs_get_tree+0x48/0x158 [ 461.192116] do_mount+0x6f8/0xb38 [ 461.195438] ksys_mount+0x8c/0xe8 [ 461.198762] __arm64_sys_mount+0x64/0x80 [ 461.202697] el0_svc_common.constprop.0+0xa0/0x1d0 [ 461.207500] el0_svc_handler+0x34/0x98 [ 461.211256] el0_svc+0x8/0xc [ 461.214150] Code: f94013f5 a8c37bfd d65f03c0 d4210000 (d4210000) [ 461.220258] ---[ end trace 13147ca9b270cd0f ]--- [ 461.224884] note: execveat03[15049] exited with preempt_count 1 [ 461.233327] ------------[ cut here ]------------ [ 461.237984] WARNING: CPU: 2 PID: 0 at kernel/rcu/tree.c:569 rcu_idle_enter+0xc4/0xd0 [ 461.245742] Modules linked in: overlay rfkill tda998x drm_kms_helper drm crct10dif_ce fuse [ 461.254052] CPU: 2 PID: 0 Comm: swapper/2 Tainted: G D 5.4.49-rc1-00549-g1d94fa9fbd5f #1 [ 461.263465] Hardware name: ARM Juno development board (r2) (DT) [ 461.269397] pstate: 20000085 (nzCv daIf -PAN -UAO) [ 461.274200] pc : rcu_idle_enter+0xc4/0xd0 [ 461.278224] lr : rcu_idle_enter+0x30/0xd0 [ 461.282397] sp : ffff000935577e90 [ 461.285715] x29: ffff000935577e90 x28: 0000000000000000 [ 461.291202] x27: ffff00091330b800 x26: ffffa0001309e220
Broadcast message from systemd-jo[ 461.296528] x25: ffff00093554ba00
x24: 1fffe00126aaefe4
urnald@juno (Tue 2020-06-23 03:3[ 461.304710] x23: ffffa00012227c38
x22: ffffa0001309e1f8
3:27 UTC):
[ 461.312810] x21: ffff0009366edc98 x20: ffffa00012231bc0 [ 461.319253] x19: ffff0009366edbc0 x18: 0000000000000000 [ 461.324576] x17: 0000000000000000 x16: 0000000000000000 [ 461.329973] x15: 0000000000000000 x14: ffffa0001009d8c0 [ 461.335298] x13: ffffa00010395afc x12: ffff800126cddb24 [ 461.340784] x11: 1fffe00126cddb23 x10: ffff800126cddb23
kernel[310]: [ 461.033832] Inter[ 461.346109] x9 : dfffa00000000000 x8 : 0000000000000001
nal error: Oops - BUG: 0 [#1] PR[ 461.354293] x7 : ffff0009366ed91b x6 : ffff0009366ed918
EEMPT SMP
[ 461.362392] x5 : 00007ffed93224dd x4 : 000000000000002d [ 461.368747] x3 : dfffa00000000000 x2 : 0000000000000007 [ 461.374071] x1 : 4000000000000002 x0 : 4000000000000000 [ 461.379468] Call trace: [ 461.381922] rcu_idle_enter+0xc4/0xd0 [ 461.385755] do_idle+0x27c/0x320 exit01 1 TPASS : exit() t[ 461.388992] cpu_startup_entry+0x20/0x40 est PASSED[ 461.395788] secondary_start_kernel+0x250/0x2b8 [ 461.401184] ---[ end trace 13147ca9b270cd10 ]---
test link,
https://lkft.validation.linaro.org/scheduler/job/1516380#L3866
metadata:
git branch: linux-5.4.y
git repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git commit: 1d94fa9fbd5f0a775217d4180270dae8cede3f92
git describe: v5.4.47-549-g1d94fa9fbd5f
make_kernelversion: 5.4.49-rc1
kernel-config:
https://builds.tuxbuild.com/-hEoWZbVgbGrYjKHXXPiuQ/kernel.config
build-url: https://gitlab.com/Linaro/lkft/kernel-runs/-/pipelines/158927561
Signature · 2 lines
Linaro LKFT https://lkft.linaro.org
Sasha Levin
maintainerPATCH 220/266 scsi: iscsi: Fix reference count leak in iscsi_boot_create_kobj
In reply to Sasha LevinFrom: Qiushi Wu <[email protected]>
[ Upstream commit 0267ffce562c8bbf9b57ebe0e38445ad04972890 ]
kobject_init_and_add() takes reference even when it fails. If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object.
--- drivers/scsi/iscsi_boot_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/iscsi_boot_sysfs.c +1 -1
@@ -352,7 +352,7 @@ iscsi_boot_create_kobj(struct iscsi_boot_kset *boot_kset, boot_kobj->kobj.kset = boot_kset->kset;if (kobject_init_and_add (&boot_kobj->kobj, &iscsi_boot_ktype,NULL , name, index)) { -kfree (boot_kobj); +kobject_put (&boot_kobj->kobj);return NULL ; } boot_kobj->data = data;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 221/266 scsi: ufs: Don't update urgent bkops level when toggling auto bkops
In reply to Sasha LevinFrom: Can Guo <[email protected]>
[ Upstream commit be32acff43800c87dc5c707f5d47cc607b76b653 ]
Urgent bkops level is used to compare against actual bkops status read from UFS device. Urgent bkops level is set during initialization and might be updated in exception event handler during runtime. But it should not be updated to the actual bkops status every time when auto bkops is toggled. Otherwise, if urgent bkops level is updated to 0, auto bkops shall always be kept enabled.
--- drivers/scsi/ufs/ufshcd.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +0 -1
@@ -5101,7 +5101,6 @@ static int ufshcd_bkops_ctrl(struct ufs_hba *hba, err =ufshcd_enable_auto_bkops (hba); else err =ufshcd_disable_auto_bkops (hba); - hba->urgent_bkops_lvl = curr_status; out:return err; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 222/266 pinctrl: imxl: Fix an error handling path in 'imx1_pinctrl_core_probe()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 9eb728321286c4b31e964d2377fca2368526d408 ]
When 'pinctrl_register()' has been turned into 'devm_pinctrl_register()', an error handling path has not been updated.
Axe a now unneeded 'pinctrl_unregister()'.
--- drivers/pinctrl/freescale/pinctrl-imx1-core.c | 1 - 1 file changed, 1 deletion(-)
drivers/pinctrl/freescale/pinctrl-imx1-core.c +0 -1
@@ -638,7 +638,6 @@ int imx1_pinctrl_core_probe(struct platform_device *pdev, ret =of_platform_populate (pdev->dev.of_node,NULL ,NULL , &pdev->dev);if (ret) { -pinctrl_unregister (ipctl->pctl);dev_err (&pdev->dev,"Failed to populate subdevices\n" );return ret; }
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 223/266 pinctrl: freescale: imx: Fix an error handling path in 'imx_pinctrl_probe()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 11d8da5cabf7c6c3263ba2cd9c00260395867048 ]
'pinctrl_unregister()' should not be called to undo 'devm_pinctrl_register_and_init()', it is already handled by the framework.
This simplifies the error handling paths of the probe function. The 'imx_free_resources()' can be removed as well.
--- drivers/pinctrl/freescale/pinctrl-imx.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx.c +2 -17
@@ -774,16 +774,6 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev,return 0 ; } -/* -* imx_free_resources() - free memory used by this driver -* @info: info driver instance -*/ -static void imx_free_resources (struct imx_pinctrl *ipctl) -{ -if (ipctl->pctl) -pinctrl_unregister (ipctl->pctl); -} -int imx_pinctrl_probe (struct platform_device *pdev,const struct imx_pinctrl_soc_info *info) {
@@ -874,23 +864,18 @@ int imx_pinctrl_probe(struct platform_device *pdev, &ipctl->pctl);if (ret) {dev_err (&pdev->dev,"could not register IMX pinctrl driver\n" ); - goto free; +return ret; } ret =imx_pinctrl_probe_dt (pdev, ipctl);if (ret) {dev_err (&pdev->dev,"fail to probe dt properties\n" ); - goto free; +return ret; }dev_info (&pdev->dev,"initialized IMX pinctrl driver\n" );return pinctrl_enable (ipctl->pctl); - -free: -imx_free_resources (ipctl); - -return ret; }static int __maybe_unused imx_pinctrl_suspend (struct device *dev)
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 224/266 pinctrl: freescale: imx: Use 'devm_of_iomap()' to avoid a resource leak in case of error in 'imx_pinctrl_probe()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit ba403242615c2c99e27af7984b1650771a2cc2c9 ]
Use 'devm_of_iomap()' instead 'of_iomap()' to avoid a resource leak in case of error.
Update the error handling code accordingly.
--- drivers/pinctrl/freescale/pinctrl-imx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx.c +4 -3
@@ -824,12 +824,13 @@ int imx_pinctrl_probe(struct platform_device *pdev,return -EINVAL ; } - ipctl->input_sel_base =of_iomap (np,0 ); + ipctl->input_sel_base =devm_of_iomap (&pdev->dev, np, +0 ,NULL );of_node_put (np); -if (!ipctl->input_sel_base) { +if (IS_ERR (ipctl->input_sel_base)) {dev_err (&pdev->dev,"iomuxc input select base address not found\n" ); -return -ENOMEM ; +return PTR_ERR (ipctl->input_sel_base); } } }
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 225/266 nfsd: safer handling of corrupted c_type
In reply to Sasha LevinFrom: "J. Bruce Fields" <[email protected]>
[ Upstream commit c25bf185e57213b54ea0d632ac04907310993433 ]
This can only happen if there's a bug somewhere, so let's make it a WARN not a printk. Also, I think it's safest to ignore the corruption rather than trying to fix it by removing a cache entry.
--- fs/nfsd/nfscache.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfsd/nfscache.c +1 -2
@@ -469,8 +469,7 @@ nfsd_cache_lookup(struct svc_rqst *rqstp) rtn =RC_REPLY ;break ;default : -printk (KERN_WARNING "nfsd: bad repcache type %d\n" , rp->c_type); -nfsd_reply_cache_free_locked (b, rp, nn); +WARN_ONCE (1 ,"nfsd: bad repcache type %d\n" , rp->c_type); } goto out;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 226/266 drm/amd/display: Revalidate bandwidth before commiting DC updates
In reply to Sasha LevinFrom: Nicholas Kazlauskas <[email protected]>
[ Upstream commit a24eaa5c51255b344d5a321f1eeb3205f2775498 ]
[Why]
Whenever we switch between tiled formats without also switching pixel formats or doing anything else that recreates the DC plane state we can run into underflow or hangs since we're not updating the DML parameters before committing to the hardware.
[How]
If the update type is FULL then call validate_bandwidth again to update the DML parmeters before committing the state.
This is basically just a workaround and protective measure against update types being added DC where we could run into this issue in the future.
We can only fully validate the state in advance before applying it to the hardware if we recreate all the plane and stream states since we can't modify what's currently in use.
The next step is to update DM to ensure that we're creating the plane and stream states for whatever could potentially be a full update in DC to pre-emptively recreate the state for DC global validation.
The workaround can stay until this has been fixed in DM.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +6 -0
@@ -2230,6 +2230,12 @@ void dc_commit_updates_for_stream(struct dc *dc,copy_stream_update_to_stream (dc, context, stream, stream_update); +if (!dc->res_pool->funcs->validate_bandwidth (dc, context, false)) { +DC_ERROR ("Mode validation failed for stream update!\n" ); +dc_release_state (context); +return ; + } + commit_planes_for_stream( dc, srf_updates,
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 227/266 crypto: omap-sham - add proper load balancing support for multicore
In reply to Sasha LevinFrom: Tero Kristo <[email protected]>
[ Upstream commit 281c377872ff5d15d80df25fc4df02d2676c7cde ]
The current implementation of the multiple accelerator core support for OMAP SHA does not work properly. It always picks up the first probed accelerator core if this is available, and rest of the book keeping also gets confused if there are two cores available. Add proper load balancing support for SHA, and also fix any bugs related to the multicore support while doing it.
--- drivers/crypto/omap-sham.c | 64 ++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 33 deletions(-)
drivers/crypto/omap-sham.c +31 -33
@@ -165,8 +165,6 @@ struct omap_sham_hmac_ctx { };struct omap_sham_ctx { -struct omap_sham_dev *dd; -unsigned long flags;/* fallback stuff */
@@ -918,27 +916,35 @@ static int omap_sham_update_dma_stop(struct omap_sham_dev *dd)return 0 ; } +struct omap_sham_dev *omap_sham_find_dev (struct omap_sham_reqctx *ctx) +{ +struct omap_sham_dev *dd; + +if (ctx->dd) +return ctx->dd; + +spin_lock_bh (&sham.lock); + dd = list_first_entry(&sham.dev_list, struct omap_sham_dev, list); +list_move_tail (&dd->list, &sham.dev_list); + ctx->dd = dd; +spin_unlock_bh (&sham.lock); + +return dd; +} +static int omap_sham_init (struct ahash_request *req) {struct crypto_ahash *tfm =crypto_ahash_reqtfm (req);struct omap_sham_ctx *tctx =crypto_ahash_ctx (tfm);struct omap_sham_reqctx *ctx =ahash_request_ctx (req); -struct omap_sham_dev *dd =NULL , *tmp; +struct omap_sham_dev *dd;int bs =0 ; -spin_lock_bh (&sham.lock); -if (!tctx->dd) { -list_for_each_entry (tmp, &sham.dev_list, list) { - dd = tmp; -break ; - } - tctx->dd = dd; - }else { - dd = tctx->dd; - } -spin_unlock_bh (&sham.lock); + ctx->dd =NULL ; - ctx->dd = dd; + dd =omap_sham_find_dev (ctx); +if (!dd) +return -ENODEV ; ctx->flags =0 ;
@@ -1187,8 +1193,7 @@ static int omap_sham_handle_queue(struct omap_sham_dev *dd,static int omap_sham_enqueue (struct ahash_request *req,unsigned int op) {struct omap_sham_reqctx *ctx =ahash_request_ctx (req); -struct omap_sham_ctx *tctx =crypto_tfm_ctx (req->base.tfm); -struct omap_sham_dev *dd = tctx->dd; +struct omap_sham_dev *dd = ctx->dd; ctx->op = op;
@@ -1198,7 +1203,7 @@ static int omap_sham_enqueue(struct ahash_request *req, unsigned int op)static int omap_sham_update (struct ahash_request *req) {struct omap_sham_reqctx *ctx =ahash_request_ctx (req); -struct omap_sham_dev *dd = ctx->dd; +struct omap_sham_dev *dd =omap_sham_find_dev (ctx);if (!req->nbytes)return 0 ;
@@ -1302,21 +1307,8 @@ static int omap_sham_setkey(struct crypto_ahash *tfm, const u8 *key,struct omap_sham_hmac_ctx *bctx = tctx->base;int bs =crypto_shash_blocksize (bctx->shash);int ds =crypto_shash_digestsize (bctx->shash); -struct omap_sham_dev *dd =NULL , *tmp;int err, i; -spin_lock_bh (&sham.lock); -if (!tctx->dd) { -list_for_each_entry (tmp, &sham.dev_list, list) { - dd = tmp; -break ; - } - tctx->dd = dd; - }else { - dd = tctx->dd; - } -spin_unlock_bh (&sham.lock); - err =crypto_shash_setkey (tctx->fallback, key, keylen);if (err)return err;
@@ -1334,7 +1326,7 @@ static int omap_sham_setkey(struct crypto_ahash *tfm, const u8 *key,memset (bctx->ipad + keylen,0 , bs - keylen); -if (!test_bit (FLAGS_AUTO_XOR , &dd->flags)) { +if (!test_bit (FLAGS_AUTO_XOR , &sham.flags)) {memcpy (bctx->opad, bctx->ipad, bs);for (i =0 ; i < bs; i++) {
@@ -2136,6 +2128,7 @@ static int omap_sham_probe(struct platform_device *pdev) } dd->flags |= dd->pdata->flags; + sham.flags |= dd->pdata->flags;pm_runtime_use_autosuspend (dev);pm_runtime_set_autosuspend_delay (dev,DEFAULT_AUTOSUSPEND_DELAY );
@@ -2163,6 +2156,9 @@ static int omap_sham_probe(struct platform_device *pdev)spin_unlock (&sham.lock);for (i =0 ; i < dd->pdata->algs_info_size; i++) { +if (dd->pdata->algs_info[i].registered) +break ; +for (j =0 ; j < dd->pdata->algs_info[i].size; j++) {struct ahash_alg *alg;
@@ -2214,9 +2210,11 @@ static int omap_sham_remove(struct platform_device *pdev)list_del (&dd->list);spin_unlock (&sham.lock);for (i = dd->pdata->algs_info_size -1 ; i >=0 ; i--) -for (j = dd->pdata->algs_info[i].registered -1 ; j >=0 ; j--) +for (j = dd->pdata->algs_info[i].registered -1 ; j >=0 ; j--) {crypto_unregister_ahash ( &dd->pdata->algs_info[i].algs_list[j]); + dd->pdata->algs_info[i].registered--; + }tasklet_kill (&dd->done_task);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 228/266 geneve: change from tx_error to tx_dropped on missing metadata
In reply to Sasha LevinFrom: Jiri Benc <[email protected]>
[ Upstream commit 9d149045b3c0e44c049cdbce8a64e19415290017 ]
If the geneve interface is in collect_md (external) mode, it can't send any packets submitted directly to its net interface, as such packets won't have metadata attached. This is expected.
However, the kernel itself sends some packets to the interface, most notably, IPv6 DAD, IPv6 multicast listener reports, etc. This is not wrong, as tunnel metadata can be specified in routing table (although technically, that has never worked for IPv6, but hopefully will be fixed eventually) and then the interface must correctly participate in IPv6 housekeeping.
The problem is that any such attempt increases the tx_error counter. Just bringing up a geneve interface with IPv6 enabled is enough to see a number of tx_errors. That causes confusion among users, prompting them to find a network error where there is none.
Change the counter used to tx_dropped. That better conveys the meaning (there's nothing wrong going on, just some packets are getting dropped) and hopefully will make admins panic less.
--- drivers/net/geneve.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/geneve.c +4 -3
@@ -987,9 +987,10 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)if (geneve->collect_md) { info =skb_tunnel_info (skb);if (unlikely (!info || !(info->mode &IP_TUNNEL_INFO_TX ))) { - err = -EINVAL ;netdev_dbg (dev,"no tunnel metadata\n" ); - goto tx_error; +dev_kfree_skb (skb); + dev->stats.tx_dropped++; +return NETDEV_TX_OK ; } }else { info = &geneve->info;
@@ -1006,7 +1007,7 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)if (likely (!err))return NETDEV_TX_OK ; -tx_error: +dev_kfree_skb (skb);if (err == -ELOOP )
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 229/266 lib/zlib: remove outdated and incorrect pre-increment optimization
In reply to Sasha LevinFrom: Jann Horn <[email protected]>
[ Upstream commit acaab7335bd6f0c0b54ce3a00bd7f18222ce0f5f ]
The zlib inflate code has an old micro-optimization based on the assumption that for pre-increment memory accesses, the compiler will generate code that fits better into the processor's pipeline than what would be generated for post-increment memory accesses.
This optimization was already removed in upstream zlib in 2016:
https://github.com/madler/zlib/commit/9aaec95e8211
This optimization causes UB according to C99, which says in section 6.5.6 "Additive operators": "If both the pointer operand and the result point to elements of the same array object, or one past the last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined".
This UB is not only a theoretical concern, but can also cause trouble for future work on compiler-based sanitizers.
According to the zlib commit, this optimization also is not optimal anymore with modern compilers.
Replace uses of OFF, PUP and UP_UNALIGNED with their definitions in the POSTINC case, and remove the macro definitions, just like in the upstream patch.
--- lib/zlib_inflate/inffast.c | 91 +++++++++++++++----------------------- 1 file changed, 35 insertions(+), 56 deletions(-)
lib/zlib_inflate/inffast.c +35 -56
@@ -10,17 +10,6 @@ #ifndef ASMINF -/* Allow machine dependent optimization for post-increment or pre-increment. - Based on testing to date, - Pre-increment preferred for: - - PowerPC G3 (Adler) - - MIPS R5000 (Randers-Pehrson) - Post-increment preferred for: - - none - No measurable difference: - - Pentium III (Anderson) - - M68060 (Nikl) - */ union uu { unsigned short us; unsigned char b[2];
@@ -38,16 +27,6 @@ get_unaligned16(const unsigned short *p)return mm.us; } -#ifdef POSTINC -# define OFF 0 -# define PUP (a) *(a)++ -# define UP_UNALIGNED (a) get_unaligned16((a)++) -#else -# define OFF 1 -# define PUP (a) *++(a) -# define UP_UNALIGNED (a) get_unaligned16(++(a)) -#endif -/* Decode literal, length, and distance codes and write out the resulting literal and match bytes until either not enough input or output is
@@ -115,9 +94,9 @@ void inflate_fast(z_streamp strm, unsigned start)/* copy state to local variables */ state = (struct inflate_state *)strm->state; - in = strm->next_in -OFF ; + in = strm->next_in; last = in + (strm->avail_in -5 ); - out = strm->next_out -OFF ; + out = strm->next_out; beg = out - (start - strm->avail_out); end = out + (strm->avail_out -257 );#ifdef INFLATE_STRICT
@@ -138,9 +117,9 @@ void inflate_fast(z_streamp strm, unsigned start)input data or output space */ do { if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; } this = lcode[hold & lmask];
@@ -150,14 +129,14 @@ void inflate_fast(z_streamp strm, unsigned start) bits -= op; op = (unsigned )(this.op);if (op ==0 ) {/* literal */ -PUP (out) = (unsigned char )(this.val); + *out++ = (unsigned char )(this.val); }else if (op &16 ) {/* length base */ len = (unsigned )(this.val); op &=15 ;/* number of extra bits */ if (op) {if (bits < op) { - hold += (unsigned long )(PUP (in)) << bits; + hold += (unsigned long )(*in++) << bits; bits +=8 ; } len += (unsigned )hold & ((1U << op) -1 );
@@ -165,9 +144,9 @@ void inflate_fast(z_streamp strm, unsigned start) bits -= op; }if (bits <15 ) { - hold += (unsigned long )(PUP (in)) << bits; + hold += (unsigned long )(*in++) << bits; bits +=8 ; - hold += (unsigned long )(PUP (in)) << bits; + hold += (unsigned long )(*in++) << bits; bits +=8 ; } this = dcode[hold & dmask];
@@ -180,10 +159,10 @@ void inflate_fast(z_streamp strm, unsigned start) dist = (unsigned )(this.val); op &=15 ;/* number of extra bits */ if (bits < op) { - hold += (unsigned long )(PUP (in)) << bits; + hold += (unsigned long )(*in++) << bits; bits +=8 ;if (bits < op) { - hold += (unsigned long )(PUP (in)) << bits; + hold += (unsigned long )(*in++) << bits; bits +=8 ; } }
@@ -205,13 +184,13 @@ void inflate_fast(z_streamp strm, unsigned start) state->mode =BAD ;break ; } - from = window -OFF ; + from = window;if (write ==0 ) {/* very common case */ from += wsize - op;if (op < len) {/* some from window */ len -= op;do { -PUP (out) =PUP (from); + *out++ = *from++; }while (--op); from = out - dist;/* rest from output */ }
@@ -222,14 +201,14 @@ void inflate_fast(z_streamp strm, unsigned start)if (op < len) {/* some from end of window */ len -= op;do { -PUP (out) =PUP (from); + *out++ = *from++; }while (--op); - from = window -OFF ; + from = window;if (write < len) {/* some from start of window */ op = write; len -= op;do { -PUP (out) =PUP (from); + *out++ = *from++; }while (--op); from = out - dist;/* rest from output */ }
@@ -240,21 +219,21 @@ void inflate_fast(z_streamp strm, unsigned start)if (op < len) {/* some from window */ len -= op;do { -PUP (out) =PUP (from); + *out++ = *from++; }while (--op); from = out - dist;/* rest from output */ } }while (len >2 ) { -PUP (out) =PUP (from); -PUP (out) =PUP (from); -PUP (out) =PUP (from); + *out++ = *from++; + *out++ = *from++; + *out++ = *from++; len -=3 ; }if (len) { -PUP (out) =PUP (from); + *out++ = *from++;if (len >1 ) -PUP (out) =PUP (from); + *out++ = *from++; } }else {
@@ -264,29 +243,29 @@ void inflate_fast(z_streamp strm, unsigned start) from = out - dist;/* copy direct from output */ /* minimum length is three */ /* Align out addr */ -if (!((long )(out -1 +OFF ) &1 )) { -PUP (out) =PUP (from); +if (!((long )(out -1 ) &1 )) { + *out++ = *from++; len--; } - sout = (unsigned short *)(out -OFF ); + sout = (unsigned short *)(out);if (dist >2 ) {unsigned short *sfrom; - sfrom = (unsigned short *)(from -OFF ); + sfrom = (unsigned short *)(from); loops = len >>1 ; do#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS -PUP (sout) =PUP (sfrom); + *sout++ = *sfrom++;#else -PUP (sout) =UP_UNALIGNED (sfrom); + *sout++ =get_unaligned16 (sfrom++);#endif while (--loops); - out = (unsigned char *)sout +OFF ; - from = (unsigned char *)sfrom +OFF ; + out = (unsigned char *)sout; + from = (unsigned char *)sfrom; }else {/* dist == 1 or dist == 2 */ unsigned short pat16; - pat16 = *(sout-1 +OFF ); + pat16 = *(sout-1 );if (dist ==1 ) {union uu mm;/* copy one char pattern to both bytes */
@@ -296,12 +275,12 @@ void inflate_fast(z_streamp strm, unsigned start) } loops = len >>1 ;do -PUP (sout) = pat16; + *sout++ = pat16;while (--loops); - out = (unsigned char *)sout +OFF ; + out = (unsigned char *)sout; }if (len &1 ) -PUP (out) =PUP (from); + *out++ = *from++; } }else if ((op &64 ) ==0 ) {/* 2nd level distance code */
@@ -336,8 +315,8 @@ void inflate_fast(z_streamp strm, unsigned start) hold &= (1U << bits) -1 ;/* update state and return */ - strm->next_in = in +OFF ; - strm->next_out = out +OFF ; + strm->next_in = in; + strm->next_out = out; strm->avail_in = (unsigned )(in < last ?5 + (last - in) :5 - (in - last)); strm->avail_out = (unsigned )(out < end ?257 + (end - out) :257 - (out - end));
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 230/266 include/linux/bitops.h: avoid clang shift-count-overflow warnings
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit bd93f003b7462ae39a43c531abca37fe7073b866 ]
Clang normally does not warn about certain issues in inline functions when it only happens in an eliminated code path. However if something else goes wrong, it does tend to complain about the definition of hweight_long() on 32-bit targets:
include/linux/bitops.h:75:41: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
^~~~~~~~~~~~
include/asm-generic/bitops/const_hweight.h:29:49: note: expanded from macro 'hweight64'
define hweight64(w) (__builtin_constant_p(w) ? __const_hweight64(w) : __arch_hweight64(w))
^~~~~~~~~~~~~~~~~~~~
include/asm-generic/bitops/const_hweight.h:21:76: note: expanded from macro '__const_hweight64'
define __const_hweight64(w) (__const_hweight32(w) + __const_hweight32((w) >> 32))
^ ~~
include/asm-generic/bitops/const_hweight.h:20:49: note: expanded from macro '__const_hweight32'
define __const_hweight32(w) (__const_hweight16(w) + __const_hweight16((w) >> 16))
^
include/asm-generic/bitops/const_hweight.h:19:72: note: expanded from macro '__const_hweight16'
define __const_hweight16(w) (__const_hweight8(w) + __const_hweight8((w) >> 8 ))
^
include/asm-generic/bitops/const_hweight.h:12:9: note: expanded from macro '__const_hweight8'
(!!((w) & (1ULL << 2))) + \Adding an explicit cast to __u64 avoids that warning and makes it easier to read other output.
--- include/linux/bitops.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bitops.h +1 -1
@@ -57,7 +57,7 @@ static inline int get_bitmask_order(unsigned int count)static __always_inline unsigned long hweight_long (unsigned long w) { -return sizeof (w) ==4 ?hweight32 (w) :hweight64 (w); +return sizeof (w) ==4 ?hweight32 (w) :hweight64 ((__u64 )w); }/**
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 231/266 selftests/vm/pkeys: fix alloc_random_pkey() to make it really random
In reply to Sasha LevinFrom: Ram Pai <[email protected]>
[ Upstream commit 6e373263ce07eeaa6410843179535fbdf561fc31 ]
alloc_random_pkey() was allocating the same pkey every time. Not all pkeys were geting tested. This fixes it.
--- tools/testing/selftests/x86/protection_keys.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/x86/protection_keys.c +2 -1
@@ -24,6 +24,7 @@#define _GNU_SOURCE#include <errno.h> #include <linux/futex.h> +#include <time.h> #include <sys/time.h> #include <sys/syscall.h> #include <string.h>
@@ -612,10 +613,10 @@ int alloc_random_pkey(void)int nr_alloced =0 ;int random_index;memset (alloced_pkeys,0 ,sizeof (alloced_pkeys)); +srand ((unsigned int )time (NULL ));/* allocate every possible key and make a note of which ones we got */ max_nr_pkey_allocs =NR_PKEYS ; - max_nr_pkey_allocs =1 ;for (i =0 ; i < max_nr_pkey_allocs; i++) {int new_pkey =alloc_pkey ();if (new_pkey <0 )
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 232/266 blktrace: use errno instead of bi_status
In reply to Sasha LevinFrom: Chaitanya Kulkarni <[email protected]>
[ Upstream commit 48bc3cd3e07a1486f45d9971c75d6090976c3b1b ]
In blk_add_trace_spliti() blk_add_trace_bio_remap() use blk_status_to_errno() to pass the error instead of pasing the bi_status. This fixes the sparse warning.
--- kernel/trace/blktrace.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/trace/blktrace.c +6 -3
@@ -999,8 +999,10 @@ static void blk_add_trace_split(void *ignore,__blk_add_trace (bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size,bio_op (bio), bio->bi_opf, -BLK_TA_SPLIT , bio->bi_status,sizeof (rpdu), - &rpdu,blk_trace_bio_get_cgid (q, bio)); +BLK_TA_SPLIT , +blk_status_to_errno (bio->bi_status), +sizeof (rpdu), &rpdu, +blk_trace_bio_get_cgid (q, bio)); }rcu_read_unlock (); }
@@ -1037,7 +1039,8 @@ static void blk_add_trace_bio_remap(void *ignore, r.sector_from =cpu_to_be64 (from);__blk_add_trace (bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size, -bio_op (bio), bio->bi_opf,BLK_TA_REMAP , bio->bi_status, +bio_op (bio), bio->bi_opf,BLK_TA_REMAP , +blk_status_to_errno (bio->bi_status),sizeof (r), &r,blk_trace_bio_get_cgid (q, bio));rcu_read_unlock (); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 233/266 blktrace: fix endianness in get_pdu_int()
In reply to Sasha LevinFrom: Chaitanya Kulkarni <[email protected]>
[ Upstream commit 71df3fd82e7cccec7b749a8607a4662d9f7febdd ]
In function get_pdu_len() replace variable type from __u64 to __be64. This fixes sparse warning.
--- kernel/trace/blktrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/blktrace.c +1 -1
@@ -1262,7 +1262,7 @@ static inline __u16 t_error(const struct trace_entry *ent)static __u64 get_pdu_int (const struct trace_entry *ent,bool has_cg) { -const __u64 *val =pdu_start (ent, has_cg); +const __be64 *val =pdu_start (ent, has_cg);return be64_to_cpu (*val); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 234/266 blktrace: fix endianness for blk_log_remap()
In reply to Sasha LevinFrom: Chaitanya Kulkarni <[email protected]>
[ Upstream commit 5aec598c456fe3c1b71a1202cbb42bdc2a643277 ]
The function blk_log_remap() can be simplified by removing the call to get_pdu_remap() that copies the values into extra variable to print the data, which also fixes the endiannness warning reported by sparse.
--- kernel/trace/blktrace.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
kernel/trace/blktrace.c +4 -15
@@ -1266,17 +1266,6 @@ static __u64 get_pdu_int(const struct trace_entry *ent, bool has_cg)return be64_to_cpu (*val); } -static void get_pdu_remap (const struct trace_entry *ent, -struct blk_io_trace_remap *r,bool has_cg) -{ -const struct blk_io_trace_remap *__r =pdu_start (ent, has_cg); -__u64 sector_from = __r->sector_from; - - r->device_from =be32_to_cpu (__r->device_from); - r->device_to =be32_to_cpu (__r->device_to); - r->sector_from =be64_to_cpu (sector_from); -} -typedef void (blk_log_action_t ) (struct trace_iterator *iter,const char *act,bool has_cg);
@@ -1402,13 +1391,13 @@ static void blk_log_with_error(struct trace_seq *s,static void blk_log_remap (struct trace_seq *s,const struct trace_entry *ent,bool has_cg) { -struct blk_io_trace_remap r = { .device_from =0 , }; +const struct blk_io_trace_remap *__r =pdu_start (ent, has_cg); -get_pdu_remap (ent, &r, has_cg);trace_seq_printf (s,"%llu + %u <- (%d,%d) %llu\n" ,t_sector (ent),t_sec (ent), -MAJOR (r.device_from),MINOR (r.device_from), - (unsigned long long )r.sector_from); +MAJOR (be32_to_cpu (__r->device_from)), +MINOR (be32_to_cpu (__r->device_from)), +be64_to_cpu (__r->sector_from)); }static void blk_log_plug (struct trace_seq *s,const struct trace_entry *ent,bool has_cg)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 235/266 gfs2: fix use-after-free on transaction ail lists
In reply to Sasha LevinFrom: Bob Peterson <[email protected]>
[ Upstream commit 83d060ca8d90fa1e3feac227f995c013100862d3 ]
Before this patch, transactions could be merged into the system transaction by function gfs2_merge_trans(), but the transaction ail lists were never merged. Because the ail flushing mechanism can run separately, bd elements can be attached to the transaction's buffer list during the transaction (trans_add_meta, etc) but quickly moved to its ail lists. Later, in function gfs2_trans_end, the transaction can be freed (by gfs2_trans_end) while it still has bd elements queued to its ail lists, which can cause it to either lose track of the bd elements altogether (memory leak) or worse, reference the bd elements after the parent transaction has been freed.
Although I've not seen any serious consequences, the problem becomes apparent with the previous patch's addition of:
gfs2_assert_warn(sdp, list_empty(&tr->tr_ail1_list));
to function gfs2_trans_free().
This patch adds logic into gfs2_merge_trans() to move the merged transaction's ail lists to the sdp transaction. This prevents the use-after-free. To do this properly, we need to hold the ail lock, so we pass sdp into the function instead of the transaction itself.
--- fs/gfs2/log.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/gfs2/log.c +9 -2
@@ -881,8 +881,10 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)* @new: New transaction to be merged */ -static void gfs2_merge_trans (struct gfs2_trans *old,struct gfs2_trans *new) +static void gfs2_merge_trans (struct gfs2_sbd *sdp,struct gfs2_trans *new) { +struct gfs2_trans *old = sdp->sd_log_tr; +WARN_ON_ONCE (!test_bit (TR_ATTACHED , &old->tr_flags)); old->tr_num_buf_new += new->tr_num_buf_new;
@@ -893,6 +895,11 @@ static void gfs2_merge_trans(struct gfs2_trans *old, struct gfs2_trans *new)list_splice_tail_init (&new->tr_databuf, &old->tr_databuf);list_splice_tail_init (&new->tr_buf, &old->tr_buf); + +spin_lock (&sdp->sd_ail_lock); +list_splice_tail_init (&new->tr_ail1_list, &old->tr_ail1_list); +list_splice_tail_init (&new->tr_ail2_list, &old->tr_ail2_list); +spin_unlock (&sdp->sd_ail_lock); }static void log_refund (struct gfs2_sbd *sdp,struct gfs2_trans *tr)
@@ -904,7 +911,7 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)gfs2_log_lock (sdp);if (sdp->sd_log_tr) { -gfs2_merge_trans (sdp->sd_log_tr, tr); +gfs2_merge_trans (sdp, tr); }else if (tr->tr_num_buf_new || tr->tr_num_databuf_new) {gfs2_assert_withdraw (sdp,test_bit (TR_ALLOCED , &tr->tr_flags)); sdp->sd_log_tr = tr;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 236/266 net: marvell: Fix OF_MDIO config check
In reply to Sasha LevinFrom: Dan Murphy <[email protected]>
[ Upstream commit 5cd119d9a05f1c1a08778a7305b4ca0f16bc1e20 ]
When CONFIG_OF_MDIO is set to be a module the code block is not compiled. Use the IS_ENABLED macro that checks for both built in as well as module.
--- drivers/net/phy/marvell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/marvell.c +1 -1
@@ -358,7 +358,7 @@ static int m88e1101_config_aneg(struct phy_device *phydev)return marvell_config_aneg (phydev); } -#ifdef CONFIG_OF_MDIO +#if IS_ENABLED (CONFIG_OF_MDIO )/* Set and/or override some configuration registers based on the * marvell,reg-init property stored in the of_node for the phydev. *
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 237/266 ntb_perf: pass correct struct device to dma_alloc_coherent
In reply to Sasha LevinFrom: Sanjay R Mehta <[email protected]>
[ Upstream commit 98f4e140264eeb52f22ff05be6b6dd48237255ac ]
Currently, ntb->dev is passed to dma_alloc_coherent and dma_free_coherent calls. The returned dma_addr_t is the CPU physical address. This works fine as long as IOMMU is disabled. But when IOMMU is enabled, we need to make sure that IOVA is returned for dma_addr_t. So the correct way to achieve this is by changing the first parameter of dma_alloc_coherent() as ntb->pdev->dev instead.
--- drivers/ntb/test/ntb_perf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ntb/test/ntb_perf.c +4 -4
@@ -556,7 +556,7 @@ static void perf_free_inbuf(struct perf_peer *peer)return ; (void )ntb_mw_clear_trans (peer->perf->ntb, peer->pidx, peer->gidx); -dma_free_coherent (&peer->perf->ntb->dev, peer->inbuf_size, +dma_free_coherent (&peer->perf->ntb->pdev->dev, peer->inbuf_size, peer->inbuf, peer->inbuf_xlat); peer->inbuf =NULL ; }
@@ -585,8 +585,9 @@ static int perf_setup_inbuf(struct perf_peer *peer)perf_free_inbuf (peer); - peer->inbuf =dma_alloc_coherent (&perf->ntb->dev, peer->inbuf_size, - &peer->inbuf_xlat,GFP_KERNEL ); + peer->inbuf =dma_alloc_coherent (&perf->ntb->pdev->dev, + peer->inbuf_size, &peer->inbuf_xlat, +GFP_KERNEL );if (!peer->inbuf) {dev_err (&perf->ntb->dev,"Failed to alloc inbuf of %pa\n" , &peer->inbuf_size);
@@ -1517,4 +1518,3 @@ static void __exit perf_exit(void)destroy_workqueue (perf_wq); }module_exit (perf_exit); -
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 238/266 ntb_tool: pass correct struct device to dma_alloc_coherent
In reply to Sasha LevinFrom: Sanjay R Mehta <[email protected]>
[ Upstream commit 433efe720674efd9fdbcef78be75793393cf05db ]
Currently, ntb->dev is passed to dma_alloc_coherent and dma_free_coherent calls. The returned dma_addr_t is the CPU physical address. This works fine as long as IOMMU is disabled. But when IOMMU is enabled, we need to make sure that IOVA is returned for dma_addr_t. So the correct way to achieve this is by changing the first parameter of dma_alloc_coherent() as ntb->pdev->dev instead.
--- drivers/ntb/test/ntb_tool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/ntb/test/ntb_tool.c +3 -3
@@ -590,7 +590,7 @@ static int tool_setup_mw(struct tool_ctx *tc, int pidx, int widx, inmw->size =min_t (resource_size_t, req_size, size); inmw->size =round_up (inmw->size, addr_align); inmw->size =round_up (inmw->size, size_align); - inmw->mm_base =dma_alloc_coherent (&tc->ntb->dev, inmw->size, + inmw->mm_base =dma_alloc_coherent (&tc->ntb->pdev->dev, inmw->size, &inmw->dma_base,GFP_KERNEL );if (!inmw->mm_base)return -ENOMEM ;
@@ -612,7 +612,7 @@ static int tool_setup_mw(struct tool_ctx *tc, int pidx, int widx,return 0 ; err_free_dma: -dma_free_coherent (&tc->ntb->dev, inmw->size, inmw->mm_base, +dma_free_coherent (&tc->ntb->pdev->dev, inmw->size, inmw->mm_base, inmw->dma_base); inmw->mm_base =NULL ; inmw->dma_base =0 ;
@@ -629,7 +629,7 @@ static void tool_free_mw(struct tool_ctx *tc, int pidx, int widx)if (inmw->mm_base !=NULL ) {ntb_mw_clear_trans (tc->ntb, pidx, widx); -dma_free_coherent (&tc->ntb->dev, inmw->size, +dma_free_coherent (&tc->ntb->pdev->dev, inmw->size, inmw->mm_base, inmw->dma_base); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 239/266 NTB: ntb_tool: reading the link file should not end in a NULL byte
In reply to Sasha LevinFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit 912e12813dd03c602e4922fc34709ec4d4380cf0 ]
When running ntb_test this warning is issued:
./ntb_test.sh: line 200: warning: command substitution: ignored null byte in input
This is caused by the kernel returning one more byte than is necessary when reading the link file.
Reduce the number of bytes read back to 2 as it was before the commit that regressed this.
--- drivers/ntb/test/ntb_tool.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/ntb/test/ntb_tool.c +1 -2
@@ -504,7 +504,7 @@ static ssize_t tool_peer_link_read(struct file *filep, char __user *ubuf, buf[1 ] ='\n' ; buf[2 ] ='\0' ; -return simple_read_from_buffer (ubuf, size, offp, buf,3 ); +return simple_read_from_buffer (ubuf, size, offp, buf,2 ); } static TOOL_FOPS_RDWR(tool_peer_link_fops,
@@ -1690,4 +1690,3 @@ static void __exit tool_exit(void)debugfs_remove_recursive (tool_dbgfs_topdir); }module_exit (tool_exit); -
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 240/266 NTB: Revert the change to use the NTB device dev for DMA allocations
In reply to Sasha LevinFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit 40da7d9a93c8941737ef4a1208d32c13ce017fe1 ]
Commit 417cf39cfea9 ("NTB: Set dma mask and dma coherent mask to NTB devices") started using the NTB device for DMA allocations which was turns out was wrong. If the IOMMU is enabled, such alloctanions will always fail with messages such as:
DMAR: Allocating domain for 0000:02:00.1 failed
This is because the IOMMU has not setup the device for such use.
Change the tools back to using the PCI device for allocations seeing it doesn't make sense to add an IOMMU group for the non-physical NTB device. Also remove the code that sets the DMA mask as it no longer makes sense to do this.
--- drivers/ntb/core.c | 1 - 1 file changed, 1 deletion(-)
drivers/ntb/core.c +0 -1
@@ -311,4 +311,3 @@ static void __exit ntb_driver_exit(void)bus_unregister (&ntb_bus); }module_exit (ntb_driver_exit); -
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 241/266 NTB: perf: Don't require one more memory window than number of peers
In reply to Sasha LevinFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit a9c4211ac918ade1522aced6b5acfbe824722f7d ]
ntb_perf should not require more than one memory window per peer. This was probably an off-by-one error.
--- drivers/ntb/test/ntb_perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ntb/test/ntb_perf.c +1 -1
@@ -653,7 +653,7 @@ static int perf_init_service(struct perf_ctx *perf) {u64 mask; -if (ntb_peer_mw_count (perf->ntb) < perf->pcnt +1 ) { +if (ntb_peer_mw_count (perf->ntb) < perf->pcnt) {dev_err (&perf->ntb->dev,"Not enough memory windows\n" );return -EINVAL ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 242/266 NTB: perf: Fix support for hardware that doesn't have port numbers
In reply to Sasha LevinFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit b54369a248c2e033bfcf5d6917e08cf9d73d54a6 ]
Legacy drivers do not have port numbers (but is reliably only two ports) and was broken by the recent commit that added mult-port support to ntb_perf. This is especially important to support the cross link topology which is perfectly symmetric and cannot assign unique port numbers easily.
Hardware that returns zero for both the local port and the peer should just always use gidx=0 for the only peer.
--- drivers/ntb/test/ntb_perf.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/ntb/test/ntb_perf.c +10 -0
@@ -1423,6 +1423,16 @@ static int perf_init_peers(struct perf_ctx *perf)if (perf->gidx ==-1 ) perf->gidx = pidx; +/* +* Hardware with only two ports may not have unique port +* numbers. In this case, the gidxs should all be zero. +*/ +if (perf->pcnt ==1 &&ntb_port_number (perf->ntb) ==0 && +ntb_peer_port_number (perf->ntb,0 ) ==0 ) { + perf->gidx =0 ; + perf->peers[0 ].gidx =0 ; + } +for (pidx =0 ; pidx < perf->pcnt; pidx++) { ret =perf_setup_peer_mw (&perf->peers[pidx]);if (ret)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 243/266 NTB: perf: Fix race condition when run with ntb_test
In reply to Sasha LevinFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit 34d8673a01b053b6231a995a4eec9341163d63be ]
When running ntb_test, the script tries to run the ntb_perf test immediately after probing the modules. Since adding multi-port support, this fails seeing the new initialization procedure in ntb_perf can not complete instantly.
To fix this we add a completion which is waited on when a test is started. In this way, run can be written any time after the module is loaded and it will wait for the initialization to complete instead of sending an error.
--- drivers/ntb/test/ntb_perf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/ntb/test/ntb_perf.c +8 -2
@@ -158,6 +158,8 @@ struct perf_peer {/* NTB connection setup service */ struct work_struct service;unsigned long sts; + +struct completion init_comp; };#define to_peer_service (__work) \ container_of(__work, struct perf_peer, service)
@@ -546,6 +548,7 @@ static int perf_setup_outbuf(struct perf_peer *peer)/* Initialization is finally done */ set_bit (PERF_STS_DONE , &peer->sts); +complete_all (&peer->init_comp);return 0 ; }
@@ -637,6 +640,7 @@ static void perf_service_work(struct work_struct *work)perf_setup_outbuf (peer);if (test_and_clear_bit (PERF_CMD_CLEAR , &peer->sts)) { +init_completion (&peer->init_comp);clear_bit (PERF_STS_DONE , &peer->sts);if (test_bit (0 , &peer->perf->busy_flag) && peer == peer->perf->test_peer) {
@@ -1052,8 +1056,9 @@ static int perf_submit_test(struct perf_peer *peer)struct perf_thread *pthr;int tidx, ret; -if (!test_bit (PERF_STS_DONE , &peer->sts)) -return -ENOLINK ; + ret =wait_for_completion_interruptible (&peer->init_comp); +if (ret <0 ) +return ret;if (test_and_set_bit_lock (0 , &perf->busy_flag))return -EBUSY ;
@@ -1419,6 +1424,7 @@ static int perf_init_peers(struct perf_ctx *perf) peer->gidx = pidx; }INIT_WORK (&peer->service, perf_service_work); +init_completion (&peer->init_comp); }if (perf->gidx ==-1 ) perf->gidx = pidx;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 244/266 NTB: ntb_test: Fix bug when counting remote files
In reply to Sasha LevinFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit 2130c0ba69d69bb21f5c52787f2587db00d13d8a ]
When remote files are counted in get_files_count, without using SSH, the code returns 0 because there is a colon prepended to $LOC. $VPATH should have been used instead of $LOC.
--- tools/testing/selftests/ntb/ntb_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ntb/ntb_test.sh +1 -1
@@ -241,7 +241,7 @@ function get_files_count() split_remote $LOC if [[ "$REMOTE" == "" ]]; then - echo $(ls -1 "$LOC"/${NAME}* 2>/dev/null | wc -l) + echo $(ls -1 "$VPATH"/${NAME}* 2>/dev/null | wc -l) else echo $(ssh "$REMOTE" "ls -1 \"$VPATH\"/${NAME}* | \ wc -l" 2> /dev/null)
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 245/266 i2c: icy: Fix build with CONFIG_AMIGA_PCMCIA=n
In reply to Sasha LevinFrom: Max Staudt <[email protected]>
[ Upstream commit cdb555397f438592bab00599037c347b700cf397 ]
This has been found by the Kernel Test Robot:
http://lkml.iu.edu/hypermail/linux/kernel/2006.0/06862.html
With CONFIG_AMIGA_PCMCIA=n, io_mm.h does not pull in amigahw.h and ZTWO_VADDR is undefined. Add forgotten include to i2c-icy.c
--- drivers/i2c/busses/i2c-icy.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-icy.c +1 -0
@@ -43,6 +43,7 @@#include <linux/i2c.h> #include <linux/i2c-algo-pcf.h> +#include <asm/amigahw.h> #include <asm/amigaints.h> #include <linux/zorro.h>
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 246/266 drivers/perf: hisi: Fix wrong value for all counters enable
In reply to Sasha LevinFrom: Shaokun Zhang <[email protected]>
[ Upstream commit 961abd78adcb4c72c343fcd9f9dc5e2ebbe9b448 ]
In L3C uncore PMU drivers, bit16 is used to control all counters enable & disable. Wrong value is given in the driver and its default value is 1'b1, it can work because each PMU counter has its own control bits too. Let's fix the wrong value.
--- drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c +1 -1
@@ -35,7 +35,7 @@/* L3C has 8-counters */ #define L3C_NR_COUNTERS 0x8 -#define L3C_PERF_CTRL_EN 0x20000 +#define L3C_PERF_CTRL_EN 0x10000#define L3C_EVTYPE_NONE 0xff/*
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 247/266 selftests/net: in timestamping, strncpy needs to preserve null byte
In reply to Sasha LevinFrom: tannerlove <[email protected]>
[ Upstream commit 8027bc0307ce59759b90679fa5d8b22949586d20 ]
If user passed an interface option longer than 15 characters, then device.ifr_name and hwtstamp.ifr_name became non-null-terminated strings. The compiler warned about this:
timestamping.c:353:2: warning: ‘strncpy’ specified bound 16 equals \
destination size [-Wstringop-truncation]
353 | strncpy(device.ifr_name, interface, sizeof(device.ifr_name));
--- .../selftests/networking/timestamping/timestamping.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
tools/testing/selftests/networking/timestamping/timestamping.c +8 -2
@@ -313,10 +313,16 @@ int main(int argc, char **argv)int val;socklen_t len;struct timeval next; +size_t if_len;if (argc <2 )usage (0 ); interface = argv[1 ]; + if_len =strlen (interface); +if (if_len >=IFNAMSIZ ) { +printf ("interface name exceeds IFNAMSIZ\n" ); +exit (1 ); + }for (i =2 ; i < argc; i++) {if (!strcasecmp (argv[i],"SO_TIMESTAMP" ))
@@ -350,12 +356,12 @@ int main(int argc, char **argv)bail ("socket" );memset (&device,0 ,sizeof (device)); -strncpy (device.ifr_name, interface,sizeof (device.ifr_name)); +memcpy (device.ifr_name, interface, if_len +1 );if (ioctl (sock,SIOCGIFADDR , &device) <0 )bail ("getting interface IP address" );memset (&hwtstamp,0 ,sizeof (hwtstamp)); -strncpy (hwtstamp.ifr_name, interface,sizeof (hwtstamp.ifr_name)); +memcpy (hwtstamp.ifr_name, interface, if_len +1 ); hwtstamp.ifr_data = (void *)&hwconfig;memset (&hwconfig,0 ,sizeof (hwconfig)); hwconfig.tx_type =
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 248/266 f2fs: don't return vmalloc() memory from f2fs_kmalloc()
In reply to Sasha LevinFrom: Eric Biggers <[email protected]>
[ Upstream commit 0b6d4ca04a86b9dababbb76e58d33c437e127b77 ]
kmalloc() returns kmalloc'ed memory, and kvmalloc() returns either kmalloc'ed or vmalloc'ed memory. But the f2fs wrappers, f2fs_kmalloc() and f2fs_kvmalloc(), both return both kinds of memory.
It's redundant to have two functions that do the same thing, and also breaking the standard naming convention is causing bugs since people assume it's safe to kfree() memory allocated by f2fs_kmalloc(). See e.g. the various allocations in fs/f2fs/compress.c.
Fix this by making f2fs_kmalloc() just use kmalloc(). And to avoid re-introducing the allocation failures that the vmalloc fallback was intended to fix, convert the largest allocations to use f2fs_kvmalloc().
--- fs/f2fs/checkpoint.c | 4 ++-- fs/f2fs/f2fs.h | 8 +------- fs/f2fs/node.c | 8 ++++---- fs/f2fs/super.c | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-)
fs/f2fs/checkpoint.c +2 -2
@@ -892,8 +892,8 @@ int f2fs_get_valid_checkpoint(struct f2fs_sb_info *sbi)int i;int err; - sbi->ckpt =f2fs_kzalloc (sbi,array_size (blk_size, cp_blks), -GFP_KERNEL ); + sbi->ckpt =f2fs_kvzalloc (sbi,array_size (blk_size, cp_blks), +GFP_KERNEL );if (!sbi->ckpt)return -ENOMEM ;/*
fs/f2fs/f2fs.h +1 -7
@@ -2789,18 +2789,12 @@ static inline bool f2fs_may_extent_tree(struct inode *inode)static inline void *f2fs_kmalloc (struct f2fs_sb_info *sbi,size_t size,gfp_t flags) { -void *ret; -if (time_to_inject (sbi,FAULT_KMALLOC )) {f2fs_show_injection_info (FAULT_KMALLOC );return NULL ; } - ret =kmalloc (size, flags); -if (ret) -return ret; - -return kvmalloc (size, flags); +return kmalloc (size, flags); } static inline void *f2fs_kzalloc(struct f2fs_sb_info *sbi,
fs/f2fs/node.c +4 -4
@@ -2933,7 +2933,7 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)return 0 ; nm_i->nat_bits_blocks =F2FS_BLK_ALIGN ((nat_bits_bytes <<1 ) +8 ); - nm_i->nat_bits =f2fs_kzalloc (sbi, + nm_i->nat_bits =f2fs_kvzalloc (sbi, nm_i->nat_bits_blocks <<F2FS_BLKSIZE_BITS ,GFP_KERNEL );if (!nm_i->nat_bits)return -ENOMEM ;
@@ -3066,9 +3066,9 @@ static int init_free_nid_cache(struct f2fs_sb_info *sbi)int i; nm_i->free_nid_bitmap = -f2fs_kzalloc (sbi,array_size (sizeof (unsigned char *), - nm_i->nat_blocks), -GFP_KERNEL ); +f2fs_kvzalloc (sbi,array_size (sizeof (unsigned char *), + nm_i->nat_blocks), +GFP_KERNEL );if (!nm_i->free_nid_bitmap)return -ENOMEM ;
fs/f2fs/super.c +1 -1
@@ -2889,7 +2889,7 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)if (nr_sectors & (bdev_zone_sectors (bdev) -1 ))FDEV (devi).nr_blkz++; -FDEV (devi).blkz_seq =f2fs_kzalloc (sbi, +FDEV (devi).blkz_seq =f2fs_kvzalloc (sbi,BITS_TO_LONGS (FDEV (devi).nr_blkz) *sizeof (unsigned long ),GFP_KERNEL );
Signature · 8 lines
2.25.1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Sasha Levin
maintainerPATCH 249/266 afs: Fix memory leak in afs_put_sysnames()
In reply to Sasha LevinFrom: Zhihao Cheng <[email protected]>
[ Upstream commit 2ca068be09bf8e285036603823696140026dcbe7 ]
Fix afs_put_sysnames() to actually free the specified afs_sysnames object after its reference count has been decreased to zero and its contents have been released.
--- fs/afs/proc.c | 1 + 1 file changed, 1 insertion(+)
fs/afs/proc.c +1 -0
@@ -562,6 +562,7 @@ void afs_put_sysnames(struct afs_sysnames *sysnames)if (sysnames->subs[i] != afs_init_sysname && sysnames->subs[i] != sysnames->blank)kfree (sysnames->subs[i]); +kfree (sysnames); } }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 250/266 ASoC: core: only convert non DPCM link to DPCM link
In reply to Sasha LevinFrom: Bard Liao <[email protected]>
[ Upstream commit 607fa205a7e4dfad28b8a67ab1c985756ddbccb0 ]
Additional checks for valid DAIs expose a corner case, where existing BE dailinks get modified, e.g. HDMI links are tagged with dpcm_capture=1 even if the DAIs are for playback.
This patch makes those changes conditional and flags configuration issues when a BE dailink is has no_pcm=0 but dpcm_playback or dpcm_capture=1 (which makes no sense).
As discussed on the alsa-devel mailing list, there are redundant flags for dpcm_playback, dpcm_capture, playback_only, capture_only. This will have to be cleaned-up in a future update. For now only correct and flag problematic configurations.
--- sound/soc/soc-core.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
sound/soc/soc-core.c +19 -3
@@ -1895,9 +1895,25 @@ static void soc_check_tplg_fes(struct snd_soc_card *card) dai_link->platforms->name = component->name;/* convert non BE into BE */ - dai_link->no_pcm =1 ; - dai_link->dpcm_playback =1 ; - dai_link->dpcm_capture =1 ; +if (!dai_link->no_pcm) { + dai_link->no_pcm =1 ; + +if (dai_link->dpcm_playback) +dev_warn (card->dev, +"invalid configuration, dailink %s has flags no_pcm=0 and dpcm_playback=1\n" , + dai_link->name); +if (dai_link->dpcm_capture) +dev_warn (card->dev, +"invalid configuration, dailink %s has flags no_pcm=0 and dpcm_capture=1\n" , + dai_link->name); + +/* convert normal link into DPCM one */ +if (!(dai_link->dpcm_playback || + dai_link->dpcm_capture)) { + dai_link->dpcm_playback = !dai_link->capture_only; + dai_link->dpcm_capture = !dai_link->playback_only; + } + }/* override any BE fixups */ dai_link->be_hw_params_fixup =
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 251/266 ASoC: SOF: nocodec: conditionally set dpcm_capture/dpcm_playback flags
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit ba4e5abc6c4e173af7c941c03c067263b686665d ]
With additional checks on dailinks, we see errors such as
[ 3.000418] sof-nocodec sof-nocodec: CPU DAI DMIC01 Pin for rtd
NoCodec-6 does not support playback
It's not clear why we set the dpcm_playback and dpcm_capture flags unconditionally, add a check on number of channels for each direction to avoid invalid configurations.
--- sound/soc/sof/nocodec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/sof/nocodec.c +4 -2
@@ -52,8 +52,10 @@ static int sof_nocodec_bes_setup(struct device *dev, links[i].platforms->name =dev_name (dev); links[i].codecs->dai_name ="snd-soc-dummy-dai" ; links[i].codecs->name ="snd-soc-dummy" ; - links[i].dpcm_playback =1 ; - links[i].dpcm_capture =1 ; +if (ops->drv[i].playback.channels_min) + links[i].dpcm_playback =1 ; +if (ops->drv[i].capture.channels_min) + links[i].dpcm_capture =1 ; } card->dai_link = links;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 252/266 ASoC: Intel: bytcr_rt5640: Add quirk for Toshiba Encore WT10-A tablet
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 199a5e8fda54ab3c8c6f6bf980c004e97ebf5ccb ]
The Toshiba Encore WT10-A tablet almost fully works with the default settings for Bay Trail CR devices. The only issue is that it uses a digital mic. connected the the DMIC1 input instead of an analog mic.
Add a quirk for this model using the default settings with the input-map replaced with BYT_RT5640_DMIC1_MAP.
--- sound/soc/intel/boards/bytcr_rt5640.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/soc/intel/boards/bytcr_rt5640.c +12 -0
@@ -754,6 +754,18 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {BYT_RT5640_JD_NOT_INV | BYT_RT5640_MCLK_EN), }, + { /* Toshiba Encore WT10-A */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"TOSHIBA" ), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "TOSHIBA WT10-A-103"), + }, + .driver_data = (void *)(BYT_RT5640_DMIC1_MAP | +BYT_RT5640_JD_SRC_JD1_IN4P | +BYT_RT5640_OVCD_TH_2000UA | +BYT_RT5640_OVCD_SF_0P75 | +BYT_RT5640_SSP0_AIF2 | + BYT_RT5640_MCLK_EN), + }, { /* Catch-all for generic Insyde tablets, must be last */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 253/266 ASoC: rt5645: Add platform-data for Asus T101HA
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 79d4f823a06796656289f97b922493da5690e46c ]
The Asus T101HA uses the default jack-detect mode 3, but instead of using an analog microphone it is using a DMIC on dmic-data-pin 1, like the Asus T100HA. Note unlike the T100HA its jack-detect is not inverted.
Add a DMI quirk with the correct settings for this model.
--- sound/soc/codecs/rt5645.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
sound/soc/codecs/rt5645.c +14 -0
@@ -3625,6 +3625,12 @@ static const struct rt5645_platform_data asus_t100ha_platform_data = { .inv_jd1_1 = true, }; +static const struct rt5645_platform_data asus_t101ha_platform_data = { + .dmic1_data_pin =RT5645_DMIC_DATA_IN2N , + .dmic2_data_pin =RT5645_DMIC2_DISABLE , + .jd_mode =3 , +}; +static const struct rt5645_platform_data lenovo_ideapad_miix_310_pdata = { .jd_mode =3 , .in2_diff = true,
@@ -3702,6 +3708,14 @@ static const struct dmi_system_id dmi_platform_data[] = { }, .driver_data = (void *)&asus_t100ha_platform_data, }, + { + .ident = "ASUS T101HA", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), + DMI_MATCH(DMI_PRODUCT_NAME, "T101HA"), + }, + .driver_data = (void *)&asus_t101ha_platform_data, + }, { .ident ="MINIX Z83-4" , .matches = {
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 254/266 bpf/sockmap: Fix kernel panic at __tcp_bpf_recvmsg
In reply to Sasha LevinFrom: dihu <[email protected]>
[ Upstream commit 487082fb7bd2a32b66927d2b22e3a81b072b44f0 ]
When user application calls read() with MSG_PEEK flag to read data of bpf sockmap socket, kernel panic happens at __tcp_bpf_recvmsg+0x12c/0x350. sk_msg is not removed from ingress_msg queue after read out under MSG_PEEK flag is set. Because it's not judged whether sk_msg is the last msg of ingress_msg queue, the next sk_msg may be the head of ingress_msg queue, whose memory address of sg page is invalid. So it's necessary to add check codes to prevent this problem.
[20759.125457] BUG: kernel NULL pointer dereference, address: 0000000000000008 [20759.132118] CPU: 53 PID: 51378 Comm: envoy Tainted: G E 5.4.32 #1 [20759.140890] Hardware name: Inspur SA5212M4/YZMB-00370-109, BIOS 4.1.12 06/18/2017 [20759.149734] RIP: 0010:copy_page_to_iter+0xad/0x300 [20759.270877] __tcp_bpf_recvmsg+0x12c/0x350 [20759.276099] tcp_bpf_recvmsg+0x113/0x370 [20759.281137] inet_recvmsg+0x55/0xc0 [20759.285734] __sys_recvfrom+0xc8/0x130 [20759.290566] ? __audit_syscall_entry+0x103/0x130 [20759.296227] ? syscall_trace_enter+0x1d2/0x2d0 [20759.301700] ? __audit_syscall_exit+0x1e4/0x290 [20759.307235] __x64_sys_recvfrom+0x24/0x30 [20759.312226] do_syscall_64+0x55/0x1b0 [20759.316852] entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- net/ipv4/tcp_bpf.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv4/tcp_bpf.c +3 -0
@@ -96,6 +96,9 @@ int __tcp_bpf_recvmsg(struct sock *sk, struct sk_psock *psock, }while (i != msg_rx->sg.end);if (unlikely (peek)) { +if (msg_rx ==list_last_entry (&psock->ingress_msg, + struct sk_msg, list)) +break ; msg_rx =list_next_entry (msg_rx, list);continue ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 255/266 bpf, sockhash: Synchronize delete from bucket list on map free
In reply to Sasha LevinFrom: Jakub Sitnicki <[email protected]>
[ Upstream commit 75e68e5bf2c7fa9d3e874099139df03d5952a3e1 ]
We can end up modifying the sockhash bucket list from two CPUs when a sockhash is being destroyed (sock_hash_free) on one CPU, while a socket that is in the sockhash is unlinking itself from it on another CPU it (sock_hash_delete_from_link).
This results in accessing a list element that is in an undefined state as reported by KASAN:
| ================================================================== | BUG: KASAN: wild-memory-access in sock_hash_free+0x13c/0x280 | Write of size 8 at addr dead000000000122 by task kworker/2:1/95 | | CPU: 2 PID: 95 Comm: kworker/2:1 Not tainted 5.7.0-rc7-02961-ge22c35ab0038-dirty #691 | Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014 | Workqueue: events bpf_map_free_deferred | Call Trace: | dump_stack+0x97/0xe0 | ? sock_hash_free+0x13c/0x280 | __kasan_report.cold+0x5/0x40 | ? mark_lock+0xbc1/0xc00 | ? sock_hash_free+0x13c/0x280 | kasan_report+0x38/0x50 | ? sock_hash_free+0x152/0x280 | sock_hash_free+0x13c/0x280 | bpf_map_free_deferred+0xb2/0xd0 | ? bpf_map_charge_finish+0x50/0x50 | ? rcu_read_lock_sched_held+0x81/0xb0 | ? rcu_read_lock_bh_held+0x90/0x90 | process_one_work+0x59a/0xac0 | ? lock_release+0x3b0/0x3b0 | ? pwq_dec_nr_in_flight+0x110/0x110 | ? rwlock_bug.part.0+0x60/0x60 | worker_thread+0x7a/0x680 | ? _raw_spin_unlock_irqrestore+0x4c/0x60 | kthread+0x1cc/0x220 | ? process_one_work+0xac0/0xac0 | ? kthread_create_on_node+0xa0/0xa0 | ret_from_fork+0x24/0x30 | ==================================================================
Fix it by reintroducing spin-lock protected critical section around the code that removes the elements from the bucket on sockhash free.
To do that we also need to defer processing of removed elements, until out of atomic context so that we can unlink the socket from the map when holding the sock lock.
--- net/core/sock_map.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
net/core/sock_map.c +21 -2
@@ -861,6 +861,7 @@ static void sock_hash_free(struct bpf_map *map) { struct bpf_htab *htab = container_of(map, struct bpf_htab, map);struct bpf_htab_bucket *bucket; +struct hlist_head unlink_list;struct bpf_htab_elem *elem;struct hlist_node *node;int i;
@@ -872,13 +873,31 @@ static void sock_hash_free(struct bpf_map *map)synchronize_rcu ();for (i =0 ; i < htab->buckets_num; i++) { bucket =sock_hash_select_bucket (htab, i); -hlist_for_each_entry_safe (elem, node, &bucket->head, node) { -hlist_del_rcu (&elem->node); + +/* We are racing with sock_hash_delete_from_link to +* enter the spin-lock critical section. Every socket on +* the list is still linked to sockhash. Since link +* exists, psock exists and holds a ref to socket. That +* lets us to grab a socket ref too. +*/ +raw_spin_lock_bh (&bucket->lock); +hlist_for_each_entry (elem, &bucket->head, node) +sock_hold (elem->sk); +hlist_move_list (&bucket->head, &unlink_list); +raw_spin_unlock_bh (&bucket->lock); + +/* Process removed entries out of atomic context to +* block for socket lock before deleting the psock's +* link to sockhash. +*/ +hlist_for_each_entry_safe (elem, node, &unlink_list, node) { +hlist_del (&elem->node);lock_sock (elem->sk);rcu_read_lock ();sock_map_unref (elem->sk, elem);rcu_read_unlock ();release_sock (elem->sk); +sock_put (elem->sk);sock_hash_free_elem (htab, elem); } }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 256/266 tracing/probe: Fix bpf_task_fd_query() for kprobes and uprobes
In reply to Sasha LevinFrom: Jean-Philippe Brucker <[email protected]>
[ Upstream commit 22d5bd6867364b41576a712755271a7d6161abd6 ]
Commit 60d53e2c3b75 ("tracing/probe: Split trace_event related data from trace_probe") removed the trace_[ku]probe structure from the trace_event_call->data pointer. As bpf_get_[ku]probe_info() were forgotten in that change, fix them now. These functions are currently only used by the bpf_task_fd_query() syscall handler to collect information about a perf event.
--- kernel/trace/trace_kprobe.c | 2 +- kernel/trace/trace_uprobe.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_kprobe.c +1 -1
@@ -1464,7 +1464,7 @@ int bpf_get_kprobe_info(const struct perf_event *event, u32 *fd_type,if (perf_type_tracepoint) tk =find_trace_kprobe (pevent, group);else - tk = event->tp_event->data; + tk =trace_kprobe_primary_from_call (event->tp_event);if (!tk)return -EINVAL ;
kernel/trace/trace_uprobe.c +1 -1
@@ -1405,7 +1405,7 @@ int bpf_get_uprobe_info(const struct perf_event *event, u32 *fd_type,if (perf_type_tracepoint) tu =find_probe_event (pevent, group);else - tu = event->tp_event->data; + tu =trace_uprobe_primary_from_call (event->tp_event);if (!tu)return -EINVAL ;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 257/266 drm/sun4i: hdmi ddc clk: Fix size of m divider
In reply to Sasha LevinFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 54e1e06bcf1cf6e7ac3f86daa5f7454add24b494 ]
m divider in DDC clock register is 4 bits wide. Fix that.
--- drivers/gpu/drm/sun4i/sun4i_hdmi.h | 2 +- drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/sun4i/sun4i_hdmi.h +1 -1
@@ -148,7 +148,7 @@#define SUN4I_HDMI_DDC_CMD_IMPLICIT_WRITE 3#define SUN4I_HDMI_DDC_CLK_REG 0x528 -#define SUN4I_HDMI_DDC_CLK_M (m) (((m) & 0x7) << 3) +#define SUN4I_HDMI_DDC_CLK_M (m) (((m) & 0xf) << 3)#define SUN4I_HDMI_DDC_CLK_N (n) ((n) & 0x7)#define SUN4I_HDMI_DDC_LINE_CTRL_REG 0x540
drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c +1 -1
@@ -33,7 +33,7 @@ static unsigned long sun4i_ddc_calc_divider(unsigned long rate,unsigned long best_rate =0 ;u8 best_m =0 , best_n =0 , _m, _n; -for (_m =0 ; _m <8 ; _m++) { +for (_m =0 ; _m <16 ; _m++) {for (_n =0 ; _n <8 ; _n++) {unsigned long tmp_rate;
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 258/266 libbpf: Handle GCC noreturn-turned-volatile quirk
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 32022fd97ed34f6812802bf1288db27c313576f4 ]
Handle a GCC quirk of emitting extra volatile modifier in DWARF (and subsequently preserved in BTF by pahole) for function pointers marked as __attribute__((noreturn)). This was the way to mark such functions before GCC 2.5 added noreturn attribute. Drop such func_proto modifiers, similarly to how it's done for array (also to handle GCC quirk/bug).
Such volatile attribute is emitted by GCC only, so existing selftests can't express such test. Simple repro is like this (compiled with GCC + BTF generated by pahole):
struct my_struct {
void __attribute__((noreturn)) (*fn)(int);
};
struct my_struct a;Without this fix, output will be:
struct my_struct {
voidvolatile (*fn)(int);
};With the fix:
struct my_struct {
void (*fn)(int);
};--- tools/lib/bpf/btf_dump.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
tools/lib/bpf/btf_dump.c +24 -9
@@ -1141,6 +1141,20 @@ static void btf_dump_emit_mods(struct btf_dump *d, struct id_stack *decl_stack) } } +static void btf_dump_drop_mods (struct btf_dump *d,struct id_stack *decl_stack) +{ +const struct btf_type *t; +__u32 id; + +while (decl_stack->cnt) { + id = decl_stack->ids[decl_stack->cnt -1 ]; + t =btf__type_by_id (d->btf, id); +if (!btf_is_mod (t)) +return ; + decl_stack->cnt--; + } +} +static void btf_dump_emit_name (const struct btf_dump *d,const char *name,bool last_was_ptr) {
@@ -1239,14 +1253,7 @@ static void btf_dump_emit_type_chain(struct btf_dump *d,* a const/volatile modifier for array, so we are * going to silently skip them here. */ -while (decls->cnt) { - next_id = decls->ids[decls->cnt -1 ]; - next_t =btf__type_by_id (d->btf, next_id); -if (btf_is_mod (next_t)) - decls->cnt--; -else -break ; - } +btf_dump_drop_mods (d, decls);if (decls->cnt ==0 ) {btf_dump_emit_name (d, fname, last_was_ptr);
@@ -1274,7 +1281,15 @@ static void btf_dump_emit_type_chain(struct btf_dump *d,__u16 vlen =btf_vlen (t);int i; -btf_dump_emit_mods (d, decls); +/* +* GCC emits extra volatile qualifier for +* __attribute__((noreturn)) function pointers. Clang +* doesn't do it. It's a GCC quirk for backwards +* compatibility with code written for GCC <2.5. So, +* similarly to extra qualifiers for array, just drop +* them, instead of handling them. +*/ +btf_dump_drop_mods (d, decls);if (decls->cnt) {btf_dump_printf (d," (" );btf_dump_emit_type_chain (d, decls, fname, lvl);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 259/266 scsi: acornscsi: Fix an error handling path in acornscsi_probe()
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 42c76c9848e13dbe0538d7ae0147a269dfa859cb ]
'ret' is known to be 0 at this point. Explicitly return -ENOMEM if one of the 'ecardm_iomap()' calls fail.
--- drivers/scsi/arm/acornscsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/arm/acornscsi.c +3 -1
@@ -2911,8 +2911,10 @@ static int acornscsi_probe(struct expansion_card *ec, const struct ecard_id *id) ashost->base =ecardm_iomap (ec,ECARD_RES_MEMC ,0 ,0 ); ashost->fast =ecardm_iomap (ec,ECARD_RES_IOCFAST ,0 ,0 ); -if (!ashost->base || !ashost->fast) +if (!ashost->base || !ashost->fast) { + ret = -ENOMEM ; goto out_put; + } host->irq = ec->irq; ashost->host = host;
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 260/266 x86/idt: Keep spurious entries unset in system_vectors
In reply to Sasha LevinFrom: Vitaly Kuznetsov <[email protected]>
[ Upstream commit 1f1fbc70c10e81f70e9fbe2102d439c883269811 ]
With commit dc20b2d52653 ("x86/idt: Move interrupt gate initialization to IDT code") non assigned system vectors are also marked as used in 'used_vectors' (now 'system_vectors') bitmap. This makes checks in arch_show_interrupts() whether a particular system vector is allocated to always pass and e.g. 'Hyper-V reenlightenment interrupts' entry always shows up in /proc/interrupts.
Another side effect of having all unassigned system vectors marked as used is that irq_matrix_debug_show() will wrongly count them among 'System' vectors.
As it is now ensured that alloc_intr_gate() is not called after init, it is possible to leave unused entries in 'system_vectors' unset to fix these issues.
--- arch/x86/kernel/idt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/kernel/idt.c +5 -1
@@ -318,7 +318,11 @@ void __init idt_setup_apic_and_irq_gates(void)#ifdef CONFIG_X86_LOCAL_APIC for_each_clear_bit_from (i, system_vectors,NR_VECTORS ) { -set_bit (i, system_vectors); +/* +* Don't set the non assigned system vectors in the +* system_vectors bitmap. Otherwise they show up in +* /proc/interrupts. +*/ entry = spurious_entries_start +8 * (i -FIRST_SYSTEM_VECTOR );set_intr_gate (i, entry); }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 261/266 net/filter: Permit reading NET in load_bytes_relative when MAC not set
In reply to Sasha LevinFrom: YiFei Zhu <[email protected]>
[ Upstream commit 0f5d82f187e1beda3fe7295dfc500af266a5bd80 ]
Added a check in the switch case on start_header that checks for the existence of the header, and in the case that MAC is not set and the caller requests for MAC, -EFAULT. If the caller requests for NET then MAC's existence is completely ignored.
There is no function to check NET header's existence and as far as cgroup_skb/egress is concerned it should always be set.
Removed for ptr >= the start of header, considering offset is bounded unsigned and should always be true. len <= end - mac is redundant to ptr + len <= end.
--- net/core/filter.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
net/core/filter.c +9 -7
@@ -1766,25 +1766,27 @@ BPF_CALL_5(bpf_skb_load_bytes_relative, const struct sk_buff *, skb, u32, offset, void *, to, u32, len, u32, start_header) {u8 *end =skb_tail_pointer (skb); -u8 *net =skb_network_header (skb); -u8 *mac =skb_mac_header (skb); -u8 *ptr; +u8 *start, *ptr; -if (unlikely (offset >0xffff || len > (end - mac))) +if (unlikely (offset >0xffff )) goto err_clear;switch (start_header) {case BPF_HDR_START_MAC : - ptr = mac + offset; +if (unlikely (!skb_mac_header_was_set (skb))) + goto err_clear; + start =skb_mac_header (skb);break ;case BPF_HDR_START_NET : - ptr = net + offset; + start =skb_network_header (skb);break ;default : goto err_clear; } -if (likely (ptr >= mac && ptr + len <= end)) { + ptr = start + offset; + +if (likely (ptr + len <= end)) {memcpy (to, ptr, len);return 0 ; }
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 262/266 nvme-pci: use simple suspend when a HMB is enabled
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit b97120b15ebd3de51325084136d3b9c3cce656d6 ]
While the NVMe specification allows the device to access the host memory buffer in host DRAM from all power states, hosts will fail access to DRAM during S3 and similar power states.
--- drivers/nvme/host/pci.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/nvme/host/pci.c +6 -0
@@ -2962,9 +2962,15 @@ static int nvme_suspend(struct device *dev)* the PCI bus layer to put it into D3 in order to take the PCIe link * down, so as to allow the platform to achieve its minimum low-power * state (which may not be possible if the link is up). +* +* If a host memory buffer is enabled, shut down the device as the NVMe +* specification allows the device to access the host memory buffer in +* host DRAM from all power states, but hosts will fail access to DRAM +* during S3. */ if (pm_suspend_via_firmware () || !ctrl->npss || !pcie_aspm_enabled (pdev) || + ndev->nr_host_mem_descs || (ndev->ctrl.quirks &NVME_QUIRK_SIMPLE_SUSPEND ))return nvme_disable_prepare_reset (ndev, true);
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 263/266 nfs: set invalid blocks after NFSv4 writes
In reply to Sasha LevinFrom: Zheng Bin <[email protected]>
[ Upstream commit 3a39e778690500066b31fe982d18e2e394d3bce2 ]
Use the following command to test nfsv4(size of file1M is 1MB):
mount -t nfs -o vers=4.0,actimeo=60 127.0.0.1/dir1 /mnt cp file1M /mnt
du -h /mnt/file1M -->0 within 60s, then 1M
When write is done(cp file1M /mnt), will call this:nfs_writeback_done
nfs4_write_done
nfs4_write_done_cb
nfs_writeback_update_inode
nfs_post_op_update_inode_force_wcc_locked(change, ctime, mtimenfs_post_op_update_inode_force_wcc_locked
nfs_set_cache_invalid
nfs_refresh_inode_locked
nfs_update_inode
nfsd write response contains change, ctime, mtime, the flag will be clear after nfs_update_inode. Howerver, write response does not contain space_used, previous open response contains space_used whose value is 0, so inode->i_blocks is still 0.
nfs_getattr -->called by "du -h"
do_update |= force_sync || nfs_attribute_cache_expired -->false in 60s cache_validity = READ_ONCE(NFS_I(inode)->cache_validity)
do_update |= cache_validity & (NFS_INO_INVALID_ATTR -->false
if (do_update) {
__nfs_revalidate_inode
}
Within 60s, does not send getattr request to nfsd, thus "du -h /mnt/file1M" is 0.
Add a NFS_INO_INVALID_BLOCKS flag, set it when nfsv4 write is done.
--- fs/nfs/inode.c | 14 +++++++++++--- include/linux/nfs_fs.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-)
fs/nfs/inode.c +11 -3
@@ -826,6 +826,8 @@ int nfs_getattr(const struct path *path, struct kstat *stat, do_update |= cache_validity &NFS_INO_INVALID_ATIME ;if (request_mask & (STATX_CTIME |STATX_MTIME )) do_update |= cache_validity &NFS_INO_REVAL_PAGECACHE ; +if (request_mask &STATX_BLOCKS ) + do_update |= cache_validity &NFS_INO_INVALID_BLOCKS ;if (do_update) {/* Update the attribute cache */ if (!(server->flags &NFS_MOUNT_NOAC ))
@@ -1750,7 +1752,8 @@ int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fa status =nfs_post_op_update_inode_locked (inode, fattr,NFS_INO_INVALID_CHANGE |NFS_INO_INVALID_CTIME - |NFS_INO_INVALID_MTIME ); + |NFS_INO_INVALID_MTIME + |NFS_INO_INVALID_BLOCKS );return status; }
@@ -1857,7 +1860,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ATIME |NFS_INO_REVAL_FORCED - |NFS_INO_REVAL_PAGECACHE ); + |NFS_INO_REVAL_PAGECACHE + |NFS_INO_INVALID_BLOCKS );/* Do atomic weak cache consistency updates */ nfs_wcc_update_inode (inode, fattr);
@@ -2019,8 +2023,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) inode->i_blocks =nfs_calc_block_size (fattr->du.nfs3.used); }else if (fattr->valid &NFS_ATTR_FATTR_BLOCKS_USED ) inode->i_blocks = fattr->du.nfs2.blocks; -else +else { + nfsi->cache_validity |= save_cache_validity & + (NFS_INO_INVALID_BLOCKS + |NFS_INO_REVAL_FORCED ); cache_revalidated = false; + }/* Update attrtimeo value if we're out of the unstable period */ if (attr_changed) {
include/linux/nfs_fs.h +1 -0
@@ -225,6 +225,7 @@ struct nfs4_copy_state {#define NFS_INO_INVALID_OTHER BIT(12)/* other attrs are invalid */ #define NFS_INO_DATA_INVAL_DEFER \ BIT(13)/* Deferred cache invalidation */ +#define NFS_INO_INVALID_BLOCKS BIT(14)/* cached blocks are invalid */ #define NFS_INO_INVALID_ATTR (NFS_INO_INVALID_CHANGE \ | NFS_INO_INVALID_CTIME \
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 264/266 xdp: Fix xsk_generic_xmit errno
In reply to Sasha LevinFrom: Li RongQing <[email protected]>
[ Upstream commit aa2cad0600ed2ca6a0ab39948d4db1666b6c962b ]
Propagate sock_alloc_send_skb error code, not set it to EAGAIN unconditionally, when fail to allocate skb, which might cause that user space unnecessary loops.
--- net/xdp/xsk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/xdp/xsk.c +1 -3
@@ -362,10 +362,8 @@ static int xsk_generic_xmit(struct sock *sk) len = desc.len; skb =sock_alloc_send_skb (sk, len,1 , &err); -if (unlikely (!skb)) { - err = -EAGAIN ; +if (unlikely (!skb)) goto out; - }skb_put (skb, len); addr = desc.addr;
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 265/266 iavf: fix speed reporting over virtchnl
In reply to Sasha LevinFrom: Brett Creeley <[email protected]>
[ Upstream commit e0ef26fbe2b0c62f42ba7667076dc38b693b6fb8 ]
Link speeds are communicated over virtchnl using an enum virtchnl_link_speed. Currently, the highest link speed is 40Gbps which leaves us unable to reflect some speeds that an ice VF is capable of. This causes link speed to be misreported on the iavf driver.
Allow for communicating link speeds using Mbps so that the proper speed can be reported for an ice VF. Moving away from the enum allows us to communicate future speed changes without requiring a new enum to be added.
In order to support communicating link speeds over virtchnl in Mbps the following functionality was added:
- Added u32 link_speed_mbps in the iavf_adapter structure.
- Added the macro ADV_LINK_SUPPORT(_a) to determine if the VF driver supports communicating link speeds in Mbps.
- Added the function iavf_get_vpe_link_status() to fill the correct link_status in the event_data union based on the ADV_LINK_SUPPORT(_a) macro.
- Added the function iavf_set_adapter_link_speed_from_vpe() to determine whether or not to fill the u32 link_speed_mbps or enum virtchnl_link_speed link_speed field in the iavf_adapter structure based on the ADV_LINK_SUPPORT(_a) macro.
- Do not free vf_res in iavf_init_get_resources() as vf_res will be accessed in iavf_get_link_ksettings(); memset to 0 instead. This memory is subsequently freed in iavf_remove().
--- drivers/net/ethernet/intel/iavf/iavf.h | 14 +++ .../net/ethernet/intel/iavf/iavf_ethtool.c | 14 ++- drivers/net/ethernet/intel/iavf/iavf_main.c | 25 ++++-- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 88 ++++++++++++++++--- 4 files changed, 120 insertions(+), 21 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +14 -0
@@ -87,6 +87,10 @@ struct iavf_vsi {#define IAVF_HLUT_ARRAY_SIZE ((IAVF_VFQF_HLUT_MAX_INDEX + 1) * 4)#define IAVF_MBPS_DIVISOR 125000/* divisor to convert to Mbps */ +#define IAVF_VIRTCHNL_VF_RESOURCE_SIZE (sizeof(struct virtchnl_vf_resource) + \ + (IAVF_MAX_VF_VSI * \ + sizeof(struct virtchnl_vsi_resource))) +/* MAX_MSIX_Q_VECTORS of these are allocated, * but we only use one per queue-specific vector. */
@@ -306,6 +310,14 @@ struct iavf_adapter {bool netdev_registered;bool link_up;enum virtchnl_link_speed link_speed; +/* This is only populated if the VIRTCHNL_VF_CAP_ADV_LINK_SPEED is set +* in vf_res->vf_cap_flags. Use ADV_LINK_SUPPORT macro to determine if +* this field is valid. This field should be used going forward and the +* enum virtchnl_link_speed above should be considered the legacy way of +* storing/communicating link speeds. +*/ +u32 link_speed_mbps; +enum virtchnl_ops current_op;#define CLIENT_ALLOWED (_a) ((_a)->vf_res ? \ (_a)->vf_res->vf_cap_flags & \
@@ -322,6 +334,8 @@ struct iavf_adapter { VIRTCHNL_VF_OFFLOAD_RSS_PF)))#define VLAN_ALLOWED (_a) ((_a)->vf_res->vf_cap_flags & \ VIRTCHNL_VF_OFFLOAD_VLAN) +#define ADV_LINK_SUPPORT (_a) ((_a)->vf_res->vf_cap_flags & \ + VIRTCHNL_VF_CAP_ADV_LINK_SPEED)struct virtchnl_vf_resource *vf_res;/* incl. all VSIs */ struct virtchnl_vsi_resource *vsi_res;/* our LAN VSI */ struct virtchnl_version_info pf_version;
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +12 -2
@@ -278,7 +278,18 @@ static int iavf_get_link_ksettings(struct net_device *netdev,ethtool_link_ksettings_zero_link_mode (cmd, supported); cmd->base.autoneg =AUTONEG_DISABLE ; cmd->base.port =PORT_NONE ; -/* Set speed and duplex */ + cmd->base.duplex =DUPLEX_FULL ; + +if (ADV_LINK_SUPPORT (adapter)) { +if (adapter->link_speed_mbps && + adapter->link_speed_mbps <U32_MAX ) + cmd->base.speed = adapter->link_speed_mbps; +else + cmd->base.speed =SPEED_UNKNOWN ; + +return 0 ; + } +switch (adapter->link_speed) {case IAVF_LINK_SPEED_40GB : cmd->base.speed =SPEED_40000 ;
@@ -306,7 +317,6 @@ static int iavf_get_link_ksettings(struct net_device *netdev,default :break ; } - cmd->base.duplex =DUPLEX_FULL ;return 0 ; }
drivers/net/ethernet/intel/iavf/iavf_main.c +18 -7
@@ -1756,17 +1756,17 @@ static int iavf_init_get_resources(struct iavf_adapter *adapter)struct net_device *netdev = adapter->netdev;struct pci_dev *pdev = adapter->pdev;struct iavf_hw *hw = &adapter->hw; -int err =0 , bufsz; +int err;WARN_ON (adapter->state != __IAVF_INIT_GET_RESOURCES);/* aq msg sent, awaiting reply */ if (!adapter->vf_res) { - bufsz =sizeof (struct virtchnl_vf_resource ) + - (IAVF_MAX_VF_VSI * -sizeof (struct virtchnl_vsi_resource )); - adapter->vf_res =kzalloc (bufsz,GFP_KERNEL ); -if (!adapter->vf_res) + adapter->vf_res =kzalloc (IAVF_VIRTCHNL_VF_RESOURCE_SIZE , +GFP_KERNEL ); +if (!adapter->vf_res) { + err = -ENOMEM ; goto err; + } } err =iavf_get_vf_config (adapter);if (err ==IAVF_ERR_ADMIN_QUEUE_NO_WORK ) {
@@ -2036,7 +2036,7 @@ static void iavf_disable_vf(struct iavf_adapter *adapter)iavf_reset_interrupt_capability (adapter);iavf_free_queues (adapter);iavf_free_q_vectors (adapter); -kfree (adapter->vf_res); +memset (adapter->vf_res,0 ,IAVF_VIRTCHNL_VF_RESOURCE_SIZE );iavf_shutdown_adminq (&adapter->hw); adapter->netdev->flags &= ~IFF_UP ;clear_bit (__IAVF_IN_CRITICAL_TASK, &adapter->crit_section);
@@ -2487,6 +2487,16 @@ static int iavf_validate_tx_bandwidth(struct iavf_adapter *adapter, {int speed =0 , ret =0 ; +if (ADV_LINK_SUPPORT (adapter)) { +if (adapter->link_speed_mbps <U32_MAX ) { + speed = adapter->link_speed_mbps; + goto validate_bw; + }else { +dev_err (&adapter->pdev->dev,"Unknown link speed\n" ); +return -EINVAL ; + } + } +switch (adapter->link_speed) {case IAVF_LINK_SPEED_40GB : speed =40000 ;
@@ -2510,6 +2520,7 @@ static int iavf_validate_tx_bandwidth(struct iavf_adapter *adapter,break ; } +validate_bw:if (max_tx_rate > speed) {dev_err (&adapter->pdev->dev,"Invalid tx rate specified\n" );
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +76 -12
138 lines not on this page · raw message
Signature · 1 line
2.25.1
Sasha Levin
maintainerPATCH 266/266 bpf: Fix memlock accounting for sock_hash
In reply to Sasha LevinFrom: Andrey Ignatov <[email protected]>
[ Upstream commit 60e5ca8a64bad8f3e2e20a1e57846e497361c700 ]
Add missed bpf_map_charge_init() in sock_hash_alloc() and correspondingly bpf_map_charge_finish() on ENOMEM.
It was found accidentally while working on unrelated selftest that checks "map->memory.pages > 0" is true for all map types.
Before:
# bpftool m l ... 3692: sockhash name m_sockhash flags 0x0 key 4B value 4B max_entries 8 memlock 0B
After:
# bpftool m l ... 84: sockmap name m_sockmap flags 0x0 key 4B value 4B max_entries 8 memlock 4096B
--- net/core/sock_map.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/sock_map.c +4 -0
@@ -837,11 +837,15 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr) err = -EINVAL ; goto free_htab; } + err =bpf_map_charge_init (&htab->map.memory, cost); +if (err) + goto free_htab; htab->buckets =bpf_map_area_alloc (htab->buckets_num *sizeof (struct bpf_htab_bucket ), htab->map.numa_node);if (!htab->buckets) { +bpf_map_charge_finish (&htab->map.memory); err = -ENOMEM ; goto free_htab; }
Signature · 1 line
2.25.1