Commit Graph

801122 Commits

Author SHA1 Message Date
Tejun Heo 223164bd80 blk-iocost: fix NULL iocg deref from racing against initialization
ANBZ: #10868

commit d16baa3f14 upstream.

When initializing iocost for a queue, its rqos should be registered before
the blkcg policy is activated to allow policy data initiailization to lookup
the associated ioc. This unfortunately means that the rqos methods can be
called on bios before iocgs are attached to all existing blkgs.

While the race is theoretically possible on ioc_rqos_throttle(), it mostly
happened in ioc_rqos_merge() due to the difference in how they lookup ioc.
The former determines it from the passed in @rqos and then bails before
dereferencing iocg if the looked up ioc is disabled, which most likely is
the case if initialization is still in progress. The latter looked up ioc by
dereferencing the possibly NULL iocg making it a lot more prone to actually
triggering the bug.

* Make ioc_rqos_merge() use the same method as ioc_rqos_throttle() to look
  up ioc for consistency.

* Make ioc_rqos_throttle() and ioc_rqos_merge() test for NULL iocg before
  dereferencing it.

* Explain the danger of NULL iocgs in blk_iocost_init().

[backport note]
fix conflict caused by "alinux: iocost: fix NULL pointer dereference in
ioc_rqos_throttle".

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Jonathan Lemon <bsd@fb.com>
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Ferry Meng <mengferry@linux.alibaba.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3840
2024-09-18 14:59:22 +08:00
leoliu-oc 8cfe551cd7 anolis: x86/hpet: Read HPET directly if panic in progress
ANBZ: #9396

When the clocksource of the system is HPET,a CPU executing read_hpet might
be interrupted by #GP/#PF to executing the panic,this may lead to
read_hpet dead loops:

CPU x				    CPU x
----                                ----
read_hpet()
  arch_spin_trylock(&hpet.lock)
  [CPU x got the hpet.lock]         #GP/#PF happened
                                    panic()
                                      kmsg_dump()
                                        pstore_dump()
                                          pstore_record_init()
                                            ktime_get_real_fast_ns()
                                              read_hpet()
                                              [dead loops]

To avoid this dead loops, read HPET directly if panic in progress.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3396
2024-09-05 11:20:36 +00:00
leoliu-oc 4518090245 anolis: iommu/vt-d: add kh40000_swiotlb_dma_ops for KH-40000
ANBZ: #4330

add kh40000_swiotlb_dma_ops for KH-40000 platform.

For coherent DMA access, memory can be allocated only from the memory node
of the node where the device resides.

For streaming DMA access, add a PCI read operation at the end of DMA
access.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3375
2024-08-08 17:24:47 +08:00
leoliu-oc 5cac6b3377 anolis: iommu/vt-d: add kh40000_direct_dma_ops for KH-40000
ANBZ: #4330

add kh40000_direct_dma_ops for KH-40000 platform.

For coherent DMA access, memory can be allocated only from the memory node
of the node where the device resides.

For streaming DMA access, add a PCI read operation at the end of DMA
access.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3375
2024-08-08 17:21:42 +08:00
leoliu-oc cc48a6b845 anolis: iommu/vt-d: add kh40000_iommu_dma_ops for KH-40000
ANBZ: #4330

Add kh40000_iommu_dma_ops for KH-40000 platform.

For coherent DMA access, memory can be allocated only from the memory node
of the node where the device resides.

For streaming DMA access, add a PCI read operation at the end of DMA
access.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3375
2024-08-08 17:15:42 +08:00
leoliu-oc 81e1e12eef anolis: iommu/vt-d: add quirk for DMA RW sequence disorder issue
ANBZ: #4330

Add quirk for DMA RW sequence disorder issue for KH-40000 platform.

For coherent DMA access, memory can be allocated only from the memory node
of the node where the device resides.

For streaming DMA access, add a PCI read operation at the end of DMA
access.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3375
2024-08-08 17:12:22 +08:00
leoliu-oc b6ae6acb18 x86/cpu: Remove pointless evaluation of x86_coreid_bits
ANBZ: #8049

commit 594957d723 upstream.

