From: Peter Maydell <peter.maydell@linaro.org>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
qiaonuohan@cn.fujitsu.com, David Hildenbrand <david@redhat.com>,
Stefan Berger <stefanb@linux.vnet.ibm.com>
Subject: Re: [PATCH 2/2] dump: fix kdump to work over non-aligned blocks
Date: Thu, 25 Aug 2022 14:34:16 +0100 [thread overview]
Message-ID: <CAFEAcA-ZNFka26CDoPEvUROkt9UpFvmZXN5rTSt7MYJjtzdhHg@mail.gmail.com> (raw)
In-Reply-To: <20220825132110.1500330-3-marcandre.lureau@redhat.com>
On Thu, 25 Aug 2022 at 14:21, <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Rewrite get_next_page() to work over non-aligned blocks. When it
> encounters non aligned addresses, it will allocate a zero-page and try
> to fill it.
>
> This solves a kdump crash with "tpm-crb-cmd" RAM memory region,
> qemu-kvm: ../dump/dump.c:1162: _Bool get_next_page(GuestPhysBlock **,
> uint64_t *, uint8_t **, DumpState *): Assertion `(block->target_start &
> ~target_page_mask) == 0' failed.
>
> because:
> guest_phys_block_add_section: target_start=00000000fed40080 target_end=00000000fed41000: added (count: 4)
>
> Fixes:
> https://bugzilla.redhat.com/show_bug.cgi?id=2120480
> static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
> - uint8_t **bufptr, DumpState *s)
> + uint8_t **bufptr, bool *allocptr, DumpState *s)
> {
> GuestPhysBlock *block = *blockptr;
> - hwaddr addr, target_page_mask = ~((hwaddr)s->dump_info.page_size - 1);
In the old code, we treated the dump_info.page size as an indication
of the target's page size...
> - uint8_t *buf;
> + uint32_t page_size = s->dump_info.page_size;
> + bool alloced = false;
> + uint8_t *buf = NULL, *hbuf;
> + hwaddr addr;
>
> /* block == NULL means the start of the iteration */
> if (block == NULL) {
> *blockptr = block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
> addr = block->target_start;
> + *pfnptr = dump_paddr_to_pfn(s, addr);
> } else {
> - addr = dump_pfn_to_paddr(s, *pfnptr + 1);
> + assert(block != NULL);
> + *pfnptr += 1;
> + addr = dump_pfn_to_paddr(s, *pfnptr);
> }
> assert(block != NULL);
>
> - if ((addr >= block->target_start) &&
> - (addr + s->dump_info.page_size <= block->target_end)) {
> - buf = block->host_addr + (addr - block->target_start);
> - } else {
> - /* the next page is in the next block */
> - *blockptr = block = QTAILQ_NEXT(block, next);
> - if (!block) {
> - return false;
> + while (1) {
> + if (addr >= block->target_start && addr < block->target_end) {
> + size_t n = MIN(block->target_end - addr, page_size - addr % page_size);
> + hbuf = block->host_addr + (addr - block->target_start);
> + if (!alloced) {
> + if (n == page_size) {
> + /* this is a whole host page, go for it */
> + assert(addr % page_size == 0);
...but here we're claiming in this comment that it is the host's
page size.
Which is it ?
thanks
-- PMM
next prev parent reply other threads:[~2022-08-25 13:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 13:21 [PATCH 0/2] Fix dumping in kdump format with non-aligned memory marcandre.lureau
2022-08-25 13:21 ` [PATCH 1/2] dump: simplify a bit kdump get_next_page() marcandre.lureau
2022-08-26 9:45 ` David Hildenbrand
2022-08-26 9:56 ` Marc-André Lureau
2022-08-26 9:58 ` David Hildenbrand
2022-08-25 13:21 ` [PATCH 2/2] dump: fix kdump to work over non-aligned blocks marcandre.lureau
2022-08-25 13:34 ` Peter Maydell [this message]
2022-08-25 13:38 ` Marc-André Lureau
2022-08-26 9:57 ` David Hildenbrand
2022-08-26 10:02 ` Marc-André Lureau
2022-08-26 10:07 ` David Hildenbrand
2022-08-26 10:10 ` David Hildenbrand
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=CAFEAcA-ZNFka26CDoPEvUROkt9UpFvmZXN5rTSt7MYJjtzdhHg@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=david@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qiaonuohan@cn.fujitsu.com \
--cc=stefanb@linux.vnet.ibm.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).