6.1.110-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 161/192 userfaultfd: fix checks for huge PMDs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
[ Upstream commit 71c186efc1b2cf1aeabfeff3b9bd5ac4c5ac14d8 ]
Patch series "userfaultfd: fix races around pmd_trans_huge() check", v2.
The pmd_trans_huge() code in mfill_atomic() is wrong in three different ways depending on kernel version:
1. The pmd_trans_huge() check is racy and can lead to a BUG_ON() (if you hit the right two race windows) - I've tested this in a kernel build with some extra mdelay() calls. See the commit message for a description of the race scenario.
On older kernels (before 6.5), I think the same bug can even theoretically lead to accessing transhuge page contents as a page table if you hit the right 5 narrow race windows (I haven't tested this case).
2. As pointed out by Qi Zheng, pmd_trans_huge() is not sufficient for detecting PMDs that don't point to page tables.
On older kernels (before 6.5), you'd just have to win a single fairly wide race to hit this.
I've tested this on 6.1 stable by racing migration (with a mdelay() patched into try_to_migrate()) against UFFDIO_ZEROPAGE - on my x86 VM, that causes a kernel oops in ptlock_ptr().
3. On newer kernels (>=6.5), for shmem mappings, khugepaged is allowed to yank page tables out from under us (though I haven't tested that), so I think the BUG_ON() checks in mfill_atomic() are just wrong.
I decided to write two separate fixes for these (one fix for bugs 1+2, one fix for bug 3), so that the first fix can be backported to kernels affected by bugs 1+2.
This patch (of 2):
This fixes two issues.
I discovered that the following race can occur:
mfill_atomic other thread
============ ============
<zap PMD>
pmdp_get_lockless() [reads none pmd]
<bail if trans_huge>
<if none:>
<pagefault creates transhuge zeropage>
__pte_alloc [no-op]
<zap PMD>
<bail if pmd_trans_huge(*dst_pmd)> BUG_ON(pmd_none(*dst_pmd))
I have experimentally verified this in a kernel with extra mdelay() calls; the BUG_ON(pmd_none(*dst_pmd)) triggers.
On kernels newer than commit 0d940a9b270b ("mm/pgtable: allow pte_offset_map[_lock]() to fail"), this can't lead to anything worse than a BUG_ON(), since the page table access helpers are actually designed to deal with page tables concurrently disappearing; but on older kernels (<=6.4), I think we could probably theoretically race past the two BUG_ON() checks and end up treating a hugepage as a page table.
The second issue is that, as Qi Zheng pointed out, there are other types of huge PMDs that pmd_trans_huge() can't catch: devmap PMDs and swap PMDs (in particular, migration PMDs).
On <=6.4, this is worse than the first issue: If mfill_atomic() runs on a PMD that contains a migration entry (which just requires winning a single, fairly wide race), it will pass the PMD to pte_offset_map_lock(), which assumes that the PMD points to a page table.
Breakage follows: First, the kernel tries to take the PTE lock (which will crash or maybe worse if there is no "struct page" for the address bits in the migration entry PMD - I think at least on X86 there usually is no corresponding "struct page" thanks to the PTE inversion mitigation, amd64 looks different).
If that didn't crash, the kernel would next try to write a PTE into what it wrongly thinks is a page table.
As part of fixing these issues, get rid of the check for pmd_trans_huge() before __pte_alloc() - that's redundant, we're going to have to check for that after the __pte_alloc() anyway.
Backport note: pmdp_get_lockless() is pmd_read_atomic() in older kernels.
--- mm/userfaultfd.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
mm/userfaultfd.c +12 -10
@@ -642,21 +642,23 @@ static __always_inline ssize_t __mcopy_atomic(struct mm_struct *dst_mm, } dst_pmdval =pmdp_get_lockless (dst_pmd); -/* -* If the dst_pmd is mapped as THP don't -* override it and just be strict. -*/ -if (unlikely (pmd_trans_huge (dst_pmdval))) { - err = -EEXIST ; -break ; - }if (unlikely (pmd_none (dst_pmdval)) &&unlikely (__pte_alloc (dst_mm, dst_pmd))) { err = -ENOMEM ;break ; } -/* If an huge pmd materialized from under us fail */ -if (unlikely (pmd_trans_huge (*dst_pmd))) { + dst_pmdval =pmdp_get_lockless (dst_pmd); +/* +* If the dst_pmd is THP don't override it and just be strict. +* (This includes the case where the PMD used to be THP and +* changed back to none after __pte_alloc().) +*/ +if (unlikely (!pmd_present (dst_pmdval) ||pmd_trans_huge (dst_pmdval) || +pmd_devmap (dst_pmdval))) { + err = -EEXIST ; +break ; + } +if (unlikely (pmd_bad (dst_pmdval))) { err = -EFAULT ;break ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 162/192 net: mana: Fix error handling in mana_create_txq/rxqs NAPI cleanup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Souradeep Chakrabarti <[email protected]>
[ Upstream commit b6ecc662037694488bfff7c9fd21c405df8411f2 ]
Currently napi_disable() gets called during rxq and txq cleanup, even before napi is enabled and hrtimer is initialized. It causes kernel panic.
? page_fault_oops+0x136/0x2b0 ? page_counter_cancel+0x2e/0x80 ? do_user_addr_fault+0x2f2/0x640 ? refill_obj_stock+0xc4/0x110 ? exc_page_fault+0x71/0x160 ? asm_exc_page_fault+0x27/0x30 ? __mmdrop+0x10/0x180 ? __mmdrop+0xec/0x180 ? hrtimer_active+0xd/0x50 hrtimer_try_to_cancel+0x2c/0xf0 hrtimer_cancel+0x15/0x30 napi_disable+0x65/0x90 mana_destroy_rxq+0x4c/0x2f0 mana_create_rxq.isra.0+0x56c/0x6d0 ? mana_uncfg_vport+0x50/0x50 mana_alloc_queues+0x21b/0x320 ? skb_dequeue+0x5f/0x80
--- drivers/net/ethernet/microsoft/mana/mana.h | 2 ++ drivers/net/ethernet/microsoft/mana/mana_en.c | 22 +++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-)
drivers/net/ethernet/microsoft/mana/mana.h +2 -0
@@ -86,6 +86,8 @@ struct mana_txq {atomic_t pending_sends; +bool napi_initialized; +struct mana_stats_tx stats; };
drivers/net/ethernet/microsoft/mana/mana_en.c +13 -9
@@ -1391,10 +1391,12 @@ static void mana_destroy_txq(struct mana_port_context *apc)for (i =0 ; i < apc->num_queues; i++) { napi = &apc->tx_qp[i].tx_cq.napi; -napi_synchronize (napi); -napi_disable (napi); -netif_napi_del (napi); - +if (apc->tx_qp[i].txq.napi_initialized) { +napi_synchronize (napi); +napi_disable (napi); +netif_napi_del (napi); + apc->tx_qp[i].txq.napi_initialized = false; + }mana_destroy_wq_obj (apc,GDMA_SQ , apc->tx_qp[i].tx_object);mana_deinit_cq (apc, &apc->tx_qp[i].tx_cq);
@@ -1450,6 +1452,7 @@ static int mana_create_txq(struct mana_port_context *apc, txq->ndev = net; txq->net_txq =netdev_get_tx_queue (net, i); txq->vp_offset = apc->tx_vp_offset; + txq->napi_initialized = false;skb_queue_head_init (&txq->pending_skbs);memset (&spec,0 ,sizeof (spec));
@@ -1514,6 +1517,7 @@ static int mana_create_txq(struct mana_port_context *apc,netif_napi_add_tx (net, &cq->napi, mana_poll);napi_enable (&cq->napi); + txq->napi_initialized = true;mana_gd_ring_cq (cq->gdma_cq,SET_ARM_BIT ); }
@@ -1525,7 +1529,7 @@ static int mana_create_txq(struct mana_port_context *apc, }static void mana_destroy_rxq (struct mana_port_context *apc, -struct mana_rxq *rxq,bool validate_state) +struct mana_rxq *rxq,bool napi_initialized) {struct gdma_context *gc = apc->ac->gdma_dev->gdma_context;
@@ -1539,15 +1543,15 @@ static void mana_destroy_rxq(struct mana_port_context *apc, napi = &rxq->rx_cq.napi; -if (validate_state) +if (napi_initialized) {napi_synchronize (napi); -napi_disable (napi); +napi_disable (napi); +netif_napi_del (napi); + }xdp_rxq_info_unreg (&rxq->xdp_rxq); -netif_napi_del (napi); -mana_destroy_wq_obj (apc,GDMA_RQ , rxq->rxobj);mana_deinit_cq (apc, &rxq->rx_cq);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 163/192 workqueue: wq_watchdog_touch is always called with valid CPU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Piggin <[email protected]>
[ Upstream commit 18e24deb1cc92f2068ce7434a94233741fbd7771 ]
Warn in the case it is called with cpu == -1. This does not appear to happen anywhere.
--- kernel/workqueue.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/workqueue.c +2 -0
@@ -5893,6 +5893,8 @@ notrace void wq_watchdog_touch(int cpu) {if (cpu >=0 )per_cpu (wq_watchdog_touched_cpu, cpu) = jiffies; +else +WARN_ONCE (1 ,"%s should be called with valid CPU" , __func__); wq_watchdog_touched = jiffies; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 137/192 iio: buffer-dmaengine: fix releasing dma channel on error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lechner <[email protected]>
commit 84c65d8008764a8fb4e627ff02de01ec4245f2c4 upstream.
If dma_get_slave_caps() fails, we need to release the dma channel before returning an error to avoid leaking the channel.
--- drivers/iio/buffer/industrialio-buffer-dmaengine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/buffer/industrialio-buffer-dmaengine.c +3 -1
@@ -180,7 +180,7 @@ static struct iio_buffer *iio_dmaengine_ ret =dma_get_slave_caps (chan, &caps);if (ret <0 ) - goto err_free; + goto err_release;/* Needs to be aligned to the maximum of the minimums */ if (caps.src_addr_widths)
@@ -206,6 +206,8 @@ static struct iio_buffer *iio_dmaengine_return &dmaengine_buffer->queue.buffer; +err_release: +dma_release_channel (chan); err_free:kfree (dmaengine_buffer);return ERR_PTR (ret);
Greg Kroah-Hartman
maintainerPATCH 138/192 iio: fix scale application in iio_convert_raw_to_processed_unlocked
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matteo Martelli <[email protected]>
commit 8a3dcc970dc57b358c8db2702447bf0af4e0d83a upstream.
When the scale_type is IIO_VAL_INT_PLUS_MICRO or IIO_VAL_INT_PLUS_NANO the scale passed as argument is only applied to the fractional part of the value. Fix it by also multiplying the integer part by the scale provided.
--- drivers/iio/inkern.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/inkern.c +4 -4
@@ -679,17 +679,17 @@ static int iio_convert_raw_to_processed_break ;case IIO_VAL_INT_PLUS_MICRO :if (scale_val2 <0 ) - *processed = -raw64 * scale_val; + *processed = -raw64 * scale_val * scale;else - *processed = raw64 * scale_val; + *processed = raw64 * scale_val * scale; *processed +=div_s64 (raw64 * (s64 )scale_val2 * scale,1000000LL );break ;case IIO_VAL_INT_PLUS_NANO :if (scale_val2 <0 ) - *processed = -raw64 * scale_val; + *processed = -raw64 * scale_val * scale;else - *processed = raw64 * scale_val; + *processed = raw64 * scale_val * scale; *processed +=div_s64 (raw64 * (s64 )scale_val2 * scale,1000000000LL );break ;
Greg Kroah-Hartman
maintainerPATCH 139/192 iio: adc: ad7124: fix config comparison
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dumitru Ceclan <[email protected]>
commit 2f6b92d0f69f04d9e2ea0db1228ab7f82f3173af upstream.
The ad7124_find_similar_live_cfg() computes the compare size by substracting the address of the cfg struct from the address of the live field. Because the live field is the first field in the struct, the result is 0.
Also, the memcmp() call is made from the start of the cfg struct, which includes the live and cfg_slot fields, which are not relevant for the comparison.
Fix by grouping the relevant fields with struct_group() and use the size of the group to compute the compare size; make the memcmp() call from the address of the group.
--- drivers/iio/adc/ad7124.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/iio/adc/ad7124.c +15 -11
@@ -146,15 +146,18 @@ struct ad7124_chip_info {struct ad7124_channel_config {bool live;unsigned int cfg_slot; -enum ad7124_ref_sel refsel; -bool bipolar; -bool buf_positive; -bool buf_negative; -unsigned int vref_mv; -unsigned int pga_bits; -unsigned int odr; -unsigned int odr_sel_bits; -unsigned int filter_type; +/* Following fields are used to compare equality. */ + struct_group(config_props, + enum ad7124_ref_sel refsel; +bool bipolar; +bool buf_positive; +bool buf_negative; +unsigned int vref_mv; +unsigned int pga_bits; +unsigned int odr; +unsigned int odr_sel_bits; +unsigned int filter_type; + ); };struct ad7124_channel {
@@ -333,11 +336,12 @@ static struct ad7124_channel_config *ad7ptrdiff_t cmp_size;int i; - cmp_size = (u8 *)&cfg->live - (u8 *)cfg; + cmp_size = sizeof_field(struct ad7124_channel_config, config_props);for (i =0 ; i < st->num_channels; i++) { cfg_aux = &st->channels[i].cfg; -if (cfg_aux->live && !memcmp (cfg, cfg_aux, cmp_size)) +if (cfg_aux->live && + !memcmp (&cfg->config_props, &cfg_aux->config_props, cmp_size))return cfg_aux; }
Greg Kroah-Hartman
maintainerPATCH 140/192 iio: adc: ad7606: remove frstdata check for serial mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Stols <[email protected]>
commit 90826e08468ba7fb35d8b39645b22d9e80004afe upstream.
The current implementation attempts to recover from an eventual glitch in the clock by checking frstdata state after reading the first channel's sample: If frstdata is low, it will reset the chip and return -EIO.
This will only work in parallel mode, where frstdata pin is set low after the 2nd sample read starts.
For the serial mode, according to the datasheet, "The FRSTDATA output returns to a logic low following the 16th SCLK falling edge.", thus after the Xth pulse, X being the number of bits in a sample, the check will always be true, and the driver will not work at all in serial mode if frstdata(optional) is defined in the devicetree as it will reset the chip, and return -EIO every time read_sample is called.
Hence, this check must be removed for serial mode.
--- drivers/iio/adc/ad7606.c | 28 +------------------------ drivers/iio/adc/ad7606.h | 2 + drivers/iio/adc/ad7606_par.c | 48 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 29 deletions(-)
drivers/iio/adc/ad7606.c +2 -26
@@ -49,7 +49,7 @@ static const unsigned int ad7616_oversam 1, 2, 4, 8, 16, 32, 64, 128, }; -static int ad7606_reset (struct ad7606_state *st) +int ad7606_reset (struct ad7606_state *st) {if (st->gpio_reset) {gpiod_set_value (st->gpio_reset,1 );
@@ -60,6 +60,7 @@ static int ad7606_reset(struct ad7606_streturn -ENODEV ; } +EXPORT_SYMBOL_NS_GPL (ad7606_reset,IIO_AD7606 ); static int ad7606_reg_access(struct iio_dev *indio_dev, unsigned int reg,
@@ -88,31 +89,6 @@ static int ad7606_read_samples(struct ad {unsigned int num = st->chip_info->num_channels -1 ;u16 *data = st->data; -int ret; - -/* -* The frstdata signal is set to high while and after reading the sample -* of the first channel and low for all other channels. This can be used -* to check that the incoming data is correctly aligned. During normal -* operation the data should never become unaligned, but some glitch or -* electrostatic discharge might cause an extra read or clock cycle. -* Monitoring the frstdata signal allows to recover from such failure -* situations. -*/ - -if (st->gpio_frstdata) { - ret = st->bops->read_block (st->dev,1 , data); -if (ret) -return ret; - -if (!gpiod_get_value (st->gpio_frstdata)) { -ad7606_reset (st); -return -EIO ; - } - - data++; - num--; - }return st->bops->read_block (st->dev, num, data); }
drivers/iio/adc/ad7606.h +2 -0
@@ -153,6 +153,8 @@ int ad7606_probe(struct device *dev, int const char *name, unsigned int id, const struct ad7606_bus_ops *bops); +int ad7606_reset (struct ad7606_state *st); +enum ad7606_supported_device_ids {ID_AD7605_4 ,ID_AD7606_8 ,
drivers/iio/adc/ad7606_par.c +45 -3
67 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 141/192 iio: adc: ad7124: fix chip ID mismatch
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dumitru Ceclan <[email protected]>
commit 96f9ab0d5933c1c00142dd052f259fce0bc3ced2 upstream.
The ad7124_soft_reset() function has the assumption that the chip will assert the "power-on reset" bit in the STATUS register after a software reset without any delay. The POR bit =0 is used to check if the chip initialization is done.
A chip ID mismatch probe error appears intermittently when the probe continues too soon and the ID register does not contain the expected value.
Fix by adding a 200us delay after the software reset command is issued.
--- drivers/iio/adc/ad7124.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/adc/ad7124.c +1 -0
@@ -765,6 +765,7 @@ static int ad7124_soft_reset(struct ad71if (ret <0 )return ret; +fsleep (200 ); timeout =100 ; do { ret = ad_sd_read_reg(&st->sd, AD7124_STATUS, 1, &readval);
Greg Kroah-Hartman
maintainerPATCH 142/192 usb: dwc3: core: update LC timer as per USB Spec V3.2
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Faisal Hassan <[email protected]>
commit 9149c9b0c7e046273141e41eebd8a517416144ac upstream.
This fix addresses STAR 9001285599, which only affects DWC_usb3 version 3.20a. The timer value for PM_LC_TIMER in DWC_usb3 3.20a for the Link ECN changes is incorrect. If the PM TIMER ECN is enabled via GUCTL2[19], the link compliance test (TD7.21) may fail. If the ECN is not enabled (GUCTL2[19] = 0), the controller will use the old timer value (5us), which is still acceptable for the link compliance test. Therefore, clear GUCTL2[19] to pass the USB link compliance test: TD 7.21.
--- drivers/usb/dwc3/core.c | 15 +++++++++++++++ drivers/usb/dwc3/core.h | 2 ++ 2 files changed, 17 insertions(+)
drivers/usb/dwc3/core.c +15 -0
@@ -1306,6 +1306,21 @@ static int dwc3_core_init(struct dwc3 *d }/* +* STAR 9001285599: This issue affects DWC_usb3 version 3.20a +* only. If the PM TIMER ECM is enabled through GUCTL2[19], the +* link compliance test (TD7.21) may fail. If the ECN is not +* enabled (GUCTL2[19] = 0), the controller will use the old timer +* value (5us), which is still acceptable for the link compliance +* test. Therefore, do not enable PM TIMER ECM in 3.20a by +* setting GUCTL2[19] by default; instead, use GUCTL2[19] = 0. +*/ + if (DWC3_VER_IS(DWC3, 320A)) { + reg =dwc3_readl (dwc->regs,DWC3_GUCTL2 ); + reg &= ~DWC3_GUCTL2_LC_TIMER ; +dwc3_writel (dwc->regs,DWC3_GUCTL2 , reg); + } + +/* * When configured in HOST mode, after issuing U3/L2 exit controller * fails to send proper CRC checksum in CRC5 feild. Because of this * behaviour Transaction Error is generated, resulting in reset and
drivers/usb/dwc3/core.h +2 -0
@@ -404,6 +404,7 @@/* Global User Control Register 2 */ #define DWC3_GUCTL2_RST_ACTBITLATER BIT(14) +#define DWC3_GUCTL2_LC_TIMER BIT(19)/* Global User Control Register 3 */ #define DWC3_GUCTL3_SPLITDISABLE BIT(14)
@@ -1232,6 +1233,7 @@ struct dwc3 {#define DWC3_REVISION_290A 0x5533290a#define DWC3_REVISION_300A 0x5533300a#define DWC3_REVISION_310A 0x5533310a +#define DWC3_REVISION_320A 0x5533320a#define DWC3_REVISION_330A 0x5533330a#define DWC31_REVISION_ANY 0x0
Greg Kroah-Hartman
maintainerPATCH 143/192 binder: fix UAF caused by offsets overwrite
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Llamas <[email protected]>
commit 4df153652cc46545722879415937582028c18af5 upstream.
Binder objects are processed and copied individually into the target buffer during transactions. Any raw data in-between these objects is copied as well. However, this raw data copy lacks an out-of-bounds check. If the raw data exceeds the data section size then the copy overwrites the offsets section. This eventually triggers an error that attempts to unwind the processed objects. However, at this point the offsets used to index these objects are now corrupted.
Unwinding with corrupted offsets can result in decrements of arbitrary nodes and lead to their premature release. Other users of such nodes are left with a dangling pointer triggering a use-after-free. This issue is made evident by the following KASAN report (trimmed):
==================================================================
BUG: KASAN: slab-use-after-free in _raw_spin_lock+0xe4/0x19c Write of size 4 at addr ffff47fc91598f04 by task binder-util/743 CPU: 9 UID: 0 PID: 743 Comm: binder-util Not tainted 6.11.0-rc4 #1 Hardware name: linux,dummy-virt (DT) Call trace: _raw_spin_lock+0xe4/0x19c binder_free_buf+0x128/0x434 binder_thread_write+0x8a4/0x3260 binder_ioctl+0x18f0/0x258c [...] Allocated by task 743: __kmalloc_cache_noprof+0x110/0x270 binder_new_node+0x50/0x700 binder_transaction+0x413c/0x6da8 binder_thread_write+0x978/0x3260 binder_ioctl+0x18f0/0x258c [...] Freed by task 745: kfree+0xbc/0x208 binder_thread_read+0x1c5c/0x37d4 binder_ioctl+0x16d8/0x258c [...] ==================================================================
To avoid this issue, let's check that the raw data copy is within the boundaries of the data section.
--- drivers/android/binder.c | 1 + 1 file changed, 1 insertion(+)
drivers/android/binder.c +1 -0
@@ -3329,6 +3329,7 @@ static void binder_transaction(struct bi*/ copy_size = object_offset - user_offset; if (copy_size && (user_offset > object_offset || + object_offset > tr->data_size || binder_alloc_copy_user_to_buffer( &target_proc->alloc, t->buffer, user_offset,
Greg Kroah-Hartman
maintainerPATCH 134/192 io_uring/sqpoll: Do not set PF_NO_SETAFFINITY on sqpoll threads
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Koutný <[email protected]>
commit a5fc1441af7719e93dc7a638a960befb694ade89 upstream.
Users may specify a CPU where the sqpoll thread would run. This may conflict with cpuset operations because of strict PF_NO_SETAFFINITY requirement. That flag is unnecessary for polling "kernel" threads, see the reasoning in commit 01e68ce08a30 ("io_uring/io-wq: stop setting PF_NO_SETAFFINITY on io-wq workers"). Drop the flag on poll threads too.
--- io_uring/sqpoll.c | 1 - 1 file changed, 1 deletion(-)
io_uring/sqpoll.c +0 -1
@@ -233,7 +233,6 @@ static int io_sq_thread(void *data)set_cpus_allowed_ptr (current,cpumask_of (sqd->sq_cpu)); elseset_cpus_allowed_ptr (current ,cpu_online_mask ); - current->flags |=PF_NO_SETAFFINITY ;/* * Force audit context to get setup, in case we do prep side async
Greg Kroah-Hartman
maintainerPATCH 165/192 ACPI: processor: Return an error if acpi_processor_get_info() fails in processor_add()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Cameron <[email protected]>
[ Upstream commit fadf231f0a06a6748a7fc4a2c29ac9ef7bca6bfd ]
Rafael observed [1] that returning 0 from processor_add() will result in acpi_default_enumeration() being called which will attempt to create a platform device, but that makes little sense when the processor is known to be not available. So just return the error code from acpi_processor_get_info() instead.
--- drivers/acpi/acpi_processor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpi_processor.c +1 -1
@@ -373,7 +373,7 @@ static int acpi_processor_add(struct acpi_device *device, result =acpi_processor_get_info (device);if (result)/* Processor is not physically present or unavailable */ -return 0 ; +return result;BUG_ON (pr->id >= nr_cpu_ids);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 174/192 drm/amdgpu: handle gfx12 in amdgpu_display_verify_sizes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Olšák <[email protected]>
[ Upstream commit 8dd1426e2c80e32ac1995007330c8f95ffa28ebb ]
It verified GFX9-11 swizzle modes on GFX12, which has undefined behavior.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 27 ++++++++++++++++++++- include/uapi/drm/drm_fourcc.h | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +26 -1
@@ -997,6 +997,30 @@ static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb) block_width =256 / format_info->cpp[i]; block_height =1 ; block_size_log2 =8 ; + }else if (AMD_FMT_MOD_GET (TILE_VERSION , modifier) >=AMD_FMT_MOD_TILE_VER_GFX12 ) { +int swizzle =AMD_FMT_MOD_GET (TILE , modifier); + +switch (swizzle) { +case AMD_FMT_MOD_TILE_GFX12_256B_2D : + block_size_log2 =8 ; +break ; +case AMD_FMT_MOD_TILE_GFX12_4K_2D : + block_size_log2 =12 ; +break ; +case AMD_FMT_MOD_TILE_GFX12_64K_2D : + block_size_log2 =16 ; +break ; +case AMD_FMT_MOD_TILE_GFX12_256K_2D : + block_size_log2 =18 ; +break ; +default : +drm_dbg_kms (rfb->base.dev, +"Gfx12 swizzle mode with unknown block size: %d\n" , swizzle); +return -EINVAL ; + } + +get_block_dimensions (block_size_log2, format_info->cpp[i], + &block_width, &block_height); }else {int swizzle =AMD_FMT_MOD_GET (TILE , modifier);
@@ -1032,7 +1056,8 @@ static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb)return ret; } -if (AMD_FMT_MOD_GET (DCC , modifier)) { +if (AMD_FMT_MOD_GET (TILE_VERSION , modifier) <=AMD_FMT_MOD_TILE_VER_GFX11 && +AMD_FMT_MOD_GET (DCC , modifier)) {if (AMD_FMT_MOD_GET (DCC_RETILE , modifier)) { block_size_log2 =get_dcc_block_size (modifier, false, false); get_block_dimensions(block_size_log2 + 8, format_info->cpp[0],
include/uapi/drm/drm_fourcc.h +2 -0
@@ -1420,6 +1420,8 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)* 6 - 64KB_3D * 7 - 256KB_3D */ +#define AMD_FMT_MOD_TILE_GFX12_256B_2D 1 +#define AMD_FMT_MOD_TILE_GFX12_4K_2D 2#define AMD_FMT_MOD_TILE_GFX12_64K_2D 3#define AMD_FMT_MOD_TILE_GFX12_256K_2D 4
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 175/192 powerpc/64e: remove unused IBM HTW code
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
[ Upstream commit 88715b6e5d529f4ef3830ad2a893e4624c6af0b8 ]
Patch series "Reimplement huge pages without hugepd on powerpc (8xx, e500, book3s/64)", v7.
Unlike most architectures, powerpc 8xx HW requires a two-level pagetable topology for all page sizes. So a leaf PMD-contig approach is not feasible as such.
Possible sizes on 8xx are 4k, 16k, 512k and 8M.
First level (PGD/PMD) covers 4M per entry. For 8M pages, two PMD entries must point to a single entry level-2 page table. Until now that was done using hugepd. This series changes it to use standard page tables where the entry is replicated 1024 times on each of the two pagetables refered by the two associated PMD entries for that 8M page.
For e500 and book3s/64 there are less constraints because it is not tied to the HW assisted tablewalk like on 8xx, so it is easier to use leaf PMDs (and PUDs).
On e500 the supported page sizes are 4M, 16M, 64M, 256M and 1G. All at PMD level on e500/32 (mpc85xx) and mix of PMD and PUD for e500/64. We encode page size with 4 available bits in PTE entries. On e300/32 PGD entries size is increases to 64 bits in order to allow leaf-PMD entries because PTE are 64 bits on e500.
On book3s/64 only the hash-4k mode is concerned. It supports 16M pages as cont-PMD and 16G pages as cont-PUD. In other modes (radix-4k, radix-6k and hash-64k) the sizes match with PMD and PUD sizes so that's just leaf entries. The hash processing make things a bit more complex. To ease things, __hash_page_huge() is modified to bail out when DIRTY or ACCESSED bits are missing, leaving it to mm core to fix it.
This patch (of 23):
The nohash HTW_IBM (Hardware Table Walk) code is unused since support for A2 was removed in commit fb5a515704d7 ("powerpc: Remove platforms/ wsp and associated pieces") (2014).
The remaining supported CPUs use either no HTW (data_tlb_miss_bolted), or the e6500 HTW (data_tlb_miss_e6500).
Stable-dep-of: d92b5cc29c79 ("powerpc/64e: Define mmu_pte_psize static")
--- arch/powerpc/include/asm/nohash/mmu-e500.h | 3 +- arch/powerpc/mm/nohash/tlb.c | 57 +----- arch/powerpc/mm/nohash/tlb_low_64e.S | 195 --------------------- 3 files changed, 2 insertions(+), 253 deletions(-)
arch/powerpc/include/asm/nohash/mmu-e500.h +1 -2
@@ -303,8 +303,7 @@ extern unsigned long linear_map_top;extern int book3e_htw_mode;#define PPC_HTW_NONE 0 -#define PPC_HTW_IBM 1 -#define PPC_HTW_E6500 2 +#define PPC_HTW_E6500 1/* * 64-bit booke platforms don't load the tlb in the tlb miss handler code.
arch/powerpc/mm/nohash/tlb.c +1 -56
82 lines not on this page · raw message
arch/powerpc/mm/nohash/tlb_low_64e.S +0 -195
201 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 176/192 powerpc/64e: split out nohash Book3E 64-bit code
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
[ Upstream commit a898530eea3d0ba08c17a60865995a3bb468d1bc ]
A reasonable chunk of nohash/tlb.c is 64-bit only code, split it out into a separate file.
Stable-dep-of: d92b5cc29c79 ("powerpc/64e: Define mmu_pte_psize static")
--- arch/powerpc/mm/nohash/Makefile | 2 +- arch/powerpc/mm/nohash/tlb.c | 343 +---------------------------- arch/powerpc/mm/nohash/tlb_64e.c | 361 +++++++++++++++++++++++++++++++ 3 files changed, 363 insertions(+), 343 deletions(-) create mode 100644 arch/powerpc/mm/nohash/tlb_64e.c
arch/powerpc/mm/nohash/Makefile +1 -1
@@ -3,7 +3,7 @@ ccflags-$(CONFIG_PPC64) := $(NO_MINIMAL_TOC) obj-y += mmu_context.o tlb.o tlb_low.o kup.o -obj-$(CONFIG_PPC_BOOK3E_64) += tlb_low_64e.o book3e_pgtable.o +obj-$(CONFIG_PPC_BOOK3E_64) += tlb_64e.o tlb_low_64e.o book3e_pgtable.o obj-$(CONFIG_40x) += 40x.o obj-$(CONFIG_44x) += 44x.o obj-$(CONFIG_PPC_8xx) += 8xx.o
arch/powerpc/mm/nohash/tlb.c +1 -342
355 lines not on this page · raw message
arch/powerpc/mm/nohash/tlb_64e.c new file +361 -0
361 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 177/192 powerpc/64e: Define mmu_pte_psize static
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit d92b5cc29c792f1d3f0aaa3b29dddfe816c03e88 ]
mmu_pte_psize is only used in the tlb_64e.c, define it static.
--- arch/powerpc/mm/nohash/tlb_64e.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/mm/nohash/tlb_64e.c +1 -1
@@ -33,7 +33,7 @@* though this will probably be made common with other nohash * implementations at some point */ -int mmu_pte_psize;/* Page size used for PTE pages */ +static int mmu_pte_psize;/* Page size used for PTE pages */ int mmu_vmemmap_psize;/* Page size used for the virtual mem map */ int book3e_htw_mode;/* HW tablewalk? Value is PPC_HTW_* */ unsigned long linear_map_top;/* Top of linear mapping */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 178/192 ASoC: tegra: Fix CBB error during probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohan Kumar <[email protected]>
[ Upstream commit 6781b962d97bc52715a8db8cc17278cc3c23ebe8 ]
When Tegra audio drivers are built as part of the kernel image, TIMEOUT_ERR is observed from cbb-fabric. Following is seen on Jetson AGX Orin during boot:
[ 8.012482] ************************************** [ 8.017423] CPU:0, Error:cbb-fabric, Errmon:2 [ 8.021922] Error Code : TIMEOUT_ERR [ 8.025966] Overflow : Multiple TIMEOUT_ERR [ 8.030644] [ 8.032175] Error Code : TIMEOUT_ERR [ 8.036217] MASTER_ID : CCPLEX [ 8.039722] Address : 0x290a0a8 [ 8.043318] Cache : 0x1 -- Bufferable [ 8.047630] Protection : 0x2 -- Unprivileged, Non-Secure, Data Access [ 8.054628] Access_Type : Write
[ 8.106130] WARNING: CPU: 0 PID: 124 at drivers/soc/tegra/cbb/tegra234-cbb.c:604 tegra234_cbb_isr+0x134/0x178
[ 8.240602] Call trace: [ 8.243126] tegra234_cbb_isr+0x134/0x178 [ 8.247261] __handle_irq_event_percpu+0x60/0x238 [ 8.252132] handle_irq_event+0x54/0xb8
These errors happen when MVC device, which is a child of AHUB device, tries to access its device registers. This happens as part of call tegra210_mvc_reset_vol_settings() in MVC device probe().
The root cause of this problem is, the child MVC device gets probed before the AHUB clock gets enabled. The AHUB clock is enabled in runtime PM resume of parent AHUB device and due to the wrong sequence of pm_runtime_enable() in AHUB driver, runtime PM resume doesn't happen for AHUB device when MVC makes register access.
Fix this by calling pm_runtime_enable() for parent AHUB device before of_platform_populate() in AHUB driver. This ensures that clock becomes available when MVC makes register access.
--- sound/soc/tegra/tegra210_ahub.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
sound/soc/tegra/tegra210_ahub.c +6 -4
@@ -2,7 +2,7 @@// // tegra210_ahub.c - Tegra210 AHUB driver // -// Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2020-2024, NVIDIA CORPORATION. All rights reserved. #include <linux/clk.h> #include <linux/device.h>
@@ -1401,11 +1401,13 @@ static int tegra_ahub_probe(struct platform_device *pdev)return err; } +pm_runtime_enable (&pdev->dev); + err =of_platform_populate (pdev->dev.of_node,NULL ,NULL , &pdev->dev); -if (err) +if (err) { +pm_runtime_disable (&pdev->dev);return err; - -pm_runtime_enable (&pdev->dev); + }return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 179/192 nvmet-tcp: fix kernel crash if commands allocation fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maurizio Lombardi <[email protected]>
[ Upstream commit 5572a55a6f830ee3f3a994b6b962a5c327d28cb3 ]
If the commands allocation fails in nvmet_tcp_alloc_cmds() the kernel crashes in nvmet_tcp_release_queue_work() because of a NULL pointer dereference.
nvmet: failed to install queue 0 cntlid 1 ret 6
Unable to handle kernel NULL pointer dereference at
virtual address 0000000000000008Fix the bug by setting queue->nr_cmds to zero in case nvmet_tcp_alloc_cmd() fails.
--- drivers/nvme/target/tcp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/tcp.c +3 -1
@@ -1816,8 +1816,10 @@ static u16 nvmet_tcp_install_queue(struct nvmet_sq *sq) } queue->nr_cmds = sq->size *2 ; -if (nvmet_tcp_alloc_cmds (queue)) +if (nvmet_tcp_alloc_cmds (queue)) { + queue->nr_cmds =0 ;return NVME_SC_INTERNAL ; + }return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 180/192 ASoc: SOF: topology: Clear SOF link platform name upon unload
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit e0be875c5bf03a9676a6bfed9e0f1766922a7dbd ]
The SOF topology loading function sets the device name for the platform component link. This should be unset when unloading the topology, otherwise a machine driver unbind/bind or reprobe would complain about an invalid component as having both its component name and of_node set:
mt8186_mt6366 sound: ASoC: Both Component name/of_node are set for AFE_SOF_DL1 mt8186_mt6366 sound: error -EINVAL: Cannot register card mt8186_mt6366 sound: probe with driver mt8186_mt6366 failed with error -22
This happens with machine drivers that set the of_node separately.
Clear the SOF link platform name in the topology unload callback.
--- sound/soc/sof/topology.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/sof/topology.c +2 -0
@@ -1817,6 +1817,8 @@ static int sof_link_unload(struct snd_soc_component *scomp, struct snd_soc_dobjif (!slink)return 0 ; + slink->link->platforms->name =NULL ; +kfree (slink->tuples);list_del (&slink->list);kfree (slink->hw_configs);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 181/192 ASoC: sunxi: sun4i-i2s: fix LRCLK polarity in i2s mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matteo Martelli <[email protected]>
[ Upstream commit 3e83957e8dd7433a69116780d9bad217b00913ea ]
This fixes the LRCLK polarity for sun8i-h3 and sun50i-h6 in i2s mode which was wrongly inverted.
The LRCLK was being set in reversed logic compared to the DAI format:
inverted LRCLK for SND_SOC_DAIFMT_IB_NF and SND_SOC_DAIFMT_NB_NF; normal LRCLK for SND_SOC_DAIFMT_IB_IF and SND_SOC_DAIFMT_NB_IF. Such reversed logic applies properly for DSP_A, DSP_B, LEFT_J and RIGHT_J modes but not for I2S mode, for which the LRCLK signal results reversed to what expected on the bus. The issue is due to a misinterpretation of the LRCLK polarity bit of the H3 and H6 i2s controllers. Such bit in this case does not mean "0 => normal" or "1 => inverted" according to the expected bus operation, but it means "0 => frame starts on low edge" and "1 => frame starts on high edge" (from the User Manuals).
This commit fixes the LRCLK polarity by setting the LRCLK polarity bit according to the selected bus mode and renames the LRCLK polarity bit definition to avoid further confusion.
--- sound/soc/sunxi/sun4i-i2s.c | 143 ++++++++++++++++++------------------ 1 file changed, 73 insertions(+), 70 deletions(-)
sound/soc/sunxi/sun4i-i2s.c +73 -70
@@ -100,8 +100,8 @@#define SUN8I_I2S_CTRL_MODE_PCM (0 << 4)#define SUN8I_I2S_FMT0_LRCLK_POLARITY_MASK BIT(19) -#define SUN8I_I2S_FMT0_LRCLK_POLARITY_INVERTED (1 << 19) -#define SUN8I_I2S_FMT0_LRCLK_POLARITY_NORMAL (0 << 19) +#define SUN8I_I2S_FMT0_LRCLK_POLARITY_START_HIGH (1 << 19) +#define SUN8I_I2S_FMT0_LRCLK_POLARITY_START_LOW (0 << 19)#define SUN8I_I2S_FMT0_LRCK_PERIOD_MASK GENMASK(17, 8)#define SUN8I_I2S_FMT0_LRCK_PERIOD (period) ((period - 1) << 8)#define SUN8I_I2S_FMT0_BCLK_POLARITY_MASK BIT(7)
@@ -727,65 +727,37 @@ static int sun4i_i2s_set_soc_fmt(const struct sun4i_i2s *i2s,static int sun8i_i2s_set_soc_fmt (const struct sun4i_i2s *i2s,unsigned int fmt) { -u32 mode, val; +u32 mode, lrclk_pol, bclk_pol, val;u8 offset; -/* -* DAI clock polarity -* -* The setup for LRCK contradicts the datasheet, but under a -* scope it's clear that the LRCK polarity is reversed -* compared to the expected polarity on the bus. -*/ -switch (fmt &SND_SOC_DAIFMT_INV_MASK ) { -case SND_SOC_DAIFMT_IB_IF : -/* Invert both clocks */ - val =SUN8I_I2S_FMT0_BCLK_POLARITY_INVERTED ; -break ; -case SND_SOC_DAIFMT_IB_NF : -/* Invert bit clock */ - val =SUN8I_I2S_FMT0_BCLK_POLARITY_INVERTED | -SUN8I_I2S_FMT0_LRCLK_POLARITY_INVERTED ; -break ; -case SND_SOC_DAIFMT_NB_IF : -/* Invert frame clock */ - val =0 ; -break ; -case SND_SOC_DAIFMT_NB_NF : - val =SUN8I_I2S_FMT0_LRCLK_POLARITY_INVERTED ; -break ; -default : -return -EINVAL ; - } - -regmap_update_bits (i2s->regmap,SUN4I_I2S_FMT0_REG , -SUN8I_I2S_FMT0_LRCLK_POLARITY_MASK | -SUN8I_I2S_FMT0_BCLK_POLARITY_MASK , - val); -/* DAI Mode */ switch (fmt &SND_SOC_DAIFMT_FORMAT_MASK ) {case SND_SOC_DAIFMT_DSP_A : + lrclk_pol =SUN8I_I2S_FMT0_LRCLK_POLARITY_START_HIGH ; mode =SUN8I_I2S_CTRL_MODE_PCM ; offset =1 ;break ;case SND_SOC_DAIFMT_DSP_B : + lrclk_pol =SUN8I_I2S_FMT0_LRCLK_POLARITY_START_HIGH ; mode =SUN8I_I2S_CTRL_MODE_PCM ; offset =0 ;break ;case SND_SOC_DAIFMT_I2S : + lrclk_pol =SUN8I_I2S_FMT0_LRCLK_POLARITY_START_LOW ; mode =SUN8I_I2S_CTRL_MODE_LEFT ; offset =1 ;break ;case SND_SOC_DAIFMT_LEFT_J : + lrclk_pol =SUN8I_I2S_FMT0_LRCLK_POLARITY_START_HIGH ; mode =SUN8I_I2S_CTRL_MODE_LEFT ; offset =0 ;break ;case SND_SOC_DAIFMT_RIGHT_J : + lrclk_pol =SUN8I_I2S_FMT0_LRCLK_POLARITY_START_HIGH ; mode =SUN8I_I2S_CTRL_MODE_RIGHT ; offset =0 ;break ;
@@ -803,6 +775,35 @@ static int sun8i_i2s_set_soc_fmt(const struct sun4i_i2s *i2s,SUN8I_I2S_TX_CHAN_OFFSET_MASK , SUN8I_I2S_TX_CHAN_OFFSET(offset)); +/* DAI clock polarity */ + bclk_pol =SUN8I_I2S_FMT0_BCLK_POLARITY_NORMAL ; + +switch (fmt &SND_SOC_DAIFMT_INV_MASK ) { +case SND_SOC_DAIFMT_IB_IF : +/* Invert both clocks */ + lrclk_pol ^=SUN8I_I2S_FMT0_LRCLK_POLARITY_MASK ; + bclk_pol =SUN8I_I2S_FMT0_BCLK_POLARITY_INVERTED ; +break ; +case SND_SOC_DAIFMT_IB_NF : +/* Invert bit clock */ + bclk_pol =SUN8I_I2S_FMT0_BCLK_POLARITY_INVERTED ; +break ; +case SND_SOC_DAIFMT_NB_IF : +/* Invert frame clock */ + lrclk_pol ^=SUN8I_I2S_FMT0_LRCLK_POLARITY_MASK ; +break ; +case SND_SOC_DAIFMT_NB_NF : +/* No inversion */ +break ; +default : +return -EINVAL ; + } + +regmap_update_bits (i2s->regmap,SUN4I_I2S_FMT0_REG , +SUN8I_I2S_FMT0_LRCLK_POLARITY_MASK | +SUN8I_I2S_FMT0_BCLK_POLARITY_MASK , + lrclk_pol | bclk_pol); +/* DAI clock master masks */ switch (fmt &SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK ) {case SND_SOC_DAIFMT_BP_FP :
@@ -834,65 +835,37 @@ static int sun8i_i2s_set_soc_fmt(const struct sun4i_i2s *i2s,static int sun50i_h6_i2s_set_soc_fmt (const struct sun4i_i2s *i2s,unsigned int fmt) { -u32 mode, val; +u32 mode, lrclk_pol, bclk_pol, val;u8 offset; -/* -* DAI clock polarity -* -* The setup for LRCK contradicts the datasheet, but under a -* scope it's clear that the LRCK polarity is reversed -* compared to the expected polarity on the bus. -*/ -switch (fmt &SND_SOC_DAIFMT_INV_MASK ) { -case SND_SOC_DAIFMT_IB_IF : -/* Invert both clocks */ - val =SUN8I_I2S_FMT0_BCLK_POLARITY_INVERTED ; -break ; -case SND_SOC_DAIFMT_IB_NF : -/* Invert bit clock */ - val =SUN8I_I2S_FMT0_BCLK_POLARITY_INVERTED | -SUN8I_I2S_FMT0_LRCLK_POLARITY_INVERTED ; -break ; -case SND_SOC_DAIFMT_NB_IF : -/* Invert frame clock */ - val =0 ; -break ; -case SND_SOC_DAIFMT_NB_NF : - val =SUN8I_I2S_FMT0_LRCLK_POLARITY_INVERTED ; -break ; -default : -return -EINVAL ; - } - -regmap_update_bits (i2s->regmap,SUN4I_I2S_FMT0_REG , -SUN8I_I2S_FMT0_LRCLK_POLARITY_MASK | -SUN8I_I2S_FMT0_BCLK_POLARITY_MASK , - val); -/* DAI Mode */ switch (fmt &SND_SOC_DAIFMT_FORMAT_MASK ) {case SND_SOC_DAIFMT_DSP_A : + lrclk_pol =SUN8I_I2S_FMT0_LRCLK_POLARITY_START_HIGH ; mode =SUN8I_I2S_CTRL_MODE_PCM ; offset =1 ;break ;case SND_SOC_DAIFMT_DSP_B : + lrclk_pol =SUN8I_I2S_FMT0_LRCLK_POLARITY_START_HIGH ; mode =SUN8I_I2S_CTRL_MODE_PCM ; offset =0 ;break ;case SND_SOC_DAIFMT_I2S : + lrclk_pol =SUN8I_I2S_FMT0_LRCLK_POLARITY_START_LOW ; mode =SUN8I_I2S_CTRL_MODE_LEFT ; offset =1 ;break ;case SND_SOC_DAIFMT_LEFT_J : + lrclk_pol =SUN8I_I2S_FMT0_LRCLK_POLARITY_START_HIGH ; mode =SUN8I_I2S_CTRL_MODE_LEFT ; offset =0 ;break ;case SND_SOC_DAIFMT_RIGHT_J : + lrclk_pol =SUN8I_I2S_FMT0_LRCLK_POLARITY_START_HIGH ; mode =SUN8I_I2S_CTRL_MODE_RIGHT ; offset =0 ;break ;
@@ -910,6 +883,36 @@ static int sun50i_h6_i2s_set_soc_fmt(const struct sun4i_i2s *i2s,SUN50I_H6_I2S_TX_CHAN_SEL_OFFSET_MASK , SUN50I_H6_I2S_TX_CHAN_SEL_OFFSET(offset)); +/* DAI clock polarity */ + bclk_pol =SUN8I_I2S_FMT0_BCLK_POLARITY_NORMAL ; + +switch (fmt &SND_SOC_DAIFMT_INV_MASK ) { +case SND_SOC_DAIFMT_IB_IF : +/* Invert both clocks */ + lrclk_pol ^=SUN8I_I2S_FMT0_LRCLK_POLARITY_MASK ; + bclk_pol =SUN8I_I2S_FMT0_BCLK_POLARITY_INVERTED ; +break ; +case SND_SOC_DAIFMT_IB_NF : +/* Invert bit clock */ + bclk_pol =SUN8I_I2S_FMT0_BCLK_POLARITY_INVERTED ; +break ; +case SND_SOC_DAIFMT_NB_IF : +/* Invert frame clock */ + lrclk_pol ^=SUN8I_I2S_FMT0_LRCLK_POLARITY_MASK ; +break ; +case SND_SOC_DAIFMT_NB_NF : +/* No inversion */ +break ; +default : +return -EINVAL ; + } + +regmap_update_bits (i2s->regmap,SUN4I_I2S_FMT0_REG , +SUN8I_I2S_FMT0_LRCLK_POLARITY_MASK | +SUN8I_I2S_FMT0_BCLK_POLARITY_MASK , + lrclk_pol | bclk_pol); + +/* DAI clock master masks */ switch (fmt &SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK ) {case SND_SOC_DAIFMT_BP_FP :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 182/192 drm/i915/fence: Mark debug_fence_init_onstack() with __maybe_unused
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit fcd9e8afd546f6ced378d078345a89bf346d065e ]
When debug_fence_init_onstack() is unused (CONFIG_DRM_I915_SELFTEST=n), it prevents kernel builds with clang, make W=1 and CONFIG_WERROR=y:
.../i915_sw_fence.c:97:20: error: unused function 'debug_fence_init_onstack' [-Werror,-Wunused-function]
97 | static inline void debug_fence_init_onstack(struct i915_sw_fence *fence)
| ^~~~~~~~~~~~~~~~~~~~~~~~
Fix this by marking debug_fence_init_onstack() with __maybe_unused.
See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static inline functions for W=1 build").
--- drivers/gpu/drm/i915/i915_sw_fence.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_sw_fence.c +2 -2
@@ -51,7 +51,7 @@ static inline void debug_fence_init(struct i915_sw_fence *fence)debug_object_init (fence, &i915_sw_fence_debug_descr); } -static inline void debug_fence_init_onstack (struct i915_sw_fence *fence) +static inline __maybe_unused void debug_fence_init_onstack (struct i915_sw_fence *fence) {debug_object_init_on_stack (fence, &i915_sw_fence_debug_descr); }
@@ -94,7 +94,7 @@ static inline void debug_fence_init(struct i915_sw_fence *fence) { } -static inline void debug_fence_init_onstack (struct i915_sw_fence *fence) +static inline __maybe_unused void debug_fence_init_onstack (struct i915_sw_fence *fence) { }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 183/192 drm/i915/fence: Mark debug_fence_free() with __maybe_unused
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit f99999536128b14b5d765a9982763b5134efdd79 ]
When debug_fence_free() is unused (CONFIG_DRM_I915_SW_FENCE_DEBUG_OBJECTS=n), it prevents kernel builds with clang, make W=1 and CONFIG_WERROR=y:
.../i915_sw_fence.c:118:20: error: unused function 'debug_fence_free' [-Werror,-Wunused-function]
118 | static inline void debug_fence_free(struct i915_sw_fence *fence)
| ^~~~~~~~~~~~~~~~
Fix this by marking debug_fence_free() with __maybe_unused.
See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static inline functions for W=1 build").
--- drivers/gpu/drm/i915/i915_sw_fence.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_sw_fence.c +2 -2
@@ -77,7 +77,7 @@ static inline void debug_fence_destroy(struct i915_sw_fence *fence)debug_object_destroy (fence, &i915_sw_fence_debug_descr); } -static inline void debug_fence_free (struct i915_sw_fence *fence) +static inline __maybe_unused void debug_fence_free (struct i915_sw_fence *fence) {debug_object_free (fence, &i915_sw_fence_debug_descr);smp_wmb ();/* flush the change in state before reallocation */
@@ -115,7 +115,7 @@ static inline void debug_fence_destroy(struct i915_sw_fence *fence) { } -static inline void debug_fence_free (struct i915_sw_fence *fence) +static inline __maybe_unused void debug_fence_free (struct i915_sw_fence *fence) { }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 166/192 ACPI: processor: Fix memory leaks in error paths of processor_add()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Cameron <[email protected]>
[ Upstream commit 47ec9b417ed9b6b8ec2a941cd84d9de62adc358a ]
If acpi_processor_get_info() returned an error, pr and the associated pr->throttling.shared_cpu_map were leaked.
The unwind code was in the wrong order wrt to setup, relying on some unwind actions having no affect (clearing variables that were never set etc). That makes it harder to reason about so reorder and add appropriate labels to only undo what was actually set up in the first place.
--- drivers/acpi/acpi_processor.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/acpi/acpi_processor.c +8 -7
@@ -373,7 +373,7 @@ static int acpi_processor_add(struct acpi_device *device, result =acpi_processor_get_info (device);if (result)/* Processor is not physically present or unavailable */ -return result; + goto err_clear_driver_data;BUG_ON (pr->id >= nr_cpu_ids);
@@ -388,7 +388,7 @@ static int acpi_processor_add(struct acpi_device *device,"BIOS reported wrong ACPI id %d for the processor\n" , pr->id);/* Give up, but do not abort the namespace scan. */ - goto err; + goto err_clear_driver_data; }/* * processor_device_array is not cleared on errors to allow buggy BIOS
@@ -400,12 +400,12 @@ static int acpi_processor_add(struct acpi_device *device, dev =get_cpu_device (pr->id);if (!dev) { result = -ENODEV ; - goto err; + goto err_clear_per_cpu; } result =acpi_bind_one (dev, device);if (result) - goto err; + goto err_clear_per_cpu; pr->dev = dev;
@@ -416,10 +416,11 @@ static int acpi_processor_add(struct acpi_device *device,dev_err (dev,"Processor driver could not be attached\n" );acpi_unbind_one (dev); - err: -free_cpumask_var (pr->throttling.shared_cpu_map); - device->driver_data =NULL ; + err_clear_per_cpu:per_cpu (processors, pr->id) =NULL ; + err_clear_driver_data: + device->driver_data =NULL ; +free_cpumask_var (pr->throttling.shared_cpu_map); err_free_pr:kfree (pr);return result;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 184/192 gpio: rockchip: fix OF node leak in probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit adad2e460e505a556f5ea6f0dc16fe95e62d5d76 ]
Driver code is leaking OF node reference from of_get_parent() in probe().
--- drivers/gpio/gpio-rockchip.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-rockchip.c +1 -0
@@ -713,6 +713,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)return -ENODEV ; pctldev =of_pinctrl_get (pctlnp); +of_node_put (pctlnp);if (!pctldev)return -EPROBE_DEFER ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 185/192 gpio: modepin: Enable module autoloading
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liao Chen <[email protected]>
[ Upstream commit a5135526426df5319d5f4bcd15ae57c45a97714b ]
Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded based on the alias from of_device_id table.
--- drivers/gpio/gpio-zynqmp-modepin.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-zynqmp-modepin.c +1 -0
@@ -146,6 +146,7 @@ static const struct of_device_id modepin_platform_id[] = { { .compatible = "xlnx,zynqmp-gpio-modepin", }, { } }; +MODULE_DEVICE_TABLE (of, modepin_platform_id);static struct platform_driver modepin_platform_driver = { .driver = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 186/192 ublk_drv: fix NULL pointer dereference in ublk_ctrl_start_recovery()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Nan <[email protected]>
[ Upstream commit e58f5142f88320a5b1449f96a146f2f24615c5c7 ]
When two UBLK_CMD_START_USER_RECOVERY commands are submitted, the first one sets 'ubq->ubq_daemon' to NULL, and the second one triggers WARN in ublk_queue_reinit() and subsequently a NULL pointer dereference issue.
Fix it by adding the check in ublk_ctrl_start_recovery() and return immediately in case of zero 'ub->nr_queues_ready'.
BUG: kernel NULL pointer dereference, address: 0000000000000028 RIP: 0010:ublk_ctrl_start_recovery.constprop.0+0x82/0x180 Call Trace: <TASK> ? __die+0x20/0x70 ? page_fault_oops+0x75/0x170 ? exc_page_fault+0x64/0x140 ? asm_exc_page_fault+0x22/0x30 ? ublk_ctrl_start_recovery.constprop.0+0x82/0x180 ublk_ctrl_uring_cmd+0x4f7/0x6c0 ? pick_next_task_idle+0x26/0x40 io_uring_cmd+0x9a/0x1b0 io_issue_sqe+0x193/0x3f0 io_wq_submit_work+0x9b/0x390 io_worker_handle_work+0x165/0x360 io_wq_worker+0xcb/0x2f0 ? finish_task_switch.isra.0+0x203/0x290 ? finish_task_switch.isra.0+0x203/0x290 ? __pfx_io_wq_worker+0x10/0x10 ret_from_fork+0x2d/0x50 ? __pfx_io_wq_worker+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK>
--- drivers/block/ublk_drv.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/block/ublk_drv.c +2 -0
@@ -1915,6 +1915,8 @@ static int ublk_ctrl_start_recovery(struct ublk_device *ub,mutex_lock (&ub->mutex);if (!ublk_can_use_recovery (ub)) goto out_unlock; +if (!ub->nr_queues_ready) + goto out_unlock;/* * START_RECOVERY is only allowd after: *
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 187/192 x86/mm: Fix PTI for i386 some more
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit c48b5a4cf3125adb679e28ef093f66ff81368d05 upstream.
So it turns out that we have to do two passes of pti_clone_entry_text(), once before initcalls, such that device and late initcalls can use user-mode-helper / modprobe and once after free_initmem() / mark_readonly().
Now obviously mark_readonly() can cause PMD splits, and pti_clone_pgtable() doesn't like that much.
Allow the late clone to split PMDs so that pagetables stay in sync.
--- arch/x86/mm/pti.c | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-)
arch/x86/mm/pti.c +29 -16
@@ -241,7 +241,7 @@ static pmd_t *pti_user_pagetable_walk_pm* * Returns a pointer to a PTE on success, or NULL on failure. */ -static pte_t *pti_user_pagetable_walk_pte (unsigned long address) +static pte_t *pti_user_pagetable_walk_pte (unsigned long address,bool late_text) {gfp_t gfp = (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO);pmd_t *pmd;
@@ -251,10 +251,15 @@ static pte_t *pti_user_pagetable_walk_ptif (!pmd)return NULL ; -/* We can't do anything sensible if we hit a large mapping. */ +/* Large PMD mapping found */ if (pmd_large (*pmd)) { -WARN_ON (1 ); -return NULL ; +/* Clear the PMD if we hit a large mapping from the first round */ +if (late_text) { +set_pmd (pmd,__pmd (0 )); + }else { +WARN_ON_ONCE (1 ); +return NULL ; + } }if (pmd_none (*pmd)) {
@@ -283,7 +288,7 @@ static void __init pti_setup_vsyscall(voif (!pte ||WARN_ON (level !=PG_LEVEL_4K ) ||pte_none (*pte))return ; - target_pte =pti_user_pagetable_walk_pte (VSYSCALL_ADDR ); + target_pte =pti_user_pagetable_walk_pte (VSYSCALL_ADDR , false);if (WARN_ON (!target_pte))return ;
@@ -301,7 +306,7 @@ enum pti_clone_level {static void pti_clone_pgtable (unsigned long start,unsigned long end, -enum pti_clone_level level) +enum pti_clone_level level,bool late_text) {unsigned long addr;
@@ -390,7 +395,7 @@ pti_clone_pgtable(unsigned long start, ureturn ;/* Allocate PTE in the user page-table */ - target_pte =pti_user_pagetable_walk_pte (addr); + target_pte =pti_user_pagetable_walk_pte (addr, late_text);if (WARN_ON (!target_pte))return ;
@@ -452,7 +457,7 @@ static void __init pti_clone_user_sharedphys_addr_t pa =per_cpu_ptr_to_phys ((void *)va);pte_t *target_pte; - target_pte =pti_user_pagetable_walk_pte (va); + target_pte =pti_user_pagetable_walk_pte (va, false);if (WARN_ON (!target_pte))return ;
@@ -475,7 +480,7 @@ static void __init pti_clone_user_shared start =CPU_ENTRY_AREA_BASE ; end = start + (PAGE_SIZE *CPU_ENTRY_AREA_PAGES ); - pti_clone_pgtable(start, end, PTI_CLONE_PMD); + pti_clone_pgtable(start, end, PTI_CLONE_PMD, false); }#endif /* CONFIG_X86_64 */
@@ -492,11 +497,11 @@ static void __init pti_setup_espfix64(vo/* * Clone the populated PMDs of the entry text and force it RO. */ -static void pti_clone_entry_text (void ) +static void pti_clone_entry_text (bool late) {pti_clone_pgtable ((unsigned long ) __entry_text_start, (unsigned long ) __entry_text_end, -PTI_LEVEL_KERNEL_IMAGE ); +PTI_LEVEL_KERNEL_IMAGE , late); }/*
@@ -571,7 +576,7 @@ static void pti_clone_kernel_text(void)* pti_set_kernel_image_nonglobal() did to clear the * global bit. */ -pti_clone_pgtable (start, end_clone,PTI_LEVEL_KERNEL_IMAGE ); +pti_clone_pgtable (start, end_clone,PTI_LEVEL_KERNEL_IMAGE , false);/* * pti_clone_pgtable() will set the global bit in any PMDs
@@ -638,8 +643,15 @@ void __init pti_init(void)/* Undo all global bits from the init pagetables in head_64.S: */ pti_set_kernel_image_nonglobal (); +/* Replace some of the global bits just for shared entry text: */ -pti_clone_entry_text (); +/* +* This is very early in boot. Device and Late initcalls can do +* modprobe before free_initmem() and mark_readonly(). This +* pti_clone_entry_text() allows those user-mode-helpers to function, +* but notably the text is still RW. +*/ +pti_clone_entry_text (false);pti_setup_espfix64 ();pti_setup_vsyscall (); }
@@ -656,10 +668,11 @@ void pti_finalize(void)if (!boot_cpu_has (X86_FEATURE_PTI ))return ;/* -* We need to clone everything (again) that maps parts of the -* kernel image. +* This is after free_initmem() (all initcalls are done) and we've done +* mark_readonly(). Text is now NX which might've split some PMDs +* relative to the early clone. */ -pti_clone_entry_text (); +pti_clone_entry_text (true);pti_clone_kernel_text ();debug_checkwx_user ();
Greg Kroah-Hartman
maintainerPATCH 188/192 btrfs: fix race between direct IO write and fsync when using same fd
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit cd9253c23aedd61eb5ff11f37a36247cd46faf86 upstream.
If we have 2 threads that are using the same file descriptor and one of them is doing direct IO writes while the other is doing fsync, we have a race where we can end up either:
1) Attempt a fsync without holding the inode's lock, triggering an assertion failures when assertions are enabled;
2) Do an invalid memory access from the fsync task because the file private points to memory allocated on stack by the direct IO task and it may be used by the fsync task after the stack was destroyed.
The race happens like this:
1) A user space program opens a file descriptor with O_DIRECT;
2) The program spawns 2 threads using libpthread for example;
3) One of the threads uses the file descriptor to do direct IO writes, while the other calls fsync using the same file descriptor.
4) Call task A the thread doing direct IO writes and task B the thread doing fsyncs;
5) Task A does a direct IO write, and at btrfs_direct_write() sets the file's private to an on stack allocated private with the member 'fsync_skip_inode_lock' set to true;
6) Task B enters btrfs_sync_file() and sees that there's a private structure associated to the file which has 'fsync_skip_inode_lock' set to true, so it skips locking the inode's VFS lock;
7) Task A completes the direct IO write, and resets the file's private to NULL since it had no prior private and our private was stack allocated. Then it unlocks the inode's VFS lock;
8) Task B enters btrfs_get_ordered_extents_for_logging(), then the assertion that checks the inode's VFS lock is held fails, since task B never locked it and task A has already unlocked it.
The stack trace produced is the following:
assertion failed: inode_is_locked(&inode->vfs_inode), in fs/btrfs/ordered-data.c:983
------------[ cut here ]------------
kernel BUG at fs/btrfs/ordered-data.c:983!
Oops: invalid opcode: 0000 [#1] PREEMPT SMP PTI
CPU: 9 PID: 5072 Comm: worker Tainted: G U OE 6.10.5-1-default #1 openSUSE Tumbleweed 69f48d427608e1c09e60ea24c6c55e2ca1b049e8
Hardware name: Acer Predator PH315-52/Covini_CFS, BIOS V1.12 07/28/2020
RIP: 0010:btrfs_get_ordered_extents_for_logging.cold+0x1f/0x42 [btrfs]
Code: 50 d6 86 c0 e8 (...)
RSP: 0018:ffff9e4a03dcfc78 EFLAGS: 00010246
RAX: 0000000000000054 RBX: ffff9078a9868e98 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff907dce4a7800 RDI: ffff907dce4a7800
RBP: ffff907805518800 R08: 0000000000000000 R09: ffff9e4a03dcfb38
R10: ffff9e4a03dcfb30 R11: 0000000000000003 R12: ffff907684ae7800
R13: 0000000000000001 R14: ffff90774646b600 R15: 0000000000000000
FS: 00007f04b96006c0(0000) GS:ffff907dce480000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f32acbfc000 CR3: 00000001fd4fa005 CR4: 00000000003726f0
Call Trace:
<TASK>
? __die_body.cold+0x14/0x24
? die+0x2e/0x50
? do_trap+0xca/0x110
? do_error_trap+0x6a/0x90
? btrfs_get_ordered_extents_for_logging.cold+0x1f/0x42 [btrfs bb26272d49b4cdc847cf3f7faadd459b62caee9a]
? exc_invalid_op+0x50/0x70
? btrfs_get_ordered_extents_for_logging.cold+0x1f/0x42 [btrfs bb26272d49b4cdc847cf3f7faadd459b62caee9a]
? asm_exc_invalid_op+0x1a/0x20
? btrfs_get_ordered_extents_for_logging.cold+0x1f/0x42 [btrfs bb26272d49b4cdc847cf3f7faadd459b62caee9a]
? btrfs_get_ordered_extents_for_logging.cold+0x1f/0x42 [btrfs bb26272d49b4cdc847cf3f7faadd459b62caee9a]
btrfs_sync_file+0x21a/0x4d0 [btrfs bb26272d49b4cdc847cf3f7faadd459b62caee9a]
? __seccomp_filter+0x31d/0x4f0
__x64_sys_fdatasync+0x4f/0x90
do_syscall_64+0x82/0x160
? do_futex+0xcb/0x190
? __x64_sys_futex+0x10e/0x1d0
? switch_fpu_return+0x4f/0xd0
? syscall_exit_to_user_mode+0x72/0x220
? do_syscall_64+0x8e/0x160
? syscall_exit_to_user_mode+0x72/0x220
? do_syscall_64+0x8e/0x160
? syscall_exit_to_user_mode+0x72/0x220
? do_syscall_64+0x8e/0x160
? syscall_exit_to_user_mode+0x72/0x220
? do_syscall_64+0x8e/0x160
entry_SYSCALL_64_after_hwframe+0x76/0x7eAnother problem here is if task B grabs the private pointer and then uses it after task A has finished, since the private was allocated in the stack of task A, it results in some invalid memory access with a hard to predict result.
This issue, triggering the assertion, was observed with QEMU workloads by two users in the Link tags below.
Fix this by not relying on a file's private to pass information to fsync that it should skip locking the inode and instead pass this information through a special value stored in current->journal_info. This is safe because in the relevant section of the direct IO write path we are not holding a transaction handle, so current->journal_info is NULL.
The following C program triggers the issue:
$ cat repro.c /* Get the O_DIRECT definition. */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <stdint.h> #include <fcntl.h> #include <errno.h> #include <string.h> #include <pthread.h>
static int fd;
static ssize_t do_write(int fd, const void *buf, size_t count, off_t offset)
{
while (count > 0) {
ssize_t ret; ret = pwrite(fd, buf, count, offset);
if (ret < 0) {
if (errno == EINTR)
continue;
return ret;
}
count -= ret;
buf += ret;
}
return 0;}
static void *fsync_loop(void *arg)
{
while (1) {
int ret; ret = fsync(fd);
if (ret != 0) {
perror("Fsync failed");
exit(6);
}
}}
int main(int argc, char *argv[])
{
long pagesize;
void *write_buf;
pthread_t fsyncer;
int ret; if (argc != 2) {
fprintf(stderr, "Use: %s <file path>\n", argv[0]);
return 1;
}
fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC | O_DIRECT, 0666);
if (fd == -1) {
perror("Failed to open/create file");
return 1;
}
pagesize = sysconf(_SC_PAGE_SIZE);
if (pagesize == -1) {
perror("Failed to get page size");
return 2;
}
ret = posix_memalign(&write_buf, pagesize, pagesize);
if (ret) {
perror("Failed to allocate buffer");
return 3;
}
ret = pthread_create(&fsyncer, NULL, fsync_loop, NULL);
if (ret != 0) {
fprintf(stderr, "Failed to create writer thread: %d\n", ret);
return 4;
}
while (1) {
ret = do_write(fd, write_buf, pagesize, 0);
if (ret != 0) {
perror("Write failed");
exit(5);
}
}
return 0;}
$ mkfs.btrfs -f /dev/sdi $ mount /dev/sdi /mnt/sdi $ timeout 10 ./repro /mnt/sdi/foo
Usually the race is triggered within less than 1 second. A test case for fstests will follow soon.
---
--- fs/btrfs/ctree.h | 1 - fs/btrfs/file.c | 25 ++++++++++--------------- fs/btrfs/transaction.h | 6 ++++++ 3 files changed, 16 insertions(+), 16 deletions(-)
fs/btrfs/ctree.h +0 -1
@@ -1553,7 +1553,6 @@ struct btrfs_drop_extents_args {struct btrfs_file_private {void *filldir_buf;u64 last_index; -bool fsync_skip_inode_lock; };
fs/btrfs/file.c +10 -15
@@ -1534,13 +1534,6 @@ again:if (IS_ERR_OR_NULL (dio)) { err =PTR_ERR_OR_ZERO (dio); }else { -struct btrfs_file_private stack_private = {0 }; -struct btrfs_file_private *private; -const bool have_private = (file->private_data !=NULL ); - -if (!have_private) - file->private_data = &stack_private; -/* * If we have a synchoronous write, we must make sure the fsync * triggered by the iomap_dio_complete() call below doesn't
@@ -1549,13 +1542,10 @@ again:* partial writes due to the input buffer (or parts of it) not * being already faulted in. */ - private = file->private_data; - private->fsync_skip_inode_lock = true; +ASSERT (current->journal_info ==NULL ); + current->journal_info =BTRFS_TRANS_DIO_WRITE_STUB ; err =iomap_dio_complete (dio); - private->fsync_skip_inode_lock = false; - -if (!have_private) - file->private_data =NULL ; + current->journal_info =NULL ; }/* No increment (+=) because iomap returns a cumulative value. */
@@ -1795,7 +1785,6 @@ static inline bool skip_inode_logging(co*/ int btrfs_sync_file (struct file *file,loff_t start,loff_t end,int datasync) { -struct btrfs_file_private *private = file->private_data;struct dentry *dentry =file_dentry (file);struct inode *inode =d_inode (dentry);struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);
@@ -1805,7 +1794,13 @@ int btrfs_sync_file(struct file *file, lint ret =0 , err;u64 len;bool full_sync; -const bool skip_ilock = (private ? private->fsync_skip_inode_lock : false); +bool skip_ilock = false; + +if (current->journal_info ==BTRFS_TRANS_DIO_WRITE_STUB ) { + skip_ilock = true; + current->journal_info =NULL ; +lockdep_assert_held (&inode->i_rwsem); + }trace_btrfs_sync_file (file, datasync);
fs/btrfs/transaction.h +6 -0
@@ -11,6 +11,12 @@#include "delayed-ref.h" #include "ctree.h" +/* +* Signal that a direct IO write is in progress, to avoid deadlock for sync +* direct IO writes when fsync is called during the direct IO write path. +*/ +#define BTRFS_TRANS_DIO_WRITE_STUB ((void *) 1) +enum btrfs_trans_state {TRANS_STATE_RUNNING ,TRANS_STATE_COMMIT_START ,
Greg Kroah-Hartman
maintainerPATCH 189/192 bpf: Silence a warning in btf_type_id_size()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghong Song <[email protected]>
commit e6c2f594ed961273479505b42040782820190305 upstream.
syzbot reported a warning in [1] with the following stacktrace:
WARNING: CPU: 0 PID: 5005 at kernel/bpf/btf.c:1988 btf_type_id_size+0x2d9/0x9d0 kernel/bpf/btf.c:1988 ... RIP: 0010:btf_type_id_size+0x2d9/0x9d0 kernel/bpf/btf.c:1988 ... Call Trace: <TASK> map_check_btf kernel/bpf/syscall.c:1024 [inline] map_create+0x1157/0x1860 kernel/bpf/syscall.c:1198 __sys_bpf+0x127f/0x5420 kernel/bpf/syscall.c:5040 __do_sys_bpf kernel/bpf/syscall.c:5162 [inline] __se_sys_bpf kernel/bpf/syscall.c:5160 [inline] __x64_sys_bpf+0x79/0xc0 kernel/bpf/syscall.c:5160 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
With the following btf
[1] DECL_TAG 'a' type_id=4 component_idx=-1
[2] PTR '(anon)' type_id=0
[3] TYPE_TAG 'a' type_id=2
[4] VAR 'a' type_id=3, linkage=static
and when the bpf_attr.btf_key_type_id = 1 (DECL_TAG), the following WARN_ON_ONCE in btf_type_id_size() is triggered:
if (WARN_ON_ONCE(!btf_type_is_modifier(size_type) &&
!btf_type_is_var(size_type)))
return NULL;Note that 'return NULL' is the correct behavior as we don't want a DECL_TAG type to be used as a btf_{key,value}_type_id even for the case like 'DECL_TAG -> STRUCT'. So there
is no correctness issue here, we just want to silence warning.
To silence the warning, I added DECL_TAG as one of kinds in btf_type_nosize() which will cause btf_type_id_size() returning NULL earlier without the warning.
[1] https://lore.kernel.org/bpf/[email protected]/
--- kernel/bpf/btf.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
kernel/bpf/btf.c +7 -6
@@ -466,10 +466,16 @@ static bool btf_type_is_fwd(const structreturn BTF_INFO_KIND (t->info) ==BTF_KIND_FWD ; } +static bool btf_type_is_decl_tag (const struct btf_type *t) +{ +return BTF_INFO_KIND (t->info) ==BTF_KIND_DECL_TAG ; +} +static bool btf_type_nosize (const struct btf_type *t) {return btf_type_is_void (t) ||btf_type_is_fwd (t) || -btf_type_is_func (t) ||btf_type_is_func_proto (t); +btf_type_is_func (t) ||btf_type_is_func_proto (t) || +btf_type_is_decl_tag (t); }static bool btf_type_nosize_or_null (const struct btf_type *t)
@@ -492,11 +498,6 @@ static bool btf_type_is_datasec(const streturn BTF_INFO_KIND (t->info) ==BTF_KIND_DATASEC ; } -static bool btf_type_is_decl_tag (const struct btf_type *t) -{ -return BTF_INFO_KIND (t->info) ==BTF_KIND_DECL_TAG ; -} -static bool btf_type_is_decl_tag_target (const struct btf_type *t) { return btf_type_is_func(t) || btf_type_is_struct(t) ||
Greg Kroah-Hartman
maintainerPATCH 190/192 memcg: protect concurrent access to mem_cgroup_idr
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
commit 9972605a238339b85bd16b084eed5f18414d22db upstream.
Commit 73f576c04b94 ("mm: memcontrol: fix cgroup creation failure after many small jobs") decoupled the memcg IDs from the CSS ID space to fix the cgroup creation failures. It introduced IDR to maintain the memcg ID space. The IDR depends on external synchronization mechanisms for modifications. For the mem_cgroup_idr, the idr_alloc() and idr_replace() happen within css callback and thus are protected through cgroup_mutex from concurrent modifications. However idr_remove() for mem_cgroup_idr was not protected against concurrency and can be run concurrently for different memcgs when they hit their refcnt to zero. Fix that.
We have been seeing list_lru based kernel crashes at a low frequency in our fleet for a long time. These crashes were in different part of list_lru code including list_lru_add(), list_lru_del() and reparenting code. Upon further inspection, it looked like for a given object (dentry and inode), the super_block's list_lru didn't have list_lru_one for the memcg of that object. The initial suspicions were either the object is not allocated through kmem_cache_alloc_lru() or somehow memcg_list_lru_alloc() failed to allocate list_lru_one() for a memcg but returned success. No evidence were found for these cases.
Looking more deeply, we started seeing situations where valid memcg's id is not present in mem_cgroup_idr and in some cases multiple valid memcgs have same id and mem_cgroup_idr is pointing to one of them. So, the most reasonable explanation is that these situations can happen due to race between multiple idr_remove() calls or race between idr_alloc()/idr_replace() and idr_remove(). These races are causing multiple memcgs to acquire the same ID and then offlining of one of them would cleanup list_lrus on the system for all of them. Later access from other memcgs to the list_lru cause crashes due to missing list_lru_one.
[ Adapted over commit 6f0df8e16eb5 ("memcontrol: ensure memcg acquired by id is
properly set up") not in the tree ]
--- mm/memcontrol.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
mm/memcontrol.c +20 -2
@@ -5143,11 +5143,28 @@ static struct cftype mem_cgroup_legacy_f*/ static DEFINE_IDR (mem_cgroup_idr); +static DEFINE_SPINLOCK (memcg_idr_lock); + +static int mem_cgroup_alloc_id (void ) +{ +int ret; + +idr_preload (GFP_KERNEL ); +spin_lock (&memcg_idr_lock); + ret =idr_alloc (&mem_cgroup_idr,NULL ,1 ,MEM_CGROUP_ID_MAX +1 , +GFP_NOWAIT ); +spin_unlock (&memcg_idr_lock); +idr_preload_end (); +return ret; +}static void mem_cgroup_id_remove (struct mem_cgroup *memcg) {if (memcg->id.id >0 ) { +spin_lock (&memcg_idr_lock);idr_remove (&mem_cgroup_idr, memcg->id.id); +spin_unlock (&memcg_idr_lock); + memcg->id.id =0 ; } }
@@ -5270,8 +5287,7 @@ static struct mem_cgroup *mem_cgroup_allif (!memcg)return ERR_PTR (error); - memcg->id.id =idr_alloc (&mem_cgroup_idr,NULL , -1 ,MEM_CGROUP_ID_MAX +1 ,GFP_KERNEL ); + memcg->id.id =mem_cgroup_alloc_id ();if (memcg->id.id <0 ) { error = memcg->id.id; goto fail;
@@ -5316,7 +5332,9 @@ static struct mem_cgroup *mem_cgroup_allINIT_LIST_HEAD (&memcg->deferred_split_queue.split_queue); memcg->deferred_split_queue.split_queue_len =0 ;#endif +spin_lock (&memcg_idr_lock);idr_replace (&mem_cgroup_idr, memcg, memcg->id.id); +spin_unlock (&memcg_idr_lock);lru_gen_init_memcg (memcg);return memcg; fail:
Greg Kroah-Hartman
maintainerPATCH 191/192 regulator: of: fix a NULL vs IS_ERR() check in of_regulator_bulk_get_all()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Wu <[email protected]>
commit c957387c402a1a213102e38f92b800d7909a728d upstream.
The regulator_get() function never returns NULL. It returns error pointers.
--- drivers/regulator/of_regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/of_regulator.c +1 -1
@@ -767,7 +767,7 @@ restart:memcpy (name, prop->name, i); name[i] ='\0' ; tmp =regulator_get (dev, name); -if (!tmp) { +if (IS_ERR (tmp)) { ret = -EINVAL ; goto error; }
Greg Kroah-Hartman
maintainerPATCH 192/192 fuse: add feature flag for expire-only
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit 5cadfbd5a11e5495cac217534c5f788168b1afd7 upstream.
Add an init flag idicating whether the FUSE_EXPIRE_ONLY flag of FUSE_NOTIFY_INVAL_ENTRY is effective.
This is needed for backports of this feature, otherwise the server could just check the protocol version.
--- fs/fuse/inode.c | 3 ++- include/uapi/linux/fuse.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
fs/fuse/inode.c +2 -1
@@ -1327,7 +1327,8 @@ void fuse_send_init(struct fuse_mount *fFUSE_ABORT_ERROR |FUSE_MAX_PAGES |FUSE_CACHE_SYMLINKS |FUSE_NO_OPENDIR_SUPPORT |FUSE_EXPLICIT_INVAL_DATA |FUSE_HANDLE_KILLPRIV_V2 |FUSE_SETXATTR_EXT |FUSE_INIT_EXT | -FUSE_SECURITY_CTX ; +FUSE_SECURITY_CTX | +FUSE_HAS_EXPIRE_ONLY ;#ifdef CONFIG_FUSE_DAX if (fm->fc->dax) flags |=FUSE_MAP_ALIGNMENT ;
include/uapi/linux/fuse.h +2 -0
@@ -365,6 +365,7 @@ struct fuse_file_lock {* FUSE_SECURITY_CTX: add security context to create, mkdir, symlink, and * mknod * FUSE_HAS_INODE_DAX: use per inode DAX +* FUSE_HAS_EXPIRE_ONLY: kernel supports expiry-only entry invalidation */ #define FUSE_ASYNC_READ (1 << 0)#define FUSE_POSIX_LOCKS (1 << 1)
@@ -401,6 +402,7 @@ struct fuse_file_lock {/* bits 32..63 get shifted down 32 bits into the flags2 field */ #define FUSE_SECURITY_CTX (1ULL << 32)#define FUSE_HAS_INODE_DAX (1ULL << 33) +#define FUSE_HAS_EXPIRE_ONLY (1ULL << 35)/** * CUSE INIT request/reply flags
Greg Kroah-Hartman
maintainerPATCH 167/192 arm64: acpi: Move get_cpu_for_acpi_id() to a header
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Morse <[email protected]>
[ Upstream commit 8d34b6f17b9ac93faa2791eb037dcb08bdf755de ]
ACPI identifies CPUs by UID. get_cpu_for_acpi_id() maps the ACPI UID to the Linux CPU number.
The helper to retrieve this mapping is only available in arm64's NUMA code.
Move it to live next to get_acpi_id_for_cpu().
--- arch/arm64/include/asm/acpi.h | 11 +++++++++++ arch/arm64/kernel/acpi_numa.c | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-)
arch/arm64/include/asm/acpi.h +11 -0
@@ -97,6 +97,17 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu)return acpi_cpu_get_madt_gicc (cpu)->uid; } +static inline int get_cpu_for_acpi_id (u32 uid) +{ +int cpu; + +for (cpu =0 ; cpu < nr_cpu_ids; cpu++) +if (uid ==get_acpi_id_for_cpu (cpu)) +return cpu; + +return -EINVAL ; +} +static inline void arch_fix_phys_package_id (int num,u32 slot) { }void __init acpi_init_cpus (void );int apei_claim_sea (struct pt_regs *regs);
arch/arm64/kernel/acpi_numa.c +0 -11
@@ -34,17 +34,6 @@ int __init acpi_numa_get_nid(unsigned int cpu)return acpi_early_node_map[cpu]; } -static inline int get_cpu_for_acpi_id (u32 uid) -{ -int cpu; - -for (cpu =0 ; cpu < nr_cpu_ids; cpu++) -if (uid ==get_acpi_id_for_cpu (cpu)) -return cpu; - -return -EINVAL ; -} -static int __init acpi_parse_gicc_pxm (union acpi_subtable_headers *header,const unsigned long end) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 168/192 arm64: acpi: Harden get_cpu_for_acpi_id() against missing CPU entry
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Cameron <[email protected]>
[ Upstream commit 2488444274c70038eb6b686cba5f1ce48ebb9cdd ]
In a review discussion of the changes to support vCPU hotplug where a check was added on the GICC being enabled if was online, it was noted that there is need to map back to the cpu and use that to index into a cpumask. As such, a valid ID is needed.
If an MPIDR check fails in acpi_map_gic_cpu_interface() it is possible for the entry in cpu_madt_gicc[cpu] == NULL. This function would
then cause a NULL pointer dereference. Whilst a path to trigger
this has not been established, harden this caller against the possibility.
--- arch/arm64/include/asm/acpi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/include/asm/acpi.h +2 -1
@@ -102,7 +102,8 @@ static inline int get_cpu_for_acpi_id(u32 uid)int cpu;for (cpu =0 ; cpu < nr_cpu_ids; cpu++) -if (uid ==get_acpi_id_for_cpu (cpu)) +if (acpi_cpu_get_madt_gicc (cpu) && + uid ==get_acpi_id_for_cpu (cpu))return cpu;return -EINVAL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 169/192 can: mcp251xfd: mcp251xfd_handle_rxif_ring_uinc(): factor out in separate function
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit d49184b7b585f9da7ee546b744525f62117019f6 ]
This is a preparation patch.
Sending the UINC messages followed by incrementing the tail pointer will be called in more than one place in upcoming patches, so factor this out into a separate function.
Also make mcp251xfd_handle_rxif_ring_uinc() safe to be called with a "len" of 0.
--- drivers/net/can/spi/mcp251xfd/mcp251xfd-rx.c | 48 +++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-rx.c +32 -16
@@ -197,6 +197,37 @@ mcp251xfd_rx_obj_read(const struct mcp251xfd_priv *priv,return err; } +static int +mcp251xfd_handle_rxif_ring_uinc (const struct mcp251xfd_priv *priv, +struct mcp251xfd_rx_ring *ring, +u8 len) +{ +int offset; +int err; + +if (!len) +return 0 ; + +/* Increment the RX FIFO tail pointer 'len' times in a +* single SPI message. +* +* Note: +* Calculate offset, so that the SPI transfer ends on +* the last message of the uinc_xfer array, which has +* "cs_change == 0", to properly deactivate the chip +* select. +*/ + offset =ARRAY_SIZE (ring->uinc_xfer) - len; + err =spi_sync_transfer (priv->spi, + ring->uinc_xfer + offset, len); +if (err) +return err; + + ring->tail += len; + +return 0 ; +} +static int mcp251xfd_handle_rxif_ring (struct mcp251xfd_priv *priv,struct mcp251xfd_rx_ring *ring)
@@ -210,8 +241,6 @@ mcp251xfd_handle_rxif_ring(struct mcp251xfd_priv *priv,return err;while ((len =mcp251xfd_get_rx_linear_len (ring))) { -int offset; - rx_tail =mcp251xfd_get_rx_tail (ring); err = mcp251xfd_rx_obj_read(priv, ring, hw_rx_obj,
@@ -227,22 +256,9 @@ mcp251xfd_handle_rxif_ring(struct mcp251xfd_priv *priv,return err; } -/* Increment the RX FIFO tail pointer 'len' times in a -* single SPI message. -* -* Note: -* Calculate offset, so that the SPI transfer ends on -* the last message of the uinc_xfer array, which has -* "cs_change == 0", to properly deactivate the chip -* select. -*/ - offset =ARRAY_SIZE (ring->uinc_xfer) - len; - err =spi_sync_transfer (priv->spi, - ring->uinc_xfer + offset, len); + err =mcp251xfd_handle_rxif_ring_uinc (priv, ring, len);if (err)return err; - - ring->tail += len; }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 170/192 can: mcp251xfd: rx: prepare to workaround broken RX FIFO head index erratum
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit 85505e585637a737e4713c1386c30e37c325b82e ]
This is a preparatory patch to work around erratum DS80000789E 6 of the mcp2518fd, the other variants of the chip family (mcp2517fd and mcp251863) are probably also affected.
When handling the RX interrupt, the driver iterates over all pending FIFOs (which are implemented as ring buffers in hardware) and reads the FIFO header index from the RX FIFO STA register of the chip.
In the bad case, the driver reads a too large head index. In the original code, the driver always trusted the read value, which caused old CAN frames that were already processed, or new, incompletely written CAN frames to be (re-)processed.
Instead of reading and trusting the head index, read the head index and calculate the number of CAN frames that were supposedly received - replace mcp251xfd_rx_ring_update() with mcp251xfd_get_rx_len().
The mcp251xfd_handle_rxif_ring() function reads the received CAN frames from the chip, iterates over them and pushes them into the network stack. Prepare that the iteration can be stopped if an old CAN frame is detected. The actual code to detect old or incomplete frames and abort will be added in the next patch.
--- .../net/can/spi/mcp251xfd/mcp251xfd-ring.c | 2 + drivers/net/can/spi/mcp251xfd/mcp251xfd-rx.c | 89 +++++++++++-------- drivers/net/can/spi/mcp251xfd/mcp251xfd.h | 12 +-- 3 files changed, 56 insertions(+), 47 deletions(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c +2 -0
@@ -513,6 +513,8 @@ int mcp251xfd_ring_alloc(struct mcp251xfd_priv *priv) } rx_ring->obj_num = rx_obj_num; + rx_ring->obj_num_shift_to_u8 =BITS_PER_TYPE (rx_ring->obj_num_shift_to_u8) - +ilog2 (rx_obj_num); rx_ring->obj_size = rx_obj_size; priv->rx[i] = rx_ring; }
drivers/net/can/spi/mcp251xfd/mcp251xfd-rx.c +52 -37
148 lines not on this page · raw message
drivers/net/can/spi/mcp251xfd/mcp251xfd.h +2 -10
@@ -553,6 +553,7 @@ struct mcp251xfd_rx_ring {u8 nr;u8 fifo_nr;u8 obj_num; +u8 obj_num_shift_to_u8;u8 obj_size;union mcp251xfd_write_reg_buf irq_enable_buf;
@@ -889,18 +890,9 @@ static inline u8 mcp251xfd_get_rx_tail(const struct mcp251xfd_rx_ring *ring)return ring->tail & (ring->obj_num -1 ); } -static inline u8 mcp251xfd_get_rx_len (const struct mcp251xfd_rx_ring *ring) -{ -return ring->head - ring->tail; -} -static inline u8 -mcp251xfd_get_rx_linear_len (const struct mcp251xfd_rx_ring *ring) +mcp251xfd_get_rx_linear_len (const struct mcp251xfd_rx_ring *ring,u8 len) { -u8 len; - - len =mcp251xfd_get_rx_len (ring); -return min_t (u8, len, ring->obj_num -mcp251xfd_get_rx_tail (ring)); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 171/192 can: mcp251xfd: clarify the meaning of timestamp
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit e793c724b48ca8cae9693bc3be528e85284c126a ]
The mcp251xfd chip is configured to provide a timestamp with each received and transmitted CAN frame. The timestamp is derived from the internal free-running timer, which can also be read from the TBC register via SPI. The timer is 32 bits wide and is clocked by the external oscillator (typically 20 or 40 MHz).
To avoid confusion, we call this timestamp "timestamp_raw" or "ts_raw" for short.
Using the timecounter framework, the "ts_raw" is converted to 64 bit nanoseconds since the epoch. This is what we call "timestamp".
This is a preparation for the next patches which use the "timestamp" to work around a bug where so far only the "ts_raw" is used.
--- .../net/can/spi/mcp251xfd/mcp251xfd-core.c | 28 +++++++++---------- drivers/net/can/spi/mcp251xfd/mcp251xfd-rx.c | 2 +- drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c | 2 +- .../can/spi/mcp251xfd/mcp251xfd-timestamp.c | 22 ++++----------- drivers/net/can/spi/mcp251xfd/mcp251xfd.h | 27 ++++++++++++++---- 5 files changed, 43 insertions(+), 38 deletions(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +14 -14
@@ -2,7 +2,7 @@// // mcp251xfd - Microchip MCP251xFD Family CAN controller driver // -// Copyright (c) 2019, 2020, 2021 Pengutronix, +// Copyright (c) 2019, 2020, 2021, 2023 Pengutronix, // Marc Kleine-Budde <[email protected]> // // Based on:
@@ -867,18 +867,18 @@ static int mcp251xfd_get_berr_counter(const struct net_device *ndev,static struct sk_buff *mcp251xfd_alloc_can_err_skb (struct mcp251xfd_priv *priv, -struct can_frame **cf,u32 *timestamp) +struct can_frame **cf,u32 *ts_raw) {struct sk_buff *skb;int err; - err =mcp251xfd_get_timestamp (priv, timestamp); + err =mcp251xfd_get_timestamp_raw (priv, ts_raw);if (err)return NULL ; skb =alloc_can_err_skb (priv->ndev, cf);if (skb) -mcp251xfd_skb_set_timestamp (priv, skb, *timestamp); +mcp251xfd_skb_set_timestamp_raw (priv, skb, *ts_raw);return skb; }
@@ -889,7 +889,7 @@ static int mcp251xfd_handle_rxovif(struct mcp251xfd_priv *priv)struct mcp251xfd_rx_ring *ring;struct sk_buff *skb;struct can_frame *cf; -u32 timestamp, rxovif; +u32 ts_raw, rxovif;int err, i; stats->rx_over_errors++;
@@ -924,14 +924,14 @@ static int mcp251xfd_handle_rxovif(struct mcp251xfd_priv *priv)return err; } - skb =mcp251xfd_alloc_can_err_skb (priv, &cf, ×tamp); + skb =mcp251xfd_alloc_can_err_skb (priv, &cf, &ts_raw);if (!skb)return 0 ; cf->can_id |=CAN_ERR_CRTL ; cf->data[1 ] =CAN_ERR_CRTL_RX_OVERFLOW ; - err =can_rx_offload_queue_timestamp (&priv->offload, skb, timestamp); + err =can_rx_offload_queue_timestamp (&priv->offload, skb, ts_raw);if (err) stats->rx_fifo_errors++;
@@ -948,12 +948,12 @@ static int mcp251xfd_handle_txatif(struct mcp251xfd_priv *priv)static int mcp251xfd_handle_ivmif (struct mcp251xfd_priv *priv) {struct net_device_stats *stats = &priv->ndev->stats; -u32 bdiag1, timestamp; +u32 bdiag1, ts_raw;struct sk_buff *skb;struct can_frame *cf =NULL ;int err; - err =mcp251xfd_get_timestamp (priv, ×tamp); + err =mcp251xfd_get_timestamp_raw (priv, &ts_raw);if (err)return err;
@@ -1035,8 +1035,8 @@ static int mcp251xfd_handle_ivmif(struct mcp251xfd_priv *priv)if (!cf)return 0 ; -mcp251xfd_skb_set_timestamp (priv, skb, timestamp); - err =can_rx_offload_queue_timestamp (&priv->offload, skb, timestamp); +mcp251xfd_skb_set_timestamp_raw (priv, skb, ts_raw); + err =can_rx_offload_queue_timestamp (&priv->offload, skb, ts_raw);if (err) stats->rx_fifo_errors++;
@@ -1049,7 +1049,7 @@ static int mcp251xfd_handle_cerrif(struct mcp251xfd_priv *priv)struct sk_buff *skb;struct can_frame *cf =NULL ;enum can_state new_state, rx_state, tx_state; -u32 trec, timestamp; +u32 trec, ts_raw;int err; err =regmap_read (priv->map_reg,MCP251XFD_REG_TREC , &trec);
@@ -1079,7 +1079,7 @@ static int mcp251xfd_handle_cerrif(struct mcp251xfd_priv *priv)/* The skb allocation might fail, but can_change_state() * handles cf == NULL. */ - skb =mcp251xfd_alloc_can_err_skb (priv, &cf, ×tamp); + skb =mcp251xfd_alloc_can_err_skb (priv, &cf, &ts_raw);can_change_state (priv->ndev, cf, tx_state, rx_state);if (new_state ==CAN_STATE_BUS_OFF ) {
@@ -1110,7 +1110,7 @@ static int mcp251xfd_handle_cerrif(struct mcp251xfd_priv *priv) cf->data[7 ] = bec.rxerr; } - err =can_rx_offload_queue_timestamp (&priv->offload, skb, timestamp); + err =can_rx_offload_queue_timestamp (&priv->offload, skb, ts_raw);if (err) stats->rx_fifo_errors++;
drivers/net/can/spi/mcp251xfd/mcp251xfd-rx.c +1 -1
@@ -160,7 +160,7 @@ mcp251xfd_hw_rx_obj_to_skb(const struct mcp251xfd_priv *priv,if (!(hw_rx_obj->flags &MCP251XFD_OBJ_FLAGS_RTR ))memcpy (cfd->data, hw_rx_obj->data, cfd->len); -mcp251xfd_skb_set_timestamp (priv, skb, hw_rx_obj->ts); +mcp251xfd_skb_set_timestamp_raw (priv, skb, hw_rx_obj->ts); } static int
drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c +1 -1
@@ -97,7 +97,7 @@ mcp251xfd_handle_tefif_one(struct mcp251xfd_priv *priv, tef_tail =mcp251xfd_get_tef_tail (priv); skb = priv->can.echo_skb[tef_tail];if (skb) -mcp251xfd_skb_set_timestamp (priv, skb, hw_tef_obj->ts); +mcp251xfd_skb_set_timestamp_raw (priv, skb, hw_tef_obj->ts); stats->tx_bytes += can_rx_offload_get_echo_skb(&priv->offload, tef_tail, hw_tef_obj->ts,
drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c +6 -16
@@ -2,7 +2,7 @@// // mcp251xfd - Microchip MCP251xFD Family CAN controller driver // -// Copyright (c) 2021 Pengutronix, +// Copyright (c) 2021, 2023 Pengutronix, // Marc Kleine-Budde <[email protected]> //
@@ -11,20 +11,20 @@#include "mcp251xfd.h" -static u64 mcp251xfd_timestamp_read (const struct cyclecounter *cc) +static u64 mcp251xfd_timestamp_raw_read (const struct cyclecounter *cc) {const struct mcp251xfd_priv *priv; -u32 timestamp =0 ; +u32 ts_raw =0 ;int err; priv = container_of(cc, struct mcp251xfd_priv, cc); - err =mcp251xfd_get_timestamp (priv, ×tamp); + err =mcp251xfd_get_timestamp_raw (priv, &ts_raw);if (err)netdev_err (priv->ndev,"Error %d while reading timestamp. HW timestamps may be inaccurate." , err); -return timestamp; +return ts_raw; }static void mcp251xfd_timestamp_work (struct work_struct *work)
@@ -39,21 +39,11 @@ static void mcp251xfd_timestamp_work(struct work_struct *work) MCP251XFD_TIMESTAMP_WORK_DELAY_SEC * HZ); } -void mcp251xfd_skb_set_timestamp (const struct mcp251xfd_priv *priv, -struct sk_buff *skb,u32 timestamp) -{ -struct skb_shared_hwtstamps *hwtstamps =skb_hwtstamps (skb); -u64 ns; - - ns =timecounter_cyc2time (&priv->tc, timestamp); - hwtstamps->hwtstamp =ns_to_ktime (ns); -} -void mcp251xfd_timestamp_init (struct mcp251xfd_priv *priv) {struct cyclecounter *cc = &priv->cc; - cc->read = mcp251xfd_timestamp_read; + cc->read = mcp251xfd_timestamp_raw_read; cc->mask =CYCLECOUNTER_MASK (32 ); cc->shift =1 ; cc->mult =clocksource_hz2mult (priv->can.clock.freq, cc->shift);
drivers/net/can/spi/mcp251xfd/mcp251xfd.h +21 -6
@@ -2,7 +2,7 @@* * mcp251xfd - Microchip MCP251xFD Family CAN controller driver * -* Copyright (c) 2019, 2020, 2021 Pengutronix, +* Copyright (c) 2019, 2020, 2021, 2023 Pengutronix, * Marc Kleine-Budde <[email protected]> * Copyright (c) 2019 Martin Sperl <[email protected]> */
@@ -794,10 +794,27 @@ mcp251xfd_spi_cmd_write(const struct mcp251xfd_priv *priv,return data; } -static inline int mcp251xfd_get_timestamp (const struct mcp251xfd_priv *priv, -u32 *timestamp) +static inline int mcp251xfd_get_timestamp_raw (const struct mcp251xfd_priv *priv, +u32 *ts_raw) { -return regmap_read (priv->map_reg,MCP251XFD_REG_TBC , timestamp); +return regmap_read (priv->map_reg,MCP251XFD_REG_TBC , ts_raw); +} + +static inline void mcp251xfd_skb_set_timestamp (struct sk_buff *skb,u64 ns) +{ +struct skb_shared_hwtstamps *hwtstamps =skb_hwtstamps (skb); + + hwtstamps->hwtstamp =ns_to_ktime (ns); +} + +static inline +void mcp251xfd_skb_set_timestamp_raw (const struct mcp251xfd_priv *priv, +struct sk_buff *skb,u32 ts_raw) +{ +u64 ns; + + ns =timecounter_cyc2time (&priv->tc, ts_raw); +mcp251xfd_skb_set_timestamp (skb, ns); }static inline u16 mcp251xfd_get_tef_obj_addr (u8 n)
@@ -918,8 +935,6 @@ void mcp251xfd_ring_free(struct mcp251xfd_priv *priv);int mcp251xfd_ring_alloc (struct mcp251xfd_priv *priv);int mcp251xfd_handle_rxif (struct mcp251xfd_priv *priv);int mcp251xfd_handle_tefif (struct mcp251xfd_priv *priv); -void mcp251xfd_skb_set_timestamp (const struct mcp251xfd_priv *priv, -struct sk_buff *skb,u32 timestamp);void mcp251xfd_timestamp_init (struct mcp251xfd_priv *priv);void mcp251xfd_timestamp_stop (struct mcp251xfd_priv *priv);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 172/192 can: mcp251xfd: rx: add workaround for erratum DS80000789E 6 of mcp2518fd
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
[ Upstream commit 24436be590c6fbb05f6161b0dfba7d9da60214aa ]
This patch tries to works around erratum DS80000789E 6 of the mcp2518fd, the other variants of the chip family (mcp2517fd and mcp251863) are probably also affected.
In the bad case, the driver reads a too large head index. In the original code, the driver always trusted the read value, which caused old, already processed CAN frames or new, incompletely written CAN frames to be (re-)processed.
To work around this issue, keep a per FIFO timestamp [1] of the last valid received CAN frame and compare against the timestamp of every received CAN frame. If an old CAN frame is detected, abort the iteration and mark the number of valid CAN frames as processed in the chip by incrementing the FIFO's tail index.
Further tests showed that this workaround can recognize old CAN frames, but a small time window remains in which partially written CAN frames [2] are not recognized but then processed. These CAN frames have the correct data and time stamps, but the DLC has not yet been updated.
[1] As the raw timestamp overflows every 107 seconds (at the usual clock rate of 40 MHz) convert it to nanoseconds with the timecounter framework and use this to detect stale CAN frames.
--- .../net/can/spi/mcp251xfd/mcp251xfd-ring.c | 1 + drivers/net/can/spi/mcp251xfd/mcp251xfd-rx.c | 32 +++++++++++++++++-- drivers/net/can/spi/mcp251xfd/mcp251xfd.h | 3 ++ 3 files changed, 33 insertions(+), 3 deletions(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c +1 -0
@@ -196,6 +196,7 @@ mcp251xfd_ring_init_rx(struct mcp251xfd_priv *priv, u16 *base, u8 *fifo_nr)int i, j;mcp251xfd_for_each_rx_ring (priv, rx_ring, i) { + rx_ring->last_valid =timecounter_read (&priv->tc); rx_ring->head =0 ; rx_ring->tail =0 ; rx_ring->base = *base;
drivers/net/can/spi/mcp251xfd/mcp251xfd-rx.c +29 -3
@@ -159,8 +159,6 @@ mcp251xfd_hw_rx_obj_to_skb(const struct mcp251xfd_priv *priv,if (!(hw_rx_obj->flags &MCP251XFD_OBJ_FLAGS_RTR ))memcpy (cfd->data, hw_rx_obj->data, cfd->len); - -mcp251xfd_skb_set_timestamp_raw (priv, skb, hw_rx_obj->ts); } static int
@@ -171,8 +169,26 @@ mcp251xfd_handle_rxif_one(struct mcp251xfd_priv *priv,struct net_device_stats *stats = &priv->ndev->stats;struct sk_buff *skb;struct canfd_frame *cfd; +u64 timestamp;int err; +/* According to mcp2518fd erratum DS80000789E 6. the FIFOCI +* bits of a FIFOSTA register, here the RX FIFO head index +* might be corrupted and we might process past the RX FIFO's +* head into old CAN frames. +* +* Compare the timestamp of currently processed CAN frame with +* last valid frame received. Abort with -EBADMSG if an old +* CAN frame is detected. +*/ + timestamp =timecounter_cyc2time (&priv->tc, hw_rx_obj->ts); +if (timestamp <= ring->last_valid) { + stats->rx_fifo_errors++; + +return -EBADMSG ; + } + ring->last_valid = timestamp; +if (hw_rx_obj->flags &MCP251XFD_OBJ_FLAGS_FDF ) skb =alloc_canfd_skb (priv->ndev, &cfd);else
@@ -183,6 +199,7 @@ mcp251xfd_handle_rxif_one(struct mcp251xfd_priv *priv,return 0 ; } +mcp251xfd_skb_set_timestamp (skb, timestamp);mcp251xfd_hw_rx_obj_to_skb (priv, hw_rx_obj, skb); err =can_rx_offload_queue_timestamp (&priv->offload, skb, hw_rx_obj->ts);if (err)
@@ -265,7 +282,16 @@ mcp251xfd_handle_rxif_ring(struct mcp251xfd_priv *priv, err =mcp251xfd_handle_rxif_one (priv, ring, (void *)hw_rx_obj + i * ring->obj_size); -if (err) + +/* -EBADMSG means we're affected by mcp2518fd +* erratum DS80000789E 6., i.e. the timestamp +* in the RX object is older that the last +* valid received CAN frame. Don't process any +* further and mark processed frames as good. +*/ +if (err == -EBADMSG ) +return mcp251xfd_handle_rxif_ring_uinc (priv, ring, i); +else if (err)return err; }
drivers/net/can/spi/mcp251xfd/mcp251xfd.h +3 -0
@@ -549,6 +549,9 @@ struct mcp251xfd_rx_ring {unsigned int head;unsigned int tail; +/* timestamp of the last valid received CAN frame */ +u64 last_valid; +u16 base;u8 nr;u8 fifo_nr;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 173/192 drm/amd: Add gfx12 swizzle mode defs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aurabindo Pillai <[email protected]>
[ Upstream commit 7ceb94e87bffff7c12b61eb29749e1d8ac976896 ]
Add GFX12 swizzle mode definitions for use with DCN401
--- include/uapi/drm/drm_fourcc.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
include/uapi/drm/drm_fourcc.h +16 -0
@@ -1390,6 +1390,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)#define AMD_FMT_MOD_TILE_VER_GFX10 2#define AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS 3#define AMD_FMT_MOD_TILE_VER_GFX11 4 +#define AMD_FMT_MOD_TILE_VER_GFX12 5/* * 64K_S is the same for GFX9/GFX10/GFX10_RBPLUS and hence has GFX9 as canonical
@@ -1400,6 +1401,8 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)/* * 64K_D for non-32 bpp is the same for GFX9/GFX10/GFX10_RBPLUS and hence has * GFX9 as canonical version. +* +* 64K_D_2D on GFX12 is identical to 64K_D on GFX11. */ #define AMD_FMT_MOD_TILE_GFX9_64K_D 10#define AMD_FMT_MOD_TILE_GFX9_64K_S_X 25
@@ -1407,6 +1410,19 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)#define AMD_FMT_MOD_TILE_GFX9_64K_R_X 27#define AMD_FMT_MOD_TILE_GFX11_256K_R_X 31 +/* Gfx12 swizzle modes: +* 0 - LINEAR +* 1 - 256B_2D - 2D block dimensions +* 2 - 4KB_2D +* 3 - 64KB_2D +* 4 - 256KB_2D +* 5 - 4KB_3D - 3D block dimensions +* 6 - 64KB_3D +* 7 - 256KB_3D +*/ +#define AMD_FMT_MOD_TILE_GFX12_64K_2D 3 +#define AMD_FMT_MOD_TILE_GFX12_256K_2D 4 +#define AMD_FMT_MOD_DCC_BLOCK_64B 0#define AMD_FMT_MOD_DCC_BLOCK_128B 1#define AMD_FMT_MOD_DCC_BLOCK_256B 2
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 164/192 workqueue: Improve scalability of workqueue watchdog touch
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Piggin <[email protected]>
[ Upstream commit 98f887f820c993e05a12e8aa816c80b8661d4c87 ]
On a ~2000 CPU powerpc system, hard lockups have been observed in the workqueue code when stop_machine runs (in this case due to CPU hotplug). This is due to lots of CPUs spinning in multi_cpu_stop, calling touch_nmi_watchdog() which ends up calling wq_watchdog_touch(). wq_watchdog_touch() writes to the global variable wq_watchdog_touched, and that can find itself in the same cacheline as other important workqueue data, which slows down operations to the point of lockups.
In the case of the following abridged trace, worker_pool_idr was in the hot line, causing the lockups to always appear at idr_find.
watchdog: CPU 1125 self-detected hard LOCKUP @ idr_find
Call Trace: get_work_pool __queue_work call_timer_fn run_timer_softirq __do_softirq do_softirq_own_stack irq_exit timer_interrupt decrementer_common_virt * interrupt: 900 (timer) at multi_cpu_stop multi_cpu_stop cpu_stopper_thread smpboot_thread_fn kthread
Fix this by having wq_watchdog_touch() only write to the line if the last time a touch was recorded exceeds 1/4 of the watchdog threshold.
--- kernel/workqueue.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
kernel/workqueue.c +8 -2
@@ -5891,12 +5891,18 @@ static void wq_watchdog_timer_fn(struct timer_list *unused) notrace void wq_watchdog_touch(int cpu) { +unsigned long thresh =READ_ONCE (wq_watchdog_thresh) *HZ ; +unsigned long touch_ts =READ_ONCE (wq_watchdog_touched); +unsigned long now = jiffies; +if (cpu >=0 ) -per_cpu (wq_watchdog_touched_cpu, cpu) = jiffies; +per_cpu (wq_watchdog_touched_cpu, cpu) = now;else WARN_ONCE (1 ,"%s should be called with valid CPU" , __func__); - wq_watchdog_touched = jiffies; +/* Don't unnecessarily store to global cacheline */ +if (time_after (now, touch_ts + thresh /4 )) +WRITE_ONCE (wq_watchdog_touched, jiffies); }static void wq_watchdog_set_thresh (unsigned long thresh)
Signature · 1 line
2.43.0
Re: [PATCH 6.1 153/192] rust: macros: provide correct provenance when constructing THIS_MODULE
In reply to Greg Kroah-HartmanQuoted 25 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boqun Feng <[email protected]>
[ Upstream commit
a5a3c952e82c1ada12bf8c55b73af26f1a454bd2]Currently while defining
THIS_MODULEsymbol inmodule!(), the pointer used to constructThisModuleis derived from an immutable reference of__this_module, which means the pointer doesn't have the provenance for writing, and that means any write to that pointer is UB regardless of data races or not. However, the usage ofTHIS_MODULEincludes passing this pointer to functions that may write to it (probably in unsafe code), and this will create soundness issues.One way to fix this is using
addr_of_mut!()but that requires the unstable feature "const_mut_refs". So instead ofaddr_of_mut()!, an extern staticOpaqueis used here: sinceOpaque<T>is transparent toT, an extern staticOpaquewill just wrap the C symbol (defined in a C compile unit) in anOpaque, which provides a pointer with writable provenance viaOpaque::get(). This fix the potential UBs because of pointer provenance unmatched.
Quoted 13 lines
Reported-by Alice Ryhl <[email protected]>Signed-off-by Boqun Feng <[email protected]>Reviewed-by Alice Ryhl <[email protected]>Reviewed-by Trevor Gross <[email protected]>Reviewed-by Benno Lossin <[email protected]>Reviewed-by Gary Guo <[email protected]>Fixes 1fbde52bde73 ("rust: add `macros` crate")Cc [email protected] # 6.6.x: be2ca1e03965: ("rust: types: Make Opaque::get const")[ Fixed two typos, reworded title. - Miguel ]Signed-off-by Miguel Ojeda <[email protected]>Signed-off-by Sasha Levin <[email protected]>
The opaque type doesn't exist yet on 6.1, so this needs to be changed for the 6.1 backport. It won't compile as-is.
Quoted 26 lines
--- rust/macros/module.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)rust/macros/module.rs +5
-2@@ -183,7 +183,11 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {// freed until the module is unloaded. #[cfg( MODULE )] static THIS_MODULE : kernel::ThisModule =unsafe {{ - kernel::ThisModule ::from_ptr (&kernel::bindings::__this_moduleas *const _ as *mut _ ) + extern \"C\" {{ +static __this_module: kernel::types::Opaque <kernel::bindings::module >; + }} + + kernel::ThisModule ::from_ptr (__this_module.get ()) }};#[cfg(not( MODULE ))] static THIS_MODULE : kernel::ThisModule =unsafe {{ --2.43.0
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.1.110 release. There are 192 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Can you quote git hash of the 6.1.110-rc1?
We do have
Linux 6.1.110-rc1 (244a97bb85be)
Greg Kroah-Hartman authored 1 day ago
passing tests
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.1.y
. But that's 1 day old.
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Greg Kroah-Hartman
maintainerQuoted 8 lines · Pavel Machek
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.1.110 release. There are 192 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Can you quote git hash of the 6.1.110-rc1?
Nope! We create the git trees for those that want throw-away trees, once I create them I automatically delete them so I don't even know the hash anymore.
Quoted 10 lines
We do have
Linux 6.1.110-rc1 (
244a97bb85be)
Greg Kroah-Hartman authored 1 day agopassing tests
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.1.y
. But that's 1 day old.
Lots have changed since then, please use the latest.
thanks,
greg k-h
Re: [PATCH 6.1 153/192] rust: macros: provide correct provenance when constructing THIS_MODULE
In reply to Alice RyhlQuoted 9 lines · Alice Ryhl
Quoted 3 lines · Greg Kroah-Hartman
Fixes 1fbde52bde73 ("rust: add `macros` crate")Cc [email protected] # 6.6.x: be2ca1e03965: ("rust: types: Make Opaque::get const")The opaque type doesn't exist yet on 6.1, so this needs to be changed for the 6.1 backport. It won't compile as-is.
+1 -- Greg/Sasha: for context, this is the one I asked about using Option 3 since otherwise the list of cherry-picks for 6.1 would be quite long.
Cheers,
Miguel
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.110 release. There are 192 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 12 Sep 2024 09:25:22 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.110-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
The SuperH defconfig builds failed due to following build warnings / errors on the stable-rc linux-6.1.y.
* SuperH, build
- gcc-8-defconfig
- gcc-11-shx3_defconfig
- gcc-11-defconfig
- gcc-8-shx3_defconfig
Build log:
--------
In file included from include/linux/mm.h:29,
from arch/sh/kernel/asm-offsets.c:14:
include/linux/pgtable.h: In function 'pmdp_get_lockless':
include/linux/pgtable.h:379:20: error: 'pmd_t' has no member named 'pmd_low'
379 | pmd.pmd_low = pmdp->pmd_low;
| ^
include/linux/pgtable.h:379:35: error: 'pmd_t' has no member named 'pmd_low'
379 | pmd.pmd_low = pmdp->pmd_low;
| ^~
Metadata:
--------
build_name: gcc-11-defconfig
config: https://storage.tuxsuite.com/public/linaro/lkft/builds/2lsNsLYIfqdkNQOzLLZO4lq580E/config
download_url:
https://storage.tuxsuite.com/public/linaro/lkft/builds/2lsNsLYIfqdkNQOzLLZO4lq580E/
git_describe: v6.1.109-193-gb220bb28da0f
git_repo: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
git_sha: b220bb28da0f6a629a0d88be3f8e57ea5025c728
compiler: {'name': 'sh4-linux-gnu-gcc', 'version': '11',
'version_full': 'sh4-linux-gnu-gcc (Debian 11.4.0-5) 11.4.0'}
Steps to reproduce:
-------
- # tuxmake --runtime podman --target-arch sh --toolchain gcc-11
--kconfig defconfig
--
Linaro LKFT
https://lkft.linaro.org
Quoted 32 lines · Naresh Kamboju
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.110 release. There are 192 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 12 Sep 2024 09:25:22 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.110-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
The SuperH defconfig builds failed due to following build warnings / errors on the stable-rc linux-6.1.y.
* SuperH, build
- gcc-8-defconfig
- gcc-11-shx3_defconfig
- gcc-11-defconfig
- gcc-8-shx3_defconfig
Quoted 12 lines
Build log:
--------
In file included frominclude/linux/mm.h:29,
fromarch/sh/kernel/asm-offsets.c:14:
include/linux/pgtable.h: In function 'pmdp_get_lockless':
include/linux/pgtable.h:379:20: error: 'pmd_t' has no member named 'pmd_low'
379 | pmd.pmd_low =pmdp->pmd_low;
| ^
include/linux/pgtable.h:379:35: error: 'pmd_t' has no member named 'pmd_low'
379 | pmd.pmd_low =pmdp->pmd_low;
| ^~
Anders bisected this down to,
# first bad commit:
[4f5373c50a1177e2a195f0ef6a6e5b7f64bf8b6c]
mm: Fix pmd_read_atomic()
[ Upstream commit 024d232ae4fcd7a7ce8ea239607d6c1246d7adc8 ]AFAICT there's no reason to do anything different than what we do for PTEs. Make it so (also affects SH)
--
Linaro LKFT
https://lkft.linaro.org
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.110 release. There are 192 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 12 Sep 2024 09:25:22 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.110-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Quoted 8 lines · Greg Kroah-Hartman
Quoted 7 lines · Pavel Machek
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.1.110 release. There are 192 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 5 lines
Quoted 1 line
Can you quote git hash of the 6.1.110-rc1?
Nope! We create the git trees for those that want throw-away trees, once I create them I automatically delete them so I don't even know the hash anymore.
Modify your scripts so that you can quote hash in the announcement?
Avoid using "-rc1" tag for things that are... well... not released as -rc1?
Quoted 5 lines
Quoted 5 lines
We do have
Linux 6.1.110-rc1 (
244a97bb85be)
Greg Kroah-Hartman authored 1 day ago
Quoted 7 lines
Quoted 5 lines
passing tests
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.1.y
. But that's 1 day old.
Lots have changed since then, please use the latest.
I will, but matching releases and tests based on timestamps is just not right.
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.110 release. There are 192 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.110 release. There are 192 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 12 Sep 2024 09:25:22 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.110-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Greg Kroah-Hartman
maintainerRe: [PATCH 6.1 153/192] rust: macros: provide correct provenance when constructing THIS_MODULE
In reply to Miguel OjedaQuoted 8 lines · Miguel Ojeda
Quoted 7 lines · Alice Ryhl
Quoted 3 lines · Greg Kroah-Hartman
Fixes 1fbde52bde73 ("rust: add `macros` crate")Cc [email protected] # 6.6.x: be2ca1e03965: ("rust: types: Make Opaque::get const")
Quoted 6 lines
Quoted 2 lines
The opaque type doesn't exist yet on 6.1, so this needs to be changed for the 6.1 backport. It won't compile as-is.
+1 -- Greg/Sasha: for context, this is the one I asked about using Option 3 since otherwise the list of cherry-picks for 6.1 would be quite long.
Sorry about the delay, yeah, this is why I didn't apply this to 6.1.y, but Sasha picked it up as he saw it looked like it applied and didn't break the build. Maybe we aren't building rust code in our systems? I know I'm not, I need to fix that...
Anyway, now dropped, thanks all!
greg k-h
Greg Kroah-Hartman
maintainerQuoted 46 lines · Naresh Kamboju
Quoted 32 lines · Naresh Kamboju
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.1.110 release. There are 192 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 12 Sep 2024 09:25:22 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.110-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.1.y
and the diffstat can be found below.thanks,
greg k-h
The SuperH defconfig builds failed due to following build warnings / errors on the stable-rc linux-6.1.y.
* SuperH, build
- gcc-8-defconfig
- gcc-11-shx3_defconfig
- gcc-11-defconfig
- gcc-8-shx3_defconfigQuoted 12 lines
Build log:
--------
In file included frominclude/linux/mm.h:29,
fromarch/sh/kernel/asm-offsets.c:14:
include/linux/pgtable.h: In function 'pmdp_get_lockless':
include/linux/pgtable.h:379:20: error: 'pmd_t' has no member named 'pmd_low'
379 | pmd.pmd_low =pmdp->pmd_low;
| ^
include/linux/pgtable.h:379:35: error: 'pmd_t' has no member named 'pmd_low'
379 | pmd.pmd_low =pmdp->pmd_low;
| ^~
Quoted 8 lines
Anders bisected this down to,
# first bad commit: [4f5373c50a1177e2a195f0ef6a6e5b7f64bf8b6c] mm: Fix pmd_read_atomic() [ Upstream commit 024d232ae4fcd7a7ce8ea239607d6c1246d7adc8 ]AFAICT there's no reason to do anything different than what we do for PTEs. Make it so (also affects SH)
Ok, I'm going to drop this series as it shouldn't be breaking builds :(
thanks,
greg k-h