cpuinfo_x86::x86_coreid_bits is only used by the AMD numa topology code. No
point in evaluating it on non AMD systems.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Juergen Gross <jgross@suse.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230814085112.687588373@linutronix.de

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3388
2024-08-08 06:36:31 +00:00
leoliu-oc ace8f1ca62 anolis: Set ASYM_PACKING Flag on Zhaoxin KH-40000 platform.
ANBZ: #9366

Set ASYM_PACKING Flag on Zhaoxin KH-40000 platform.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3379
2024-08-07 08:44:28 +00:00
leoliu-oc 96a0c4ccf3 anolis: cpufreq: acpi-cpufreq: add ITMT support when CPPC enabled
ANBZ: #9366

The _CPC method can get per-core highest frequency. The highest frequency
may varies between cores which mean cores can running at different max
frequency, so can use it as a core priority and give a hint to scheduler
in order to put critical task to the higher priority core.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3379
2024-08-07 08:44:28 +00:00
leoliu-oc b4456ef531 anolis: configs: enable CONFIG_SENSORS_ZHAOXIN_CPUTEMP to m
ANBZ: #4320

Enable CONFIG_SENSORS_ZHAOXIN_CPUTEMP for Zhaoxin cputemp driver.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3364
2024-08-07 08:41:22 +00:00
leoliu-oc 6cea908c30 anolis: hwmon: Add driver for Zhaoxin CPU core temperature
ANBZ: #4320

Add support for the temperature sensor inside CPU.
Supported are all known variants of the Zhaoxin processors.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3364
2024-08-07 08:41:22 +00:00
leoliu-oc f8da120e57 anolis: configs: enable Zhaoxin pinctrl driver as default
ANBZ: #7916

Enabled Zhaoxin pinctrl drivers as default:
CONFIG_PINCTRL_ZHAOXIN=y
CONFIG_PINCTRL_KX7000=m

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3381
2024-08-07 08:36:09 +00:00
leoliu-oc 800fda436f anolis: pinctrl: Add support for Zhaoxin GPIO pinctrl
ANBZ: #7916

Implements gpio interrupt and gpio management functions and provides
standard pinctrl and gpio interfaces.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3381
2024-08-07 08:36:09 +00:00
leoliu-oc 770d40fde6 anolis: configs: zhaoxin: enable CONFIG_I2C_ZHAOXIN_SMBUS
ANBZ: #8038

To support Zhaoxin I2C SMbus, enable the
following CONFIGs:

CONFIG_I2C_ZHAOXIN_SMBUS=m

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3384
2024-08-07 08:33:38 +00:00
leoliu-oc fefda4241b anolis: i2c: smbus: Add support for Zhaoxin SMBUS controller
ANBZ: #8038

The Zhaoxin platform implements the SMBUS controller on the hardware,
enabling information exchange and collaboration between devices using the
SMBus protocol.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3384
2024-08-07 08:33:38 +00:00
leoliu-oc 4899963c48 anolis: x86/mce: Set bios_cmci_threshold for CMCI threshold
ANBZ: #9393

In the Linux kernel, the CMCI threshold is set to 1 by default. This patch
prevents Linux from overwriting the CMCI threshold set by the bios. With
this patch, the CMCI threshold can be set through the BIOS, which can also
avoid CMCI storms, on Zhaoxin/Centaur CPUs.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3392
2024-08-07 08:30:11 +00:00
leoliu-oc b943feb80d anolis: configs: enable zhaoxin AES & SHA drivers
ANBZ: #4319

Set Zhaoxin AES & SHA drivers as module:
CONFIG_CRYPTO_DEV_ZHAOXIN=m
CONFIG_CRYPTO_DEV_ZHAOXIN_AES=m
CONFIG_CRYPTO_DEV_ZHAOXIN_SHA=m

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3363
2024-08-07 05:58:38 +00:00
leoliu-oc 988107a4a6 anolis: Zhaoxin: Driver for Zhaoxin SHA algorithm
ANBZ: #4319

Some Zhaoxin processors come with an integrated crypto engine (so called
Zhaoxin ACE, Advanced Cryptography Engine) that provides instructions for
very fast cryptographic operations with supported SHA algorithms.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3363
2024-08-07 05:58:38 +00:00
leoliu-oc d2d9a3f67e anolis: Zhaoxin: Driver for Zhaoxin AES algorithm
ANBZ: #4319

