[PATCH v4] pci-bridge: avoid linking a single downstream port more than once

2024-07-25 Thread Yao Xingtao via
Since the downstream port is not checked, two slots can be linked to a single port. However, this can prevent the driver from detecting the device properly. It is necessary to ensure that a downstream port is not linked more than once. Links: https://lore.kernel.org/qemu-devel/oszpr01mb6453bc61d

[PATCH] scripts/coccinelle: New range.cocci

2024-07-24 Thread Yao Xingtao via
This is the semantic patch from commit 7b3e371526 "cxl/mailbox: make range overlap check more readable" Signed-off-by: Yao Xingtao --- scripts/coccinelle/range.cocci | 49 ++ 1 file changed, 49 insertions(+) create mode 100644 scripts/coccinelle/range.cocci diff

[PATCH v3] pci-bridge: avoid linking a single downstream port more than once

2024-07-24 Thread Yao Xingtao via
Since the downstream port is not checked, two slots can be linked to a single port. However, this can prevent the driver from detecting the device properly. It is necessary to ensure that a downstream port is not linked more than once. Links: https://lore.kernel.org/qemu-devel/oszpr01mb6453bc61d

[PATCH 1/2] mips/loongson3_virt: remove useless type cast

2024-07-22 Thread Yao Xingtao via
The type of kernel_entry, kernel_low and kernel_high is uint64_t, cast the pointer of this type to uint64_t* is useless. Signed-off-by: Yao Xingtao --- hw/mips/loongson3_virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_vi

[PATCH 0/2] remove useless type cast

2024-07-22 Thread Yao Xingtao via
Currently the pattern in scripts/coccinelle/typecast.cocci is used to remove the useless type cast. Use the following command to find out the use cases and remove the useless type case: $ spatch --macro-file scripts/cocci-macro-file.h \ --sp-file ./scripts/coccinelle/typecast.cocci \

[PATCH 2/2] nvme/ctrl: remove useless type cast

2024-07-22 Thread Yao Xingtao via
The type of req->cmd is NvmeCmd, cast the pointer of this type to NvmeCmd* is useless. Signed-off-by: Yao Xingtao --- hw/nvme/ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 5b1b0cabcfc3..221818f551cd 100644 --- a/hw/nvme/ctrl.c ++

[PATCH 06/13] aspeed_smc: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- hw/ssi/aspeed_smc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c index 49205ab76d38..cdca359e1

[PATCH 12/13] dump: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- dump/dump.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index 84064d890d2c..45e84428aea5 100644 ---

[PATCH 13/13] block/qcow2-cluster: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use range_overlaps_range() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- block/qcow2-cluster.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-clust

[PATCH 11/13] crypto/block-luks: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- crypto/block-luks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 5b777c15d3cd..45347adeeb7

[PATCH 09/13] system/memory_mapping: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- system/memory_mapping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/memory_mapping.c b/system/memory_mapping.c index 6f884c5b90c

[PATCH 05/13] display/sm501: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- hw/display/sm501.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 26dc8170d89b..c25

[PATCH 10/13] block/vhdx: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use range_overlaps_range() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- block/vhdx.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/block/vhdx.c b/block/vhdx.c index 5aa1a1350626..c31661b946b6 10

[PATCH 08/13] sparc/ldst_helper: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- target/sparc/ldst_helper.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index 2

[PATCH 07/13] qtest/fuzz: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- tests/qtest/fuzz/generic_fuzz.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fu

[PATCH 04/13] cxl/mailbox: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- hw/cxl/cxl-mailbox-utils.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c inde

[PATCH 02/13] arm/boot: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- hw/arm/boot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index d480a7da02cf..a004a90e87be 100644 --- a/

[PATCH 03/13] core/loader: make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao --- hw/core/loader.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/core/loader.c b/hw/core/loader.c index 31593a117171..dac0df561b16 100644

[PATCH 01/13] range: Make ranges_overlap() return bool

2024-07-21 Thread Yao Xingtao via
Just like range_overlaps_range(), use the returned bool value to check whether 2 given ranges overlap. Signed-off-by: Yao Xingtao --- include/qemu/range.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qemu/range.h b/include/qemu/range.h index 4ce694a39831..d446a

[PATCH 00/13] make range overlap check more readable

