All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Andrew Jeffery <andrew@aj.id.au>,
	mark.burton@greensocs.com,
	QEMU Developers <qemu-devel@nongnu.org>,
	qemu-arm <qemu-arm@nongnu.org>,
	"mar.krzeminski" <mar.krzeminski@gmail.com>,
	fred.konrad@greensocs.com
Subject: Re: [Qemu-arm] [PATCH 4/7] m25p80: add a m25p80_set_rom_storage() routine
Date: Sat, 24 Sep 2016 10:55:05 +0200	[thread overview]
Message-ID: <20160924085505.GA5931@toto> (raw)
In-Reply-To: <723852a7-a5ab-9acb-cea9-4a5637b8eada@kaod.org>

On Sat, Sep 24, 2016 at 10:25:39AM +0200, Cédric Le Goater wrote:
> On 09/23/2016 08:26 PM, mar.krzeminski wrote:
> > Hi Cedric,
> > 
> > W dniu 23.09.2016 o 10:28, Cédric Le Goater pisze:
> >> On 09/23/2016 10:17 AM, Peter Maydell wrote:
> >>> On 23 September 2016 at 08:19, Cédric Le Goater <clg@kaod.org> wrote:
> >>>> But the goal is to boot from the device, so I added a memory region alias
> >>>> at 0 to trigger the flash module mmios at boot time, as this is where
> >>>> u-boot expects to be.
> >>>>
> >>>> and I fell in this trap :/
> >>>>
> >>>>          aspeed_smc_flash_read: To 0x0 of size 1: 0xbe mode:0
> >>>>          Bad ram pointer (nil)
> >>>>          Aborted (core dumped)
> >>>>
> >>>> There is a failure in get_page_addr_code(), possibly because qemu uses
> >>>> byte per byte reads of the code (cpu_ldub_code). But this is beyond my
> >>>> understanding of qemu's internal.
> >>> This is a bug in how we report the problem, but the underlying
> >>> issue here is attempting to execute from something that's not RAM
> >>> or ROM. You can't execute code out of something backed by MMIO.
> >> OK. So I see two solutions. T
> >>
> >> The "brutal" one which is to copy the flash contents in a rom blob
> >> at 0, but there is still an issue in getting access to the storage
> >> anyhow, as it is internal to m25p80. Or we should get the name of the
> >> backing file of the drive but I am not sure we are expected to do
> >> that as I don't see any API for it.
> >>
> >> The other solution is something like this patch which lets the storage
> >> of the flash device be assigned externally.
> > Since I do not like dirty hacks in the code, I want just to suggest a 
> > workaround, that probably you will not like ;]
> 
> It's a feature ! :)

CC: Mark and Fred

I agree, I think these are fair attempts to try to solve a real problem.


> I am just trying to find a solution to this issue. So, we could also 
> introduce a routine :
> 
> +uint8_t *m25p80_get_storage(DeviceState *dev, uint32_t *size)
> +{
> +    Flash *s = M25P80(dev);
> +
> +    *size = s->size;
> +    return s->storage;
> +}
> 
> and use rom_add_blob_fixed() with the return values. Maybe this is less 
> intrusive in the m25p80 device model flow. Thoughts ? 
> 
> > As Qemu expects that first running code will be in ROM or RAM memory,
> > you can implement in your board -bios option that you will use to
> > pass u-boot binary to rom memory, or even use generic loader functionality
> > when it reach master.
> 
> but if we use -bios <file> to have a ROM, we will need to pass a second 
> time <file> as a drive to have a CS0 flash slave: 
> 
> 	-bios "flash-palmetto-test"  \
> 	-drive file="flash-palmetto-test",format=raw,if=mtd \
> 	-drive file="palmetto.pnor",format=raw,if=mtd
> 
> This feels awkward. The virt platform and vexpress forbid that for 
> instance.
> 
> Are there any other platform with similar need ? 

