memory: fix return value on unassigned reads
PATCH 1/1 memory: fix return value on unassigned reads
The memory API returns -1 on unassigned reads, different from the original in exec.c, which returned zero. This breaks grlib_uart; apparently some users depend on it.
Fix by returning zero; however if reading from the uart is legal, then it should be modified to accept reads.
--- memory.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
memory.c +1 -1
@@ -917,7 +917,7 @@ static uint64_t memory_region_dispatch_read1(MemoryRegion *mr,uint64_t data =0 ;if (!memory_region_access_valid (mr, addr, size, false)) { -return -1U ;/* FIXME: better signalling */ +return 0 ;/* FIXME: better signalling */ }if (!mr->ops->read) {
Signature · 1 line
1.7.7.1
Quoted 2 lines · Avi Kivity
The memory API returns -1 on unassigned reads, different from the original in
exec.c, which returned zero.
Isn't this return value platform specific?
Quoted 5 lines
This breaks
grlib_uart; apparently some users depend on it.Fix by returning zero; however if reading from the uart is legal, then it should be modified to accept reads.
That's right, grlib_uart depends on it because I took the easy (lazy?) way. I will send a patch to handle reads to UART's registers.
Signature · 1 line
Fabien Chouteau
Quoted 5 lines · Fabien Chouteau
Quoted 2 lines · Avi Kivity
The memory API returns -1 on unassigned reads, different from the original in
exec.c, which returned zero.Isn't this return value platform specific?
Maybe (and I think ~0 is the common one); the patch just restores the previous behaviour.
Quoted 9 lines
Quoted 6 lines
This breaks
grlib_uart; apparently some users depend on it.Fix by returning zero; however if reading from the uart is legal, then it should be modified to accept reads.
That's right,
grlib_uartdepends on it because I took the easy (lazy?) way. I will send a patch to handle reads to UART's registers.
Definitely that's the best way to fix the problem.
Signature · 1 line
error compiling committee.c: too many arguments to function