From: Stefan Hajnoczi <stefanha@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Steffen Görtz" <mail@steffen-goertz.de>,
"Steffen Görtz" <contrib@steffen-goertz.de>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Joel Stanley" <joel@jms.id.au>,
"Jim Mussared" <jim@groklearning.com>,
"Julia Suvorova" <jusual@mail.ru>
Subject: Re: [Qemu-devel] [PATCH v5 05/14] hw/nvram/nrf51_nvm: Add nRF51 non-volatile memories
Date: Sun, 16 Dec 2018 06:20:24 +0000 [thread overview]
Message-ID: <20181216062024.GA6123@stefanha-x1.localdomain> (raw)
In-Reply-To: <CAFEAcA_Du4OTLqfNECY=BTvW089RTNu3qpxm2yv=iLL9g-m5qQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3226 bytes --]
On Mon, Nov 26, 2018 at 05:43:59PM +0000, Peter Maydell wrote:
> On Mon, 26 Nov 2018 at 00:24, Steffen Görtz <mail@steffen-goertz.de> wrote:
> >
> > Hi Peter,
> >
> > thank you for your remarks!
> >
> > >> +};
> > >> +
> > >> +static uint64_t ficr_read(void *opaque, hwaddr offset
> > >
> > >> + value &= ~(NRF51_PAGE_SIZE - 1);
> > >> + if (value < (s->flash_size - NRF51_PAGE_SIZE)) {
> > >> + memset(s->storage + value / 4, 0xFF, NRF51_PAGE_SIZE);
> > >
> > > Can the guest try to execute from the flash storage? If so
> > > then just updating the backing storage directly like this is
> > > not sufficient to ensure that QEMU discards any now-stale
> > > translated code blocks from the affected memory.
> >
> > What else is necessary to invalidate stale blocks?
>
> You need an AddressSpace that points to the MemoryRegion(s)
> you're altering, and you need to use the operations on
> the AddressSpace like address_space_write(). These will
> under the hood do the right thing with TB invalidation.
I'm not sure about this. The memory region looks like this:
{parent_obj = {class = 0x5555565ee350, free = 0x0, Python Exception <class 'gdb.error'> There is no member named keys.:
properties = 0x55555672f860, ref = 1, parent = 0x5555566620f0}, romd_mode = true, ram = false, subpage = false, readonly = false,
nonvolatile = false, rom_device = true, flush_coalesced_mmio = false, global_locking = true, dirty_log_mask = 0 '\000', is_iommu = false, ram_block = 0x555556768b40,
owner = 0x5555566620f0, ops = 0x55555615d360 <flash_ops>, opaque = 0x5555566620f0, container = 0x0, size = 262144, addr = 0, destructor = 0x555555893f00 <memory_region_destructor_ram>,
align = 2097152, terminates = true, ram_device = false, enabled = true, warning_printed = false, vga_logging_count = 0 '\000', alias = 0x0, alias_offset = 0, priority = 0, subregions = {
tqh_first = 0x0, tqh_last = 0x555556662778}, subregions_link = {tqe_next = 0x0, tqe_prev = 0x0}, coalesced = {tqh_first = 0x0, tqh_last = 0x555556662798},
name = 0x5555568033d0 "nrf51_soc.flash", ioeventfd_nb = 0, ioeventfds = 0x0}
I see nothing that invalidates TBs in the address_space_write() code for
MMIO memory regions (not RAM). Only the RAM case calls
invalidate_and_set_dirty().
There are a few complications with this device:
1. Stores from the CPU are only honored when the NRF51_NVMC_CONFIG_WEN
write enable bit is set. NRF51_NVMC_ERASEPCRx and
NRF51_NVMC_ERASEALL commands use a separate erase enable bit
(NRF51_NVMC_CONFIG_EEN) and are therefore different from normal
writes.
2. Stores from the CPU can only flip 1s to 0s (this is NOR flash). When
we erase a page of flash memory it must be set to 0xff (i.e. flip
0s to 1s).
3. nrf51_nvm.c:flash_write() does not mark the page dirty for live
migration.
My questions:
1. Is the current rom+mmio device approach okay or should it be modelled
differently?
2. Erase operations cannot use ordinary address_space_write() for the
reasons mentioned above. Should this device directly call
cpu_physical_memory_set_dirty_range() and tb_invalidate_phys_range()?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2018-12-16 6:20 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-12 21:42 [Qemu-devel] [PATCH v5 00/14] arm: nRF51 Devices and Microbit Support Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 01/14] qtest: Add set_irq_in command to set IRQ/GPIO level Steffen Görtz
2018-11-13 6:30 ` Thomas Huth
2018-11-13 9:38 ` Laurent Vivier
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 02/14] arm: Add header to host common definition for nRF51 SOC peripherals Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 03/14] hw/misc/nrf51_rng: Add NRF51 random number generator peripheral Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 04/14] arm: Instantiate NRF51 random number generator Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 05/14] hw/nvram/nrf51_nvm: Add nRF51 non-volatile memories Steffen Görtz
2018-11-16 16:24 ` Peter Maydell
2018-11-26 0:24 ` Steffen Görtz
2018-11-26 17:43 ` Peter Maydell
2018-12-16 6:20 ` Stefan Hajnoczi [this message]
2018-12-16 12:40 ` Peter Maydell
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 06/14] arm: Instantiate NRF51 special NVM's and NVMC Steffen Görtz
2018-11-16 16:25 ` Peter Maydell
2018-11-16 18:04 ` Stefan Hajnoczi
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 07/14] tests: Add bbc:microbit / nRF51 test suite Steffen Görtz
2018-11-13 6:40 ` Thomas Huth
2018-11-26 0:35 ` Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 08/14] hw/gpio/nrf51_gpio: Add nRF51 GPIO peripheral Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 09/14] arm: Instantiate NRF51 general purpose I/O Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 10/14] tests/microbit-test: Add Tests for nRF51 GPIO Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 11/14] hw/timer/nrf51_timer: Add nRF51 Timer peripheral Steffen Görtz
2018-11-16 16:37 ` Peter Maydell
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 12/14] arm: Instantiate NRF51 Timers Steffen Görtz
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 13/14] tests/microbit-test: Add Tests for nRF51 Timer Steffen Görtz
2018-11-16 18:19 ` Stefan Hajnoczi
2018-11-12 21:42 ` [Qemu-devel] [PATCH v5 14/14] arm: Add Clock peripheral stub to NRF51 SOC Steffen Görtz
2018-11-13 19:45 ` [Qemu-devel] [PATCH v5 00/14] arm: nRF51 Devices and Microbit Support no-reply
2018-11-13 19:55 ` no-reply
2018-11-16 16:07 ` Peter Maydell
2018-11-19 13:02 ` Stefan Hajnoczi
2018-11-20 18:01 ` Steffen Görtz
2018-12-16 6:22 ` Stefan Hajnoczi
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=20181216062024.GA6123@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=contrib@steffen-goertz.de \
--cc=jim@groklearning.com \
--cc=joel@jms.id.au \
--cc=jusual@mail.ru \
--cc=mail@steffen-goertz.de \
--cc=peter.maydell@linaro.org \
--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).