Yes, ZynqMP has a linear memory mapping of SPI memory contents. It gets
slightly more complicated there as the mapping supports various modes
including parallel SPIs with striping done by the controller (i.e
bytes as seen via the linearly mapped area are interleaved from multiple
SPI memories).

So a plain RAM mapping of m25p80_get_storage won't work.

A ROM version of the linear data might work at controller level. The controller
would have to populate the ROM area at startup (slow) and keep it in sync for all
writes. We would also need to signal write events so that TCG can flush it's
caches. TCG only keeps track of modifications being made to cached code if changes
are done with writes to RAM area (not if they happen indirectly via other registers).

Another solution is to implement support in TCG to execute from MMIO mapped areas.
We'd also need to solve the problem of signalling content changes to TCG.

I think these approaches have some overlap. Personally, I think TCG executing from
MMIO areas would be quite useful. It's also useful for QEMU & SystemC integration.

Best regards,
Edgar

WARNING: multiple messages have this Message-ID (diff)
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: "mar.krzeminski" <mar.krzeminski@gmail.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Andrew Jeffery <andrew@aj.id.au>, qemu-arm <qemu-arm@nongnu.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	mark.burton@greensocs.com, fred.konrad@greensocs.com
Subject: Re: [Qemu-devel] [Qemu-arm] [PATCH 4/7] m25p80: add a m25p80_set_rom_storage() routine
Date: Sat, 24 Sep 2016 10:55:05 +0200	[thread overview]
Message-ID: <20160924085505.GA5931@toto> (raw)
In-Reply-To: <723852a7-a5ab-9acb-cea9-4a5637b8eada@kaod.org>

On Sat, Sep 24, 2016 at 10:25:39AM +0200, Cédric Le Goater wrote:
> On 09/23/2016 08:26 PM, mar.krzeminski wrote:
> > Hi Cedric,
> > 
> > W dniu 23.09.2016 o 10:28, Cédric Le Goater pisze:
> >> On 09/23/2016 10:17 AM, Peter Maydell wrote:
> >>> On 23 September 2016 at 08:19, Cédric Le Goater <clg@kaod.org> wrote:
> >>>> But the goal is to boot from the device, so I added a memory region alias
> >>>> at 0 to trigger the flash module mmios at boot time, as this is where
> >>>> u-boot expects to be.
> >>>>
> >>>> and I fell in this trap :/
> >>>>
> >>>>          aspeed_smc_flash_read: To 0x0 of size 1: 0xbe mode:0
> >>>>          Bad ram pointer (nil)
> >>>>          Aborted (core dumped)
> >>>>
> >>>> There is a failure in get_page_addr_code(), possibly because qemu uses
> >>>> byte per byte reads of the code (cpu_ldub_code). But this is beyond my
> >>>> understanding of qemu's internal.
> >>> This is a bug in how we report the problem, but the underlying
> >>> issue here is attempting to execute from something that's not RAM
> >>> or ROM. You can't execute code out of something backed by MMIO.
> >> OK. So I see two solutions. T
> >>
> >> The "brutal" one which is to copy the flash contents in a rom blob
> >> at 0, but there is still an issue in getting access to the storage
> >> anyhow, as it is internal to m25p80. Or we should get the name of the
> >> backing file of the drive but I am not sure we are expected to do
> >> that as I don't see any API for it.
> >>
> >> The other solution is something like this patch which lets the storage
> >> of the flash device be assigned externally.
> > Since I do not like dirty hacks in the code, I want just to suggest a 
> > workaround, that probably you will not like ;]
> 
> It's a feature ! :)

CC: Mark and Fred

I agree, I think these are fair attempts to try to solve a real problem.