2024-07-21 Thread Yao Xingtao via
Currently, some components still open-coding the range overlap check. Sometimes this check may be fail because some patterns are missed. To avoid the above problems and improve the readability of the code, it is better to use the ranges_overlap() to do this check. Yao Xingtao (13): range: Make

[PATCH v2] mem/cxl_type3: Fix overlapping region validation error

2024-07-18 Thread Yao Xingtao via
When injecting a new poisoned region through qmp_cxl_inject_poison(), the newly injected region should not overlap with existing poisoned regions. The current validation method does not consider the following overlapping region: +---+---+---+ | a | b(a) | a | +---+---+---+ (a is a newly

[PATCH] mem/cxl_type3: Fix overlapping region validation error

2024-07-18 Thread Yao Xingtao via
When injecting a new poisoned region through qmp_cxl_inject_poison(), the newly injected region should not overlap with existing poisoned regions. The current validation method does not consider the following overlapping region: ┌───┬───┬───┐ │a │ b(a) │a │ └───┴───┴───┘ (a is a newly a

[PATCH v2] pci-bridge: avoid linking a single downstream port more than once

2024-07-17 Thread Yao Xingtao via
Since the downstream port is not checked, two slots can be linked to a single port. However, this can prevent the driver from detecting the device properly. It is necessary to ensure that a downstream port is not linked more than once. Links: https://lore.kernel.org/qemu-devel/oszpr01mb6453bc61d

[PATCH] pci-bridge: avoid linking a single downstream port more than once

2024-07-03 Thread Yao Xingtao via
Since the downstream port is not checked, two slots can be linked to a single port. However, this can prevent the driver from detecting the device properly. It is necessary to ensure that a downstream port is not linked more than once. Links: https://lore.kernel.org/qemu-devel/oszpr01mb6453bc61d

[PATCH v3] mem/cxl_type3: support 3, 6, 12 and 16 interleave ways

2024-05-07 Thread Yao Xingtao via
Since the kernel does not check the interleave capability, a 3-way, 6-way, 12-way or 16-way region can be create normally. Applications can access the memory of 16-way region normally because qemu can convert hpa to dpa correctly for the power of 2 interleave ways, after kernel implementing the ch

[PATCH v2] mem/cxl_type3: support 3, 6, 12 and 16 interleave ways

2024-04-06 Thread Yao Xingtao via
Since the kernel does not check the interleave capability, a 3-way, 6-way, 12-way or 16-way region can be create normally. Applications can access the memory of 16-way region normally because qemu can convert hpa to dpa correctly for the power of 2 interleave ways, after kernel implementing the ch

[PATCH] mem/cxl_type3: fix hpa to dpa logic

2024-03-26 Thread Yao Xingtao via
In 3, 6, 12 interleave ways, we could not access cxl memory properly, and when the process is running on it, a 'segmentation fault' error will occur. According to the CXL specification '8.2.4.20.13 Decoder Protection', there are two branches to convert HPA to DPA: b1: Decoder[m].IW < 8 (for 1, 2,

[PATCH v3] contrib/plugins/execlog: Fix compiler warning

2024-03-25 Thread Yao Xingtao via
1. The g_pattern_match_string() is deprecated when glib2 version >= 2.70. Use g_pattern_spec_match_string() instead to avoid this problem. 2. The type of second parameter in g_ptr_array_add() is 'gpointer' {aka 'void *'}, but the type of reg->name is 'const char*'. Cast the type of reg->n

[PATCH v2] contrib/plugins/execlog: Fix compiler warning

2024-03-24 Thread Yao Xingtao via
1. The g_pattern_match_string() is deprecated when glib2 version >= 2.70. Use g_pattern_spec_match_string() instead to avoid this problem. 2. The type of second parameter in g_ptr_array_add() is 'gpointer' {aka 'void *'}, but the type of reg->name is 'const char*'. Cast the type of reg->n

[PATCH] contrib/plugins/execlog: Fix compiler warning

2024-03-19 Thread Yao Xingtao via
1. The g_pattern_match_string() is deprecated when glib2 version >= 2.70. Use g_pattern_spec_match_string() instead to avoid this problem. 2. The type of second parameter in g_ptr_array_add() is 'gpointer' {aka 'void *'}, but the type of reg->name is 'const char*'. Cast the type of reg->n