MemoryRegionOps access sizes
Hello,
Could someone please explain how the MemoryRegionOps valid.{min,max}_access_size and unaligned and corresponding impl constraints work and where are these implemented? And in particular if this would work:
static const MemoryRegionOps ops = {
.read = readfn,
.write = writefn,
.valid.min_access_size = 1,
.valid.max_access_size = 4,
.impl.min_access_size = 4,
.impl.max_access_size = 4,
.endianness = DEVICE_LITTLE_ENDIAN,
};This is related to this question:
http://lists.nongnu.org/archive/html/qemu-devel/2019-02/msg03157.html
but that's probably ignored in the middle of a thread so I ask separately.
Thank you,
BALATON Zoltan
Quoted 16 lines · BALATON Zoltan
Hello,
Could someone please explain how the MemoryRegionOps valid.{min,max}_access_size and unaligned and corresponding impl constraints work and where are these implemented? And in particular if this would work:
static const MemoryRegionOps ops = { .read = readfn, .write = writefn, .valid.min_access_size = 1, .valid.max_access_size = 4, .impl.min_access_size = 4, .impl.max_access_size = 4, .endianness = DEVICE_LITTLE_ENDIAN, };
Quoted 3 lines
This is related to this question:
http://lists.nongnu.org/archive/html/qemu-devel/2019-02/msg03157.html
but that's probably ignored in the middle of a thread so I ask separately.
CCing Paolo and Peter, who might know the answer.
Otherwise the easiest way to understand the behavior would be to create the memory region and try it out using qtest to see what happens in practice.
Stefan
Quoted 8 lines · BALATON Zoltan
Hello,
Could someone please explain how the MemoryRegionOps valid.{min,max}_access_size and unaligned and corresponding impl constraints work and where are these implemented? And in particular if this would work:
Quoted 9 lines
static const MemoryRegionOps ops = {
.read = readfn,
.write = writefn,
.valid.min_access_size = 1,
.valid.max_access_size = 4,
.impl.min_access_size = 4,
.impl.max_access_size = 4,
.endianness = DEVICE_LITTLE_ENDIAN,
};These are implemented in memory.c. The documentation is in the comments on the MemoryRegionOps struct in include/exec/memory.h.
The .valid parts should specify what the device permits the guest to do (and where failures result in MemTxErrors usually meaning bus error/data abort). These ought to be handled by the memory_region_access_valid() function, but I can't see how the logic there actually does the right thing. Maybe Paolo understands that part better than me.
The .impl parts specify what the implementation can deal with, and access_with_adjusted_size() takes care of making multiple accesses to the underlying device if necessary. (The fiddling of the data to put it in the right place is done at the next level down by memory_region_shift_read_access() and memory_region_shift_write_access().)
I think your suggested MemoryRegionOps ought to work.
thanks
-- PMM