From: Igor Mammedov <imammedo@redhat.com>
To: Ani Sinha <ani@anisinha.ca>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v3 2/3] hw/smbios: fix table memory corruption with large memory vms
Date: Thu, 17 Feb 2022 09:54:30 +0100 [thread overview]
Message-ID: <20220217095430.38d2b6b7@redhat.com> (raw)
In-Reply-To: <20220214141237.47946-3-ani@anisinha.ca>
On Mon, 14 Feb 2022 19:42:35 +0530
Ani Sinha <ani@anisinha.ca> wrote:
> The current smbios table implementation splits the main memory in 16 GiB
> (DIMM like) chunks. With the current smbios table assignment code, we can have
> only 512 such chunks before the 16 bit handle numbers in the header for tables
> 17 and 19 conflict. A guest with more than 8 TiB of memory will hit this
> limitation and would fail with the following assertion in isa-debugcon:
>
> ASSERT_EFI_ERROR (Status = Already started)
> ASSERT /builddir/build/BUILD/edk2-ca407c7246bf/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c(125): !EFI_ERROR (Status)
>
> This change adds an additional offset between tables 17 and 19 handle numbers
> when configuring VMs larger than 8 TiB of memory. The value of the offset is
> calculated to be equal to the additional space required to be reserved
> in order to accomodate more DIMM entries without the table handles colliding.
> In normal cases where the VM memory is smaller or equal to 8 TiB, this offset
> value is 0. Hence in this case, no additional handle numbers are reserved and
> table handle values remain as before.
>
> As table handles are altered for large memory VMs, this change can break
> migration in those cases. However, in those situations, qemu crashes anyway
1. pls explain how migration breaks
2. it's not QEMU which crashes
> without this fix and hence we do not preserve the old bug by introducing
> compat knobs/machine types.
>
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2023977
s/buglink/Resolves/
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
with above fixed
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
> hw/smbios/smbios.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> changelog:
> v3: reworded the commit log and comment in code.
>
> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> index 56b412ce35..44c53797a4 100644
> --- a/hw/smbios/smbios.c
> +++ b/hw/smbios/smbios.c
> @@ -799,12 +799,13 @@ static void smbios_build_type_17_table(unsigned instance, uint64_t size)
> SMBIOS_BUILD_TABLE_POST;
> }
>
> -static void smbios_build_type_19_table(unsigned instance,
> +static void smbios_build_type_19_table(unsigned instance, unsigned offset,
> uint64_t start, uint64_t size)
> {
> uint64_t end, start_kb, end_kb;
>
> - SMBIOS_BUILD_TABLE_PRE(19, T19_BASE + instance, true); /* required */
> + SMBIOS_BUILD_TABLE_PRE(19, T19_BASE + offset + instance,
> + true); /* required */
>
> end = start + size - 1;
> assert(end > start);
> @@ -996,7 +997,7 @@ void smbios_get_tables(MachineState *ms,
> uint8_t **anchor, size_t *anchor_len,
> Error **errp)
> {
> - unsigned i, dimm_cnt;
> + unsigned i, dimm_cnt, offset;
>
> if (smbios_legacy) {
> *tables = *anchor = NULL;
> @@ -1026,6 +1027,16 @@ void smbios_get_tables(MachineState *ms,
>
> dimm_cnt = QEMU_ALIGN_UP(current_machine->ram_size, MAX_DIMM_SZ) / MAX_DIMM_SZ;
>
> + /*
> + * The offset determines if we need to keep additional space betweeen
> + * table 17 and table 19 header handle numbers so that they do
> + * not overlap. For example, for a VM with larger than 8 TB guest
> + * memory and DIMM like chunks of 16 GiB, the default space between
> + * the two tables (T19_BASE - T17_BASE = 512) is not enough.
> + */
> + offset = (dimm_cnt > (T19_BASE - T17_BASE)) ? \
> + dimm_cnt - (T19_BASE - T17_BASE) : 0;
> +
> smbios_build_type_16_table(dimm_cnt);
>
> for (i = 0; i < dimm_cnt; i++) {
> @@ -1033,7 +1044,7 @@ void smbios_get_tables(MachineState *ms,
> }
>
> for (i = 0; i < mem_array_size; i++) {
> - smbios_build_type_19_table(i, mem_array[i].address,
> + smbios_build_type_19_table(i, offset, mem_array[i].address,
> mem_array[i].length);
> }
>
next prev parent reply other threads:[~2022-02-17 9:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 14:12 [PATCH v3 0/3] hw/smbios: fix table memory corruption with large memory vms Ani Sinha
2022-02-14 14:12 ` [PATCH v3 1/3] hw/smbios: code cleanup - use macro definitions for table header handles Ani Sinha
2022-02-14 14:12 ` [PATCH v3 2/3] hw/smbios: fix table memory corruption with large memory vms Ani Sinha
2022-02-17 8:54 ` Igor Mammedov [this message]
2022-02-17 13:32 ` Ani Sinha
2022-02-21 7:12 ` Igor Mammedov
2022-02-14 14:12 ` [PATCH v3 3/3] hw/smbios: add assertion to ensure handles of tables 19 and 32 do not collide Ani Sinha
2022-02-17 8:56 ` Igor Mammedov
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=20220217095430.38d2b6b7@redhat.com \
--to=imammedo@redhat.com \
--cc=ani@anisinha.ca \
--cc=mst@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 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).