cputlb: Fix io_readx() to respect the access_type
PATCH 1/1 cputlb: Fix io_readx() to respect the access_type
This change adapts io_readx() to its input access_type. Currently io_readx() treats any memory access as a read, although it has an input argument "MMUAccessType access_type". This results in:
1) Calling the tlb_fill() only with MMU_DATA_LOAD
2) Considering only entry->addr_read as the tlb_addr
---
Changelog:
- Extra space before closing parenthesis is removed
accel/tcg/cputlb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
accel/tcg/cputlb.c +5 -2
@@ -878,10 +878,13 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry,CPUTLBEntry *entry;target_ulong tlb_addr; -tlb_fill (cpu, addr, size,MMU_DATA_LOAD , mmu_idx, retaddr); +tlb_fill (cpu, addr, size, access_type, mmu_idx, retaddr); entry =tlb_entry (env, mmu_idx, addr); - tlb_addr = entry->addr_read; + tlb_addr = + (access_type ==MMU_DATA_LOAD ) ? entry->addr_read : + (access_type ==MMU_DATA_STORE ) ? entry->addr_write : + entry->addr_code;if (!(tlb_addr & ~(TARGET_PAGE_MASK |TLB_RECHECK ))) {/* RAM access */ uintptr_t haddr = addr + entry->addend;
Signature · 1 line
2.21.0
Quoted 10 lines · Shahab Vahedi
This change adapts
io_readx()to its inputaccess_type. Currentlyio_readx()treats any memory access as a read, although it has an input argument "MMUAccessTypeaccess_type". This results in:1) Calling the
tlb_fill()only withMMU_DATA_LOAD
2) Considering onlyentry->addr_readas thetlb_addr
Quoted 7 lines
Signed-off-by Shahab Vahedi <[email protected]>---
Changelog:
- Extra space before closing parenthesis is removedaccel/tcg/cputlb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Hi; this patch mostly looks good; thanks for submitting it.
Quoted 7 lines
accel/tcg/cputlb.c +0
-0@@ -878,10 +878,13 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry,CPUTLBEntry *entry;target_ulong tlb_addr;
accel/tcg/cputlb.c static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, · line 887
Quoted 10 lines
accel/tcg/cputlb.c +5
-2-tlb_fill (cpu, addr, size,MMU_DATA_LOAD , mmu_idx, retaddr); +tlb_fill (cpu, addr, size, access_type, mmu_idx, retaddr); entry =tlb_entry (env, mmu_idx, addr); - tlb_addr = entry->addr_read; + tlb_addr = + (access_type ==MMU_DATA_LOAD ) ? entry->addr_read : + (access_type ==MMU_DATA_STORE ) ? entry->addr_write : + entry->addr_code;
Here you don't need to handle MMU_DATA_STORE, because we're in io_readx -- stores will go to io_writex, not here.
Style-wise it's probably better just to use an
if (...) {
tlb_addr = ...;
} else {
tlb_addr = ...;}
rather than a multi-line ?: expression.
Quoted 6 lines
accel/tcg/cputlb.c +0
-1if (!(tlb_addr & ~(TARGET_PAGE_MASK |TLB_RECHECK ))) {/* RAM access */ uintptr_t haddr = addr + entry->addend; --2.21.0
thanks
-- PMM
Hi Peter,
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Shahab Vahedi
This change adapts
io_readx()to its inputaccess_type. Currentlyio_readx()treats any memory access as a read, although it has an input argument "MMUAccessTypeaccess_type". This results in:1) Calling the
tlb_fill()only withMMU_DATA_LOAD
2) Considering onlyentry->addr_readas thetlb_addrSigned-off-by Shahab Vahedi <[email protected]>---
Changelog:
- Extra space before closing parenthesis is removed
Quoted 5 lines
Quoted 2 lines
accel/tcg/cputlb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)Hi; this patch mostly looks good; thanks for submitting it.
Please let me remind you that there is a newer [PATCH v3].
Quoted 11 lines
Quoted 11 lines
accel/tcg/cputlb.c +1
-1@@ -878,10 +878,13 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry,CPUTLBEntry *entry;target_ulong tlb_addr; -tlb_fill (cpu, addr, size,MMU_DATA_LOAD , mmu_idx, retaddr); +tlb_fill (cpu, addr, size, access_type, mmu_idx, retaddr);
Quoted 10 lines
accel/tcg/cputlb.c static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, · line 887
Quoted 6 lines
accel/tcg/cputlb.c +4
-1entry =tlb_entry (env, mmu_idx, addr); - tlb_addr = entry->addr_read; + tlb_addr = + (access_type ==MMU_DATA_LOAD ) ? entry->addr_read : + (access_type ==MMU_DATA_STORE ) ? entry->addr_write : + entry->addr_code;Here you don't need to handle
MMU_DATA_STORE, because we're inio_readx-- stores will go toio_writex, not here.
This concern was already raised by Alex (Bennée) and in [PATCH v3] I addressed it the way he suggested: an _assert_ in the beginning to verify that "access_type" is only for fetching and reading. I must say, Philippe (Mathieu-Daudé) has his doubts about using an _assert_ like this.
Quoted 10 lines
Style-wise it's probably better just to use an
if (...) { tlb_addr = ...; } else { tlb_addr = ...;}
rather than a multi-line ?: expression.
Sure Peter, I will do that, but please let me remind you that in [PATCH v3] the conditional part is a two-liner (i.s.o the three- liner here).
Quoted 9 lines
Quoted 6 lines
accel/tcg/cputlb.c +0
-1if (!(tlb_addr & ~(TARGET_PAGE_MASK |TLB_RECHECK ))) {/* RAM access */ uintptr_t haddr = addr + entry->addend; --2.21.0
thanks
-- PMM
I have a question though: Richard (Henderson) has already _reviewed_ [PATCH v3]. Is it OK if I change the code further and submit yet a newer version?
Cheers,
Shahab
Quoted 20 lines · Shahab Vahedi
Hi Peter,
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Shahab Vahedi
This change adapts
io_readx()to its inputaccess_type. Currentlyio_readx()treats any memory access as a read, although it has an input argument "MMUAccessTypeaccess_type". This results in:1) Calling the
tlb_fill()only withMMU_DATA_LOAD
2) Considering onlyentry->addr_readas thetlb_addrSigned-off-by Shahab Vahedi <[email protected]>---
Changelog:
- Extra space before closing parenthesis is removed
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
accel/tcg/cputlb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)Hi; this patch mostly looks good; thanks for submitting it.
Please let me remind you that there is a newer [PATCH v3].
Oops, yes, I missed that (was going through a lot of list emails after being away for a bit). Sorry.
Quoted 3 lines
I have a question though: Richard (Henderson) has already _reviewed_ [PATCH v3]. Is it OK if I change the code further and submit yet a newer version?
If you think it's necessary, you can -- for instance if you find a bug or other problem in it. If you change the code much then you should drop the reviewed-by:
line as the code needs re-review. If the change is entirely trivial (eg fixing a comment typo) then you can let the reviewed-by tag stand (ie include it in the version you send out).
But if you're thinking of doing it just to fiddle with the ?: style issue I suggested above, don't bother -- it doesn't matter that much (and not trying to deal with all 3 cases means you don't have the nested ?: anyway).
thanks
-- PMM