From: "Michael S. Tsirkin" <mst@redhat.com>
To: Anton Kuchin <antonkuchin@nebius.com>
Cc: qemu-devel@nongnu.org, Igor Mammedov <imammedo@redhat.com>,
Ani Sinha <anisinha@redhat.com>,
NB-CoreTeam@nebius.com
Subject: Re: [PATCH 1/2] hw/acpi/aml-build: Ignore used ranges outside the requested window
Date: Tue, 17 Nov 2026 07:28:11 -0500 [thread overview]
Message-ID: <20261117072730-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20261107-users-antonkuchin-to-send-fix-crs-replace-with-free-ranges-v1-1-0cede42456c4@nebius.com>
On Sat, Nov 07, 2026 at 12:59:48AM +0100, Anton Kuchin wrote:
> build_crs() collects used resources without any information about
> valid address windows. These resources can therefore lie outside
> the interval passed to crs_replace_with_free_ranges().
>
> crs_replace_with_free_ranges() assumed all used ranges lie within
> the interval. Ranges outside it could therefore produce free ranges
> extending below or above its bounds. As a result, the guest kernel
> may assign a device an invalid address range.
>
> Skip ranges with limit below the interval start or with base above
> the interval's end.
>
> Signed-off-by: Anton Kuchin <antonkuchin@nebius.com>
Given it's a bugfix, pls figure out when was the bug
introduced and include a Fixes: tag.
> ---
> hw/acpi/aml-build.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> index 990abc64cd8b..90837b513e69 100644
> --- a/hw/acpi/aml-build.c
> +++ b/hw/acpi/aml-build.c
> @@ -124,7 +124,7 @@ static gint crs_range_compare(gconstpointer a, gconstpointer b)
> }
>
> /*
> - * crs_replace_with_free_ranges - given the 'used' ranges within [start - end]
> + * crs_replace_with_free_ranges - given the 'used' ranges and [start - end]
> * interval, computes the 'free' ranges from the same interval.
> * Example: If the input array is { [a1 - a2],[b1 - b2] }, the function
> * will return { [base - a1], [a2 - b1], [b2 - limit] }.
> @@ -140,6 +140,16 @@ void crs_replace_with_free_ranges(GPtrArray *ranges,
> for (i = 0; i < ranges->len; i++) {
> CrsRangeEntry *used = g_ptr_array_index(ranges, i);
>
> + /* skip ranges below the window */
> + if (used->limit < free_base) {
> + continue;
> + }
> +
> + /* skip ranges above the window */
> + if (used->base > end) {
> + break;
> + }
> +
> if (free_base < used->base) {
> crs_range_insert(free_ranges, free_base, used->base - 1);
> }
>
> --
> 2.43.0
next prev parent reply other threads:[~2026-11-17 12:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 23:59 [PATCH 0/2] hw/acpi/aml-build: Fix free ranges calculation in crs_replace_with_free_ranges() Anton Kuchin
2026-11-06 23:59 ` [PATCH 1/2] hw/acpi/aml-build: Ignore used ranges outside the requested window Anton Kuchin
2026-11-17 12:19 ` Michael S. Tsirkin
2026-11-17 12:28 ` Michael S. Tsirkin [this message]
2026-11-06 23:59 ` [PATCH 2/2] hw/acpi/aml-build: Avoid overflow when advancing the free_base cursor Anton Kuchin
2026-11-17 12:20 ` Michael S. Tsirkin
2026-11-17 12:21 ` [PATCH 0/2] hw/acpi/aml-build: Fix free ranges calculation in crs_replace_with_free_ranges() Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117072730-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=NB-CoreTeam@nebius.com \
--cc=anisinha@redhat.com \
--cc=antonkuchin@nebius.com \
--cc=imammedo@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.