qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Any reason we need memoryregionsection
@ 2021-02-22 14:55 沈梦姣
  2021-02-22 17:11 ` Peter Xu
  0 siblings, 1 reply; 3+ messages in thread
From: 沈梦姣 @ 2021-02-22 14:55 UTC (permalink / raw)
  To: QEMU Developers, qemu-discuss

Usually when we add memory region in the platform init process, the corresponding address range in address space will not overlap with others, I’m not sure in which case we should use MemoryRegionSection? Thanks 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Any reason we need memoryregionsection
  2021-02-22 14:55 Any reason we need memoryregionsection 沈梦姣
@ 2021-02-22 17:11 ` Peter Xu
  2021-02-22 17:22   ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Xu @ 2021-02-22 17:11 UTC (permalink / raw)
  To: 沈梦姣; +Cc: QEMU Developers, qemu-discuss

On Mon, Feb 22, 2021 at 10:55:15PM +0800, 沈梦姣 wrote:
> Usually when we add memory region in the platform init process, the corresponding address range in address space will not overlap with others, I’m not sure in which case we should use MemoryRegionSection? Thanks 
> 

Memory regions can overlap, see memory_region_add_subregion_overlap() and the
comment above its definition.  memory_region_add_subregion() is actually
similar to that, but just set the MR priority to zero as default.

IMHO MemoryRegion is the major abstraction layer of the address range in QEMU
along with the bigger AddressSpace idea, while MemoryRegionSection is mostly
used as a temporarly variable to describe part of a MemoryRegion in many
contexts, so that this partial range information can be further consumed by
callers of a lot of memory APIs.

Feel free to have a look at commit 2177955a89 ("memory: introduce
memory_region_find()", 2011-12-20) too - that should be the place where
MemoryRegionSection is firstly introduced.

Thanks,

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Any reason we need memoryregionsection
  2021-02-22 17:11 ` Peter Xu
@ 2021-02-22 17:22   ` Peter Maydell
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2021-02-22 17:22 UTC (permalink / raw)
  To: Peter Xu; +Cc: qemu-discuss, QEMU Developers, 沈梦姣

On Mon, 22 Feb 2021 at 17:19, Peter Xu <peterx@redhat.com> wrote:
>
> On Mon, Feb 22, 2021 at 10:55:15PM +0800, 沈梦姣 wrote:
> > Usually when we add memory region in the platform init process, the corresponding address range in address space will not overlap with others, I’m not sure in which case we should use MemoryRegionSection? Thanks
> >
>
> Memory regions can overlap, see memory_region_add_subregion_overlap() and the
> comment above its definition.  memory_region_add_subregion() is actually
> similar to that, but just set the MR priority to zero as default.
>
> IMHO MemoryRegion is the major abstraction layer of the address range in QEMU
> along with the bigger AddressSpace idea, while MemoryRegionSection is mostly
> used as a temporarly variable to describe part of a MemoryRegion in many
> contexts, so that this partial range information can be further consumed by
> callers of a lot of memory APIs.

Yes. You only really need to care about MemoryRegionSections if you're
using an API that deals with them (notably if you're working with a
MemoryListener, or if you're using memory_region_find()). Most code,
and in particular almost all device and board code, works with
MemoryRegions.

-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-22 17:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22 14:55 Any reason we need memoryregionsection 沈梦姣
2021-02-22 17:11 ` Peter Xu
2021-02-22 17:22   ` Peter Maydell

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).