1859cdc01SPeter Maydell============== 2859cdc01SPeter MaydellThe memory API 3859cdc01SPeter Maydell============== 4859cdc01SPeter Maydell 5859cdc01SPeter MaydellThe memory API models the memory and I/O buses and controllers of a QEMU 6859cdc01SPeter Maydellmachine. It attempts to allow modelling of: 7859cdc01SPeter Maydell 8859cdc01SPeter Maydell- ordinary RAM 9859cdc01SPeter Maydell- memory-mapped I/O (MMIO) 10859cdc01SPeter Maydell- memory controllers that can dynamically reroute physical memory regions 11859cdc01SPeter Maydell to different destinations 12859cdc01SPeter Maydell 13859cdc01SPeter MaydellThe memory model provides support for 14859cdc01SPeter Maydell 15859cdc01SPeter Maydell- tracking RAM changes by the guest 16859cdc01SPeter Maydell- setting up coalesced memory for kvm 17859cdc01SPeter Maydell- setting up ioeventfd regions for kvm 18859cdc01SPeter Maydell 19859cdc01SPeter MaydellMemory is modelled as an acyclic graph of MemoryRegion objects. Sinks 20859cdc01SPeter Maydell(leaves) are RAM and MMIO regions, while other nodes represent 21859cdc01SPeter Maydellbuses, memory controllers, and memory regions that have been rerouted. 22859cdc01SPeter Maydell 23859cdc01SPeter MaydellIn addition to MemoryRegion objects, the memory API provides AddressSpace 24859cdc01SPeter Maydellobjects for every root and possibly for intermediate MemoryRegions too. 25859cdc01SPeter MaydellThese represent memory as seen from the CPU or a device's viewpoint. 26859cdc01SPeter Maydell 27859cdc01SPeter MaydellTypes of regions 28859cdc01SPeter Maydell---------------- 29859cdc01SPeter Maydell 30859cdc01SPeter MaydellThere are multiple types of memory regions (all represented by a single C type 31859cdc01SPeter MaydellMemoryRegion): 32859cdc01SPeter Maydell 33859cdc01SPeter Maydell- RAM: a RAM region is simply a range of host memory that can be made available 34859cdc01SPeter Maydell to the guest. 35859cdc01SPeter Maydell You typically initialize these with memory_region_init_ram(). Some special 36859cdc01SPeter Maydell purposes require the variants memory_region_init_resizeable_ram(), 37859cdc01SPeter Maydell memory_region_init_ram_from_file(), or memory_region_init_ram_ptr(). 38859cdc01SPeter Maydell 39859cdc01SPeter Maydell- MMIO: a range of guest memory that is implemented by host callbacks; 40859cdc01SPeter Maydell each read or write causes a callback to be called on the host. 41859cdc01SPeter Maydell You initialize these with memory_region_init_io(), passing it a 42859cdc01SPeter Maydell MemoryRegionOps structure describing the callbacks. 43859cdc01SPeter Maydell 44859cdc01SPeter Maydell- ROM: a ROM memory region works like RAM for reads (directly accessing 45859cdc01SPeter Maydell a region of host memory), and forbids writes. You initialize these with 46859cdc01SPeter Maydell memory_region_init_rom(). 47859cdc01SPeter Maydell 48859cdc01SPeter Maydell- ROM device: a ROM device memory region works like RAM for reads 49859cdc01SPeter Maydell (directly accessing a region of host memory), but like MMIO for 50859cdc01SPeter Maydell writes (invoking a callback). You initialize these with 51859cdc01SPeter Maydell memory_region_init_rom_device(). 52859cdc01SPeter Maydell 53859cdc01SPeter Maydell- IOMMU region: an IOMMU region translates addresses of accesses made to it 54859cdc01SPeter Maydell and forwards them to some other target memory region. As the name suggests, 55859cdc01SPeter Maydell these are only needed for modelling an IOMMU, not for simple devices. 56859cdc01SPeter Maydell You initialize these with memory_region_init_iommu(). 57859cdc01SPeter Maydell 58859cdc01SPeter Maydell- container: a container simply includes other memory regions, each at 59859cdc01SPeter Maydell a different offset. Containers are useful for grouping several regions 60859cdc01SPeter Maydell into one unit. For example, a PCI BAR may be composed of a RAM region 61859cdc01SPeter Maydell and an MMIO region. 62859cdc01SPeter Maydell 63859cdc01SPeter Maydell A container's subregions are usually non-overlapping. In some cases it is 64859cdc01SPeter Maydell useful to have overlapping regions; for example a memory controller that 65859cdc01SPeter Maydell can overlay a subregion of RAM with MMIO or ROM, or a PCI controller 66859cdc01SPeter Maydell that does not prevent card from claiming overlapping BARs. 67859cdc01SPeter Maydell 68859cdc01SPeter Maydell You initialize a pure container with memory_region_init(). 69859cdc01SPeter Maydell 70859cdc01SPeter Maydell- alias: a subsection of another region. Aliases allow a region to be 71*9d696cd5SAlex Bennée split apart into discontiguous regions. Examples of uses are memory 72*9d696cd5SAlex Bennée banks used when the guest address space is smaller than the amount 73*9d696cd5SAlex Bennée of RAM addressed, or a memory controller that splits main memory to 74*9d696cd5SAlex Bennée expose a "PCI hole". You can also create aliases to avoid trying to 75*9d696cd5SAlex Bennée add the original region to multiple parents via 76*9d696cd5SAlex Bennée `memory_region_add_subregion`. 77*9d696cd5SAlex Bennée 78*9d696cd5SAlex Bennée Aliases may point to any type of region, including other aliases, 79859cdc01SPeter Maydell but an alias may not point back to itself, directly or indirectly. 80859cdc01SPeter Maydell You initialize these with memory_region_init_alias(). 81859cdc01SPeter Maydell 82859cdc01SPeter Maydell- reservation region: a reservation region is primarily for debugging. 83859cdc01SPeter Maydell It claims I/O space that is not supposed to be handled by QEMU itself. 84859cdc01SPeter Maydell The typical use is to track parts of the address space which will be 85859cdc01SPeter Maydell handled by the host kernel when KVM is enabled. You initialize these 86859cdc01SPeter Maydell by passing a NULL callback parameter to memory_region_init_io(). 87859cdc01SPeter Maydell 88859cdc01SPeter MaydellIt is valid to add subregions to a region which is not a pure container 89859cdc01SPeter Maydell(that is, to an MMIO, RAM or ROM region). This means that the region 90859cdc01SPeter Maydellwill act like a container, except that any addresses within the container's 91859cdc01SPeter Maydellregion which are not claimed by any subregion are handled by the 92859cdc01SPeter Maydellcontainer itself (ie by its MMIO callbacks or RAM backing). However 93859cdc01SPeter Maydellit is generally possible to achieve the same effect with a pure container 94859cdc01SPeter Maydellone of whose subregions is a low priority "background" region covering 95859cdc01SPeter Maydellthe whole address range; this is often clearer and is preferred. 96859cdc01SPeter MaydellSubregions cannot be added to an alias region. 97859cdc01SPeter Maydell 98859cdc01SPeter MaydellMigration 99859cdc01SPeter Maydell--------- 100859cdc01SPeter Maydell 101859cdc01SPeter MaydellWhere the memory region is backed by host memory (RAM, ROM and 102859cdc01SPeter MaydellROM device memory region types), this host memory needs to be 103859cdc01SPeter Maydellcopied to the destination on migration. These APIs which allocate 104859cdc01SPeter Maydellthe host memory for you will also register the memory so it is 105859cdc01SPeter Maydellmigrated: 106859cdc01SPeter Maydell 107859cdc01SPeter Maydell- memory_region_init_ram() 108859cdc01SPeter Maydell- memory_region_init_rom() 109859cdc01SPeter Maydell- memory_region_init_rom_device() 110859cdc01SPeter Maydell 111859cdc01SPeter MaydellFor most devices and boards this is the correct thing. If you 112859cdc01SPeter Maydellhave a special case where you need to manage the migration of 113859cdc01SPeter Maydellthe backing memory yourself, you can call the functions: 114859cdc01SPeter Maydell 115859cdc01SPeter Maydell- memory_region_init_ram_nomigrate() 116859cdc01SPeter Maydell- memory_region_init_rom_nomigrate() 117859cdc01SPeter Maydell- memory_region_init_rom_device_nomigrate() 118859cdc01SPeter Maydell 119859cdc01SPeter Maydellwhich only initialize the MemoryRegion and leave handling 120859cdc01SPeter Maydellmigration to the caller. 121859cdc01SPeter Maydell 122859cdc01SPeter MaydellThe functions: 123859cdc01SPeter Maydell 124859cdc01SPeter Maydell- memory_region_init_resizeable_ram() 125859cdc01SPeter Maydell- memory_region_init_ram_from_file() 126859cdc01SPeter Maydell- memory_region_init_ram_from_fd() 127859cdc01SPeter Maydell- memory_region_init_ram_ptr() 128859cdc01SPeter Maydell- memory_region_init_ram_device_ptr() 129859cdc01SPeter Maydell 130859cdc01SPeter Maydellare for special cases only, and so they do not automatically 131859cdc01SPeter Maydellregister the backing memory for migration; the caller must 132859cdc01SPeter Maydellmanage migration if necessary. 133859cdc01SPeter Maydell 134859cdc01SPeter MaydellRegion names 135859cdc01SPeter Maydell------------ 136859cdc01SPeter Maydell 137859cdc01SPeter MaydellRegions are assigned names by the constructor. For most regions these are 138859cdc01SPeter Maydellonly used for debugging purposes, but RAM regions also use the name to identify 139859cdc01SPeter Maydelllive migration sections. This means that RAM region names need to have ABI 140859cdc01SPeter Maydellstability. 141859cdc01SPeter Maydell 142859cdc01SPeter MaydellRegion lifecycle 143859cdc01SPeter Maydell---------------- 144859cdc01SPeter Maydell 145859cdc01SPeter MaydellA region is created by one of the memory_region_init*() functions and 146859cdc01SPeter Maydellattached to an object, which acts as its owner or parent. QEMU ensures 147859cdc01SPeter Maydellthat the owner object remains alive as long as the region is visible to 148859cdc01SPeter Maydellthe guest, or as long as the region is in use by a virtual CPU or another 149859cdc01SPeter Maydelldevice. For example, the owner object will not die between an 150859cdc01SPeter Maydelladdress_space_map operation and the corresponding address_space_unmap. 151859cdc01SPeter Maydell 152859cdc01SPeter MaydellAfter creation, a region can be added to an address space or a 153859cdc01SPeter Maydellcontainer with memory_region_add_subregion(), and removed using 154859cdc01SPeter Maydellmemory_region_del_subregion(). 155859cdc01SPeter Maydell 156859cdc01SPeter MaydellVarious region attributes (read-only, dirty logging, coalesced mmio, 157859cdc01SPeter Maydellioeventfd) can be changed during the region lifecycle. They take effect 158859cdc01SPeter Maydellas soon as the region is made visible. This can be immediately, later, 159859cdc01SPeter Maydellor never. 160859cdc01SPeter Maydell 161859cdc01SPeter MaydellDestruction of a memory region happens automatically when the owner 162859cdc01SPeter Maydellobject dies. 163859cdc01SPeter Maydell 164859cdc01SPeter MaydellIf however the memory region is part of a dynamically allocated data 165859cdc01SPeter Maydellstructure, you should call object_unparent() to destroy the memory region 166859cdc01SPeter Maydellbefore the data structure is freed. For an example see VFIOMSIXInfo 167859cdc01SPeter Maydelland VFIOQuirk in hw/vfio/pci.c. 168859cdc01SPeter Maydell 169859cdc01SPeter MaydellYou must not destroy a memory region as long as it may be in use by a 170859cdc01SPeter Maydelldevice or CPU. In order to do this, as a general rule do not create or 171859cdc01SPeter Maydelldestroy memory regions dynamically during a device's lifetime, and only 172859cdc01SPeter Maydellcall object_unparent() in the memory region owner's instance_finalize 173859cdc01SPeter Maydellcallback. The dynamically allocated data structure that contains the 174859cdc01SPeter Maydellmemory region then should obviously be freed in the instance_finalize 175859cdc01SPeter Maydellcallback as well. 176859cdc01SPeter Maydell 177859cdc01SPeter MaydellIf you break this rule, the following situation can happen: 178859cdc01SPeter Maydell 179859cdc01SPeter Maydell- the memory region's owner had a reference taken via memory_region_ref 180859cdc01SPeter Maydell (for example by address_space_map) 181859cdc01SPeter Maydell 182859cdc01SPeter Maydell- the region is unparented, and has no owner anymore 183859cdc01SPeter Maydell 184859cdc01SPeter Maydell- when address_space_unmap is called, the reference to the memory region's 185859cdc01SPeter Maydell owner is leaked. 186859cdc01SPeter Maydell 187859cdc01SPeter Maydell 188859cdc01SPeter MaydellThere is an exception to the above rule: it is okay to call 189859cdc01SPeter Maydellobject_unparent at any time for an alias or a container region. It is 190859cdc01SPeter Maydelltherefore also okay to create or destroy alias and container regions 191859cdc01SPeter Maydelldynamically during a device's lifetime. 192859cdc01SPeter Maydell 193859cdc01SPeter MaydellThis exceptional usage is valid because aliases and containers only help 194859cdc01SPeter MaydellQEMU building the guest's memory map; they are never accessed directly. 195859cdc01SPeter Maydellmemory_region_ref and memory_region_unref are never called on aliases 196859cdc01SPeter Maydellor containers, and the above situation then cannot happen. Exploiting 197859cdc01SPeter Maydellthis exception is rarely necessary, and therefore it is discouraged, 198859cdc01SPeter Maydellbut nevertheless it is used in a few places. 199859cdc01SPeter Maydell 200859cdc01SPeter MaydellFor regions that "have no owner" (NULL is passed at creation time), the 201859cdc01SPeter Maydellmachine object is actually used as the owner. Since instance_finalize is 202859cdc01SPeter Maydellnever called for the machine object, you must never call object_unparent 203859cdc01SPeter Maydellon regions that have no owner, unless they are aliases or containers. 204859cdc01SPeter Maydell 205859cdc01SPeter Maydell 206859cdc01SPeter MaydellOverlapping regions and priority 207859cdc01SPeter Maydell-------------------------------- 208859cdc01SPeter MaydellUsually, regions may not overlap each other; a memory address decodes into 209859cdc01SPeter Maydellexactly one target. In some cases it is useful to allow regions to overlap, 210859cdc01SPeter Maydelland sometimes to control which of an overlapping regions is visible to the 211859cdc01SPeter Maydellguest. This is done with memory_region_add_subregion_overlap(), which 212859cdc01SPeter Maydellallows the region to overlap any other region in the same container, and 213859cdc01SPeter Maydellspecifies a priority that allows the core to decide which of two regions at 214859cdc01SPeter Maydellthe same address are visible (highest wins). 215859cdc01SPeter MaydellPriority values are signed, and the default value is zero. This means that 216859cdc01SPeter Maydellyou can use memory_region_add_subregion_overlap() both to specify a region 217859cdc01SPeter Maydellthat must sit 'above' any others (with a positive priority) and also a 218859cdc01SPeter Maydellbackground region that sits 'below' others (with a negative priority). 219859cdc01SPeter Maydell 220859cdc01SPeter MaydellIf the higher priority region in an overlap is a container or alias, then 221859cdc01SPeter Maydellthe lower priority region will appear in any "holes" that the higher priority 222859cdc01SPeter Maydellregion has left by not mapping subregions to that area of its address range. 223859cdc01SPeter Maydell(This applies recursively -- if the subregions are themselves containers or 224859cdc01SPeter Maydellaliases that leave holes then the lower priority region will appear in these 225859cdc01SPeter Maydellholes too.) 226859cdc01SPeter Maydell 227859cdc01SPeter MaydellFor example, suppose we have a container A of size 0x8000 with two subregions 228859cdc01SPeter MaydellB and C. B is a container mapped at 0x2000, size 0x4000, priority 2; C is 229859cdc01SPeter Maydellan MMIO region mapped at 0x0, size 0x6000, priority 1. B currently has two 230859cdc01SPeter Maydellof its own subregions: D of size 0x1000 at offset 0 and E of size 0x1000 at 231859cdc01SPeter Maydelloffset 0x2000. As a diagram:: 232859cdc01SPeter Maydell 233859cdc01SPeter Maydell 0 1000 2000 3000 4000 5000 6000 7000 8000 234859cdc01SPeter Maydell |------|------|------|------|------|------|------|------| 235859cdc01SPeter Maydell A: [ ] 236859cdc01SPeter Maydell C: [CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC] 237859cdc01SPeter Maydell B: [ ] 238859cdc01SPeter Maydell D: [DDDDD] 239859cdc01SPeter Maydell E: [EEEEE] 240859cdc01SPeter Maydell 241859cdc01SPeter MaydellThe regions that will be seen within this address range then are:: 242859cdc01SPeter Maydell 243859cdc01SPeter Maydell [CCCCCCCCCCCC][DDDDD][CCCCC][EEEEE][CCCCC] 244859cdc01SPeter Maydell 245859cdc01SPeter MaydellSince B has higher priority than C, its subregions appear in the flat map 246859cdc01SPeter Maydelleven where they overlap with C. In ranges where B has not mapped anything 247859cdc01SPeter MaydellC's region appears. 248859cdc01SPeter Maydell 249859cdc01SPeter MaydellIf B had provided its own MMIO operations (ie it was not a pure container) 250859cdc01SPeter Maydellthen these would be used for any addresses in its range not handled by 251859cdc01SPeter MaydellD or E, and the result would be:: 252859cdc01SPeter Maydell 253859cdc01SPeter Maydell [CCCCCCCCCCCC][DDDDD][BBBBB][EEEEE][BBBBB] 254859cdc01SPeter Maydell 255859cdc01SPeter MaydellPriority values are local to a container, because the priorities of two 256859cdc01SPeter Maydellregions are only compared when they are both children of the same container. 257859cdc01SPeter MaydellThis means that the device in charge of the container (typically modelling 258859cdc01SPeter Maydella bus or a memory controller) can use them to manage the interaction of 259859cdc01SPeter Maydellits child regions without any side effects on other parts of the system. 260859cdc01SPeter MaydellIn the example above, the priorities of D and E are unimportant because 261859cdc01SPeter Maydellthey do not overlap each other. It is the relative priority of B and C 262859cdc01SPeter Maydellthat causes D and E to appear on top of C: D and E's priorities are never 263859cdc01SPeter Maydellcompared against the priority of C. 264859cdc01SPeter Maydell 265859cdc01SPeter MaydellVisibility 266859cdc01SPeter Maydell---------- 267859cdc01SPeter MaydellThe memory core uses the following rules to select a memory region when the 268859cdc01SPeter Maydellguest accesses an address: 269859cdc01SPeter Maydell 270859cdc01SPeter Maydell- all direct subregions of the root region are matched against the address, in 271859cdc01SPeter Maydell descending priority order 272859cdc01SPeter Maydell 273859cdc01SPeter Maydell - if the address lies outside the region offset/size, the subregion is 274859cdc01SPeter Maydell discarded 275859cdc01SPeter Maydell - if the subregion is a leaf (RAM or MMIO), the search terminates, returning 276859cdc01SPeter Maydell this leaf region 277859cdc01SPeter Maydell - if the subregion is a container, the same algorithm is used within the 278859cdc01SPeter Maydell subregion (after the address is adjusted by the subregion offset) 279859cdc01SPeter Maydell - if the subregion is an alias, the search is continued at the alias target 280859cdc01SPeter Maydell (after the address is adjusted by the subregion offset and alias offset) 281859cdc01SPeter Maydell - if a recursive search within a container or alias subregion does not 282859cdc01SPeter Maydell find a match (because of a "hole" in the container's coverage of its 283859cdc01SPeter Maydell address range), then if this is a container with its own MMIO or RAM 284859cdc01SPeter Maydell backing the search terminates, returning the container itself. Otherwise 285859cdc01SPeter Maydell we continue with the next subregion in priority order 286859cdc01SPeter Maydell 287859cdc01SPeter Maydell- if none of the subregions match the address then the search terminates 288859cdc01SPeter Maydell with no match found 289859cdc01SPeter Maydell 290859cdc01SPeter MaydellExample memory map 291859cdc01SPeter Maydell------------------ 292859cdc01SPeter Maydell 293859cdc01SPeter Maydell:: 294859cdc01SPeter Maydell 295859cdc01SPeter Maydell system_memory: container@0-2^48-1 296859cdc01SPeter Maydell | 297859cdc01SPeter Maydell +---- lomem: alias@0-0xdfffffff ---> #ram (0-0xdfffffff) 298859cdc01SPeter Maydell | 299859cdc01SPeter Maydell +---- himem: alias@0x100000000-0x11fffffff ---> #ram (0xe0000000-0xffffffff) 300859cdc01SPeter Maydell | 301859cdc01SPeter Maydell +---- vga-window: alias@0xa0000-0xbffff ---> #pci (0xa0000-0xbffff) 302859cdc01SPeter Maydell | (prio 1) 303859cdc01SPeter Maydell | 304859cdc01SPeter Maydell +---- pci-hole: alias@0xe0000000-0xffffffff ---> #pci (0xe0000000-0xffffffff) 305859cdc01SPeter Maydell 306859cdc01SPeter Maydell pci (0-2^32-1) 307859cdc01SPeter Maydell | 308859cdc01SPeter Maydell +--- vga-area: container@0xa0000-0xbffff 309859cdc01SPeter Maydell | | 310859cdc01SPeter Maydell | +--- alias@0x00000-0x7fff ---> #vram (0x010000-0x017fff) 311859cdc01SPeter Maydell | | 312859cdc01SPeter Maydell | +--- alias@0x08000-0xffff ---> #vram (0x020000-0x027fff) 313859cdc01SPeter Maydell | 314859cdc01SPeter Maydell +---- vram: ram@0xe1000000-0xe1ffffff 315859cdc01SPeter Maydell | 316859cdc01SPeter Maydell +---- vga-mmio: mmio@0xe2000000-0xe200ffff 317859cdc01SPeter Maydell 318859cdc01SPeter Maydell ram: ram@0x00000000-0xffffffff 319859cdc01SPeter Maydell 320859cdc01SPeter MaydellThis is a (simplified) PC memory map. The 4GB RAM block is mapped into the 321859cdc01SPeter Maydellsystem address space via two aliases: "lomem" is a 1:1 mapping of the first 322859cdc01SPeter Maydell3.5GB; "himem" maps the last 0.5GB at address 4GB. This leaves 0.5GB for the 323859cdc01SPeter Maydellso-called PCI hole, that allows a 32-bit PCI bus to exist in a system with 324859cdc01SPeter Maydell4GB of memory. 325859cdc01SPeter Maydell 326859cdc01SPeter MaydellThe memory controller diverts addresses in the range 640K-768K to the PCI 327859cdc01SPeter Maydelladdress space. This is modelled using the "vga-window" alias, mapped at a 328859cdc01SPeter Maydellhigher priority so it obscures the RAM at the same addresses. The vga window 329859cdc01SPeter Maydellcan be removed by programming the memory controller; this is modelled by 330859cdc01SPeter Maydellremoving the alias and exposing the RAM underneath. 331859cdc01SPeter Maydell 332859cdc01SPeter MaydellThe pci address space is not a direct child of the system address space, since 333859cdc01SPeter Maydellwe only want parts of it to be visible (we accomplish this using aliases). 334859cdc01SPeter MaydellIt has two subregions: vga-area models the legacy vga window and is occupied 335859cdc01SPeter Maydellby two 32K memory banks pointing at two sections of the framebuffer. 336859cdc01SPeter MaydellIn addition the vram is mapped as a BAR at address e1000000, and an additional 337859cdc01SPeter MaydellBAR containing MMIO registers is mapped after it. 338859cdc01SPeter Maydell 339859cdc01SPeter MaydellNote that if the guest maps a BAR outside the PCI hole, it would not be 340859cdc01SPeter Maydellvisible as the pci-hole alias clips it to a 0.5GB range. 341859cdc01SPeter Maydell 342859cdc01SPeter MaydellMMIO Operations 343859cdc01SPeter Maydell--------------- 344859cdc01SPeter Maydell 345859cdc01SPeter MaydellMMIO regions are provided with ->read() and ->write() callbacks, 346859cdc01SPeter Maydellwhich are sufficient for most devices. Some devices change behaviour 347859cdc01SPeter Maydellbased on the attributes used for the memory transaction, or need 348859cdc01SPeter Maydellto be able to respond that the access should provoke a bus error 349859cdc01SPeter Maydellrather than completing successfully; those devices can use the 350859cdc01SPeter Maydell->read_with_attrs() and ->write_with_attrs() callbacks instead. 351859cdc01SPeter Maydell 352859cdc01SPeter MaydellIn addition various constraints can be supplied to control how these 353859cdc01SPeter Maydellcallbacks are called: 354859cdc01SPeter Maydell 355859cdc01SPeter Maydell- .valid.min_access_size, .valid.max_access_size define the access sizes 356859cdc01SPeter Maydell (in bytes) which the device accepts; accesses outside this range will 357859cdc01SPeter Maydell have device and bus specific behaviour (ignored, or machine check) 358859cdc01SPeter Maydell- .valid.unaligned specifies that the *device being modelled* supports 359859cdc01SPeter Maydell unaligned accesses; if false, unaligned accesses will invoke the 360859cdc01SPeter Maydell appropriate bus or CPU specific behaviour. 361859cdc01SPeter Maydell- .impl.min_access_size, .impl.max_access_size define the access sizes 362859cdc01SPeter Maydell (in bytes) supported by the *implementation*; other access sizes will be 363859cdc01SPeter Maydell emulated using the ones available. For example a 4-byte write will be 364859cdc01SPeter Maydell emulated using four 1-byte writes, if .impl.max_access_size = 1. 365859cdc01SPeter Maydell- .impl.unaligned specifies that the *implementation* supports unaligned 366859cdc01SPeter Maydell accesses; if false, unaligned accesses will be emulated by two aligned 367859cdc01SPeter Maydell accesses. 368f3224c52SPaolo Bonzini 369f3224c52SPaolo BonziniAPI Reference 370f3224c52SPaolo Bonzini------------- 371f3224c52SPaolo Bonzini 372f3224c52SPaolo Bonzini.. kernel-doc:: include/exec/memory.h 373