From: "Michael S. Tsirkin" <mst@redhat.com>
To: Feng Sun <loyou85@gmail.com>
Cc: Igor Mammedov <imammedo@redhat.com>,
qemu-devel@nongnu.org, ani@anisinha.ca
Subject: Re: [PATCH] acpi: Set maximum size to 64k for "etc/acpi/rsdp" blob
Date: Mon, 30 Jan 2023 10:07:31 -0500 [thread overview]
Message-ID: <20230130100531-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAAiCvkiFL7PWYSF24YxaOvu_v2fFfaWkuaQgUBr_9AFwsxHOrQ@mail.gmail.com>
On Mon, Jan 30, 2023 at 10:47:25PM +0800, Feng Sun wrote:
> Igor Mammedov <imammedo@redhat.com> 于2023年1月24日周二 18:30写道:
> >
> > On Tue, 17 Jan 2023 19:15:21 +0800
> > Sun Feng <loyou85@gmail.com> wrote:
> >
> > > Migrate from aarch64 host with PAGE_SIZE 64k to 4k failed with following errors:
> > >
> > > qmp_cmd_name: migrate-incoming, arguments: {"uri": "tcp:[::]:49152"}
> > > {"timestamp": {"seconds": 1673922775, "microseconds": 534702}, "event": "MIGRATION", "data": {"status": "setup"}}
> > > {"timestamp": {"seconds": 1673922776, "microseconds": 53003}, "event": "MIGRATION", "data": {"status": "active"}}
> > > 2023-01-17T02:32:56.058827Z qemu-system-aarch64: Length too large: /rom@etc/acpi/rsdp: 0x10000 > 0x1000: Invalid argument
> >
> > this should mention/explain why it's happening.
> >
> > i.e we now have 4k limit for RSDP, but then source somehow managed to start with 64k
> > allocated to for RSDP. It looks like limit isn't working as expected to me.
>
> 4k limit should be romsize limit. I can see Rom '/rom@etc/acpi/rsdp'
> with romsize:4096, datasize:36.
> RAMBlock's used_length is set with datasize aligned to PAGE_SIZE, so
> it become 64k when PAGE_SIZE is 64k.
> ```
> static
> RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
> void (*resized)(const char*,
> uint64_t length,
> void *host),
> void *host, uint32_t ram_flags,
> MemoryRegion *mr, Error **errp)
> {
> RAMBlock *new_block;
> Error *local_err = NULL;
>
> assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC |
> RAM_NORESERVE)) == 0);
> assert(!host ^ (ram_flags & RAM_PREALLOC));
>
> size = HOST_PAGE_ALIGN(size);
> max_size = HOST_PAGE_ALIGN(max_size);
> new_block = g_malloc0(sizeof(*new_block));
> new_block->mr = mr;
> new_block->resized = resized;
> new_block->used_length = size;
> ```
> So when migrate to 4k PAGE_SIZE, it will report the errors.
>
> ramblock information for PAGE_SIZE 64k and 4k.
> ```
> # getconf PAGE_SIZE
> 65536
> # virsh qemu-monitor-command testvm --hmp 'info ramblock'
> Block Name PSize Offset
> Used Total
> mach-virt.ram 64 KiB 0x0000000000000000
> 0x0000000040000000 0x0000000040000000
> virt.flash0 64 KiB 0x0000000040000000
> 0x0000000004000000 0x0000000004000000
> virt.flash1 64 KiB 0x0000000044000000
> 0x0000000004000000 0x0000000004000000
> /rom@etc/acpi/tables 64 KiB 0x0000000048040000
> 0x0000000000020000 0x0000000000200000
> 0000:00:01.2:00.0/virtio-net-pci.rom 64 KiB 0x0000000048000000
> 0x0000000000040000 0x0000000000040000
> /rom@etc/table-loader 64 KiB 0x0000000048240000
> 0x0000000000010000 0x0000000000010000
> /rom@etc/acpi/rsdp 64 KiB 0x0000000048280000
> 0x0000000000010000 0x0000000000010000
>
> # getconf PAGE_SIZE
> 4096
> # virsh qemu-monitor-command testvm --hmp 'info ramblock'
> Block Name PSize Offset
> Used Total
> mach-virt.ram 4 KiB 0x0000000000000000
> 0x0000000800000000 0x0000000800000000
> virt.flash0 4 KiB 0x0000000800000000
> 0x0000000004000000 0x0000000004000000
> virt.flash1 4 KiB 0x0000000804000000
> 0x0000000004000000 0x0000000004000000
> /rom@etc/acpi/tables 4 KiB 0x0000000808000000
> 0x0000000000020000 0x0000000000200000
> /rom@etc/table-loader 4 KiB 0x0000000808200000
> 0x0000000000001000 0x0000000000010000
> /rom@etc/acpi/rsdp 4 KiB 0x0000000808240000
> 0x0000000000001000 0x0000000000001000
> ```
Oh interesting. I don't remember why I decided to align in.
What does the following do (warning: completely untested):
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index cb998cdf23..5c732101b9 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -2154,7 +2154,7 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
RAM_NORESERVE)) == 0);
assert(!host ^ (ram_flags & RAM_PREALLOC));
- size = HOST_PAGE_ALIGN(size);
+ // size = HOST_PAGE_ALIGN(size);
max_size = HOST_PAGE_ALIGN(max_size);
new_block = g_malloc0(sizeof(*new_block));
new_block->mr = mr;
next prev parent reply other threads:[~2023-01-30 15:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 11:15 [PATCH] acpi: Set maximum size to 64k for "etc/acpi/rsdp" blob Sun Feng
2023-01-24 10:30 ` Igor Mammedov
2023-01-30 14:47 ` Feng Sun
2023-01-30 15:07 ` Michael S. Tsirkin [this message]
2023-01-31 9:17 ` Feng Sun
2025-05-06 7:08 ` Dongli Zhang
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=20230130100531-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=ani@anisinha.ca \
--cc=imammedo@redhat.com \
--cc=loyou85@gmail.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.