> I am just trying to find a solution to this issue. So, we could also 
> introduce a routine :
> 
> +uint8_t *m25p80_get_storage(DeviceState *dev, uint32_t *size)
> +{
> +    Flash *s = M25P80(dev);
> +
> +    *size = s->size;
> +    return s->storage;
> +}
> 
> and use rom_add_blob_fixed() with the return values. Maybe this is less 
> intrusive in the m25p80 device model flow. Thoughts ? 
> 
> > As Qemu expects that first running code will be in ROM or RAM memory,
> > you can implement in your board -bios option that you will use to
> > pass u-boot binary to rom memory, or even use generic loader functionality
> > when it reach master.
> 
> but if we use -bios <file> to have a ROM, we will need to pass a second 
> time <file> as a drive to have a CS0 flash slave: 
> 
> 	-bios "flash-palmetto-test"  \
> 	-drive file="flash-palmetto-test",format=raw,if=mtd \
> 	-drive file="palmetto.pnor",format=raw,if=mtd
> 
> This feels awkward. The virt platform and vexpress forbid that for 
> instance.
> 
> Are there any other platform with similar need ? 

Yes, ZynqMP has a linear memory mapping of SPI memory contents. It gets
slightly more complicated there as the mapping supports various modes
including parallel SPIs with striping done by the controller (i.e
bytes as seen via the linearly mapped area are interleaved from multiple
SPI memories).

So a plain RAM mapping of m25p80_get_storage won't work.

A ROM version of the linear data might work at controller level. The controller
would have to populate the ROM area at startup (slow) and keep it in sync for all
writes. We would also need to signal write events so that TCG can flush it's
caches. TCG only keeps track of modifications being made to cached code if changes
are done with writes to RAM area (not if they happen indirectly via other registers).

Another solution is to implement support in TCG to execute from MMIO mapped areas.
We'd also need to solve the problem of signalling content changes to TCG.

I think these approaches have some overlap. Personally, I think TCG executing from
MMIO areas would be quite useful. It's also useful for QEMU & SystemC integration.

