From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
qemu-devel@nongnu.org, qemu-arm@nongnu.org,
eric.auger@redhat.com, imammedo@redhat.com
Cc: peter.maydell@linaro.org, xiaoguangrong.eric@gmail.com,
mst@redhat.com, david@redhat.com, dgilbert@redhat.com,
xuwei5@hisilicon.com, linuxarm@huawei.com,
shannon.zhaosl@gmail.com, lersek@redhat.com
Subject: Re: [PATCH for-5.0 v2 3/3] exec: Fix for qemu_ram_resize() callback
Date: Fri, 3 Apr 2020 12:50:11 +0200 [thread overview]
Message-ID: <a350c04a-786d-639c-6754-024fc10e92b6@redhat.com> (raw)
In-Reply-To: <20200403101827.30664-4-shameerali.kolothum.thodi@huawei.com>
On 4/3/20 12:18 PM, Shameer Kolothum wrote:
> From: David Hildenbrand <david@redhat.com>
>
> Summarizing the issue:
> 1. Memory regions contain ram blocks with a different size, if the
> size is not properly aligned. While memory regions can have an
> unaligned size, ram blocks can't. This is true when creating
> resizable memory region with an unaligned size.
> 2. When resizing a ram block/memory region, the size of the memory
> region is set to the aligned size. The callback is called with
> the aligned size. The unaligned piece is lost.
>
> Because of the above, if ACPI blob length modifications happens
> after the initial virt_acpi_build() call, and the changed blob
> length is within the PAGE size boundary, then the revised size
> is not seen by the firmware on Guest reboot.
>
> Hence make sure callback is called if memory region size is changed,
> irrespective of aligned or not.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> [Shameer: added commit log]
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> Please find previous discussion here,
> https://patchwork.kernel.org/patch/11432375/#23216751
> ---
> exec.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/exec.c b/exec.c
> index de9d949902..2874bb5088 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -2074,11 +2074,23 @@ static int memory_try_enable_merging(void *addr, size_t len)
> */
> int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
> {
> + const ram_addr_t unaligned_size = newsize;
> +
> assert(block);
>
> newsize = HOST_PAGE_ALIGN(newsize);
>
> if (block->used_length == newsize) {
> + /*
> + * We don't have to resize the ram block (which only knows aligned
> + * sizes), however, we have to notify if the unaligned size changed.
> + */
> + if (unaligned_size != memory_region_size(block->mr)) {
> + memory_region_set_size(block->mr, unaligned_size);
> + if (block->resized) {
> + block->resized(block->idstr, unaligned_size, block->host);
> + }
> + }
> return 0;
> }
>
> @@ -2102,9 +2114,9 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
> block->used_length = newsize;
> cpu_physical_memory_set_dirty_range(block->offset, block->used_length,
> DIRTY_CLIENTS_ALL);
> - memory_region_set_size(block->mr, newsize);
> + memory_region_set_size(block->mr, unaligned_size);
> if (block->resized) {
> - block->resized(block->idstr, newsize, block->host);
> + block->resized(block->idstr, unaligned_size, block->host);
> }
> return 0;
> }
>
next prev parent reply other threads:[~2020-04-03 10:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-03 10:18 [PATCH for-5.0 v2 0/3] acpi: Fixes for inconsistency in ACPI MR size during migration Shameer Kolothum
2020-04-03 10:18 ` [PATCH for-5.0 v2 1/3] acpi: Use macro for table-loader file name Shameer Kolothum
2020-04-03 10:45 ` Philippe Mathieu-Daudé
2020-04-03 10:18 ` [PATCH for-5.0 v2 2/3] fw_cfg: Migrate ACPI table mr sizes separately Shameer Kolothum
2020-04-07 14:17 ` Philippe Mathieu-Daudé
2020-04-07 14:34 ` Michael S. Tsirkin
2020-04-07 14:54 ` David Hildenbrand
2020-04-07 17:03 ` Philippe Mathieu-Daudé
2020-04-03 10:18 ` [PATCH for-5.0 v2 3/3] exec: Fix for qemu_ram_resize() callback Shameer Kolothum
2020-04-03 10:50 ` Philippe Mathieu-Daudé [this message]
2020-04-03 12:37 ` [PATCH for-5.0 v2 0/3] acpi: Fixes for inconsistency in ACPI MR size during migration 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=a350c04a-786d-639c-6754-024fc10e92b6@redhat.com \
--to=philmd@redhat.com \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eric.auger@redhat.com \
--cc=imammedo@redhat.com \
--cc=lersek@redhat.com \
--cc=linuxarm@huawei.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shannon.zhaosl@gmail.com \
--cc=xiaoguangrong.eric@gmail.com \
--cc=xuwei5@hisilicon.com \
/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).