On Thu, 15 Aug 2019 at 23:17, Palmer Dabbelt <pal...@sifive.com> wrote: > You're more than welcome to take them over. I've got something that boots > Linux on my unassigned_access branch (github.com/palmer-dabbelt/qemu), but I > haven't sanitized the whole port for physical accesses and I haven't convinced > myself that my hook implementation is correct.
Rather than doing if (retaddr) { cpu_restore_state(cs, retaddr, true); } at the start of the hook I think you just want to pass 'retaddr' as the final argument to riscv_raise_exception() instead of using GETPC(). Other than that I think the hook itself is right. The 'git grep' regexes in docs/devel/loads-stores.rst are handy for finding the places where the target code is doing physical accesses. IIRC the only ones I found with a quick scan were the PTE loads in get_physical_address() via ldl_phys/ldq_phys, which will now return 0 and run into the 'invalid PTE' code path. I don't know whether your architecture requires some different behaviour for bus errors on page table walk than that (you might want to specifically code the error path anyway or comment it even if the behaviour is right, to be a bit more explicit that it can happen). thanks -- PMM