Best regards,
Edgar

  reply	other threads:[~2016-09-24  8:56 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04 12:18 [Qemu-arm] [PATCH 0/7] ast2400: U-boot support Cédric Le Goater
2016-07-04 12:18 ` [Qemu-devel] " Cédric Le Goater
2016-07-04 12:18 ` [Qemu-devel] [PATCH 1/7] tests: add a m25p80 test Cédric Le Goater
2016-07-04 12:18   ` Cédric Le Goater
2016-07-04 12:24   ` [Qemu-arm] " Peter Maydell
2016-07-04 12:24     ` [Qemu-devel] " Peter Maydell
2016-07-04 12:39     ` Cédric Le Goater
2016-07-04 12:39       ` Cédric Le Goater
2016-07-04 12:51       ` [Qemu-arm] " Peter Maydell
2016-07-04 12:51         ` [Qemu-devel] " Peter Maydell
2016-07-04 13:08         ` Cédric Le Goater
2016-07-04 13:08           ` Cédric Le Goater
2016-07-04 12:18 ` [Qemu-devel] [PATCH 2/7] m25p80: add mx25l25635f chip Cédric Le Goater
2016-07-04 12:18   ` Cédric Le Goater
2016-07-04 12:57   ` Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-07-04 13:41     ` Cédric Le Goater
2016-07-04 15:23       ` [Qemu-devel] Odp.: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-07-04 15:48         ` [Qemu-arm] Odp.: [Qemu-devel] " Cédric Le Goater
2016-07-04 15:48           ` [Qemu-devel] Odp.: " Cédric Le Goater
2016-07-04 16:03           ` [Qemu-arm] Odp.: Odp.: [Qemu-devel] " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-07-04 16:03             ` [Qemu-devel] Odp.: Odp.: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-07-04 16:18             ` Cédric Le Goater
2016-07-04 12:18 ` [Qemu-arm] [PATCH 3/7] ast2400: use a " Cédric Le Goater
2016-07-04 12:18   ` [Qemu-devel] " Cédric Le Goater
2016-07-04 12:18 ` [Qemu-arm] [PATCH 4/7] m25p80: add a m25p80_set_rom_storage() routine Cédric Le Goater
2016-07-04 12:18   ` [Qemu-devel] " Cédric Le Goater
2016-07-04 17:57   ` [Qemu-arm] " mar.krzeminski
2016-07-04 17:57     ` [Qemu-devel] " mar.krzeminski
2016-07-04 18:12     ` [Qemu-arm] " Cédric Le Goater
2016-07-04 18:12       ` [Qemu-devel] " Cédric Le Goater
2016-07-04 18:42       ` [Qemu-arm] " mar.krzeminski
2016-07-04 18:42         ` [Qemu-devel] " mar.krzeminski
2016-07-06 16:30       ` Cédric Le Goater
2016-07-06 16:30         ` Cédric Le Goater
2016-07-06 17:44         ` [Qemu-arm] " mar.krzeminski
2016-07-06 17:44           ` [Qemu-devel] " mar.krzeminski
2016-07-09 23:38     ` Peter Crosthwaite
2016-07-09 23:38       ` Peter Crosthwaite
2016-07-11 16:37       ` [Qemu-arm] " Cédric Le Goater
2016-07-11 16:37         ` [Qemu-devel] " Cédric Le Goater
2016-09-23  7:19     ` [Qemu-arm] " Cédric Le Goater
2016-09-23  7:19       ` [Qemu-devel] " Cédric Le Goater
2016-09-23  8:17       ` [Qemu-arm] " Peter Maydell
2016-09-23  8:17         ` [Qemu-devel] " Peter Maydell
2016-09-23  8:28         ` Cédric Le Goater
2016-09-23  8:28           ` Cédric Le Goater
2016-09-23 18:26           ` [Qemu-arm] " mar.krzeminski
2016-09-23 18:26             ` [Qemu-devel] " mar.krzeminski
2016-09-24  8:25             ` [Qemu-arm] " Cédric Le Goater
2016-09-24  8:25               ` [Qemu-devel] " Cédric Le Goater
2016-09-24  8:55               ` Edgar E. Iglesias [this message]
2016-09-24  8:55                 ` [Qemu-devel] [Qemu-arm] " Edgar E. Iglesias
2016-09-26  8:25                 ` [Qemu-arm] [Qemu-devel] " KONRAD Frederic
2016-09-26  8:25                   ` [Qemu-devel] [Qemu-arm] " KONRAD Frederic
2016-09-26  8:56                   ` [Qemu-arm] [Qemu-devel] " Cédric Le Goater
2016-09-26  8:56                     ` [Qemu-devel] [Qemu-arm] " Cédric Le Goater
2016-09-26 21:25                     ` [Qemu-arm] [Qemu-devel] " mar.krzeminski
2016-09-26 21:25                       ` [Qemu-devel] [Qemu-arm] " mar.krzeminski
2016-07-04 12:18 ` [Qemu-devel] [PATCH 5/7] ast2400: handle SPI flash Command mode (read only) Cédric Le Goater
2016-07-04 12:18   ` Cédric Le Goater
2016-07-04 12:18 ` [Qemu-arm] [PATCH 6/7] ast2400: use contents of first SPI flash as a rom Cédric Le Goater
2016-07-04 12:18   ` [Qemu-devel] " Cédric Le Goater
2016-07-04 14:58   ` Cédric Le Goater
2016-07-04 14:58     ` Cédric Le Goater
2016-07-04 12:18 ` [Qemu-devel] [PATCH 7/7] ast2400: add a memory controller device model Cédric Le Goater
2016-07-04 12:18   ` Cédric Le Goater
2016-07-06  4:34   ` [Qemu-arm] " Andrew Jeffery
2016-07-06  4:34     ` [Qemu-devel] " Andrew Jeffery
2016-07-06  6:51     ` Cédric Le Goater
2016-07-06  6:51       ` Cédric Le Goater

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=20160924085505.GA5931@toto \
    --to=edgar.iglesias@gmail.com \
    --cc=andrew@aj.id.au \
    --cc=clg@kaod.org \
    --cc=fred.konrad@greensocs.com \
    --cc=mar.krzeminski@gmail.com \
    --cc=mark.burton@greensocs.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.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 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.