Some Zhaoxin processors come with an integrated crypto engine (so called
Zhaoxin ACE, Advanced Cryptography Engine) that provides instructions for
very fast cryptographic operations with supported AES algorithms.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3363
2024-08-07 05:58:38 +00:00
leoliu-oc f35362522a anolis: configs: enable Zhaoxin SM3 and SM4 driver as module
ANBZ: #8009

Set Zhaoxin SM3 and SM4 driver items in anolis_defconfig:
CONFIG_CRYPTO_SM3_ZHAOXIN_GMI=m
CONFIG_CRYPTO_SM4_ZHAOXIN_GMI=m

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3377
2024-08-07 05:52:26 +00:00
leoliu-oc 77f2ff13ef anolis: crypto: x86/sm4 - add support for Zhaoxin GMI SM4 Block Cipher Algorithm
ANBZ: #8009

This SM4 algorithm driver is developed to support the SM4 instruction,
making user develop their applications with both high performance and high
security.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3377
2024-08-07 05:52:26 +00:00
leoliu-oc 377fec00ca anolis: crypto: x86/sm3 - add support for Zhaoxin GMI SM3 Secure Hash algorithm
ANBZ: #8009

This SM3 algorithm driver is developed to support the SM3 instruction,
making user develop their applications with both high performance and high
security.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3377
2024-08-07 05:52:26 +00:00
leoliu-oc c3a10409cd anolis: crypto: x86/sm2 -add Zhaoxin SM2 algorithm implementation
ANBZ: #7915

Add support for SM2 (ShangMi 2) public key algorithm by Zhaoxin GMI
Instruction. The purpose of this driver is to ensure that the application
has both high performance and high security.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3385
2024-08-07 05:46:43 +00:00
Bart Van Assche a6f62c5fff scsi: sd: Rely on the driver core for asynchronous probing
ANBZ: #9563

commit f049cf1a7b upstream

As explained during the 2018 LSF/MM session about increasing SCSI disk
probing concurrency, the problems with the current probing approach are as
follows:

 - The driver core is unaware of asynchronous SCSI LUN probing.
   wait_for_device_probe() waits for all asynchronous probes except
   asynchronous SCSI disk probes.

 - There is unnecessary serialization between sd_probe() and sd_remove().
   This can lead to a deadlock.

Hence this patch that modifies the sd driver such that it uses the driver
core framework for asynchronous probing. The async domain and
get_device()/put_device() pairs that became superfluous due to this change
are removed.

This patch does not affect the time needed for loading the scsi_debug
kernel module with parameters delay=0 and max_luns=256.

