All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Xiang Zheng <zhengxiang9@huawei.com>
Cc: kwolf@redhat.com, peter.maydell@linaro.org,
	qemu-block@nongnu.org, ard.biesheuvel@linaro.org,
	qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com,
	guoheyi@huawei.com, wanghaibin.wang@huawei.com,
	lersek@redhat.com
Subject: Re: [Qemu-devel] [PATCH] pflash: Only read non-zero parts of backend image
Date: Tue, 07 May 2019 20:01:00 +0200	[thread overview]
Message-ID: <87a7fyb0v7.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20190505070059.4664-1-zhengxiang9@huawei.com> (Xiang Zheng's message of "Sun, 5 May 2019 15:00:59 +0800")

The subject is slightly misleading.  Holes read as zero.  So do
non-holes full of zeroes.  The patch avoids reading the former, but
still reads the latter.

Xiang Zheng <zhengxiang9@huawei.com> writes:

> Currently we fill the memory space with two 64MB NOR images when
> using persistent UEFI variables on virt board. Actually we only use
> a very small(non-zero) part of the memory while the rest significant
> large(zero) part of memory is wasted.

Neglects to mention that the "virt board" is ARM.

> So this patch checks the block status and only writes the non-zero part
> into memory. This requires pflash devices to use sparse files for
> backends.

I started to draft an improved commit message, but then I realized this
patch can't work.

The pflash_cfi01 device allocates its device memory like this:

    memory_region_init_rom_device(
        &pfl->mem, OBJECT(dev),
        &pflash_cfi01_ops,
        pfl,
        pfl->name, total_len, &local_err);

pflash_cfi02 is similar.

memory_region_init_rom_device() calls
memory_region_init_rom_device_nomigrate() calls qemu_ram_alloc() calls
qemu_ram_alloc_internal() calls g_malloc0().  Thus, all the device
memory gets written to even with this patch.

I'm afraid you neglected to test.

I still believe this approach can be made to work.  Need a replacement
for memory_region_init_rom_device() that uses mmap() with MAP_ANONYMOUS.


  parent reply	other threads:[~2019-05-07 18:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-05  7:00 [Qemu-devel] [PATCH] pflash: Only read non-zero parts of backend image Xiang Zheng
2019-05-05  7:00 ` Xiang Zheng
2019-05-05 15:37 ` Peter Maydell
2019-05-05 15:37   ` Peter Maydell
2019-05-06  2:51   ` Xiang Zheng
2019-05-07 18:01 ` Markus Armbruster [this message]
2019-05-07 19:03   ` Laszlo Ersek
2019-05-08 13:20     ` Markus Armbruster
2019-05-09  7:14       ` Xiang Zheng
2019-05-09 11:59         ` Markus Armbruster
2019-05-10 13:12           ` Xiang Zheng
2019-05-10 15:16             ` Markus Armbruster
2019-05-11  8:36               ` Xiang Zheng
2019-05-13 11:59                 ` Markus Armbruster
2019-05-13 13:15                   ` Kevin Wolf
2019-05-13 13:36                     ` Markus Armbruster

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=87a7fyb0v7.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=guoheyi@huawei.com \
    --cc=kwolf@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=zhengxiang9@huawei.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 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.