* [PATCH v2] mem/cxl_type3: Fix overlapping region validation error
@ 2024-07-19 1:28 Yao Xingtao via
2024-07-19 7:16 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 2+ messages in thread
From: Yao Xingtao via @ 2024-07-19 1:28 UTC (permalink / raw)
To: jonathan.cameron, fan.ni
Cc: qemu-devel, Yao Xingtao, Jonathan Cameron, Peter Maydell
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 added region, b is an existing region, and b is a
subregion of a)
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huwei.com>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
---
V1[1] -> V2:
- Use ranges_overlap() to improve code readability
- Replace the ASCII extended graph to ASCII basic in comment.
[1] https://lore.kernel.org/qemu-devel/20240718090753.59163-1-yaoxt.fnst@fujitsu.com
---
hw/mem/cxl_type3.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c
index 35ac59883a5b..b2f3e2090b57 100644
--- a/hw/mem/cxl_type3.c
+++ b/hw/mem/cxl_type3.c
@@ -1331,9 +1331,7 @@ void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length,
ct3d = CXL_TYPE3(obj);
QLIST_FOREACH(p, &ct3d->poison_list, node) {
- if (((start >= p->start) && (start < p->start + p->length)) ||
- ((start + length > p->start) &&
- (start + length <= p->start + p->length))) {
+ if (ranges_overlap(start, length, p->start, p->length)) {
error_setg(errp,
"Overlap with existing poisoned region not supported");
return;
--
2.37.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] mem/cxl_type3: Fix overlapping region validation error
2024-07-19 1:28 [PATCH v2] mem/cxl_type3: Fix overlapping region validation error Yao Xingtao via
@ 2024-07-19 7:16 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-19 7:16 UTC (permalink / raw)
To: Yao Xingtao, jonathan.cameron, fan.ni
Cc: qemu-devel, Jonathan Cameron, Peter Maydell
On 19/7/24 03:28, Yao Xingtao via wrote:
> 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 added region, b is an existing region, and b is a
> subregion of a)
>
Cc: qemu-stable@nongnu.org
Fixes: 9547754f40 ("hw/cxl: QMP based poison injection support")
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huwei.com>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
>
> ---
> V1[1] -> V2:
> - Use ranges_overlap() to improve code readability
> - Replace the ASCII extended graph to ASCII basic in comment.
>
> [1] https://lore.kernel.org/qemu-devel/20240718090753.59163-1-yaoxt.fnst@fujitsu.com
> ---
> hw/mem/cxl_type3.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-19 7:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-19 1:28 [PATCH v2] mem/cxl_type3: Fix overlapping region validation error Yao Xingtao via
2024-07-19 7:16 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).