This patch depends on commit ef0ff68351 ("driver core: Probe devices
asynchronously instead of the driver") that went upstream in kernel version
v5.1-rc1.

Cc: Lee Duncan <lduncan@suse.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Bitao Hu <yaoma@linux.alibaba.com>
Reviewed-by: Xunlei Pang <xlpang@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3525
2024-07-19 18:05:55 +08:00
Zhang Wensheng 277a2a02fe driver core: fix potential deadlock in __driver_attach
ANBZ: #9563

commit 70fe758352 upstream

In __driver_attach function, There are also AA deadlock problem,
like the commit b232b02bf3 ("driver core: fix deadlock in
__device_attach").

stack like commit b232b02bf3 ("driver core: fix deadlock in
__device_attach").
list below:
    In __driver_attach function, The lock holding logic is as follows:
    ...
    __driver_attach
    if (driver_allows_async_probing(drv))
      device_lock(dev)      // get lock dev
        async_schedule_dev(__driver_attach_async_helper, dev); // func
          async_schedule_node
            async_schedule_node_domain(func)
              entry = kzalloc(sizeof(struct async_entry), GFP_ATOMIC);
              /* when fail or work limit, sync to execute func, but
                 __driver_attach_async_helper will get lock dev as
                 will, which will lead to A-A deadlock.  */
              if (!entry || atomic_read(&entry_count) > MAX_WORK) {
                func;
              else
                queue_work_node(node, system_unbound_wq, &entry->work)
      device_unlock(dev)

    As above show, when it is allowed to do async probes, because of
    out of memory or work limit, async work is not be allowed, to do
    sync execute instead. it will lead to A-A deadlock because of
    __driver_attach_async_helper getting lock dev.

Reproduce:
and it can be reproduce by make the condition
(if (!entry || atomic_read(&entry_count) > MAX_WORK)) untenable, like
below:

[  370.785650] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables
this message.
[  370.787154] task:swapper/0       state:D stack:    0 pid:    1 ppid:
0 flags:0x00004000
[  370.788865] Call Trace:
[  370.789374]  <TASK>
[  370.789841]  __schedule+0x482/0x1050
[  370.790613]  schedule+0x92/0x1a0
[  370.791290]  schedule_preempt_disabled+0x2c/0x50
[  370.792256]  __mutex_lock.isra.0+0x757/0xec0
[  370.793158]  __mutex_lock_slowpath+0x1f/0x30
[  370.794079]  mutex_lock+0x50/0x60
[  370.794795]  __device_driver_lock+0x2f/0x70
[  370.795677]  ? driver_probe_device+0xd0/0xd0
[  370.796576]  __driver_attach_async_helper+0x1d/0xd0
[  370.797318]  ? driver_probe_device+0xd0/0xd0
[  370.797957]  async_schedule_node_domain+0xa5/0xc0
[  370.798652]  async_schedule_node+0x19/0x30
[  370.799243]  __driver_attach+0x246/0x290
[  370.799828]  ? driver_allows_async_probing+0xa0/0xa0
[  370.800548]  bus_for_each_dev+0x9d/0x130
[  370.801132]  driver_attach+0x22/0x30
[  370.801666]  bus_add_driver+0x290/0x340
[  370.802246]  driver_register+0x88/0x140
[  370.802817]  ? virtio_scsi_init+0x116/0x116
[  370.803425]  scsi_register_driver+0x1a/0x30
[  370.804057]  init_sd+0x184/0x226
[  370.804533]  do_one_initcall+0x71/0x3a0
[  370.805107]  kernel_init_freeable+0x39a/0x43a
[  370.805759]  ? rest_init+0x150/0x150
[  370.806283]  kernel_init+0x26/0x230
[  370.806799]  ret_from_fork+0x1f/0x30

To fix the deadlock, move the async_schedule_dev outside device_lock,
as we can see, in async_schedule_node_domain, the parameter of
queue_work_node is system_unbound_wq, so it can accept concurrent
operations. which will also not change the code logic, and will
not lead to deadlock.

Fixes: ef0ff68351 ("driver core: Probe devices asynchronously instead of the driver")
Signed-off-by: Zhang Wensheng <zhangwensheng5@huawei.com>
Link: https://lore.kernel.org/r/20220622074327.497102-1-zhangwensheng5@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bitao Hu <yaoma@linux.alibaba.com>
Reviewed-by: Xunlei Pang <xlpang@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3525
2024-07-19 18:05:10 +08:00
Zhang Wensheng 2380b1c816 driver core: fix deadlock in __device_attach
ANBZ: #9563

commit b232b02bf3 upstream

In __device_attach function, The lock holding logic is as follows:
...
__device_attach
device_lock(dev)      // get lock dev
  async_schedule_dev(__device_attach_async_helper, dev); // func
    async_schedule_node
      async_schedule_node_domain(func)
        entry = kzalloc(sizeof(struct async_entry), GFP_ATOMIC);
	/* when fail or work limit, sync to execute func, but
	   __device_attach_async_helper will get lock dev as
	   well, which will lead to A-A deadlock.  */
	if (!entry || atomic_read(&entry_count) > MAX_WORK) {
	  func;
	else
	  queue_work_node(node, system_unbound_wq, &entry->work)
  device_unlock(dev)

As shown above, when it is allowed to do async probes, because of
out of memory or work limit, async work is not allowed, to do
sync execute instead. it will lead to A-A deadlock because of
__device_attach_async_helper getting lock dev.

To fix the deadlock, move the async_schedule_dev outside device_lock,
as we can see, in async_schedule_node_domain, the parameter of
queue_work_node is system_unbound_wq, so it can accept concurrent
operations. which will also not change the code logic, and will
not lead to deadlock.

Fixes: 765230b5f0 ("driver-core: add asynchronous probing support for drivers")
Signed-off-by: Zhang Wensheng <zhangwensheng5@huawei.com>
Link: https://lore.kernel.org/r/20220518074516.1225580-1-zhangwensheng5@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bitao Hu <yaoma@linux.alibaba.com>
Reviewed-by: Xunlei Pang <xlpang@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3525
2024-07-19 18:04:49 +08:00
Alexander Duyck 231f0b1c4b driver core: Probe devices asynchronously instead of the driver
ANBZ: #9563

commit ef0ff68351 upstream

Probe devices asynchronously instead of the driver. This results in us
seeing the same behavior if the device is registered before the driver or
after. This way we can avoid serializing the initialization should the
driver not be loaded until after the devices have already been added.

The motivation behind this is that if we have a set of devices that
take a significant amount of time to load we can greatly reduce the time to
load by processing them in parallel instead of one at a time. In addition,
each device can exist on a different node so placing a single thread on one
CPU to initialize all of the devices for a given driver can result in poor
performance on a system with multiple nodes.

This approach can reduce the time needed to scan SCSI LUNs significantly.
The only way to realize that speedup is by enabling more concurrency which
is what is achieved with this patch.

To achieve this it was necessary to add a new member "async_driver" to the
device_private structure to store the driver pointer while we wait on the
deferred probe call.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bitao Hu <yaoma@linux.alibaba.com>
Reviewed-by: Xunlei Pang <xlpang@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3525
2024-07-19 18:04:15 +08:00
Alexander Duyck 56cee160d2 device core: Consolidate locking and unlocking of parent and device
ANBZ: #9563

commit ed88747c6c upstream

Try to consolidate all of the locking and unlocking of both the parent and
device when attaching or removing a driver from a given device.

To do that I first consolidated the lock pattern into two functions
__device_driver_lock and __device_driver_unlock. After doing that I then
created functions specific to attaching and detaching the driver while
acquiring these locks. By doing this I was able to reduce the number of
spots where we touch need_parent_lock from 12 down to 4.

This patch should produce no functional changes, it is meant to be a code
clean-up/consolidation only.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bitao Hu <yaoma@linux.alibaba.com>
Reviewed-by: Xunlei Pang <xlpang@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3525
2024-07-19 18:02:46 +08:00
Florian Westphal 5579010831 netfilter: nftables: exthdr: fix 4-byte stack OOB write
ANBZ: #9412

commit fd94d9dade upstream.

If priv->len is a multiple of 4, then dst[len / 4] can write past
the destination array which leads to stack corruption.

This construct is necessary to clean the remainder of the register
in case ->len is NOT a multiple of the register size, so make it
conditional just like nft_payload.c does.

The bug was added in 4.1 cycle and then copied/inherited when
tcp/sctp and ip option support was added.

Bug reported by Zero Day Initiative project (ZDI-CAN-21950,
ZDI-CAN-21951, ZDI-CAN-21961).

Fixes: 49499c3e6e ("netfilter: nf_tables: switch registers to 32 bit addressing")
Fixes: 935b7f6430 ("netfilter: nft_exthdr: add TCP option matching")
Fixes: 133dc203d7 ("netfilter: nft_exthdr: Support SCTP chunks")
Fixes: dbb5281a1f ("netfilter: nf_tables: add support for matching IPv4 options")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

[Fixes conflicts]
Fixes: CVE-2023-52628
Signed-off-by: Xiao Long <xiaolong@openanolis.org>
Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3416
2024-06-27 10:49:18 +00:00
Liao Xuan 4914aa2b44 anolis: ALSA: hda: Add support for Hygon family 18h model 10h HD-Audio
ANBZ: #9404

Add the new PCI ID 0x1d94 0x14c9 for Hygon family 18h model 10h
HDA controller.

Signed-off-by: Liao Xuan <liaoxuan@hygon.cn>
Reviewed-by: Xingrui Yi <yixingrui@linux.alibaba.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3406
2024-06-26 02:47:04 -04:00
Liao Xuan 8923359f27 anolis: hwmon/k10temp: Add support for Hygon family 18h model 10h
ANBZ: #9404

Add 18H_M10H DF F3 device ID to get the temperature for Hygon
family 18h model 10h processor.

Signed-off-by: Liao Xuan <liaoxuan@hygon.cn>
Reviewed-by: Xingrui Yi <yixingrui@linux.alibaba.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3406
2024-06-26 02:46:56 -04:00
Liao Xuan e2c16bfbf9 anolis: EDAC/amd64: Add support for Hygon family 18h model 10h
ANBZ: #9404

Add Hygon family 18h model 10h processor support for amd64_edac.

Signed-off-by: Liao Xuan <liaoxuan@hygon.cn>
Reviewed-by: Xingrui Yi <yixingrui@linux.alibaba.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3406
2024-06-26 02:45:43 -04:00
Liao Xuan 1a7a4bb4d0 anolis: x86/amd_nb: Add support for Hygon family 18h model 10h
ANBZ: #9404

Add root and DF F1/F3/F4 device IDs for Hygon family 18h model
10h processors.

Signed-off-by: Liao Xuan <liaoxuan@hygon.cn>
Reviewed-by: Xingrui Yi <yixingrui@linux.alibaba.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3406
2024-06-26 02:42:00 -04:00
Liao Xuan a004a0eb46 anolis: x86/cpu: Get LLC ID for Hygon family 18h model 10h
ANBZ: #9404

Get LLC ID from ApicId[3].

Signed-off-by: Liao Xuan <liaoxuan@hygon.cn>
Reviewed-by: Xingrui Yi <yixingrui@linux.alibaba.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3406
2024-06-26 02:41:52 -04:00
Liao Xuan 60964146b7 anolis: perf/x86/uncore: Add L3 PMU support for Hygon family 18h model 7h
ANBZ: #9404

From model 6h, Hygon processors can use the same L3 PMU slicemask
and threadmask.

Signed-off-by: Liao Xuan <liaoxuan@hygon.cn>
Reviewed-by: Xingrui Yi <yixingrui@linux.alibaba.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3405
2024-06-26 04:24:37 +00:00
Liao Xuan ab4dcfbbbe anolis: EDAC/amd64: Add support for Hygon family 18h model 7h
ANBZ: #9404

Add Hygon family 18h model 7h processor support for amd64_edac.

Signed-off-by: Liao Xuan <liaoxuan@hygon.cn>
Reviewed-by: Xingrui Yi <yixingrui@linux.alibaba.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3405
2024-06-26 04:24:37 +00:00
Liao Xuan 722a2bf2ba anolis: x86/amd_nb: Add support for Hygon family 18h model 7h
ANBZ: #9404

Add Hygon family 18h model 7h processor support for amd_nb.

Signed-off-by: Liao Xuan <liaoxuan@hygon.cn>
Reviewed-by: Xingrui Yi <yixingrui@linux.alibaba.com>
Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3405
2024-06-26 04:24:37 +00:00
YiLin.Li 2f12e62107 anolis: Revert "tpm: add support for partial reads"
ANBZ: #9397

This reverts commit 47413af3f4.

This patch affects the normal use of tpm2_pcrlist. Thus revert it.

Signed-off-by: YiLin.Li <YiLin.Li@linux.alibaba.com>
Reviewed-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Reviewed-by: Guixin Liu <kanie@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3403
2024-06-21 19:44:59 +08:00
Gao Xiang 23b3b1f886 erofs: avoid allocating DEFLATE streams before mounting
ANBZ: #9242

commit 80eb4f6205 upstream

Currently, each DEFLATE stream takes one 32 KiB permanent internal
window buffer even if there is no running instance which uses DEFLATE
algorithm.

It's unexpected and wasteful on embedded devices with limited resources
and servers with hundreds of CPU cores if DEFLATE is enabled but unused.

Fixes: ffa09b3bd0 ("erofs: DEFLATE compression support")
Cc: <stable@vger.kernel.org> # 6.6+
Reviewed-by: Sandeep Dhavale <dhavale@google.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240520090106.2898681-1-hsiangkao@linux.alibaba.com
Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3281
2024-06-05 03:09:49 +00:00
Hongzhen Luo c01e8ac00d erofs: derive fsid from on-disk UUID for .statfs() if possible
ANBZ: #9242

commit 1872df8dcd upstream

Use the superblock's UUID to generate the fsid when it's non-null.

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240409113022.74720-1-hongzhen@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3281
2024-06-05 03:09:49 +00:00
Amir Goldstein f0ae098e58 fs: introduce a wrapper uuid_to_fsid()
ANBZ: #9242

commit 9591c3a34f upstream

Some filesystem's use a digest of their uuid for f_fsid.
Create a simple wrapper for this open coded folding.

Filesystems that have a non null uuid but use the block device
number for f_fsid may also consider using this helper.

[JK: Added missing asm/byteorder.h include]
Link: https://lore.kernel.org/r/20210322173944.449469-2-amir73il@gmail.com
Acked-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3281
2024-06-05 03:09:49 +00:00
Al Viro e44ca1325b [PATCH] reduce boilerplate in fsid handling
ANBZ: #9242

commit 6d1349c769 upstream

Get rid of boilerplate in most of ->statfs()
instances...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3281
2024-06-05 03:09:49 +00:00
Duanqiang Wen 342ba9005d anolis: net: txgbe: fix semaphore can't acquire
ANBZ: #9271

above 0x2000f firmware version, fireware will access
i2c, driver and firmware maybe race the i2c bus, so
add semaphore to protect i2c bus.

Signed-off-by: Duanqiang Wen <duanqiangwen@net-swift.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3309
2024-06-03 17:29:41 +08:00
Yuanhe Shu 1559785612 anolis: Revert "bpf: add bpf helper bpf_skb_ecn_set_ce"
ANBZ: #9263

This reverts commit 7f3defbff2.

Some tools that detect kernel support for bpf_skb_ecn_set_ce
assume that tc queue_mapping writes are also supported,
but the kernel does not support this. Thus revert it.

Signed-off-by: Yuanhe Shu <xiangzao@linux.alibaba.com>
Reviewed-by: Tianchen Ding <dtcccc@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3301
2024-06-03 02:21:14 +00:00
Duanqiang Wen fdb5e67c7d anolis: net: txgbe: support to set multi rss when sriov is enabled
ANBZ: #8072

multi rss mode when sriov is enabled, so ethtool -X to set
ethx indir table or rss hash key need to support multi rss mode.

Signed-off-by: Duanqiang Wen <duanqiangwen@net-swift.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3121
2024-05-27 07:30:09 +00:00
Duanqiang Wen c5eae6144f anolis: net: txgbe:support for set vf mac with zero_ether_addr
ANBZ: #8072

ip link set dev ethx vf 0 mac 00:00:00:00:00:00 will return -EINVAL
allow the mac address of vf to be set to all zero.

Signed-off-by: Duanqiang Wen <duanqiangwen@net-swift.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3121
2024-05-27 07:30:09 +00:00
Duanqiang Wen dfc4b97b61 anolis: net: txgbe: support for vf trust setting
ANBZ: #8072

support for ip link command to set vf trust on or
off.

Signed-off-by: Duanqiang Wen <duanqiangwen@net-swift.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3121
2024-05-27 07:30:09 +00:00
Duanqiang Wen 0f9665679a anolis: net: txgbe: fix to create fdir rule index 0
ANBZ: #8072

When the 2046th rule is created, this rule index is 0. If no ether
type filter has been created, this info of rule 0 will be confused.

Signed-off-by: Duanqiang Wen <duanqiangwen@net-swift.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3121
2024-05-27 07:30:09 +00:00
Duanqiang Wen 672981178d anolis: net: txgbe: close rx-vlan-offload rx-vlan-stag-filter together
ANBZ: #8072

when close rx-vlan-filter feature, rx-vlan-stag-filter feature not close,
when close rx-vlan-offload feature, it not work as expected.

Signed-off-by: Duanqiang Wen <duanqiangwen@net-swift.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3121
2024-05-27 07:30:09 +00:00
Duanqiang Wen 626bf1926f anolis: net: txgbe: fix combined queue num error
ANBZ: #8072

ethtool -l ethx show error combined queue num.

Signed-off-by: Duanqiang Wen <duanqiangwen@net-swift.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/3121
2024-05-27 07:30:09 +00:00